API DOCS

How to get started with our api's

Getting Access Token

Our api's are json based and for you to make a successful call you have to generate an access token that expires after an hour.

Access 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
}
                                               

PayBill/Till Number

Listing your linked paybill/till number

How To Get PayBill/Till Numbers

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);
});

                                               

Apps

Listing all your apps.

Apps

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);
});

                                                

Transactions

Listing all your latest transactions.

Transactions

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);
});

                                                

Validating PayBill/Till Number

Provide all the valid information to check if the paybill/till number credentials are valid.

Validation

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
}
                                                

Register C2B Callback

Here register the confirm and validation url.

C2B Callbacks

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);
});

                                                
{
    "data": {
        "Message": "Validation and Confirmation URLs are already registered"
    },
    "success": true
}
                                                

STK PUSH

This section shows how to make stk push and callback data for both stk-push and lipa na mpesa.

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"
}
                                              

B2C

This is where all the bulk payments are made.

Bulk Payments

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"
}

                                               

API Libraries

To make your work easier for integration. We have developed libraries to get you started quicly.