Skip to main content

Web Hook Response

hook.json
{
"status":"FAILED",
"designation":"Marmite",
"transaction_id":"ADP_016700_004602",
"client_reference":"8DyMmQuv0NZKIgjL0jzTf1wYD0Z3vH8c",
"amount":"10.00",
"phone_number":"0778487321",
"buyer_name":"Kouyate Karim",
"currency_code":"CFA",
"cancelled_at":null,
"approuved_at":null,
"transaction_type":"ORANGE-CI"
}
Json content

Code PHP#

hook.php
<?php
$status = $_POST['status'];
$designation = $_POST['designation'];
$transaction_id = $_POST['transaction_id'];
$client_reference = $_POST['client_reference'];
$amount = $_POST['amount'];
$currency_code = $_POST['currency_code'];
$buyer_name = $_POST['buyer_name'] ? $_POST['buyer_name'] : 'null';
$cancelled_at = $_POST['cancelled_at'] ? $_POST['cancelled_at'] : 'null' ;
$approuved_at = $_POST['approuved_at'] ?? 'null' ;
$transaction_type = $_POST['transaction_type'] ?? 'null' ;
$notification = $db->prepare("INSERT INTO notifications(status,designation,transaction_id,client_reference,amount,
phone_number, buyer_name, currency_code, cancelled_at, approuved_at, transaction_type)
VALUES (?,?,?,?,?,?,?,?,?,?,?)");
$notification->execute(array($status,$designation,$transaction_id, $client_reference,
$amount, $phone_number, $buyer_name, $currency_code, $cancelled_at,
$approuved_at, $transaction_type));
?>
Attention

Verifier toujours l'existance du paramètre avant de l'utiliser sinon vous pourrez avoir des erreurs du type : PHP Notice: Undefined index: cancelled_at in /home/adjeminpay/test.php on line 5 , qui bloquera la noyification du backend.