Search…
Receiving Callbacks
You'll need some server-side code to handle the callbacks sent by our system when a payment is detected.
As mentioned before, each time a payment is received and forwarded to your Bitcoin address, your callback URL will be sent data about the payment. This is necessary for automated systems to know when a specific payment is sent. Our server will forward the payments and send these callbacks to your server immediately after payments are received and confirmed 1 times. After this, every time the confirmations value changes, we will send another callback, up to 20 confirmations or 20 bad callback requests.
Callbacks will always be sent as POST requests containing the details of the payment and the forwarded transaction, in addition to any parameters already present in the callback URL. Once again, please recall that callback URLs have a maximum length of 1024 characters.
Remember that for security, you should make sure that you include a unique, secret parameter in your callback URL. This secret string will be passed back to the callback script when the callback is sent, along with any other parameters already present in the callback URL. It should be checked against the original secret string to ensure that the callback is coming from us and is not forged.
post
Receive callback data
Do not POST this to us. This is the information we POST to your callback URL.

Example code

The following code will check that 3 confirmations have passed.
PHP
1
<?php
2
// Payment Settings
3
$my_address = "1LisLsZd3bx8U1NYzpNHqpo8Q6UCXKMJ4z";
4
$desiredConfirmations = 3;
5
6
// If you're using a secret, put it in here
7
$secret = "7j0ap91o99cxj8k9";
8
9
// Start of checks
10
if(!isset($_GET['secret'])) {
11
die('No secret found.');
12
}
13
14
if ($_GET["secret"] !== $secret) die();
15
16
// Make sure we have all the POST variables we want to get
17
if(!isset($_POST['input_address']) || !isset($_POST['input_transaction_hash']) || !isset($_POST['transaction_hash']) || !isset($_POST['value']) || !isset($_POST['confirmations']) || !isset($_POST['destination_address'])) {
18
die('One of more of the POST variables was not set in the request to our callback url.');
19
}
20
21
if ($_POST["destination_address"] !== $my_address) die();
22
23
// Now we can show them the 200 status code as they've passed our checks
24
http_response_code(200);
25
26
$input_address = $_POST["input_address"];
27
$input_transaction_hash = $_POST["input_transaction_hash"];
28
$transaction_hash = $_POST["transaction_hash"];
29
$value_in_btc = $_POST["value"];
30
$confirmations = $_POST["confirmations"];
31
32
// Confirmation check to make sure the confirmations is above our desired amount
33
if($confirmations >= $desiredConfirmations) {
34
// We should store the payment as soon as we receive it inside this callback file
35
// We can later update details such as confirms if needed
36
// {{ Do your magic here }}
37
} else {
38
// Transaction has not reached our desired number of confirmations.
39
// Keep waiting for confirmations to be larger
40
}
41
?>
Copied!
Last modified 3mo ago