Ola Money Developer Hub

Welcome to the Ola Money developer hub. You'll find comprehensive guides and documentation to help you start working with Ola Money as quickly as possible, as well as support if you get stuck.

Documentation
Suggest Edits

Introduction to offline Api's

 

What is offline api?

We have api's for retailers who would like to integrate with Olamoney. This requires deep integration with POS terminals of the merchant.

Suggest Edits

Offline flow - OTP

 

Merchant will have to implement a form on their end to accept the customers phone number and the bill amount and hit "Pay Now" button. Upon which another form has to accept the OTP

Then the merchant has to call the debit API with the following.

Step 1 : Call Debit API - Merchant Side

The JSON post of the debit call is attached below.
The phone number of the user has to sent in the call as a param.
http://sandbox.olamoney.in/olamoney/v1/debit?phone=<Mobile Number>

{
  "command": "debit",  // Always as debit
  "accessToken": "string", //Shared with you
  "uniqueId": "string",  // Unique transaction ID from your end
  "comments": "string",  // Any string Mandatory
  "udf": "string", //Mandatory
  "hash": "string", 
  "returnUrl": "string",
  "notificationUrl": "string",
  "amount": 100.00,  // Always in two decimal
  "currency": "string",
  "couponCode": "string"
}

Response of the transaction will be as follows.

{
  "type": "debit",
  "status": "string",
  "transactionId": "string",
  "merchantBillId": "string",
  "amount": "string",
  "hash": "string",
  "timestamp": 48146194691,
  "comments": "string",
  "udf": "string",
  "isCashbackSuccessful": "string",
  "isCashbackAttempted": "string"
}

However, the status of this response will remain in 'pending' stage.
The customer will get an OTP on the phone number.
Ask the OTP from the customer.

For these calls, the hash is calculated as given in the "Bill Generator" section.

Step 2: Customer Authentication

With the OTP from the customer and the bill params passed earlier make another POST call with the given JSON

http://sandbox.olamoney.in/olamoney/v1/capture

{
  "command": "capture",
  "accessToken": "string",
  "uniqueId": "string",
  "comments": "string",
  "udf": "string",
  "hash": "string",
  "returnUrl": "string",
  "notificationUrl": "string",
  "amount": 100.00,
  "currency":"INR",
  "otp": "string"
}

For this the hash is calculated with the string as given below.

<AccessToken>|command|comments|notificationUrl|otp|returnUrl|udf|uniqueId|<Salt>

This will give an updated response with a status "success"

{
  "type": "debit",
  "status": "string",
  "transactionId": "string",
  "merchantBillId": "string",
  "amount": "string",
  "hash": "string",
  "timestamp": 0,
  "comments": "string",
  "udf": "string",
  "isCashbackSuccessful": "string",
  "isCashbackAttempted": "string"
}

Also always verify the response hash as well :


data_string =  'type|status|merchantBillId|transactionId|amount|comments|udf|isCashbackAttempted|isCashbackSuccessful|timestamp|salt';
merchant_hash = sha512(data_string);
Suggest Edits

/resendTransactionOTP

 
posthttp://sandbox.olamoney.in/olamoney/v1/resendTransactionOTP
curl --request POST \
  --url http://sandbox.olamoney.in/olamoney/v1/resendTransactionOTP
var request = require("request");

var options = { method: 'POST',
  url: 'http://sandbox.olamoney.in/olamoney/v1/resendTransactionOTP' };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
require 'uri'
require 'net/http'

url = URI("http://sandbox.olamoney.in/olamoney/v1/resendTransactionOTP")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)

response = http.request(request)
puts response.read_body
var data = JSON.stringify(false);

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "http://sandbox.olamoney.in/olamoney/v1/resendTransactionOTP");

xhr.send(data);
import requests

url = "http://sandbox.olamoney.in/olamoney/v1/resendTransactionOTP"

response = requests.request("POST", url)

print(response.text)
A binary file was returned

You couldn't be authenticated

{
  "status": "success"
}
{"errorCode":"invalid_otp","message":"Not a valid
OTP","status":"error"}

Form Data

accessToken
string

merchant accessToken

command
string

resendOTP

timestamp
date-time

Current timestamp YYY-MM-DD HH:mm:SS e.g. 2015-08-13 13:17:12

uniqueBillId
string

uniqueBill Id to which OTP needs to be resend

hash
string

sha512(accessToken|resendOTP|<current timestamp>|<unique bill id>|<salt>)

 

In 1 minute you can hit the RE-SEND-OTP API, 4 times. From 5th time within that 1 minute,API will return 429 status code with no content. User can try again, from next minute.
Resend OTP will be valid only for 15 minutes from the commencement of transaction.
You can check the status code and if its 429, you can conclude OTP rate limiting error.

Suggest Edits

Offline flow - QR Code

 

Merchant has to enter the amount of transaction and generate the bill.

Step 1 : Call Debit API - Merchant Side

The JSON post of the debit call is attached below.
http://sandbox.olamoney.in/olamoney/v1/debit

{
  "command": "debit",
  "accessToken": "string",
  "uniqueId": "string",
  "comments": "string",
  "udf": "string",
  "hash": "string",
  "returnUrl": "string",
  "notificationUrl": "string",
  "amount": 1.00,
  "currency": "string",
  "couponCode": "string"
}

Response of the transaction will be as follows.

{
  "type": "debit",
  "status": "string",
  "transactionId": "string",
  "merchantBillId": "string",
  "amount": "string",
  "hash": "string",
  "timestamp": 1446655693970,
  "comments": "string",
  "udf": "string",
  "isCashbackSuccessful": "string",
  "isCashbackAttempted": "string"
}

However, the status of this response will remain in 'pending' stage.
The TransactionID in this response should be used to make a QR code.
QR codes can be generated with the help of the following link.

For these calls, the hash is calculated as given in the "Bill Generator" section.

Step 2: Customer authentication

When the Consumer side app scans the QR code, it should return the same TransactionID. This is for user authentication which upon which you'll get this response with a "success" status.

{
  "type": "debit",
  "status": "success",
  "transactionId": "string",
  "merchantBillId": "string",
  "amount": "1.00",
  "hash": "bb3e508655c7511f1980af88a64e962d4cf70a5fca8668a01a721dfda41f21d1a7e767523ecc001f294e96df54dddcd5e20fa737c95bec9afecdb4f114fe7e19",
  "timestamp": 1446655693970,
  "comments": "string",
  "udf": "string"
}
Suggest Edits

Offline flow - PayCode & Teller

 

Merchant will have sign-up into OM Merchant Console and create "Tellers" ( These tellers are to represent the POS terminal of the merchant )
Teller will be provided with Username & Password.
Bulk Teller Creation is supported.
These "Tellers" can consume Offline PayCodes provided by Customers

Step 1 : Login for teller ( Returns Access_Token used to call further APIs )

POST 'http://stark-teller-qa-002.app.qa.olamoney.net/teller/v1/login'
Host: stark-teller-qa-002.app.qa.olamoney.net
Content-Type: application/json
Authorization: Basic <Basic Auth Token>
Body : Null

Response contains AccessToken & RefreshToken
AccessToken --> Expires in a while ( Configurable by OlaMoney )
RefreshToken --> Always remains constant for a given Login ( no expiry )

Step 2. Teller Initiated Debit

POST 'http://stark-teller-qa-002.app.qa.olamoney.net/teller/v1/payment/teller/initiateDebit'
Host: stark-teller-qa-002.app.qa.olamoney.net
Content-Type: application/json
Authorization: Bearer <Access_token>
Body :

{
  "payCode": "2522737",
  "amount": 10,
  "transactionId": "112112",
  "content": {}
}

Incase response is of type 401 ( UnAuthorized , please call the below API to refresh the Access Token )
Once Refresh is complete , use the new AccessToken with the above transaction.

Step 3. Teller Refresh Token ( Refresh the Access_Token sent in Login )

POST 'http://stark-teller-qa-002.app.qa.olamoney.net/teller/v1/refreshToken'
Host: stark-teller-qa-002.app.qa.olamoney.net
Content-Type: application/json
Authorization: Bearer <Access_token>
Body :

{
    "access_token": "6db19673-f64f-409d-9aa9-d412ebbd9e99",
    "refresh_token": "3a70f6aa3f644be4a22c13a3ee1b1fec"
}
Suggest Edits

Introduction to Merchant Reward Points

 

What is merchant reward points?

Merchant gives loyalty points to its customers.Merchant can convert these loyalty points into Ola money but to use that they need to put prepaid money with Ola.While they redeem the loyalty point respective amount will be deducted from that available balance.
Using this reward point feature they can convert their reward points into Ola Money, get their available prepaid balance and even check their redeem transaction details. With the redeem API you can add money to a user’s Ola Money wallet with their mobile number.

Suggest Edits

Step 1: Buy reward points

 

Header Auth

 Authentication is required for this endpoint.
posthttp://sandbox.olamoney.in
curl --request POST \
  --url http://sandbox.olamoney.in/
var request = require("request");

var options = { method: 'POST', url: 'http://sandbox.olamoney.in/' };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
require 'uri'
require 'net/http'

url = URI("http://sandbox.olamoney.in/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)

response = http.request(request)
puts response.read_body
var data = JSON.stringify(false);

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "http://sandbox.olamoney.in/");

xhr.send(data);
import requests

url = "http://sandbox.olamoney.in/"

response = requests.request("POST", url)

print(response.text)
A binary file was returned

You couldn't be authenticated

Try the API to see results
 

Merchant has to pay the amount to the finance team to buy the reward points.
Once we receive the amount, we will credit the amount to your merchant account.
You can check the available credit balance at any point of time using the API in step 2.

Suggest Edits

Step 2: Check your Available prepaid balance

 

Header Auth

 Authentication is required for this endpoint.
posthttp://sandbox.olamoney.in/olamoney/v1/rewardpoints/balance
{
  "command": "reward_point_query",
  "accessToken": "merchant_access_token",
  "hash": "8ee7189ee2ee02867705098aee4b8a94c47f56e69b2668cf71bd98bdb30cb0dc35d4e9dd91658731bbecc8f39d8197a2a099b1c54522ca904a48e85ac1d70fbc"
}
A binary file was returned

You couldn't be authenticated

{
  "type": "reward_point",
  "status": "success",
  "externalMerchantId": "RUM863",
  "amount": "2000.00",
  "hash": "423c733d80f80c04d54f6a5a6e5fde7c4ebb9af23cbff93781072eb67965f3baa75e2d1029581449c83c410fd85afc8e63f30c59262e266c5864409156ad7fb3",
  "timestamp": 1470207751431
}
{
  "errorCode": "hash_mismatch",
  "message": "Hash verification failed",
  "status": "error"
}
 

Merchant can check their available balance in their prepaid account that they can use for redeeming the user's reward point.
Send http POST request with the JSON body .

{
  "command": "reward_point_query",
  "accessToken": "merchant_access_token",
  "hash": "8ee7189ee2ee02867705098aee4b8a94c47f56e69b2668cf71bd98bdb30cb0dc35d4e9dd91658731bbecc8f39d8197a2a099b1c54522ca904a48e85ac1d70fbc"
}
hash=sha512('merchant_access_token|reward_point_query|<SALT>');
Suggest Edits

Step 3: Validate Before Redeeming Amount

 

Header Auth

 Authentication is required for this endpoint.
posthttp://sandbox.olamoney.in/olamoney/v1/rewardpoints/validatecredit
{
 "command": "reward_point",
 "accessToken": "ola_access_token",
 "amount": "10.01",
 "currency": "INR",
 "mobile": "9999999999",
 "hash": "d2616084511420a576b777fa0d3eeba4781c65f2150d73844d9ad30e5d681bd6761c4b11daeb530a0881d76ba8436f4d5d74951fb354ac3856e535982955c706"
}
A binary file was returned

You couldn't be authenticated


{
  "status": "success"
}
{
  "status": "FAILED"
}
{
  "errorCode": "invalid_command",
  "message": "Hash Mismatch",
  "status": "error"
}
 

Merchants may end up debiting amount from user's bank but redeem transaction may fail. Before proceeding to actually redeeming or crediting amount let us figure out whether the transaction may get succeeded or failed. This is achieved through Validate API. This API helps Merchants to debit user's amount only in case of success response.

Validate API , helps the merchant to know in advance whether the redeem transaction fulfils all constraints to get succeeded from our end. It can be either success or failure.
Failure cases may be due to monthly limit breach, invalid user, blocked user or rate limiting factors.
Redeem instructions are given in next step.

Validate POST request needs Basic Authentication and Application/JSON headers.

{
 "command": "reward_point",
 "accessToken": "ola_access_token",
 "amount": "10.01",// Always in 2 decimals
 "currency": "INR",
 "mobile": "9999999999",
 "hash": "d2616084511420a576b777fa0d3eeba4781c65f2150d73844d9ad30e5d681bd6761c4b11daeb530a0881d76ba8436f4d5d74951fb354ac3856e535982955c706"
}

Hash for the validate API is calculated as follows.

hash=sha512('<Merchant access token>|reward_point|INR|9999999999|10.01|<salt>');
Suggest Edits

Step 4: Redeem Reward Points

 

Header Auth

 Authentication is required for this endpoint.
posthttp://sandbox.olamoney.in/olamoney/v1/rewardpoints/redeem
{
  "command": "reward_point",
  "accessToken": "merchant_access_token",
  "uniqueId": "ttab988977",
  "comments": "string",
  "udf": "string",
  "hash": "string",
  "returnUrl": "string",
  "notificationUrl": "string",
  "amount": "50.00",
  "balanceType": "cash",
  "balanceName": "string",
  "currency": "INR",
  "mobile": "9999999999",
  "agentId": "string"// Anything but not null
}
A binary file was returned

You couldn't be authenticated


{
  "type": "credit",
  "status": "success",
  "transactionId": "c7t8-9pqv-5rgj",
  "merchantBillId": "ttab988977",
  "amount": "50.00",
  "hash": "459c9a3e65e3d6589f483f3663f1c7fb26845623500c80ac8eea42ee342ab4f1aa9ece6d5028ce9f0383ca813ae3675dda1999c25b75e34dec1cce4f976ec5c5",
  "timestamp": 1470153253189,
  "comments": "string",
  "udf": "udf"
}
{
  "errorCode": "hash_mismatch",
  "message": "Hash verification failed",
  "status": "error"
}
 

Allow your users to convert their reward points into Ola Money with this redeem API. With the redeem API you can add money to a user’s Ola Money wallet with their mobile number.

In order to use this API you must prepay a certain amount to Ola Money. Every time you credit Ola Money to a user, the amount is deducted from your prepaid balance.

As you get closer to exhausting your prepaid balance, you will receive an email with instructions to recharge your prepaid balance.
Send http POST request with the JSON body .

Basic Authentication key is required for this API.
POST call to Redeem API with headers "Authorization": "Basic Auth" and "Content-Type": "application/json"

{
  "command": "reward_point",
  "accessToken": "merchant_access_token",
  "uniqueId": "uniqueId",
  "comments": "redeem 50 reward points",
  "udf": "udf",
  "hash": "f85798463bd0b7a32aa6ce9952b3db87a0e82ca19ef13b6696df758a0071389c130b4937e086656404d3edc4a39090b5c7fe86dc3857ec4afa5fcd4fa09821c3",
  "returnUrl": "returnUrl",
  "notificationUrl": "notificationUrl",
  "amount": "50.00",
  "balanceType": "cash",
  "balanceName": "cash",
  "currency": "INR",
  "mobile": "9999999999",
  "agentId": "123"
}
hash=sha512('merchant_access_token|uniqueId|redeem 50 reward points|udf|returnUrl|notificationUrl|INR|50.00|cash|cash|9999999999|<SALT>');
Suggest Edits

Step 5: Check redeem transaction details

 

Header Auth

 Authentication is required for this endpoint.
posthttp://sandbox.olamoney.in/olamoney/v1/rewardpoints/query
{
  "command": "reward_point_query",
  "accessToken": "merchan_access_token",
  "uniqueId": "UniqueBillId",
  "hash": "4382fec90203cff78d18a627a1512a84dc718a493cb2c9555ad777197d2a029c14ba555a0dafad1c617b45f504029e31c2883fb0058ba252bc9226f58a2b6926"
}
A binary file was returned

You couldn't be authenticated


{
  "type": "reward_point",
  "status": "completed",
  "uniqueBillId": "UniqueBillId",
  "externalMerchantId": "RUM863",
  "amount": "13.30",
  "udf": "udf",
  "hash": "fba2648df13f38df743f5a05a3d69c8a809af8d3730c404294d0e04033ad1c7492e6c780b8d47409f780b97090b900d889f69d147cc1465f9ee88439661fb143",
  "timestamp": 1470161314078
}
{
  "errorCode": "hash_mismatch",
  "message": "Hash verification failed",
  "status": "error"
}
 

This API allow merchant to view their redeem transaction so that they can check the status and other details of the transaction.
Send http POST request with the JSON body .

{
  "command": "reward_point_query",
  "accessToken": "merchan_access_token",
  "uniqueId": "UniqueBillId",
  "hash": "4382fec90203cff78d18a627a1512a84dc718a493cb2c9555ad777197d2a029c14ba555a0dafad1c617b45f504029e31c2883fb0058ba252bc9226f58a2b6926"
}
hash=sha512('merchant_access_token|UniqueBillId|reward_point_query|<SALT>');
Suggest Edits

Introduction

This page outlines the deep integration of Ola Money wallet with your checkout

 

What is Auto Debit?

Auto debit feature allows your customers to deep link his Ola Money wallet to his account. Once the customer link the wallet to your account, it will allow you to debit your customer account for the services you provided without customer authenticating the payment. This feature helps your business grow by providing a great payment experience to your customers.

Auto debit

Its recommended that Auto debit flow should be used only after user has completed merchant authentication i.e only once the user has logged in on the merchant platform.

Agreement

The usage of this flow should be mutually agreed between the merchant and OLA money teams since this flows would require certain technical approach agreements.

Suggest Edits

Integration guide - Auto Debit

This page outlines the deep integration of Ola Money wallet with your checkout

 

To link a user wallet with his account , merchant need to call addUserWallet API with phone number and emailId. Note that in case the user does not exists with Olamoney, a new user account is signed up with Ola money account. On below API call user will receive a OTP

Merchant needs to render OTP page for the user to enter this OTP.
Followed by linkUserWallet API call Step 2.

Suggest Edits

Step 1: Call addUserWallet API

 

Basic Auth

 Authentication is required for this endpoint.
posthttp://sandbox.olamoney.in/olamoney/v1/userWallet/addUserWallet?phone=phone&email=email
curl --request POST \
  --url 'http://sandbox.olamoney.in/olamoney/v1/userWallet/addUserWallet?email=email&phone=phone'
var request = require("request");

var options = { method: 'POST',
  url: 'http://sandbox.olamoney.in/olamoney/v1/userWallet/addUserWallet',
  qs: { email: 'email', phone: 'phone' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
require 'uri'
require 'net/http'

url = URI("http://sandbox.olamoney.in/olamoney/v1/userWallet/addUserWallet?email=email&phone=phone")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)

response = http.request(request)
puts response.read_body
var data = JSON.stringify(false);

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "http://sandbox.olamoney.in/olamoney/v1/userWallet/addUserWallet?email=email&phone=phone");

xhr.send(data);
import requests

url = "http://sandbox.olamoney.in/olamoney/v1/userWallet/addUserWallet"

response = requests.request("POST", url)

print(response.text)
A binary file was returned

You couldn't be authenticated

{ 
"status": "success", 
"message": "" 
}
{
 "status": "FAILED",
 "message": "User wallet already added"
}

Query Params

phone
string

User's Phone number

email
string

user's Email

 

To link a user wallet with his account , merchant need to call addUserWallet API with phone number and emailId.

Note that in case the user does not exists with Olamoney, a new user account is signed up with Ola money account. On below API call user will receive a OTP

Merchant needs to render OTP page for the user to enter this OTP.
Followed by linkUserWallet API call Step 2.

POST CALL to addUserWallet API with headers set as "Authorization":Basic Auth and "Content-Type":application/json

AddUserWallet option

  1. You should not allow guest users to add ola money wallet
  2. Render the email id and phone number using which user has been signed in on merchant app.
Suggest Edits

Step 2 : Call linkUserWallet API

 

Basic Auth

 Authentication is required for this endpoint.
posthttp://sandbox.olamoney.in/olamoney/v1/userWallet/linkUserWallet?phone=phone&otp=:otp
curl --request POST \
  --url 'http://sandbox.olamoney.in/olamoney/v1/userWallet/linkUserWallet?otp=%3Aotp&phone=phone'
var request = require("request");

var options = { method: 'POST',
  url: 'http://sandbox.olamoney.in/olamoney/v1/userWallet/linkUserWallet',
  qs: { otp: ':otp', phone: 'phone' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
require 'uri'
require 'net/http'

url = URI("http://sandbox.olamoney.in/olamoney/v1/userWallet/linkUserWallet?otp=%3Aotp&phone=phone")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)

response = http.request(request)
puts response.read_body
var data = JSON.stringify(false);

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "http://sandbox.olamoney.in/olamoney/v1/userWallet/linkUserWallet?otp=%3Aotp&phone=phone");

xhr.send(data);
import requests

url = "http://sandbox.olamoney.in/olamoney/v1/userWallet/linkUserWallet"

response = requests.request("POST", url)

print(response.text)
A binary file was returned

You couldn't be authenticated

{ 
"status": "success", 
"message": "", 
"accessToken": "1938ee1a-df6c-4562-b378-c713434b9f1a", 
"refreshToken": "619186e816a14c65912d7d7126b2fc66” 
}
{
 "status": "FAILED",
 "message": "Invalid OTP",
 "accessToken": "",
 "refreshToken": ""
}

Query Params

phone
string

User Phone Number

OTP
string

user OTP

 

With OTP from the customer and his phone number make another POST call

Above two steps are mandatory for the new customer.After that Merchant needs to store accessToken and refreshToken generated at their end for every user.

NOTE : accessToken expiry time is 8 hour,refresh token expiry time is 6 month.

If the token is expired you need to call the refresh API explained in next step.

Note : Merchant need to persist access token and refresh token on their side and send then to Ola as and when required by the other API - autoDebit, delinkUserWallet, userBalance etc.

What if you lose user access token ?

In case merchant fails to persist access token and refresh token user, then step 1 and step 2 has to be repeated for that particular user.

Suggest Edits

Step 3. Call refresh API (If any token is expired)

 

Basic Auth

 Authentication is required for this endpoint.
posthttp://sandbox.olamoney.in/olamoney/v1/userWallet/refresh
curl --request POST \
  --url http://sandbox.olamoney.in/olamoney/v1/userWallet/refresh
var request = require("request");

var options = { method: 'POST',
  url: 'http://sandbox.olamoney.in/olamoney/v1/userWallet/refresh' };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
require 'uri'
require 'net/http'

url = URI("http://sandbox.olamoney.in/olamoney/v1/userWallet/refresh")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)

response = http.request(request)
puts response.read_body
var data = JSON.stringify(false);

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "http://sandbox.olamoney.in/olamoney/v1/userWallet/refresh");

xhr.send(data);
import requests

url = "http://sandbox.olamoney.in/olamoney/v1/userWallet/refresh"

response = requests.request("POST", url)

print(response.text)
A binary file was returned

You couldn't be authenticated

{
  "status": "success",
  "refreshSessionResponse": {
    "access_token": "8e6e3f70-b6a9-4984-9372-b51326895f04",
    "access_token_expiry": 9223372036854775807,
    "access_token_expiry_from_now": 9223372036854775807
  },
  "message": ""
}
{
  "errorCode": "unknown_error",
  "message": "Something went wrong!!",
  "status": "error"
}

Query Params

accessToken
string

user access token

refreshToken
string

user refresh token

 

When access token for the user is expired, call POST with the given JSON

with headers set as "Authorization" and "Content-Type" as Basic Auth and application/json respectively.

{
 "accessToken":"8e6e3f70-b6a9-4984-9372-v51326895f04",
 "refreshToken":"ae831906-d3ca-4c33-8dba-7bc8ae9aafe6"
}
Suggest Edits

Step 4: Call userBalance API

 

Basic Auth

 Authentication is required for this endpoint.
posthttp://sandbox.olamoney.in/olamoney/v1/userBalance
curl --request POST \
  --url http://sandbox.olamoney.in/olamoney/v1/userBalance
var request = require("request");

var options = { method: 'POST',
  url: 'http://sandbox.olamoney.in/olamoney/v1/userBalance' };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
require 'uri'
require 'net/http'

url = URI("http://sandbox.olamoney.in/olamoney/v1/userBalance")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)

response = http.request(request)
puts response.read_body
var data = JSON.stringify(false);

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "http://sandbox.olamoney.in/olamoney/v1/userBalance");

xhr.send(data);
import requests

url = "http://sandbox.olamoney.in/olamoney/v1/userBalance"

response = requests.request("POST", url)

print(response.text)
A binary file was returned

You couldn't be authenticated

{
  "status": "success",
  "comments": "string",
  "amount": 0,
  "balanceType": "string”
}
{
  "status": "error",
  "comments": "Invalid user access token",
  "amount": 0,
  "balanceType": null
}

Query Params

userAccessToken
string

user' access token for the one, you want to check the balance

 

Once the tokens are generated , call the balance API to check the user has the sufficient balance or not.

Headers :
Authorization : Basic Auth
Content-Type: application/json

Request Payload specified below

{"userAccessToken":"8e6e3f70-b6a9-4984-9372-b51326895f04"}
Suggest Edits

Step 5. Call autoDebit API

 

Basic Auth

 Authentication is required for this endpoint.
posthttp://sandbox.olamoney.in/olamoney/v1/autoDebit
{
  "command": "debit",
  "accessToken": "string",
  "uniqueId": "string",
  "comments": "string",
  "udf": "string",
  "hash": "string",
  "returnUrl": "string",
  "notificationUrl": "string",
  "amount": 10.00,
  "currency": "string",
  "couponCode": "NA",
  "userAccessToken": "string"
}
A binary file was returned

You couldn't be authenticated

{
  "type": "debit",
  "status": "string",
  "transactionId": "string",
  "merchantBillId": "string",
  "amount": "string",
  "hash": "string",
  "timestamp": 1472024600672,
  "comments": "string",
  "udf": "string",
  "isCashbackSuccessful": "string",
  "isCashbackAttempted": "string”
}

Body Params

command
string

It will be "debit"

accessToken
string

Merchant access token.

comments
string

Comments for the transaction - Mandatory

udf
string

To be provided by you - Mandatory

hash
string

SHA 512 of given string explained below

returnUrl
string
notificationUrl
string
amount
string

It should be in two decimal

currency
string

INR

couponCode
string

For any running offers other wise you have to pass it as "NA"

userAccessToken
string

Token of the user for whom you want to make the debit

 

command - This will be ‘debit’ for a charge transaction.

accessToken - An unique key using which Ola identifies the merchant.

uniqueId - A unique transaction ID provided by merchant. The generation of uniqueId completely lies with you.

amount - Amount for which you wish to charge the customer.Upto two decimal and same value has to be passed in hash as well.

udf - user defined fields significant to merchants.

currency - currency of the payment made.

notify_url - this is a url hosted on merchant server where we post the details of the transaction after the transaction is complete. This is a server to server call.

return_url - this is a url hosted on merchant server where we redirect the user after the transaction is complete. This redirect happens in your web-view. (In case of in-app payments, there is no redirect and return_url is ignored.)

CouponCode - This is a coupon code that Ola Money team can generate for running cashback offers. If you pass this, then the user will get the appropriate cashback, if you don't it you can just pass any param such as "NA".

userAccessToken - Generated at Step 2. If the token is expired repeat step 3 and pass the newly generated accessToken.

{
  "command": "debit",
  "accessToken": "string",
  "uniqueId": "string",
  "comments": "string",
  "udf": "string",
  "hash": "string",
  "returnUrl": "string",
  "notificationUrl": "string",
  "amount": 10.00,
  "currency": "string",
  "couponCode": "NA",
  "userAccessToken": "string"
}

HASH GENERATION

You need to generate a hash, in the following format, using SHA-512:
hash = sha512('access_token|uniqueId|comments|udf|returnUrl|notifyUrl|currency|amount|useracessToken|couponCode|salt')

Suggest Edits

Step 6 . Call delinkUserWallet

 

Basic Auth

 Authentication is required for this endpoint.
posthttp://sandbox.olamoney.in/olamoney/v1/userWallet/delinkUserWallet
curl --request POST \
  --url http://sandbox.olamoney.in/olamoney/v1/userWallet/delinkUserWallet
var request = require("request");

var options = { method: 'POST',
  url: 'http://sandbox.olamoney.in/olamoney/v1/userWallet/delinkUserWallet' };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
require 'uri'
require 'net/http'

url = URI("http://sandbox.olamoney.in/olamoney/v1/userWallet/delinkUserWallet")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)

response = http.request(request)
puts response.read_body
var data = JSON.stringify(false);

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "http://sandbox.olamoney.in/olamoney/v1/userWallet/delinkUserWallet");

xhr.send(data);
import requests

url = "http://sandbox.olamoney.in/olamoney/v1/userWallet/delinkUserWallet"

response = requests.request("POST", url)

print(response.text)
A binary file was returned

You couldn't be authenticated


{
  "status": "string",
  "message": "string"
}

{
 "status": "FAILED",
 "message": "Invalid phone number"
}

Body Params

phoneNumber
string

user phone number

refreshToken
string

refresh token of the user

 

Finally when user want to delink from the merchant, call the delinkUserWallet with given JSON post

Headers :
Authorization : Basic Auth
Content-Type: application/json

{
  "phoneNumber": "8989898989",
  "refreshToken": "23c16592-7d1c-4178-9b51-b443fea8010d"
}
Suggest Edits

In Case of Insufficient Balance- Web

 

You can user userBalance API to check the user balance beforehand before proceeding to payment.
In case user does not have sufficient balance , webview will be rendered for the user , from there user can recharge its ola money wallet

Step 1. WebView - Wallet Recharge (Credit) Payload

Merchant first need to generate a JSON credit payload for the required amount, as shown below.

{
"command":"credit",
"accessToken":"MerchantAccessToken",
" merchantReferenceId ":"XCd54def32",
"comments":"tX9EY",
"udf":"Ip63u",
"hash":"85f4fe6f19bef13135936565c0a32787a3f6b0acf81167a0a8ef639c256a94caab96725ef040155b5be121f130284cbfdee2f91d44d771d12dc6fe084360989b",
"returnUrl":"http://localhost:8080/olamoney/dummy_return",
"notificationUrl":"http://localhost:8080/olamoney/dummy_return",
"amount":"1.00",// amount should be upto two decimal same has to be pass in hash
"userAccessToken":"e9c6956d-efcd-4cc6-a6d5-38888fc4e50a",
"currency":"INR",
"balanceType":"cash",
"balanceName":"cash"
}

DETAILS:

command - This will be ‘credit’ for a load money transaction.

accessToken - An unique key using which Ola identifies the merchant.

merchantReferenceId - A unique transaction ID provided by merchant. The generation of uniqueId completely lies with you.

amount - Required amount to be loaded for the payment of transaction.

udf - user defined fields significant to merchants.

currency - currency of the payment made.

notify_url - this is a url hosted on merchant server where we post the details of the transaction after the transaction is complete. This is a server to server call.

return_url - this is a url hosted on merchant server where we redirect the user after the transaction is complete. This redirect happens in your web-view. (In case of in-app payments, there is no redirect and return_url is ignored.)

userAcessToken – which you have stored at your end, generated from the linkUserWallet API

HASH GENERATION

hash= sha512('access_token|merchantReferenceId|comments|udf|returnUrl|notifyUrl|currency|amount|userAccessToken|salt'); // All the params are mandatory

Step 2. Base64 Encode the Credit Payload

Merchant need to Base65 encode the JSON created at Step 1.

After Base64 encoding the it will look like =>

eyJjb21tYW5kIjoiY3JlZGl0IiwNCiJhY2Nlc3NUb2tlbiI6Ik1lcmNoYW50QWNjZXNzVG9rZW4iLA0KIiBtZXJjaGFudFJlZmVyZW5jZUlkICI6IlhDZDU0ZGVmMzIiLA0KImNvbW1lbnRzIjoidFg5RVkiLA0KInVkZiI6IklwNjN1IiwNCiJoYXNoIjoiODVmNGZlNmYxOWJlZjEzMTM1OTM2NTY1YzBhMzI3ODdhM2Y2YjBhY2Y4MTE2N2EwYThlZjYzOWMyNTZhOTRjYWFiOTY3MjVlZjA0MDE1NWI1YmUxMjFmMTMwMjg0Y2JmZGVlMmY5MWQ0NGQ3NzFkMTJkYzZmZTA4NDM2MDk4OWIiLA0KInJldHVyblVybCI6Imh0dHA6Ly9sb2NhbGhvc3Q6ODA4MC9vbGFtb25leS9kdW1teV9yZXR1cm4iLA0KIm5vdGlmaWNhdGlvblVybCI6Imh0dHA6Ly9sb2NhbGhvc3Q6ODA4MC9vbGFtb25leS9kdW1teV9yZXR1cm4iLA0KImFtb3VudCI6IjEuMDAiLA0KInVzZXJBY2Nlc3NUb2tlbiI6ImU5YzY5NTZkLWVmY2QtNGNjNi1hNmQ1LTM4ODg4ZmM0ZTUwYSIsDQoiY3VycmVuY3kiOiJJTlIifQ0K

STEP 3. OPEN THE FOLLOWING URL ALONG WITH BILL

http://sandbox.olamoney.in/olamoney/webview/index.html?bill=<Base64bill>

Once the user redirects after the above webview flow to the returnURL you have provided. Use the below API (Verify Load Money) to check the status of the transaction and accordingly you can display the status to the user.

Suggest Edits

In Case of Insufficient Balance - Android

 

Step 1 Wallet Recharge(Credit) in Android app

To launch the webview following is the code snippet =>

The payload that you have generated in STEP 1 "Wallet Recharge (Credit) Payload" has to be passed below.

StringBuffer buffer=new StringBuffer("http://sandbox.olamoney.in/olamoney/webview/index.html");
String base64_bill = Base64.encodeToString(bill.getBytes(), Base64.DEFAULT); 
buffer.append("?bill="+base64_bill); 
webview.getSettings().setJavaScriptEnabled(true);
webView.setWebViewClient(new WebViewClient());
webView.loadUrl(buffer.toString());

Step 2. TO GET BACK TO YOUR APP

STEP 1: DECLARE A JAVASCRIPT INTERFACE FOR YOUR WEB-VIEW

interface OlaMoneyInteface {
 @android.webkit.JavascriptInterface
 void onPaymentDone(String jsonResponse); }

STEP 2: ADD THIS JAVASCRIPT INTERFACE TO THE WEBVIEW:

webView.addJavascriptInterface(new OlaMoneyInteface() { @Override 
@android.webkit.JavascriptInterface 
public void onPaymentDone(String jsonResponse) 
{ /*Control is returned to the native code   You can get the data in jsonResponse */ } }, "OlaMoney");

STEP 3: MODIFY PROGUARD CONFIGURATION (OPTIONAL)

If you are using proguard, then you need to add the following line to your proguard configuration file:

-keepclassmembers class * {  @android.webkit.JavascriptInterface <methods>; }

STEP 4: HANDLE RETURN_URL

We will send data to the return_url specified in your bill, and you should invoke the function send_user_native in your javascript once you get the data received from Ola Money, as below:

<script type="text/javascript">     function send_user_native(data) {         OlaMoney.onPaymentDone(data);      } </script>
Suggest Edits

Verify Load Money

 

Basic Auth

 Authentication is required for this endpoint.
posthttp://sandbox.olamoney.in/olamoney/v1/verifyloadmoney?merchantReferenceId=id
curl --request POST \
  --url 'http://sandbox.olamoney.in/olamoney/v1/verifyloadmoney?merchantReferenceId=id'
var request = require("request");

var options = { method: 'POST',
  url: 'http://sandbox.olamoney.in/olamoney/v1/verifyloadmoney',
  qs: { merchantReferenceId: 'id' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
require 'uri'
require 'net/http'

url = URI("http://sandbox.olamoney.in/olamoney/v1/verifyloadmoney?merchantReferenceId=id")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)

response = http.request(request)
puts response.read_body
var data = JSON.stringify(false);

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "http://sandbox.olamoney.in/olamoney/v1/verifyloadmoney?merchantReferenceId=id");

xhr.send(data);
import requests

url = "http://sandbox.olamoney.in/olamoney/v1/verifyloadmoney"

response = requests.request("POST", url)

print(response.text)
A binary file was returned

You couldn't be authenticated


{
 "status": "completed",
 "amount": 100,
 "created_at": 1464879700000,
 "merchantTransactionId": "kDbTc",
 "transaction": "c79j-anu0-5iua"
}

Query Params

id
string

merchantReferenceId is the unique id provided during recharge (credit) payload.

 

Merchant can verify the status of wallet recharge done by the user from merchant app in order to display proper message to the end user.

Below is the Verify API =>

POST CALL
Headers :
Authorization : Basic Auth
Content Type : application/json

 
posthttp://sandbox.olamoney.in/olamoney/v2/refund
curl --request POST \
  --url http://sandbox.olamoney.in/olamoney/v2/refund
var request = require("request");

var options = { method: 'POST',
  url: 'http://sandbox.olamoney.in/olamoney/v2/refund' };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
require 'uri'
require 'net/http'

url = URI("http://sandbox.olamoney.in/olamoney/v2/refund")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)

response = http.request(request)
puts response.read_body
var data = JSON.stringify(false);

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "http://sandbox.olamoney.in/olamoney/v2/refund");

xhr.send(data);
import requests

url = "http://sandbox.olamoney.in/olamoney/v2/refund"

response = requests.request("POST", url)

print(response.text)
A binary file was returned

You couldn't be authenticated

{
 "type":"refund",
 "status":"success",
 "transactionId":"bgho-5bot-ne16",
 "merchantBillId":"cd1501ce-a88e-4654-898d-8b2a266bc467",
 "amount":"20.00",
 "hash":"d1880d064c17db0121645f7c4492176dafa24a25c168d1a045bc46ee2521156c845ebeba2005a487d76d23e47178b7aedd238db2130aab1fb9cca00dbd9294e9",
 "timestamp":1439473847354,
 "comments":"test",
 "udf":"test"
}
{
  "message": "Invalid parameters",
  "status": "error"
}
 

You need to post a JSON in the body to make this work. A sample JSON is below:

{
   "command": "refund",
   "accessToken": "ola_access_token",
   "uniqueId": "7c9f7b95-0f43-4028-9e01-3126b58b61d4", (new one merchant has to generate for the refund txn)
   "comments": "test",
   "udf": "test",
   "hash": "10b4ba7039136ecb5246c4107b4eb124f0462c1dbb9a5fdaaa160d9a143385ecdc17c88047f8d23bc4e5544a719822949a685b1d37132da0ba510f9aa35cb178",
   "returnUrl": "test",
   "notificationUrl": "test",
   "amount": "20.00",//Always in 2 decimals
   "balanceType": "cash",
   "balanceName": "cash",
   "saleId": "4cd39a6a-afda-4b45-9a66-653325aad744", (original parent txn id)
   "currency": "test"
}

where the hash is computed as follows:

hash_string = 'accessToken|uniqueId|comments|udf|returnUrl|notificationUrl|currency|amount|balanceType|balanceName|saleId|salt';

hash = sha512(hash_string);
 
gethttp://sandbox.olamoney.in/olamoney/v2/query?uniqueBillId=uniqueBillId&accessToken=accessToken&timestamp=timestamp&hash=hash
curl --request GET \
  --url 'http://sandbox.olamoney.in/olamoney/v2/query?hash=hash&timestamp=timestamp&accessToken=accessToken&uniqueBillId=uniqueBillId'
var request = require("request");

var options = { method: 'GET',
  url: 'http://sandbox.olamoney.in/olamoney/v2/query',
  qs: 
   { hash: 'hash',
     timestamp: 'timestamp',
     accessToken: 'accessToken',
     uniqueBillId: 'uniqueBillId' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
require 'uri'
require 'net/http'

url = URI("http://sandbox.olamoney.in/olamoney/v2/query?hash=hash&timestamp=timestamp&accessToken=accessToken&uniqueBillId=uniqueBillId")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body
var data = JSON.stringify(false);

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "http://sandbox.olamoney.in/olamoney/v2/query?hash=hash&timestamp=timestamp&accessToken=accessToken&uniqueBillId=uniqueBillId");

xhr.send(data);
import requests

url = "http://sandbox.olamoney.in/olamoney/v2/query"

response = requests.request("GET", url)

print(response.text)
A binary file was returned

You couldn't be authenticated

{
  "status": "completed",
  "uniqueBillId": "xyz",
  "merchantDetails": "ola money cashback",
  "amount": "10.00",
  "createdAt": 1454583091000,
  "type": "debit",
  "comments": "ola money cashback for coupon MIN10CR",
  "udf": "ola money cashback for coupon MIN10CR",
  "globalMerchantId": "c66c-cwoc-or8p"
}
{
    "errorCode": "stale_query",
    "message": "Invalid timestamp",
    "status": "error"
}

Path Params

uniqueBillId
string
required

saleId (uniqueBillId of the transaction already happened/initiated)

accessToken
string
required

accessToken of the merchant

timestamp
string
required

current timestamp of your system in the form of YYYY-MM-DD HH MM SS e.g. 2015-08-13 13:17:12

hash
string
required

sha512('access_token|uniqueBillId||timestamp|||merchant_salt')

 
Suggest Edits

Introduction

 

This page refers to all the Api's used in Offline Flow as explained here

Suggest Edits

MPIN FLOW

 

Basic Auth

 Authentication is required for this endpoint.
posthttp://sandbox.olamoney.in/olamoney/v1/payment/initiateDebit
{
    "command": "debit",
    "accessToken": "ola_access_token",
    "uniqueId": "7820d4d0-bb16-434e-9f95-0e21c76d11d6",
    "comments": "Test Comment",
    "udf": "Test User",
    "hash": "a8ead1805535143a743381339063cbe6d73ba47f51092e282aacff3a924ada8371e5f9b5d00b32a6a3465ca4df7929bd8bc5de4b01ef4b10feb9f15ed562280f",
    "returnUrl": "http://localhost:1251/return",
    "notificationUrl": "http://localhost:1251/notify",
    "amount": "10.00",
    "currency": "INR",
    "payCode": "0116042",
    "couponCode": "ABC"
}
A binary file was returned

You couldn't be authenticated

{
    "type": "debit",
    "status": "success",
    "transactionId": "c725-713m-fu9i",
    "merchantBillId": "7820d4d0-bb16-434e-9f95-0e21c76d11d6",
    "amount": "10.00",
    "hash": "dc1c30a259eb0cc6deebf0eb217487830140a36ba9a171579fb87beff88d2da75609346ec4164af0c1f79ddfc0ec07f23f550f49028d63cf8662c44732bb4d2a",
    "timestamp": "1464336120023",
    "comments": "Test Comment",
    "udf": "Test User",
    "isCashbackSuccessful": "false",
    "isCashbackAttempted": "true",
    "sdf": "{\"phone\":\"7204477564\"}"
}
{
  "status": "string",
  "message": "string",
  "errorCode": "string"
}

Headers

Authorization
string

Basic Auth : We will be providing this to you

 

You need to post a JSON in the body to make this work. A sample JSON is below:

{
  "command": "debit",
  "accessToken": "string",
  "uniqueId": "string",
  "comments": "string",
  "udf": "string",
  "hash": "string",
  "returnUrl": "string",
  "notificationUrl": "string",
  "amount": "100.00",
  "currency": "string",
  "payCode": "string",
  "couponCode": "string"
}

where the hash is computed as follows:

hash_string = 'accessToken|uniqueId|comments|udf|returnUrl|notificationUrl|currency|amount|payCode|couponCode|salt'
hash = sha512(hash_string);

Hash Validation for received Response

You need to calculate hash using the received parameters from the response. Only then you need to check the status of response whether success or failed. If hash you generated and received don't match, straight away reject the response.

data_string =  'type|status|merchantBillId|transactionId|amount|comments|udf|isCashbackAttempted|isCashbackSuccessful|timestamp|sdf|salt'; 
merchant_hash = sha512(data_string);