After the first phase, RDP payment gateway will process the payment or transaction. The result of the payment or transaction will then be communicated to merchant system through two ways or methods. One of the methods is called ‘Push Notification’. As the name suggest, RDP push the payment-result to the Merchant’s system as is indicated by the URL that is sent within the request under the field of notify_url. The following are the important points of this push notification:
Push notification result example:
{"mid":"1000089029","transaction_id":"pruefer_9is_9901523031657784985","order_id":"pruefer_9is","acquirer_transaction_id":"311815","request_amount":"0.01","request_ccy":"SGD","authorized_amount":"0.01","authorized_ccy":"SGD","acquirer_authorized_amount":"0.01","acquirer_authorized_ccy":"SGD","response_code":"0","response_msg":"successful","acquirer_response_code":"0","acquirer_response_msg":"APPROVED OR COMPLETED","acquirer_authorization_code":"657300","created_timestamp":"2017-05-05 09:49:24","acquirer_created_timestamp":"2017-05-05 09:49:15","first_6":"411111","last_4":"1111","request_timestamp":"2017-05-05 09:49:08","request_mid":"1000089029","transaction_type":"S","payment_mode":"1","signature":"cf966933ef6b23ab45b95e9a0d8d4d51bd024f9ed3aaa0b0ff66132e317f8b0fa077dcd5b50dd2dcc6808d8b00b90b4cc53a9cfa04278118f8a848f86782eb2a"}
Below is the sample code for push notification handling in PHP programming language.
/*
This sample code is retrieving the result from the BODY of an RDP push notification, and parse the JSON into array, traverse and print it out to the screen.
By default a successful PHP script returns status 200
*/
$content = '';
/* RETRIEVE RESULT FROM BODY */
$querystring = @file_get_contents('php://input');
$arrParam = array();
$prefix = '';
try {
$arrParam = json_decode($querystring, true);
$content .= $querystring;
foreach($arrParam as $key => $val) {
$content .=$key.'='.$val."\n";
}
$prefix = "";
if(isset($arrParam["mid"])) $prefix .= $arrParam["mid"];
$prefix .= "_";
if(isset($arrParam["transaction_id"]))
$prefix .= $arrParam["transaction_id"];
file_put_contents(
"notif_log/".$prefix."-".date('Y_m_d_H_i_s').rand(100,999).
'res'.'.txt', $content);
}
catch (Exception $e) {
file_put_contents(
"notif_log/".$prefix."-".date('Y_m_d_H_i_s').rand(100,999).
'-errorres'.'.txt',
$e->getMessage());
}