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 Ethereum 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 12 confirmations have passed.
PHP
1
<?php
2
// Payment Settings
3
$my_address = "0xd85f18d58982db82e1916d84bc9ecec2a6e93d45"; // Your destination address
4
$desiredConfirmations = 12;
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(!$_POST['input_address'] || !$_POST['input_transaction_hash'] || !$_POST['transaction_hash'] || !$_POST['valueWEI'] || !$_POST['gas'] || !$_POST['gasPrice'] || !$_POST['valueETH'] || !$_POST['confirmations'] || !$_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
$gas = $_POST["gas"];
24
$gasPrice = $_POST["gasPrice"];
25
26
$value_in_eth = $_POST["valueETH"];
27
$value_in_wei = $_POST["valueWEI"];
28
29
$transaction_fee = ($gasPrice * $gas); // Transaction fee in WEI
30
31
$input_address = $_POST["input_address"];
32
$input_transaction_hash = $_POST["input_transaction_hash"];
33
$transaction_hash = $_POST["transaction_hash"];
34
$confirmations = $_POST["confirmations"];
35
36
// Work out the real amount they sent to the our address
37
$totalSent = bcsub($value_in_wei, $transaction_fee); // Use BCMath extension to use this - it's for huge/large numbers that do not fit into 32bit
38
39
// Confirmation check to make sure the confirmations is above our desired amount
40
if($confirmations >= $desiredConfirmations) {
41
42
// Insert your data into a database so you can later on, fetch that data and update it
43
// {{ Do you magic here }}
44
45
} else {
46
// Transaction has not reached our desired number of confirmations.
47
// Keep waiting for confirmations to be larger
48
}
49
?>
Copied!
Last modified 3mo ago