Skip to main content

pesapal@1.0.1

get(path, options)
post(path, body, options)
request(method, path, body, options)

Functions

get

get(path, options) ⇒ Operation

Make a GET request to Pesapal

ParamTypeDescription
pathstringPath to resource
optionsRequestOptionsOptional request options

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
responsethe response from the Pesapal server, including headers, statusCode, etc
referencesan array of all previous data objects used in the Job

Example: Get all registered IPN URLs for a merchant

get('URLSetup/GetIpnList')

post

post(path, body, options) ⇒ Operation

Make a POST request to Pesapal

ParamTypeDescription
pathstringPath to resource
bodyobjectObject which will be attached to the POST body
optionsRequestOptionsOptional request options

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
responsethe response from the Pesapal server, including headers, statusCode, etc
referencesan array of all previous data objects used in the Job

Example: Send an order request

post('Transactions/SubmitOrderRequest', 
{
"id": "TEST-05",
"currency": "KES",
"amount": "1",
"description": "Testing",
"callback_url": "https://www.myapplication.com/response-page",
"notification_id": "fe078e53-78da-4a83-aa89-e7ded5c456e6",
"billing_address": {
"email_address": "john.doe@example.com",
"phone_number": "0712xxxxxx",
"country_code": "",
"first_name": "Doe",
"middle_name": "",
"last_name": "John",
"line_1": "",
"line_2": "",
"city": "",
"state": "",
"postal_code": "",
"zip_code": ""
}
})

request

request(method, path, body, options) ⇒ Operation

Make a general HTTP request to Pesapal

ParamTypeDescription
methodstringHTTP method to use
pathstringPath to resource
bodyobjectObject which will be attached to the POST body
optionsRequestOptionsOptional request options

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
responsethe response from the Pesapal server, including headers, statusCode, etc
referencesan array of all previous data objects used in the Job

Example: Register IPN URL

request("POST", "URLSetup/RegisterIPN", {
"url": "https://www.myapplication.com/ipn",
"ipn_notification_type": "GET"
});

Example: Get transaction status

request('GET', 'GetTransactionStatus', {}, {query:{
orderTrackingId: '123456'
}})

Interfaces

RequestOptions

Options provided to the Pesapal request

Properties

NameTypeDescription
bodyobject | stringbody data to append to the request. JSON will be converted to a string.
errorsobjectMap of errorCodes -> error messages, ie, { 404: 'Resource not found;' }. Pass false to suppress errors for this code.
queryobjectAn object of query parameters to be encoded into the URL.
headersobjectAn object of headers to append to the request.