Giter Site home page Giter Site logo

lipa-na-mpesa_nodejs's Introduction

Lipa Na Mpesa Online

A Nodejs implementation of Safaricom's Lipa na Mpesa Online Payment Api. Use this as a starting point template for your app.

Requirements

Credentials are required including:

  • Consumer Key
  • Consumer Secret
  • Passkey

The consumer key & secret can be obtained by registering for an account here https://developer.safaricom.co.ke/ and once you have an account, the passkey can be got here https://developer.safaricom.co.ke/test_credentials

Installing

To automatically get the correct dependencies used in this project, ensure you have Node.js installed then:

  1. Clone the project by running git clone https://github.com/petekmunz/Lipa-Na-Mpesa_Nodejs.git in your Git terminal.
  2. In your terminal ensure you are in the directory Lipa-Na-Mpesa_Nodejs then run npm install

Pre-requirements

  • Create a .env file in the root directory with the following variables.
NODE_ENV=development
MYPORT=3000                 //You can set to your preferrable port
CONSUMER_KEY=******************
CONSUMER_SECRET=***************
PASSKEY=***************
SHORTCODE=174379            //This is the test shortcode
  • In the app.js file, replace the url here "CallBackURL": "http://example.com/api/v1/c2bconfirmation" with your actual callback url. The endpoint needs to be exposed to the internet if it is to receive a payload from Safaricom.

Running

  • Make a POST request to the endpoint http://localhost:3000/mpesa with a JSON with the parameters as in the example below
{
    "phoneNumber":"254722xxxxxx",
    "amount":11
}

When all the required variables have been input, a succesful request will result in a STK push as shown below

lipa-na-mpesa_nodejs's People

Contributors

dependabot[bot] avatar petekmunz avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

lipa-na-mpesa_nodejs's Issues

ERROR

when i make a request i get this error errorMessage: 'Invalid grant type passed'

Https Callback URL

Hey peter, i have my code for stk push but am stuck on getting a secure callback URL that's online always. How can i get one please

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.