safaricom / mpesa-node-library Goto Github PK
View Code? Open in Web Editor NEWM-Pesa Library for Node.js using REST API
License: Apache License 2.0
M-Pesa Library for Node.js using REST API
License: Apache License 2.0
docs inform on a single requirement of providing consumerKey and consumerSecret.
Though for the accountBalance request securityCredential is also a requirement. Where to find this for our Mpesa account?
Created a contribution guide to allow newer members understand how they can contribute towards the project's growth
Describe the bug
The callback returns the following error response but I seem to have done everything right.
Error
{
"Result": {
"ResultType": 0,
"ResultCode": 2001,
"ResultDesc": "The initiator information is invalid.",
"OriginatorConversationID": "11143-7569966-1",
"ConversationID": "AG_20181024_000043ade8e082b13567",
"TransactionID": "MJO61H754M",
"ReferenceData": {
"ReferenceItem": {
"Key": "QueueTimeoutURL",
"Value": "https://internalsandbox.safaricom.co.ke/mpesa/b2cresults/v1/submit"
}
}
}
}
Expected behavior
I was expecting a successful response because I had followed all the specifications.
Not really a bug actually the sandbox certificate specified in this repo is correct and I managed to get successful transactions using this key. This is not the case for https://developer.safaricom.co.ke/sites/default/files/cert/cert_sandbox/cert.cer that is different from the certificate that the library uses. The certificate posted on the docs didn't work
Steps to reproduce the behaviour:
A successful transaction
Transaction with the error Initiator Information is invalid
Is this SDK still in use or is there an updated version I should be aware of? I ask because I want to contribute if it is and because it seems that the last update was 3 years ago
"express": "^4.18.2"
node v14.18.1
and "mpesa-node": "^0.1.3"
data: {
requestId: '2275-94324073-1',
errorCode: '500.001.1001',
errorMessage: 'Wrong credentials'
}
const lnm = async () => {
const mpesaApi = new Mpesa({
consumerKey: 'myconsumerkey',
consumerSecret: 'myconsumerasecret',
environment: 'sandbox',
shortCode: 174379
})
const testMSISDN = "254720003332"
const amount = 100
const callBackURL = "http://arbaaz.herokuapp.com/log.txt"
const accountRef = "CLINTON"
const transactionDesc = "Test-CLINTON"
const transactionType = "CustomerPayBillOnline"
const shortCode = 174379
const passKey ="MTc0Mzc5YmZiMjc5ZjlhYTliZGJjZjE1OGU5N2RkNzFhNDY3Y2QyZTBjODkzMDU5YjEwZjc4ZTZiNzJhZGExZWQyYzkxOTIwMTkxMjEzMTA1NzEz"
await mpesaApi.lipaNaMpesaOnline(
testMSISDN,
amount,
callBackURL,
accountRef,
transactionDesc,
transactionType,
shortCode,
passKey
)
.then((result) => {
console.log("result here.. ", result);
})
.catch((err) => {
console.log("error here.. ", err);
})
}
lnm();
It would be nice, for users to know, what open source license covers this code, before they dive in.
Why is my test credentials not showing?
Describe the bug
Not a bug, but a request to look into updating transitive dependencies, specifically axios
:
Seems rather low effort (given existing integration testing will catch regressions), and also seen Dependabot pull requests for updates that haven't been merged.
Any updates from the team/or link to documentation on how to resolve such issues?
CallbackURL doesn not receive any request from MPesa servers
For some reason, there appears to be zero requests sent to the callbackurl after a transaction is made. As a result, the client keeps on waiting and waiting for a server reply in vain.
Axios Issue
Since the Mpesa Library for node is built on top of axios
, A vulnerability has been detected thanks to Sync
. This issue affects all axios versions.
This commit claims to have fixed it. The decision remains whether to work on how to use the fix, or change to another module.
Please add a link to the documentation on where to obtain the keys (consumer/consume).
Describe the bug
When trying to use the LipaNaMpesaOnline api, I keep getting 404 error with the message Unable to identify proxy for host: secure and url: /mpesa/stkpush/v1/processrequest
To Reproduce
Steps to reproduce the behavior:
Expected behavior
STK Push initiated
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context
Add any other context about the problem here.
When I login and check api details for the app, I find consumerKey and consumerSecret. But your package/The REST also requires the "securityCredential" . Where can we find this after going life is initiated?
Is there a syntax error in your code?
Detailed stack trace: /user_code/node_modules/mpesa-node/src/m-pesa.js:31
this.configs = { ...config }
^^^
Use Typescript as my cloud Function Language.
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.