The Update Wallet API enables you to add/deduct points to a customer's wallet
Rehook Platform API provides resource oriented URLs to work with your business data. Our API uses JSON for request and response. API errors are returned using standard HTTP response codes.
Introduction
This API will enable you to add or deduct point to a customer wallet when customer have used wallet points to complete a transaction or customer have recharged their wallet on your application.
API details
API Endpoint: https://api.rehook.ai/wallets/customer/{source_id}/transactions/{wallet_id}
HTTP Method: PUT
Prerequisites
- API Key and Secret Key for your application
- If you don't know the API key and secret key, please go to setting module on admin panel to view API details for your application. To know more about application settings, please visit Application setting
- API key and secret key are auto generated and cannot be changed.
- Custom wallet to be created for your application. To know more about how to create wallet, please visit Wallet setting
Authentication
You need to provide the API key and Secret of your application in every new request as Authorization. Rehook use Basic authentication method to authenticate the API calls.
Authorization | Value |
---|---|
Username | API Key of your application |
Password | Secret key of your application |
Parameters
Query parameter
This API doesn't have any query parameter.
Path URL
Please pass the below parameter in the path URL
Parameter | In | Definition | example |
---|---|---|---|
source_id | Path | required Rehook Id or source id of a customer | KMN@123 |
wallet_id | Path | required wallet id of your custom wallet. you will get this id in Get customer wallet API | 123459_jdks |
Body parameter
Field | Definition | Example |
---|---|---|
description | Description is the description of the transaction. | customer have credited his wallet |
points | wallet points to be debited or credited | 20 |
type | transaction type - credit or debit | credit |
Sample request and response
Path: https://api.rehook.ai/wallets/customer/krishna123/transactions/waty_XbgBcerLwjoMhAGcmAHhZ
In above URL path, 'krishna123' is the source id and 'waty_XbgBcerLwjoMhAGcmAHhZ' is the wallet id
request body
{
"description": "Customer have credited his wallet with 20 points",
"points": 20,
"type": "credit"
}
response
On successful API call, rehook will debit or credit the customer wallet based on the transaction type passed in the request body.
{
"requestId": "59ab618b-3c16-9a8d-9577-db4676513188",
"txn_id": "trhi_wcufiD5LRWQ067dDhBGA9",
"id": "cust_SbwItbqREfhaj2UWdc42X",
"wallet_id": "waty_XbgBcerLwjoMhAGcmAHhZ",
"loyalty_points": 60,
"previous_loyalty_points": 40,
"points": 20,
"description": "Customer have credited his wallet with 20 points"
}
Below table shows the definition of response body
Field name | Definition | Example |
---|---|---|
txn_id | transaction id assigned to a wallet transaction when it's credited or debited | trhi_wcufiD5LRWQ067dDhBGA9 |
id | rehook id of customer | cust_SbwItbqREfhaj2UWdc42X |
request_id | API request id assigned by rehook | 59ab618b-3c16-9a8d-9577 |
wallet_id | wallet id of custom wallet created on rehook in which transaction to be updated | waty_XbgBcerLwjoMhAGcmAHhZ |
loyalty_points | Current loyalty points of customer | 60 |
previous_loyalty_points | Previous loyalty points of customer before this transaction happened | 40 |
points | points added/deducted in this transaction | 20 |
description | description of the transaction | Customer have credited his wallet with 20 points |
In the above transaction, customer wallet is credited with 20 points.
Error cases
If API call is failed, then Rehook will return the following HTTP success code with response body as given below:
HTTP Code | Message |
---|---|
400 | bad request |
error response body
field name | description | example |
---|---|---|
Code | Error code | 400 |
details | Error details | Given resource Id is wrong |
message | error message | Resource Id not found |
request_id | API request Id assigned by Rehook | abc_123 |
Sample error response
- When source_id in path is wrong
{
"code": 404,
"message": "resource not found",
"details": "customer not found",
"request_id": "9d06ea48-1b7e-984d-9557-9e69d24233af"
}
-
When wallet_id in path is wrong
You will get empty response
-
When parameter is missing
Cannot PUT /wallets/customer/krishna123/transactions
- When type field is missing
{
"code": 401,
"key": "type",
"message": "type field is required",
"details": "type field is required",
"request_id": "157b9904-ac33-93e2-8860-8bf9e9ba98ba"
}
- when points are not passed
{
"code": 400,
"key": "invalid_payload",
"message": "Invalid payload",
"details": "The payload cannot be empty",
"request_id": "6b26ebac-5c04-95e8-84cb-9b7df3024055"
}