Coder Social home page Coder Social logo

newtonmunene99 / mpesa-api Goto Github PK

View Code? Open in Web Editor NEW
106.0 13.0 52.0 990 KB

A NodeJs Module to help you with M-Pesa Daraja API calls.

Home Page: http://npmjs.com/package/mpesa-api

License: MIT License

TypeScript 93.77% JavaScript 6.23%
mpesa mpesa-api mpesa-payments mpesa-rest mpesa-sdk mpesapi money online-payments online-payment-system safaricom

mpesa-api's Issues

Getting "The initiator information is invalid." when Live

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} 

Initiator Password in Daraja 2.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

Getting fs.readFileSync is not a function

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

B2C API bug :- "Bad Request - Invalid InitiatorName"

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

version mismatch npm i gets version 2.2.0 , however latest version is 2.3.1

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```

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.