Introduction
Airbuy provides your e-commerce store with REST API endpoints to complete checkout transactions.
For testing, you can use your Airbuy API test details provided on your business account dashboard.
All API requests must be made over HTTPS. Calls made over plain HTTP will fail. API requests without authentication will also fail.
https://airbuy.africa/api
Use our alternative plugins to get started with Airbuy.
Make a payment
Enable your customers to checkout with Airbuy by sending a JSON object and handle the response objects.
JSON OBJECT
Sends a request to initiate the payment transaction. Below are the parameters required to return a successful response
id string required
A unique id referencing the transaction object. For example, the invoice or reference value. This value will be important for the return callback.
api_key string required
Your api key which will be used to identify your store. Follow steps 1 - 18 to setup your
api_key
.type string required
The transaction method taking place.
currency string required
At the moment, only South African Rands are supported.
total_amount float required
Total amount used to checkout. This amount should be inclusive of any additional costs, such as shipping or discounts, etc.
items string required
A short string of items bought by the online customer. **Used as reference.
return_method string required
HTTP method that should be used to send PAYMENT RESPONSE back to the return_url. Choose between GET or POST.
return_url string required
Callback url used to handle the response with the results from the transaction. The HTTP method provided in return_method will be used to send the PAYMENT RESPONSEto the
return_url
.
JSON OBJECT RESPONSE
Returns the result object from the initiating request, including the transaction id.
If "success": False
, the message key will state the reason why the initiating request failed and the complete_payment_url key will have a blank string value.
If "success": True
, use the complete_payment_url value as suggested below for the customer to complete the transaction.
complete_payment_url string
On success and once you've handled the response, use this url to redirect users to complete the transaction on Airbuy. For example,
window.location.href = complete_payment_url
PAYMENT RESPONSE
Returns the result object from the payment transaction, including the transaction id. This object will be sent to the return_url using the return_method provided.
If "success": False
, the message key will state the reason why the payment transaction failed. A new initiating request would have to be created.
If "success": True
, the payment would complete.
ENDPOINT URL
POST /payment/
{
"id": "#1878567",
"api_key": "Srtygo#4789gdfg398+dg",
"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/"
}
{
"id": "#1878567",
"success": True,
"message": "Initiating payment request successful",
"datetime": "2020-10-22T20:13:08.958619Z",
"complete_payment_url": "https://airbuy.africa/api/payment/T29vaE0Nso/",
"status_code": 200
}
{
"id": "#1878567",
"success": True,
"message": "Payment successful",
"datetime": "2020-10-22T20:18:08.105378Z",
"status_code": 200
}
Refunds
Retrieves a PaymentMethod object.
Parameters
id string required
The unique id that was used to initiate the transaction.
api_key string required
Your api key which will be used to identify your store. Follow steps 1 - 18 to setup your
api_key
.type string required
The transaction method taking place.
currency string required
At the moment, only South African Rands are supported.
total_amount float required
Total amount refundable inclusive of any additional costs.
reason string required
A short reason for returning the goods.
Returns
Returns an object with the refund results.
ENDPOINT URL
POST /refund/
{
"id": "#1878567",
"api_key": "Srtygo#4789gdfg398+dg",
"type": "refund",
"currency": "R",
"total_amount": 290.50,
"reason": "Clothes didn't fit"
}
{
"id": "#1878567",
"success": True,
"message": "Refund successful",
"datetime": "2020-10-26T10:56:14.3710522Z",
"status_code": 200
}
Request Status
Airbuy uses conventional HTTP response codes to indicate the success or failure of an API request. In general: Codes in the 2xx
range indicate success. Codes in the 4xx
range indicate an error that failed given the information provided (e.g., a required parameter was omitted, a charge failed, etc.). Codes in the 5xx
range indicate an error with Airbuy's servers (these are rare).
200 - OK | Everything worked as expected. |
---|---|
400 - Bad Request | The request was unacceptable, often due to missing a required parameter. |
401 - Unauthorized | No valid API key provided. |
402 - Request Failed | The parameters were valid but the request failed. |
403 - Forbidden | The API key doesn't have permissions to perform the request. |
404 - Not Found | The requested resource doesn't exist. |
409 - Conflict | The request conflicts with another request (perhaps due to using the same idempotent key). |
429 - Too Many Requests | Too many requests hit the API too quickly. We recommend an exponential backoff of your requests. |
500, 502, 503, 504 - Server Errors | Something went wrong on Airbuy's end. (These are rare.) |