Prerequisites
- A PesaPal merchant account
- A consumer key and consumer secret from the PesaPal dashboard
- A publicly accessible server URL for IPN notifications
Integration steps
Install and configure credentials
Add the following environment variables to your The sandbox base URL is
.env file:https://cybqa.pesapal.com/pesapalv3. You will swap this for the production URL when going live.Initialize the SDK
Import
FintechSDK and ProviderType from finconnect, then construct an instance using your credentials:Register your IPN URL
You must register your IPN URL before submitting a payment order.
registerIpn authenticates with PesaPal and returns an ipnId that you pass to subsequent pay() calls.The
ipnId returned by registerIpn is passed both in the payload as notification_id and as the second argument to pay(). FinConnect handles merging it into the request automatically.Handle the IPN callback
Set up an Express route to receive payment notifications from PesaPal. The route must be reachable at the URL you registered in step 3.PesaPal sends the
OrderTrackingId, OrderMerchantReference, and OrderNotificationType as query parameters for GET-type IPNs. Use these to look up and update the corresponding order in your system.