How to do a Spendback
The usual workflow for performing a spend back involves the following steps:
Step 1: Authenticate: Obtain an API token by validating your credentials.
Step 2: Get Account Balance: Retrieve the account balance using the API.
Step 3: Make Spend Back Payment: Execute the spend back payment using the API.
API Endpoints Used
In this guide, you will use the following API endpoints:
Below, you will go through the necessary API calls to achieve the steps above within the i-payout system.
Recipe
You can also follow our recipe by clicking the link below:
🦉How to do a SpendbackOpen Recipe
Step 1: Authenticate
To start using i-payout solutions, you will need to authenticate with your API Token. Refer to the Get a Token guide to learn how to:
Step 2: Get Account Balance
To check the available funds before making a spend back payment, you need to retrieve the account balance. Use the Get Account Balance endpoint. Below is an example request to get the account balance:
curl --request GET \
--url "https://merchantapi.testewallet.com/api/v1/beneficiaries/<BENEFICIARY_TOKEN>/balances/<CURRENCY_CODE>" \
--header 'Authorization: Bearer <YOUR_API_TOKEN>' \
--header 'X-MerchantId: <YOUR_MERCHANT_ID>' \
--header 'accept: application/json'
{
"isSuccess": true,
"message": "Account balance retrieved successfully",
"statusCode": 200,
"data": {
"balance": 1000.00,
"currency": "USD"
}
}
Step 3: Make Spend Back Payment
Once you have confirmed the available balance, you can proceed with the spend back payment. Use the Make Spend Back Payment endpoint to perform the spend back. Below, you will find an example request to make a spend back payment:
curl --request POST \
--url "https://merchantapi.testewallet.com/api/v1/payins/spendback" \
--header 'Authorization: Bearer <YOUR_API_TOKEN>' \
--header 'X-MerchantId: <YOUR_MERCHANT_ID>' \
--header 'accept: application/json' \
--header 'content-type: application/*+json' \
--data '{
"amount": 100.00,
"currency": "USD",
"reference": "spendback_001"
}'
{
"isSuccess": true,
"message": "Spend back payment created successfully",
"statusCode": 200,
"data": {
"transactionId": "spendback_001",
"amount": 100.00,
"currency": "USD",
"status": "Completed"
}
}
Check Available balance
Ensure that the amount specified in the spend back payment does not exceed the available balance retrieved in Step 2.
Updated 22 days ago