Blockchain Receive Payments API Not Working

2

I want to accept payments with the Blockchain Receive Payments API (https://blockchain.info/api/api_receive) 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:

callback.php

$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", "xeon.io");
    $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 {
            die("ERROR!!!!1");
        }       
    }
} else {
    die("Blank secret");
}

receive.php

$secret = 'testSecret';
$my_address = '1339LGRGE44QMLYa4hTuyAsbKVjVAGXwHW';
$my_callback_url = 'http://example.com/pay?secret='.$secret;
$root_url = 'https://blockchain.info/api/receive';
$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 :)

Deranged

Posted 2015-05-18T23:51:28.453

Reputation: 21

I investigated and solved that (solution included + some debugging) http://bitcoin.stackexchange.com/questions/51980/php-blockchain-api-callback-not-working/52006#52006

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

Answers

1

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.

guestpost112233

Posted 2015-05-18T23:51:28.453

Reputation: 11