PAM API DOCS
-
Welcome to PAM API,this api is organized around REST API. Our API has predictable resource-oriented URLs, accepts json/form-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs that is GET and POST. You can invoke our API endpoints using REST clients like Postman or SoapUI and command line tools like curl and Node.js.
-
The PAM API only accepts the Content-Type: application/json & Accept: application/json
- To make an API call, you will need to authenticate your app. We have provided an OAuth API for you to generate an access token, we support Authorization grant type. To authorize your API call to the OAuth API, you will need a Basic Auth over HTTPS authorization token.
https://pam.api.easyncpay.com/api/v1/token
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://pam.api.easyncpay.com/api/v1/token',
'headers': {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Basic ACCOUNT_API_TOKEN'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
{
"data": {
"Token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvcGFtLmFwaS5lYXN5bmNwYXkuY29tXC9hcGlcL3YxXC90b2tlbiIsImlhdCI6MTYxNDU5NTI4MywiZXhwIjoxNjE0NTk4ODgzLCJuYmYiOjE2MTQ1OTUyODMsImp0aSI6IkYzVmpQNDJQb1ZjU0YycjIiLCJzdWIiOiI4OTczODllMy01ZjdjLTRhYjAtYjI2OS01YjFmNmI3NTM2NGEiLCJwcnYiOiI4N2UwYWYxZWY5ZmQxNTgxMmZkZWM5NzE1M2ExNGUwYjA0NzU0NmFhIn0.KWJbcAoIW6yF0IgCaylv7EqotDZnkXt5MvmuEZrjNbA",
"TokenType": "Bearer",
"Expires": 3600
},
"success": true
}
https://pam.api.easyncpay.com/api/v1/shortcode
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://pam.api.easyncpay.com/api/v1/shortcode',
'headers': {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
https://pam.api.easyncpay.com/api/v1/app
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://pam.api.easyncpay.com/api/v1/app',
'headers': {
'Accept': 'application/json'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
https://pam.api.easyncpay.com/api/v1/pay-loads
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://pam.api.easyncpay.com/api/v1/pay-loads',
'headers': {
'Accept': 'application/json'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
Provide all the valid information to check if the paybill/till number credentials are valid.
POST https://pam.api.easyncpay.com/api/v1/m-pesa/shortcode validate
Params
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://pam.api.easyncpay.com/api/v1/m-pesa/shortcode/validate',
'headers': {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({"ConsumerKey":"","ConsumerSecret":"","Environment":"sandbox/production"})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
{
"data": {
"Message": "The m-pesa app keys are valid."
},
"success": true
}
https://pam.api.easyncpay.com/api/v1/m-pesa/c2b/register-url
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://pam.api.easyncpay.com/api/v1/m-pesa/c2b/register-url',
'headers': {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: JSON.stringify({"Secret":""})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
expected response
{
"data": {
"Message": "Validation and Confirmation URLs are already registered"
},
"success": true
}
This section shows how to make stk push and callback data for both stk-push and lipa na mpesa.
https://pam.api.easyncpay.com/api/v1/m-pesa/c2b/stk-push
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://pam.api.easyncpay.com/api/v1/m-pesa/c2b/stk-push',
'headers': {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({"CallingCode":"254","Secret":"","PhoneNumber":"","Amount":"1","ResultUrl":"","Description":"Testing the PAM API","TransactionType":"CustomerPayBillOnline/CustomerBuyGoodsOnline"})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
"data": {
"Success": true,
"Description": "Transaction description.",
"ReferenceNumber": "2BONOSBBTN",
"PhoneNumber": "254XXXXXXXXX",
"MpesaReceiptNumber": "PBO2ZOBY44",
"Amount": 20000
}
"data": {
"Success": true,
"Description": "Transaction description.",
"ReferenceNumber": "2BONOSBBTN",
"PhoneNumber": "254XXXXXXXXX",
"MpesaReceiptNumber": "PBO2ZOBY44",
"Amount": 20000,
'TransactionType': 'Pay Bill'
'OrgAccountBalance': 50000
}
"data": {
"Success": false,
"Description": "Request cancelled by user",
"ReferenceNumber": "2BOXRDNMLU",
"PhoneNumber": "254XXXXXXXXX"
}
https://pam.api.easyncpay.com/api/v1/m-pesa/c2b/confirm-stk-payment
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://pam.api.easyncpay.com/api/v1/m-pesa/c2b/confirm-stk-payment',
'headers': {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: JSON.stringify({"Secret":"", "ReferenceNumber":"", "ResultUrl":"",})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
"data": {
"Success": true,
"Description": "Transaction description.",
"ReferenceNumber": "2BONOSBBTN",
"PhoneNumber": "254XXXXXXXXX",
"MpesaReceiptNumber": "PBO2ZOBY44",
"Amount": 20000
}
"data": {
"Success": false,
"Description": "Request cancelled by user",
"ReferenceNumber": "2BOXRDNMLU",
"PhoneNumber": "254XXXXXXXXX"
}
This is where all the bulk payments are made.
https://pam.api.easyncpay.com/api/v1/m-pesa/b2c
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://pam.api.easyncpay.com/api/v1/m-pesa/b2c',
'headers': {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: JSON.stringify({"CallingCode":"254","Secret":"","PhoneNumber":"","Amount":"10","ResultUrl":"","Description":"Testing the PAM API","TransactionType":"BusinessPayment/SalaryPayment/PromotionPayment"})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
"data": {
'Success' => true,
'Description' => 'Salary payment',
'ReferenceNumber' => '2BO6BCTLYF',
'PhoneNumber' => '254XXXXXXXXX',
'MpesaReceiptNumber' => 'PBO2ZOBY44',
'Amount' => 50000,
'B2CUtilityAccountAvailableFunds' => 70000,
'B2CWorkingAccountAvailableFunds' => 70000,
'B2CChargesPaidAccountAvailableFunds' => 70000
}
"data": {
"Success": false,
"Description": "The initiator information is invalid.",
"ReferenceNumber": "2BO6BCTLYF",
"PhoneNumber": "254XXXXXXXXX"
}
confirming stk paymentPOST
https://pam.api.easyncpay.com/api/v1/m-pesa/b2c/confirm-withdraw
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://pam.api.easyncpay.com/api/v1/m-pesa/b2c/confirm-withdraw',
'headers': {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: JSON.stringify({"Secret":"", "ReferenceNumber":"", "ResultUrl":"",})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
"data": {
'Success' => true,
'Description' => 'Salary payment',
'ReferenceNumber' => '2BO6BCTLYF',
'PhoneNumber' => '254XXXXXXXXX',
'MpesaReceiptNumber' => 'PBO2ZOBY44',
'Amount' => 50000,
'B2CUtilityAccountAvailableFunds' => 70000,
'B2CWorkingAccountAvailableFunds' => 70000,
'B2CChargesPaidAccountAvailableFunds' => 70000
}
"data": {
"Success": false,
"Description": "The initiator information is invalid.",
"ReferenceNumber": "2BO6BCTLYF",
"PhoneNumber": "254XXXXXXXXX"
}
Having trouble with API integration?. Check out our libraries for a quick intergration, or contact support and we’ll help you sort it out.