- To serve as a backend for the Sample App. You can find the documentation for the Sample App here
- To help you get started with the backend for your Application.
The project currently implements the following features:
- Generate
access_token
and uniquetransaction_id
. This will be called before a new order is created on Sample App. - Getting Order Details of an
Order
attached to thetransaction_id
ororder_id
. - Initiate refund for the
Order
attached to thetransaction_id
.
Generating the access_token is a HTTP POST
request.
You need to generate this on your server and send it to client.
The post parameters are as follows:
"client_id":"YOUR CLIENT ID"
"client_secret":"YOUR CLIENT SECRET"
"grant_type": "client_credentials"
URL for production - "https://api.instamojo.com/oauth2/token/"
URL for test - "https://test.instamojo.com/oauth2/token/"
{
"access_token": "y70kak2K0Rg7J4PAL8sdW0MutnGJEl",
"token_type": "Bearer",
"expires_in": 36000,
"scope": "read write"
}
{
"error": "unsupported_grant_type"
}
{
"error": "invalid_client"
}
Example code for this post request can be found here.
The Sample Server generates a random string of length 15. Since, the server doesn't have any database attached to store data,
it doesn't store the transaction ID.
But you would need to implement the database logic to store the transaction_id
and other relevant information before creating the Order
for later checks.
Getting specific Order details is a HTTP GET
request.
The following are the mandatory headers to be passed along with the request.
"Content-Type":"application/x-www-form-urlencoded"
"Authorization", "Bearer <Access Token>"
Example code for this request can be found here.
Initiating Refund is a HTTP POST
request with following mandatory post parameters as well as headers:
"Content-Type":"application/x-www-form-urlencoded"
"Authorization", "Bearer <Access Token>"
-
"type":"REFUND TYPE"
should be with in the following types:
RFD: Duplicate/delayed payment.
TNR: Product/service no longer available.
QFL: Customer not satisfied.
QNR: Product lost/damaged.
EWN: Digital download issue.
TAN: Event was canceled/changed.
PTH: Problem not described above.
-
"refund_amount":"Amount"
Should be with in 0 and originalOrder
amount -
"body":"Reason for refund"
Example code for refund can be found here.
If this documentation didn't answer all your queries, do raise a support ticket. Will will respond ASAP.