|
Welcome,
Guest
|
|
|
Hey,
Does the demo IPN listener really send back the status? How long does it take pesapal to send back the payment status? |
|
|
|
Hi thomas,
The IPN runs immediately a status change is noted, howevre, it does not return the status, instead it returns:
From the data returned you can query the status of the transaction then update your database. |
|
Regards,
Lazaro Ong'ele Web Developer Skype: Lazrotep +254-020-249-5438 ; +254-706-191-729 Dagoretti Lane, Off Naivasha Road. Facebook: www.facebook.com/pesapal Twitter: twitter.com/PesaPal Helpdesk: support.pesapal.com This e-mail address is being protected from spambots. You need JavaScript enabled to view it. |
|
Lazro,
Below is my IPN listener code.But it does not still give back the status.Where might I have gone wrong? Thanks <?php include_once('OAuth.php'); $con = mysql_connect('localhost','username','pwd') or die(mysql_error()); mysql_select_db('db', $con); $consumer_key = 'JemHupqfTk43tvoPH0rdtz/G3Hg/YgRA'; $consumer_secret = 'eb15l9eluffagA7SeR1nEXw9vvw='; $statusrequestAPI = 'demo.pesapal.com/api/QueryPaymentStatus'; $pesapal_notification_type = $_GET['pesapal_notification_type']; $pesapal_transaction_tracking_id = $_GET['pesapal_transaction_tracking_id']; $pesapal_merchant_reference = $_GET['pesapal_merchant_reference']; if ($pesapal_notification_type == 'CHANGE' && $pesapal_transaction_tracking_id != '') { // Pesapal parameters $token = $params = NULL; $consumer = new OAuthConsumer($consumer_key, $consumer_secret); // Get transaction status $signature_method = new OAuthSignatureMethod_HMAC_SHA1(); $request_status = OAuthRequest::from_consumer_and_token($consumer, $token, 'GET', $statusrequestAPI, $params); $request_status -> set_parameter('pesapal_merchant_reference', $pesapal_merchant_reference); $request_status -> set_parameter('pesapal_transaction_tracking_id',$pesapal_transaction_tracking_id); $request_status -> sign_request($signature_method, $consumer, $token); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $request_status); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); if (defined('CURL_PROXY_REQUIRED')) { if (CURL_PROXY_REQUIRED == 'True') { $proxy_tunnel_flag = (defined('CURL_PROXY_TUNNEL_FLAG') && strtoupper(CURL_PROXY_TUNNEL_FLAG) == 'FALSE') ? false : true; curl_setopt ($ch, CURLOPT_HTTPPROXYTUNNEL, $proxy_tunnel_flag); curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); curl_setopt ($ch, CURLOPT_PROXY, CURL_PROXY_SERVER_DETAILS); } } $response = curl_exec($ch); $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE); $raw_header = substr($response, 0, $header_size - 4); $headerArray = explode('\r\n\r\n', $raw_header); $header = $headerArray[count($headerArray) - 1]; // Transaction status $elements = preg_split('/=/',substr($response, $header_size)); $status = $elements[1]; // PENDING, COMPLETED or FAILED curl_close ($ch); if ($status == 'COMPLETED') { $db_update_successful = mysql_query("UPDATE details SET status = 'S' where transaction_id = '$pesapal_transaction_tracking_id' " , $con); if ($db_update_successful > 0) { // Send Pesapal response only if we were able to update DB $resp = 'pesapal_notification_type='.$pesapal_notification_type; $resp .= '&pesapal_transaction_tracking_id='.$pesapal_transaction_tracking_id; $resp .= '&pesapal_merchant_reference='.$pesapal_merchant_reference; ob_start(); echo $resp; ob_flush(); } } elseif ($status == 'FAILED') { // Transaction confirmed that it's NOT successful so we update the DB // UPDATE YOUR DB TABLE AND CANCEL TRANSACTION OR MARK AS FAILED, POSSIBLY NOTIFY USER // pesapal_transaction_tracking_id $pesapal_transaction_tracking_id mysql_query("UPDATE details SET status = 'F' where transaction_id = '$pesapal_transaction_tracking_id' ",$con); $resp = 'pesapal_notification_type='.$pesapal_notification_type; $resp .= '&pesapal_transaction_tracking_id='.$pesapal_transaction_tracking_id; $resp .= '&pesapal_merchant_reference='.$pesapal_merchant_reference; ob_start(); echo $resp; ob_flush(); } // If PENDING ... we do nothing ... Pesapal will keep sending us the IPN but // at least we know it's pending exit; } ?> |
|
|
|
Hi Thomas,
There seems to be an issue with the IPN. We are working to correct that and you shall be informed once its corrected. Apologies for the inconveniences caused. |
|
Regards,
Lazaro Ong'ele Web Developer Skype: Lazrotep +254-020-249-5438 ; +254-706-191-729 Dagoretti Lane, Off Naivasha Road. Facebook: www.facebook.com/pesapal Twitter: twitter.com/PesaPal Helpdesk: support.pesapal.com This e-mail address is being protected from spambots. You need JavaScript enabled to view it. |
|
Hi Thomas,
Please try now. IPN is working. |
|
Regards,
Lazaro Ong'ele Web Developer Skype: Lazrotep +254-020-249-5438 ; +254-706-191-729 Dagoretti Lane, Off Naivasha Road. Facebook: www.facebook.com/pesapal Twitter: twitter.com/PesaPal Helpdesk: support.pesapal.com This e-mail address is being protected from spambots. You need JavaScript enabled to view it.
Last Edit: 12 years, 6 months ago by lazro.
|
|
Hi,
I have the code as above and i am checking the status with the this piece of code if ($status == 'COMPLETED') { but still receive 2 replies from the IPN. Is there anything else i am missing? |
|
|
|