pesapaljs-v3
v1.0.13
Published
Integrate PesaPal into your Node application v3
Downloads
33
Maintainers
Readme
pesapaljs-v3 (MAINTAINED)
Goal
Make it easy to integrate PesaPal into a website or mobile app.
Core Features
init(options)
: Initialize Package.options
should contain akey
, asecret
anddebug
together.authenticate()
: Authenticate with pesapal servers and set bearer token.register_ipn_url(options)
: Register an IPN url, that will be used by pesapal to inform your server on any changes.options
should contain aurl
and aipn_notification_type
.get_ipn_list()
: Returns the list of registered IPN'ssubmit_order(options)
: Initiates an order to pesapal and returns the iframe src url.options
should include,id
-unique system generated id,currency
- if KES or other,amount
,description
,callback_url
- to where the user will be redirected to on the UI ,notification_id
- unique id associated with yout IPN url,billing_address
- an object with user details as such{ "email_address": "[email protected]", "phone_number": None, "country_code": "", "first_name": "John", "middle_name": "", "last_name": "Doe", "line_1": "", "line_2": "", "city": "", "state": "", "postal_code": None, "zip_code": None }
get_transaction_status(oPTIONS)
: Returns the status details of a trasaction.options
should includeOrderTrackingId
that you receives from the callback.
Usage
Install
$ npm i pesapaljs-v3
Setup
var PesaPal = require('pesapaljs-v3').init({
key: CONSUMER_KEY,
secret: CONSUMER_SECRET,
debug: true // false in production!
});
When the debug
option is set, pesapaljs-v3
will use the cybqa.pesapal.com*
endpoints.
Authenticate with pesapal
// initiate an authentication with the package
PesaPal.authenticate();
POST an IPN url
var options = {
url: "ngrok.something/ipn",
ipn_notification_type: "GET"
};
PesaPal.register_ipn_url(options)
.then(function(status){ /* do stuff*/ })
.catch(function(error){ /* do stuff*/ });
GET registered IPN list
PesaPal.get_ipn_list()
.then(function(status){ /* do stuff*/ })
.catch(function(error){ /* do stuff*/ });
POST an order request
PesaPal.submit_order({
"id": 231323, //generate some unique value, probably use uuid.
"currency": "KES",
"amount": 10,
"description": "payment for masterclass", // transaction description
"callback_url": "https://some.com/home", //front end url for redirect
"notification_id": "b3699d97-1c04-45b5-8062-de69d6dad9a1", //IPN url
"billing_address": {
"email_address": "[email protected]",
"phone_number": "",
"country_code": "KE",
"first_name": "John",
"middle_name": "",
"last_name": "Doe",
"line_1": "",
"line_2": "",
"city": "",
"state": "",
"postal_code": "",
"zip_code": ""
}
})
.then(function(status){ /* do stuff*/ })
.catch(function(error){ /* do stuff*/ });
GET transaction status
PesaPal.get_transaction_status({
OrderTrackingId:OrderTrackingId // ensure you get the spelling correct!
})
.then(function(status){ /* do stuff*/ })
.catch(function(error){ /* do stuff*/ });
Contributing
- Fork this repo and make changes in your own fork.
- Commit your changes and push to your fork
git push origin master
- Create a new pull request and submit it back to the project.
Bugs & Issues
To report bugs (or any other issues), use the issues page.