IPN (Instant Payment Notification)
Payment notification
The payment process and confirmation of transaction may take from several minutes to several hours. Our service will notify you about confirmation by sending a POST request with data to the status URL you specified. The notification will occur twice: after the transaction appears on the network (1st confirmation) and after its 12th confirmation.
Data structure
Data in JSON format:
{
etherapi.net: version
type: message type = (in-payment / track-tracking / out-sending)
date: date and time in UNIX format
from: address-sender
to: address-receiver
token: token = (only for token transaction, ERC20 token ID)
amount: amount
txid: transaction txid (hash)
confirmations: number of confirmations = (1/12)
tag: tag
sign: signature
}
Signature verification
To verify the signature, you must calculate a hash from the received data and compare it with the value in the sign field.
A hash is a (40-character hexadecimal number) result of the sha1 function from the string received by connecting through the colon (:) the values of the type, date, from, to, [token,] amount, txid, confirmations, tag and API key.
Result
The service expects a text response from the IPN handler.
This text can be seen in the office on the "Notifications" tab.
Example
PHP IPN Handler Code Example:
...
if (!$_POST)
$_POST = @json_decode(file_get_contents('php://input'), true);
if (!$_POST['etherapi.net'])
return;
$sign = sha1(implode(':', array(
$_POST['type'],
$_POST['date'],
$_POST['from'],
$_POST['to'],
//$_POST['token'], // only for token transactions
$_POST['amount'],
$_POST['txid'],
$_POST['confirmations'],
$_POST['tag'],
$cfg['apikey'] // API access key
)));
if ($sign !== $_POST['sign'])
die('Sign wrong'); // this answer will be visible in the dashboard
echo('OK');
...