Comments (7)
Hi there, does this occur in the sandbox?
It doesn't seem to suggest a problem with the library, you might be passing the wrong initiator name.
When you say everything else works, does that include other methods which require initiator name?
from mpesa-api.
The withdrawal works in postman but fails when i use the code with the same credentials
from mpesa-api.
Any solution to this problem ?
from mpesa-api.
Hi @cngeru i'm still unable to reproduce this. You mentioned it worked for you on Postman. Can you share your request, with dummy values for sensitive fields.
from mpesa-api.
The request body in postman
{
"InitiatorName": "CODE",
"SecurityCredential": "CODE",
"CommandID": "BusinessPayment",
"Amount": "100",
"PartyA": "CODE",
"PartyB": "CODE",
"Remarks": "CODEWithdrawal",
"QueueTimeOutURL": "https://us-central1-CODE.cloudfunctions.net/mpesaWithdrawalTimeout?userId=xx&wAuth=xx",
"ResultURL": "https://us-central1-CODE.cloudfunctions.net/mpesaWithdrawalResult?userId=xx&wAuth=xx",
"Occasion": "CODE Withdrawal"
}
The code (JS)
const B2C_CREDS ={
client_key: CODE,
client_secret: 'CODE',
initiator_password: "CODE",
certificatepath: null
}
const B2C_DETAILS= {
SHORTCODE : CODE,
INITIATOR_NAME:'CODE',
};
const environment = "production";
const B2C = new Mpesa(B2C_CREDS, environment);
try {
await B2C.b2c({
Initiator:B2C_DETAILS.INITIATOR_NAME,
Amount: amount,
PartyA: B2C_DETAILS.SHORTCODE,
PartyB: phoneNumber,
QueueTimeOutURL:timeout,
ResultURL: result,
CommandID: "BusinessPayment",
Occasion: `Withdrawal By ${CODE}`,
Remarks: "CODE Withdrawal"
})
.then((mpesaResponse)=>{
console.log(JSON.stringify(mpesaResponse));
return {result: 'Mpesa Transaction was successful'};
})
from mpesa-api.
@cngeru I'm still looking into this, in the meantime, I've added the option to pass security credentials when initiating. This means you can generate the security credential in your M-Pesa web portal and pass it statically as a string. The library will generate it automatically if you exclude this field or pass it as null.
from mpesa-api.
Alrighty
from mpesa-api.
Related Issues (7)
- Security credential key missing HOT 8
- version mismatch npm i gets version 2.2.0 , however latest version is 2.3.1 HOT 6
- lib folder isn't included with npm install
- Initiator Password in Daraja 2.0 HOT 2
- Getting fs.readFileSync is not a function HOT 7
- B2C API bug :- "Bad Request - Invalid InitiatorName" HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mpesa-api.