Skip to main content

mtn-momo@1.0.0

request(method, path, body, options)

This adaptor exports the following from common:

combine()
cursor()
dataPath()
dataValue()
dateFns
each()
field()
fields()
fn()
fnIf()
group()
lastReferenceValue()
merge()
scrubEmojis()
sourceValue()
util

Functions

request

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

Make a HTTP request to the MTN MoMo API

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

This operation writes the following keys to state:

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

Example: Get basic user information

request("GET", "/collection/v1_0/accountholder/MSISDN/46733123451/basicuserinfo", {}, { headers: { "X-Target-Environment": "sandbox" } });

Example: Create an invoice

request("POST", "/collection/v2_0/invoice", 
{
"externalId": "996b82e6-d498-4c7c-87ee-7b0654350a2c",
"amount": "100",
"currency": "EUR",
"validityDuration": "3600",
"intendedPayer": {
"partyIdType": "MSISDN",
"partyId": "46733123450"
},
"payee": {
"partyIdType": "MSISDN",
"partyId": "46733123452"
}
"description": ""
},
{
"headers": {
"X-Target-Environment": "sandbox",
"X-Reference-Id": "ceb46c4f-1523-405b-9d16-dd9ad45e202c"
}
});

Interfaces

HttpState

State object

Properties

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

RequestOptions

Options provided to the HTTP request

Properties

NameTypeDescription
errorsobjectMap of errorCodes -> error messages, ie, { 404: 'Resource not found;' }. Pass false to suppress errors for this code.
formobjectPass a JSON object to be serialised into a multipart HTML form (as FormData) in the body.
queryobjectAn object of query parameters to be encoded into the URL.
headersobjectAn object of headers to append to the request.
parseAsstringParse the response body as json, text or stream. By default will use the response headers.
timeoutnumberRequest timeout in ms. Default: 300 seconds.
tlsobjectTLS/SSL authentication options. See https://nodejs.org/api/tls.html#tlscreatesecurecontextoptions