Blockchain Receive Payments API Not Working


I want to accept payments with the Blockchain Receive Payments API ( but I can't seem to figure out how to work it. I cannot test it too much because there is a minimum amount of BTC that can be sent to the account for it to work and I just ran out from testing because there is no destination for the address but that's another story- I just need to know that it should work. This is what I have so far:


$secret = "testSecret";
if (isset($_GET['secret'])) {
if ($_GET['secret'] != $secret) {
    die("Invalid secret");
} else {
    define("HOST", "localhost"); 
    define("USER", "root"); 
    define("PASSWORD", "DBPASS"); 
    define("DATABASE", "");
    $mysqli = new mysqli(HOST, USER, PASSWORD, DATABASE);
    $query = "INSERT INTO invoices (item_id, price_in_btc, bought_by, deliver_to, time) VALUES ('2', '001', '1', '1', '0')";
        if ($mysqli->query($query)) {
            echo "*ok*";
        } else {
} else {
    die("Blank secret");


$secret = 'testSecret';
$my_address = '1339LGRGE44QMLYa4hTuyAsbKVjVAGXwHW';
$my_callback_url = ''.$secret;
$root_url = '';
$parameters = 'method=create&address=' . $my_address .'&callback='.     urlencode($my_callback_url);
$response = file_get_contents($root_url . '?' . $parameters);
$object = json_decode($response);
echo 'Send Payment To : ' . $object->input_address;

Generating new accounts works just fine but that's not the problem. The test callback on their site works but when I actually test it, nothing gets written to the database and the BTC isn't returned to the original account nor sent to the destination account. I basically just want to know if I am doing anything wrong with the above code. Thanks for the help :)


Posted 2015-05-18T23:51:28.453

Reputation: 21

I investigated and solved that (solution included + some debugging)

– Fero – 2017-03-10T14:00:43.020



Not an expert, but have I have an ecommerce site that relies on blockchain's API and the error log I have looked at seems to indicate that cloud flare is preventing the return of the info that I'm looking to populate my stores db (just checking balances, etc).

Are there error logs that you've looked at and do they confirm that cloud flare is not the issue? Seems like it plagues everybody using their API for basic functions.


Posted 2015-05-18T23:51:28.453

Reputation: 11