How to Register Mpesa URL's in Postman For Mpesa Payment Integration - Webcom Kenya

Contact Info

Garden Estate Road, Cedar Court, Block A Room A3 & A7

+254 720 727 460

info@webcomkenya.com

payment integration

What is Postman ?

Postman is an API platform for building and using APIs. Postman simplifies each step of the API lifecycle and streamlines collaboration so you can create better API faster. It is a powerful and simple tool and only requires you to sign up for an account for you to be able to use.

Payment Integration Process

One of the most popular payment solution in Kenya, Mpesa is rated most preferred method of payment may it be online shopping to paying for services. At Webcom Kenya we have a track record of successful Mpesa payment integration in multiple websites (e-commerce) to billing system software such as Liquibill.

What you need for the Payment Integration Process

  • Mpesa Daraja Portal Account – You can simply register here:
  • Postman Account
  • Domain / Website / System URL eg. https://webcomkenya.com
  • Mpesa shortcode (Paybill or Till Number)

 

Once you are logged in to Mpesa Daraja portal, navigate to API’s tab and click the Get Postman Collection green button

payment integration

To register the urls, you need to import the Mpesa collection urls to postman workspace as indicated below and click on Postman for Web option.

In your postman dashboard, under workspace you’ll have the imported collection url’s stated as Safaricom APIs Click on it and a drop down showing various url’s for different operations and in our case we only interested with two; one being Generate an OAuth Access Token which uses a Get Method and the second url Register C2B Confirmation and Validation URLs and this uses POST method

Generate Access Token

For us to successfully register our urls we need to first generate an access token which will allow us to interact with the API at a specified time usually expires in 3599 seconds as indicated in the image below on number 6.

To do so click on the Generate an OAuth Access Token as indicated by step 1, A tab will open automatically with several actions to be done systematically as  indicated by step 2 – 3

On Step 2 the drop down will provide various options, what we need is Bearer Token (step 3) since we are dealing with access token at this point.

Next we will insert the username and password, as indicated in step 3 and these are consumer key and secret key from the Daraja Developer Portal under My Apps you created.

The username being the consumer key and password is the secret key, change the url on step 4 from https://sandbox.safaricom.co.ke/oauth/v1/generate?grant_type=client_credentials to https://api.safaricom.co.ke/oauth/v1/generate?grant_type=client_credentials then proceed and hit send button (step 5)

On step 6 you’ll see the access token generated, keep since we will use on the next step for url validation.

Note: Sandbox – Demo purposes and api for going live.

Verifying the URL’s

To verify the url’s we navigate to Register C2B confirmation and Validation URLs under Safaricom APIs drop down list. Go to Authorization tab and select bearer token and insert the token generated from the previous step. Once done go to Body tab and fill in your shortcode (usually your Paybill or Till number), response type (as Completed), confirmationURL (your website / system url) and ValidationURL (your website / system url) as indicated from step 2 to 5 below

Finally, click send button (step 6) and below there should be a success message indicating your website URLs have been validated. As a side note safaricom have updated their validation URL from v1 to v2  i.e: https://api.safaricom.co.ke/mpesa.c2b/v2/registerurl

Note: Confirm the URL from https://sandbox.safaricom.co.ke/oauth/v1/generate?grant_type=client_credentials to https://api.safaricom.co.ke/oauth/v1/generate?grant_type=client_credentials before clicking send button.

Conclusion

In conclusion, the integration of M-Pesa as an online payment solution for websites represents a pivotal step towards financial inclusion and convenience in the digital age. With its widespread adoption and proven reliability, M-Pesa offers businesses and consumers alike a secure and efficient means of transacting online. By seamlessly bridging the gap between traditional financial services and the digital world, M-Pesa not only enhances the user experience but also unlocks new opportunities for businesses to reach previously underserved markets. As we continue to witness the rapid evolution of online commerce, M-Pesa’s integration serves as a testament to the power of innovative financial technology in shaping the future of payments on the web.