Instant Payment Notifications (IPN)

Finally it is here! Instant Payment Notifications, otherwise known as IPN. No more cron jobs. Phew!

Okay, so what is all the fuss about? If you have an e-commerce website that is integrated with PesaPal, or are planning to have one, read on!

Previously, when a customer made a purchase on your site, you posted the transaction to PesaPal where your customer then made a payment.

It was cumbersome, to say the least, for you to then figure out if the payment completed successfully or not. You had to query PesaPal repeatedly until PesaPal had the final answer to the query.

With Instant Payment Notifications, your code can kick-back, chill and just wait for PesaPal to notify it!

How does IPN work?

Whenever a payment state change has occurred on one of your transactions, PesaPal will call your website with three query parameters, for example:

pesapal_notification_type=CHANGE&pesapal_transaction_tracking_id=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX&pesapal_merchant_reference=12345

The pesapal_transaction_tracking_id and pesapal_merchant_reference identify which transaction this is in reference to.

Once you get such a notification from PesaPal, you can query for the status of this transaction using the QueryPaymentStatus API method, and update your database with the status returned by PesaPal.

That’s it!

Security

You may be wondering why PesaPal does not send the status of the transaction to you when sending you the notification.

Well, in order to do this securely, we would require you to have SSL enabled for your website (so your website can be accessed using https instead of plain old http).

Since this may not be cost effective for most e-commerce businesses, we made the decision to only send you fields that identify a transaction uniquely.

When you subsequently query PesaPal, using these unique identifiers, for the payment status, the result is returned over a secure SSL connection (since you will be querying https://www.pesapal.com/api/querypaymentstatus).

How to Enable IPN?

Log in to your business account and click on the “IPN Settings” menu option.

Enter the domain of your website as well as the URL at which you will be listening to PesaPal notifications.

PesaPal™   Merchant IPN Settings

Reference and Code Samples

Please visit http://developer.pesapal.com for references and code samples (both PHP and .Net). Also, there is a forum where you can raise questions and suggestions.

Happy coding!

Leave a Reply