How To Setup Lipa Na M-Pesa Online Api

  • HOW TO SETUP LIPA NA M-PESA ONLINE API

  • HOW TO SETUP LIPA NA M-PESA ONLINE API

    LIPA NA M-PESA PAYMENT INTERGRATION

    Mpesa is a mobile money payment service by Safaricom based in Kenya. It was released in 2007 and since then it has become the common means of payment in Kenya. To help developers implement Mpesa in their platforms, Safaricom released the Daraja API.

    PREREQUISITES

    • Have a Kenyan based Safaricom phone number.

    • Have Node.js installed on your computer.

    • Have some basic knowledge of JavaScript and Express JS.

    WHAT WE WILL COVER

    • Creating a Safaricom developer account.

    • Creating-an-app.

    • Getting an Oauth token.

    • Lipa na Mpesa online.

    CREATING A SAFARICOM DEVELOPER ACCOUNT

    Safaricom controls all the operations concerning Mpesa and Daraja API. For you to access Daraja API, you need to have a developer account. The following steps explain how you can create a developer account. Feel free to skip if you already have one.

    • Step 1: The first step is to proceed to Safaricom Developer website.

    • Step 2: Click on the signup button on the center or visit directly from here. Proceed to the signup section.

    • Step 3: After registering, a welcome message with further instructions is sent to your email address. In the email, you shall find a confirmation link, click on it and it shall direct you to a password entry page.

    • Step 4: Enter your password and confirm it and then click login. On the page that follows, you shall view the credentials that you have entered. If you want to edit the credentials, make sure you do the changes and hit save. Otherwise, you are all set.

    CREATING AN APP

    To be able to use the Daraja API, you need to have an app so that you have the required access keys. Creating an app is a very simple process.

    Follow the following steps:

    • Step 1: Click on the My Apps link on the navbar in the developer portal.

    • Step 2: On that page, click the Add a new app button.

    • Step 3: On the page that follows, enter your preferred app name. Check the Lipa na Mpesa Sandbox and then click create app. After that, you are all set.

    • Step 4: Enter your password and confirm it and then click login. On the page that follows, you shall view the credentials that you have entered. If you want to edit the credentials, make sure you do the changes and hit save. Otherwise, you are all set.

    CONFIGURING OUR APPLICATION

    Having set up the developer account and an app, it’s time we set up our application. For this article, we shall implement a REST API with Express.js framework. Our end goal is to implement a working endpoint for Lipa na Mpesa online. To handle communication to and from the Daraja API we shall use Axios.

    To follow along effectively, clone the finalized project from here. To test our API, we will use Postman. If you are not experienced in postman, feel free to watch this video.

    OBTAINING CONSUMER KEY AND CONSUMER SECRET

    On the portal’s apps page, click on the newly created app from the previous process. In the keys section, copy the consumer key and the consumer secret and paste them in your .env file respectively as shown:

    consumer_key = "your consumer key" consumer_secret = "your consumer secret"

Tags:



Related Posts


Comments (0)

Leave a Comment

Type the above code here


More from hatequizzes




Categories


Law & AttorneyParentingHow toLoan & InsuranceGeneralHealthHosting & DomainEducationLatest JobsHealth & FitnessFinanceAutomotiveQuestions & answersinsuranceHome & Garden