newtonmunene99 / mpesa-api Goto Github PK
View Code? Open in Web Editor NEWA NodeJs Module to help you with M-Pesa Daraja API calls.
Home Page: http://npmjs.com/package/mpesa-api
License: MIT License
A NodeJs Module to help you with M-Pesa Daraja API calls.
Home Page: http://npmjs.com/package/mpesa-api
License: MIT License
I'm getting the error above in production when using the Account Balance API and the B2C. Could it be an error when generating the security credential coz everything else works.
Here's an example of the error (Account Balance)
{"ResultDesc":"The initiator information is invalid.",
"ConversationID":"AG_20200625_0000650ea6a99ae1c0bb",
"TransactionID":"OFP0000000",
"ResultParameters":{"ResultParameter":{"Key":"BOCompletedTime","Value":20200625232427}},
"ResultCode":2001,"ReferenceData":{"ReferenceItem":{"Value":"https://internalapi.safaricom.co.ke/mpesa/abresults/v1/submit","Key":"QueueTimeoutURL"}},
"OriginatorConversationID":"13443-10746354-1",
"ResultType":0}
Hello Team,
I am trying to access use the mpesa-api to make the request of authorization but gives me a 400 status invalid credentials unAuthorized error.I am trying to confirm the link in the documentation of how to get my initiator
For the initiator_password, use the security credential from the test credentials page.link :https://developer.safaricom.co.ke/test_credentials
As specified in the docs the link to get the initiator password isnt working.I have a page under this link when logged in
https://developer.safaricom.co.ke/Profile
When I view it there is a place to generate security credentials but above it there is a password field I have come to know you can type anything and a key will be generated which password is required to generate a security credentials and is it same as initiator password on sandbox
Thank You
I'm getting fs.readFileSync is not a function
when running the library on Node : 12.0.0
and React : 16.10.2
It's occurring when getting the certificates
import { Mpesa } from "mpesa-api";
const credentials = {
client_key: '',
client_secret: '',
initiator_password: ' Safaricom007@',
certificatepath:null
};
const environment = "sandbox";
const mpesa = new Mpesa(credentials, environment);
On your mpesa-api, while invoking the B2C API in the sandbox, I am getting the below error
"data":{"requestId":"3911-7748949-1","errorCode":"400.002.02","errorMessage":"Bad Request - Invalid InitiatorName"},"service":"user-service"}
even though the InitiatorName is part of the parameters in the code. i.e.
But when checking the payload in the logs, it's actually missing i.e
"data":"{\"SecurityCredential\":\"lAqo9GH\",\"CommandID\":\"BusinessPayment\",\"Amount\":\"10\",\"PartyA\":600638,\"PartyB\":\"2547xxxxxxxx\",\"Remarks\":\"DriverPayment\",\"QueueTimeOutURL\":\"https://test.com/api/callback.php\",\"ResultURL\":\"https://test.com/api/callback.php\",\"Occasion\":\"account\"}"
// invoking the mpesa api
mpesa
.b2c({
InitiatorName: Constants.initiatorName,
Amount: req.body.Amount,
PartyA: Constants.PaybillB2C,
PartyB: req.body.PhoneNumber,
QueueTimeOutURL: Constants.QueueTimeOutURL,
ResultURL: Constants.ResultURL,
CommandID: Constants.CommandID,
Occassion: Constants.Occassion,
Remarks: req.body.TransactionDesc
})
Does the lib generate it or isn't it compulsory ?
Also how (Where) do I get the initiator Name?
npm i mpesa-api gets a previous version 2.2.0 , however latest version is 2.3.1
$ npm view mpesa-api
[email protected] | MIT | deps: 1 | versions: 8
An NPM Module built with NodeJs to help you with M-Pesa Daraja API calls.
https://github.com/newtonmunene99/mpesa-api/
keywords: mpesa, nodejs, node, mobile money, money
dist
.tarball: https://registry.npmjs.org/mpesa-api/-/mpesa-api-2.2.0.tgz
.shasum: 28574429cdbb6cd34b530e77c41f2726d4739116
.integrity: sha512-004ASyvfITbj5DkzwgbWw9ayVV5+qzR6pQmqdm+kJp+AXV5v1co4lS1o0u8SHoqG6AeXXf2cbylTUNeZ2ltMOw==
.unpackedSize: 66.1 kB
dependencies:
axios: ^0.19.0
maintainers:
- newtonmunene99 <[email protected]>
dist-tags:
latest: 2.2.0```
The lib folder is ignored by the .npmignore
file.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.