此请求通过 http post 请求从支付网关发送到我指定的 url
POST https://mywebsite.com/checkout/?oid=12345
{
"status":"SUCCESS",
"notif_token":"dd497bda3b250e536186fc0663f32f40",
"txnid": "MP150709.1341.A00073"
}
如何在 checkout.php 文件中接收此请求数据
我想将此数据存储到变量中
// Get the JSON contents notif respone in varibale
$notif_response_body = file_get_contents('php://input');
// decode json respone
$notif_response_data = json_decode($notif_response_body, true);
switch ($notif_response_data['status']){
case "PENDING":
$sorder->add_order_note( __('The Transaction id ' . $notif_response_data['txnid'] . 'is in progress on Orange Money Payment Gateway ', 'orange_money'), true );
$sorder->status = 'On hold';
break;
case "SUCCESS":
$sorder->add_order_note( __('Order Paid via Orange Money Payment Gateway transaction id : ' . $notif_response_data['txnid'], 'orange_money'), true );
$sorder->status = 'Processing';
break;
case "FAILED":
$sorder->add_order_note( __('Payment Failed on Orange Money Payment Gateway transaction id : ' . $notif_response_data['txnid'], 'orange_money'), true );
$sorder->status = 'Failed';
break;
case "EXPIRED":
$sorder->add_order_note( __('Payment Expired on Orange Money Payment Gateway transaction id : ' . $notif_response_data['txnid'], 'orange_money'), true );
$sorder->status = 'Failed';
break;
default:
break;
}