<p>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).</p>

<p>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.</p>

CC BY-SA 3.0
2015-05-20T00:25:07.913Z
2015-05-29T19:19:06.373Z
2015-05-29T19:19:06.373Z
guestpost112233
<p>I want to accept payments with the Blockchain Receive Payments API (<a href="https://blockchain.info/api/api_receive" rel="nofollow">https://blockchain.info/api/api_receive</a>) 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:</p>

<p>callback.php</p>

<pre><code>$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-&gt;query($query)) {
            echo "*ok*";
        } else {
            die("ERROR!!!!1");
        }       
    }
} else {
    die("Blank secret");
}
</code></pre>

<p>receive.php</p>

<pre><code>$secret = 'testSecret';
$my_address = '1339LGRGE44QMLYa4hTuyAsbKVjVAGXwHW';
$my_callback_url = 'http://example.com/pay?secret='.$secret;
$root_url = 'https://blockchain.info/api/receive';
$parameters = 'method=create&amp;address=' . $my_address .'&amp;callback='.     urlencode($my_callback_url);
$response = file_get_contents($root_url . '?' . $parameters);
$object = json_decode($response);
echo 'Send Payment To : ' . $object-&gt;input_address;
</code></pre>

<p>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 :)</p>

CC BY-SA 3.0
2017-03-10T14:00:43.020Z
I investigated and solved that (solution included + some debugging) http://bitcoin.stackexchange.com/questions/51980/php-blockchain-api-callback-not-working/52006#52006
Fero
<api><blockchain.info><payment><php>
Blockchain Receive Payments API Not Working
Deranged
# Blockchain Receive Payments API Not Working

(Asked by: username_0 on 2015-05-18)

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 :)

**Tags:** api, blockchain.info, payment, php

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

---

## 1 answers

### Answer by username_2 on 2015-05-20. Score: 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.


---

