Introduction
Badala provides your e-commerce store with REST API endpoints to complete checkout transactions.
For testing, you can use your Badala API test details provided on your business account dashboard.
Important: All API requests must be made over HTTPS. Calls made over plain HTTP will fail. API requests without authentication will also fail.
Base URL
Not a developer?
Use our alternative plugins to get started with Badala without writing code.
Authentication
All API requests require your API key for authentication. You can find your API key in your business dashboard.
Include your API key in the request body:
{
"api_key": "your-api-key-here"
}
For Escrow API endpoints, use JWT Bearer token authentication:
Authorization: Bearer <your-jwt-token>
Make a Payment
Enable your customers to checkout with Badala by sending a JSON object and handling the response.
POST
Request Parameters
| Parameter | Type | Description |
|---|---|---|
| id required | string | Unique transaction reference (e.g., invoice number) |
| api_key required | string | Your API key from the business dashboard |
| type required | string | Transaction type: "payment" |
| currency required | string | Currency code (currently only "R" for ZAR) |
| total_amount required | float | Total checkout amount including all costs |
| items required | string | Short description of items purchased |
| return_method required | string | HTTP method for callback: "GET" or "POST" |
| return_url required | string | Your callback URL for payment response |
Example Request
{
"id": "#1878567",
"api_key": "your-api-key",
"type": "payment",
"currency": "R",
"total_amount": 290.50,
"items": "Bucket hat, Sleeve less Tee",
"return_method": "GET",
"return_url": "https://your-domain.com/handle/response/"
}
Success Response
{
"id": "#1878567",
"success": true,
"message": "Initiating payment request successful",
"datetime": "2020-10-22T20:13:08.958619Z",
"complete_payment_url": "https://badala.co.za/api/payment/T29vaE0Nso/",
"status_code": 200
}
Next Step: Redirect the customer to the complete_payment_url to finish the transaction:
window.location.href = complete_payment_url
Refunds
Process refunds for completed transactions.
POST
Request Parameters
| Parameter | Type | Description |
|---|---|---|
| id required | string | Original transaction ID |
| api_key required | string | Your API key |
| type required | string | Transaction type: "refund" |
| total_amount required | float | Amount to refund |
| reason required | string | Reason for the refund |
Example Request
{
"id": "#1878567",
"api_key": "your-api-key",
"type": "refund",
"currency": "R",
"total_amount": 290.50,
"reason": "Clothes didn't fit"
}
Escrow API Overview
The Badala Escrow API enables secure payment processing between buyers and sellers. Funds are held safely in escrow until the transaction is completed, protecting both parties.
How Escrow Works
- Create: Merchant creates an escrow account for an order
- Fund: Customer funds the escrow (via Paystack, Ozow, or wallet)
- Activate: Escrow becomes active once funded
- Release: Funds are released to merchant after order fulfillment
Base URL
Escrow Statuses
| Status | Description |
|---|---|
| CREATED | Escrow created, awaiting funding |
| FUNDED | Funds received and held |
| ACTIVE | Ready for operations |
| RELEASED | Funds released to merchant |
| DISPUTED | Under dispute, funds frozen |
| CANCELLED | Cancelled, funds refunded |
| EXPIRED | Expired without completion |
Create Escrow Account
Create a new escrow account for a transaction between a buyer and seller.
POST
Request Parameters
| Parameter | Type | Description |
|---|---|---|
| payer_id required | UUID | Buyer's unique identifier |
| payee_id required | UUID | Seller's unique identifier |
| amount required | string | Escrow amount (e.g., "250.00") |
| currency | string | ZAR, AIRBUCKS, or USD (default: AIRBUCKS) |
| external_transaction_id | string | Your order reference ID |
| expires_at | ISO 8601 | Expiration datetime (default: 7 days) |
| auto_release_enabled | boolean | Enable auto-release (default: true) |
| auto_release_delay_hours | integer | Hours before auto-release (default: 24) |
Example Request
{
"payer_id": "550e8400-e29b-41d4-a716-446655440000",
"payee_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
"amount": "250.00",
"currency": "ZAR",
"external_transaction_id": "ORDER-2024-001234"
}
Success Response
{
"account_number": "ESC87654321",
"status": "created",
"amount": "250.00",
"currency": "ZAR",
"expires_at": "2024-01-22T10:30:00Z"
}
Fund Escrow
Fund an existing escrow account using various payment methods.
POST
Request Parameters
| Parameter | Type | Description |
|---|---|---|
| payment_method required | string | wallet, paystack, or ozow |
| amount | string | Amount to fund (default: full escrow amount) |
Release Funds
Release escrow funds to the seller after transaction completion.
POST
Request Parameters
| Parameter | Type | Description |
|---|---|---|
| release_amount | string | Amount to release (default: full amount) |
| release_note | string | Optional note for the release |
Check Escrow Status
Retrieve the current status and details of an escrow account.
GET
Response
{
"account_number": "ESC87654321",
"status": "funded",
"amount": "250.00",
"funded_amount": "250.00",
"currency": "ZAR",
"created_at": "2024-01-15T10:30:00Z",
"expires_at": "2024-01-22T10:30:00Z"
}
Cancel Escrow
Cancel an escrow and refund funds to the buyer.
POST
Request Parameters
| Parameter | Type | Description |
|---|---|---|
| cancellation_reason required | string | Reason for cancellation |
HTTP Status Codes
Badala uses conventional HTTP response codes to indicate success or failure of API requests.
| 200 - OK | Request succeeded |
| 201 - Created | Resource created successfully |
| 400 - Bad Request | Invalid request parameters |
| 401 - Unauthorized | Invalid or missing API key |
| 403 - Forbidden | Insufficient permissions |
| 404 - Not Found | Resource not found |
| 429 - Too Many Requests | Rate limit exceeded |
| 500 - Server Error | Internal server error |
Need Help?
Contact our developer support at info@badala.co.za for assistance with API integration.