Monday, September 25, 2017

Mobitel Charging As A Service API

September 25, 2017 Posted by Akalanka 1 comment

Mobitel's Charging as a service API via Inzpire enables developers to integrate carrier billing to the applications with the minimum amount of hassle. This is one of the two charging related APIs in the Mobitel API suite in Inzpire along with the Subscription API. Using this API requires you to be registered as a developer in the Inzpire developer portal. You can refer this post to learn how to register yourself.

Step 1: Create an application key in API Manager

First you have to create an application in case if you have not already created one. To create an application click on 'Apps' link on the API portal and click on 'Create new App' on the top. Fill the following details to create the application
    • Title - name of your application
    • Description- brief description on what your app will do
    • OAuth Redirect URI - The redirect URI used in oAuth flow if your application uses oAuth based authorization in any of the APIs. More on this later.

  • You can view your newly created app under 'Apps' and click on the app name to view further details. Note the ClientID in the and click the 'show' checkbox to view the ClientID. You will need this in consuming the APIs below
  • Go to the API product page here and select the Charging As A Service API
  • Click on the 'Subscribe' button and select the the application that you just created on the menu that pops up. Now your app is subscribed to the Charging As A Service API


Step 2: Call CaaS API

The charging as a service API exposes the following two services

  • Charging request service
    • This service needs to be called to initiate a transaction. 
    • It will send a USSD popup to the user with the details of the transaction and will request the user to approve the same. 
    • It will return a reference number for the transaction which will be used with the confirmation service to check if the customer has approved the charging request
    • If the user fails to approve the transaction due to any reason, you can re-initiate the process by calling this service after 2 minutes
  • Transaction confirmation service - This service needs to be called to confirm the transaction. The service call will return a successful response if the user has given the consent to the USSD popup message sent previously to obtain consent.

2.1 API definition - Charging Request


  • URL: 
    • API Endpointhttps://apphub.mobitel.lk/mobext/mapi/caas/chargRequest
  • Request type:
    • HTTP POST
  • Headers:
    • x-ibm-client-id : The application's client ID
  • Body: The body should be a JSON formatted string with the following parameters
    • amount: The amount that needs to be charged in Rupees  
    • customer: The customer mobile number from which the amount should be charged
      • eg: {"amount":"5","receiver":"0712755777"}
  • Response: received as a JSON formatted string with the following parameters
    • reference: reference number of the transaction. Very important as this reference is used in the next API call to complete the transaction
    • message: verbose response message
    • status: response code
You can play with the API by visiting the online portal here


2.2 API definition - Charge confirmation
  • URL: 
    • API Endpointhttps://apphub.mobitel.lk/mobext/mapi/caas/confirm
  • Request type:
    • HTTP POST
  • Headers:
    • x-ibm-client-id : The application's client ID
  • Body: The body should be a JSON formatted string with the following parameters
    • ref: the reference number received in the previous API call
      • eg: {"ref":"320438941208291"}
  • Response: received as a JSON formatted string with the following parameters
    • reference: reference number of the transaction. Useful for logging and tracking purposes.
    • message: verbose response message
    • status: response code
You can play with the API by visiting the online portal here

1 comment:

  1. Now that we’ve mentioned all one of the best MyBookie promo codes, let’s speak more about this web site. Observe such issues as RTP, volatility, hit frequency, payment system, game mechanics, and so on. It’s necessary to know the circumstances, which 온라인 카지노 allow acquiring extras and then utilizing them in the right means, to take essentially the most profit.

    ReplyDelete