API Docs
Refunding Transactions
You can refund transactions either using a transaction reference or a transaction ID. The response will provide detailed information about the refund status and other relevant details.
Headers
- Authorization:
Bearer YOUR_SECRET_KEY - Content-Type:
application/json
Query Parameters
- transaction_reference:
string(optional) - Transaction reference provided by merchant/developer. - transaction_id:
string(optional) - Transaction ID.
Sample Request to Create a Refund
1. Create Refund using Transaction Reference
cURL
curl -X POST "https://api.motapa.africa/v1/transactions/refund" \
-H "Authorization: Bearer mp_test_26PHem9AhJZvU623DfE1x4sd" \
-H "Content-Type: application/json" \
-d '{
"transaction_reference": "MOTAPAPAY1234567890",
"amount": 1000
}'Python
import requests
url = "https://api.motapa.africa/v1/transactions/refund"
data = {
"transaction_reference": "MOTAPAPAY1234567890",
"amount": 1000
}
headers = {
"Authorization": "Bearer mp_test_26PHem9AhJZvU623DfE1x4sd",
"Content-Type": "application/json"
}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200:
print("Refund details:", response.json())
else:
print("Error:", response.status_code, response.text)2. Create Refund using Transaction ID
cURL
curl -X POST "https://api.motapa.africa/v1/transactions/refund" \
-H "Authorization: Bearer mp_test_26PHem9AhJZvU623DfE1x4sd" \
-H "Content-Type: application/json" \
-d '{
"transaction_id": "mp_1234567890",
"amount": 1000
}'Python
import requests
url = "https://api.motapa.africa/v1/transactions/refund"
data = {
"transaction_id": "mp_1234567890",
"amount": 1000
}
headers = {
"Authorization": "Bearer mp_test_26PHem9AhJZvU623DfE1x4sd",
"Content-Type": "application/json"
}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200:
print("Refund details:", response.json())
else:
print("Error:", response.status_code, response.text)Sample Request to List Refunds
1. List Refunds using Date Range
cURL
curl -X GET "https://api.motapa.africa/v1/transactions/refunds?start_date=2023-01-01&end_date=2023-01-31" \ -H "Authorization: Bearer mp_test_26PHem9AhJZvU623DfE1x4sd" \ -H "Content-Type: application/json"
Python
import requests
url = "https://api.motapa.africa/v1/transactions/refunds"
params = {
"start_date": "2023-01-01",
"end_date": "2023-01-31"
}
headers = {
"Authorization": "Bearer mp_test_26PHem9AhJZvU623DfE1x4sd",
"Content-Type": "application/json"
}
response = requests.get(url, headers=headers, params=params)
if response.status_code == 200:
print("Refund details:", response.json())
else:
print("Error:", response.status_code, response.text)2. List Last 100 Refunds
cURL
curl -X GET "https://api.motapa.africa/v1/transactions/refunds?limit=100" \ -H "Authorization: Bearer mp_test_26PHem9AhJZvU623DfE1x4sd" \ -H "Content-Type: application/json"
Python
import requests
url = "https://api.motapa.africa/v1/transactions/refunds"
params = {
"limit": 100
}
headers = {
"Authorization": "Bearer mp_test_26PHem9AhJZvU623DfE1x4sd",
"Content-Type": "application/json"
}
response = requests.get(url, headers=headers, params=params)
if response.status_code == 200:
print("Refund details:", response.json())
else:
print("Error:", response.status_code, response.text)Sample Request to Fetch a Refund
1. Fetch Refund using Refund ID
cURL
curl -X GET "https://api.motapa.africa/v1/transactions/refund/{refund_id}" \
-H "Authorization: Bearer mp_test_26PHem9AhJZvU623DfE1x4sd" \
-H "Content-Type: application/json"Python
import requests
url = "https://api.motapa.africa/v1/transactions/refund/{refund_id}"
headers = {
"Authorization": "Bearer mp_test_26PHem9AhJZvU623DfE1x4sd",
"Content-Type": "application/json"
}
response = requests.get(url, headers=headers)
if response.status_code == 200:
print("Refund details:", response.json())
else:
print("Error:", response.status_code, response.text)Sample Responses
Successful Refund Creation (200)
{
"result": "success",
"refund_id": "mp_refund_1234567890",
"transaction_id": "mp_1234567890",
"transaction_reference": "MOTAPAPAY1234567890",
"amount": "1000",
"currency": "USD",
"message": "Refund created successfully.",
"details": {}
}Bad Request (400)
{
"result": "error",
"message": "Invalid request parameters."
}Unauthorized (401)
{
"result": "error",
"message": "Unauthorized. Please provide a valid API key."
}Internal Server Error (500)
{
"result": "error",
"message": "Internal server error. Please try again later."
}