PesapalProvider implements the FinConnect provider interface for PesaPal, handling OAuth2 token exchange, IPN registration, and order submission via PesaPal’s v3 API.
authenticate()
POST {baseUrl}/api/Auth/RequestToken
Request body:
response.data.token).
Throws: "Authentication failed: ..." if the request fails.
registerIpn()
FintechSDK.registerIpn() and store the returned ID.
Endpoint: POST {baseUrl}/api/URLSetup/RegisterIPN
Request body:
Authorization: Bearer <token>
Returns: The ipn_id string from PesaPal’s response. Pass this as ipnId when calling sdk.pay().
Throws: "IPN registration failed: ..." if the request fails.
initiateUssdPushRequest()
ipnId is merged into the payload as notification_id before the request is sent.
Endpoint: POST {baseUrl}/api/Transactions/SubmitOrderRequest
Effective request body: { ...payload, notification_id: ipnId }
Headers: Authorization: Bearer <token>
Returns: PesaPal order response object.
Throws: "Payment request failed: ..." if the request fails.
Use
FintechSDK.pay() and FintechSDK.registerIpn() rather than calling PesapalProvider methods directly. FintechSDK handles payload normalisation and provider selection for you.