pesapal@1.1.3
This adaptor exports the following from common:
- as()
- cursor()
- dataPath()
- dataValue()
- dateFns
- each()
- field()
- fields()
- fn()
- lastReferenceValue()
- merge()
- sourceValue()
Functions
get
get(path, options) ⇒ Operation
Make a GET request to Pesapal
Param | Type | Description |
---|---|---|
path | string | Path to resource |
options | RequestOptions | Optional request options |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | the parsed response body |
response | the response from the Pesapal server, including headers, statusCode, etc |
references | an 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
Param | Type | Description |
---|---|---|
path | string | Path to resource |
body | object | Object which will be attached to the POST body |
options | RequestOptions | Optional request options |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | the parsed response body |
response | the response from the Pesapal server, including headers, statusCode, etc |
references | an 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
Param | Type | Description |
---|---|---|
method | string | HTTP method to use |
path | string | Path to resource |
body | object | Object which will be attached to the POST body |
options | RequestOptions | Optional request options |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | the parsed response body |
response | the response from the Pesapal server, including headers, statusCode, etc |
references | an 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
Name | Type | Description |
---|---|---|
body | object | string | body data to append to the request. JSON will be converted to a string. |
errors | object | Map of errorCodes -> error messages, ie, { 404: 'Resource not found;' } . Pass false to suppress errors for this code. |
query | object | An object of query parameters to be encoded into the URL. |
headers | object | An object of headers to append to the request. |