Obtenção do status da transação enviada
Não se esqueça de especificar a "ID da plataforma" e "Chave secreta."
CURL:
curl -X POST -d "platform_id=1&txhash=vw45hbw45v&hash=a81983b1...tb8kfyhjd" https://api.passimpay.io/transactionstatus
PHP:
$url =
'https://api.passimpay.io/transactionstatus'
;
$platform_id =
0
;
// ID da plataforma
$apikey =
'1111-2222-3333-4444-5555'
;
// Chave secreta
$txhash =
'erthbe46hw45tv34tyb6'
;
// hash da transação no sistema Passimpay
$payload = http_build_query([
'platform_id'
=> $platform_id,
'txhash'
=> $txhash]);
$hash = hash_hmac(
'sha256'
, $payload, $apikey);
$data = [
'platform_id'
=> $platform_id,
'txhash'
> $txhash,
'hash'
> $hash,
];
$post_data = http_build_query($data);
$curl = curl_init();
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_HTTPHEADER, ['
'Content-Type: application/x-www-form-urlencoded'
]);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_ENCODING,
'gzip'
);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
$result = curl_exec($curl);
curl_close( $curl );
$result = json_decode($result, true);
// Opções de resposta
// Em caso de sucesso
if (isset($result[
'result'
]) && $result[
'result'
] == 1)
{
$approve = $result[
'approve'
];
// 0 - trabalhando, 1 - completa, 2 - erro
$payment_id = $result[
'payment_id'
];
$address_to = $result[
'address_to'
];
$amount = $result[
'amount'
];
$fee = $result[
'fee'
];
$txhash = $result[
'txhash'
];
}
// Em caso de erro
else
{
$error = $result[
'message'
];
// Texto do erro
}