Your trusted solution for secure and seamless payments in South Africa.
Dive into our comprehensive documentation to get started with integrating Bancwild into your application. Whether you’re building a marketplace, e-commerce store, or any platform requiring payment solutions, Bancwild has you covered.
Follow these steps to integrate Bancwild’s APIs into your application seamlessly.
Use the following base URLs depending on the environment:
Sandbox: https://stagingapi.bancwild.com/api
Production: https://api.bancwild.com/apiObtain your Client ID and Client Secret from the Bancwild developer portal.
Authenticate by sending a POST request to the authentication endpoint to obtain an access token:
POST https://stagingapi.bancwild.com/api/auth/token
Headers:
Content-Type: application/json
Authorization: Basic base64(client_id:client_secret)
The response will include an access token:
{
"access_token": "your-access-token",
"token_type": "Bearer",
"expires_in": 3600
}Use this token in the Authorization header for subsequent API requests:
Authorization: Bearer your-access-tokenNow that you’re authenticated and have made your first API request, explore the other sections of this documentation to learn about processing payments, handling refunds, and retrieving transactions.
Proceed to Payment API →To interact with Bancwild’s APIs, you need to authenticate using your **Client ID** and **Client Secret**. Follow the steps below to obtain these credentials and start integrating.
Create an account on the Bancwild Platform. Use a valid email address and set up your profile.
1. Go to https://bancwild.com
2. Enter your email and create a password.
3. Verify your email to activate your account.After signing up, you need to request a **Merchant Account**. This account allows you to process payments via Bancwild’s platform.
Once your request is approved, you’ll receive an email with confirmation.
After your Merchant Account is approved, you can generate your **Client ID** and **Client Secret**:
1. Log in to your Bancwild account.
2. Go to "API Credentials" in the Developer section.
3. Click "Generate Credentials".
4. Your Client ID and Client Secret will be displayed.
- Client ID: Used to identify your application.
- Client Secret: Keep this confidential and secure.Store these credentials securely, as they are required for authenticating your API requests.
Ensure your **Client Secret** is never exposed in public repositories or client-side applications. We recommend storing it in environment variables or a secure key management system.
# Example .env file
CLIENT_ID=your-client-id
CLIENT_SECRET=your-client-secretNow that you have your API credentials, you can authenticate with Bancwild’s API and begin making requests. Proceed to the next section to learn about generating an access token.
Generate Access Token →To authenticate with Bancwild’s APIs, you need to generate an **Access Token**. This requires sending your **Client ID** and **Client Secret** in the `Authorization` header as a Base64-encoded string.
Use the following endpoint to obtain your access token:
POST https://stagingapi.bancwild.com/api/authorize/tokenSend a POST request with the following headers and body:
Authorization: Basic base64(client_id:client_secret)
Content-Type: application/x-www-form-urlencodedgrant_type=client_credentialsHere’s an example using cURL:
curl -X POST https://stagingapi.bancwild.com/api/auth/token \
-H "Authorization: Basic base64encoded(client_id:client_secret)" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials"Or using Axios in JavaScript:
import axios from 'axios';
const clientId = 'your-client-id';
const clientSecret = 'your-client-secret';
const base64Credentials = btoa(`${clientId}:${clientSecret}`);
const response = await axios.post('https://stagingapi.bancwild.com/api/auth/token',
'grant_type=client_credentials', {
headers: {
Authorization: `Basic ${base64Credentials}`,
'Content-Type': 'application/x-www-form-urlencoded',
},
});
console.log(response.data);If your request is successful, you will receive a response like this:
{
"access_token": "your-access-token",
"token_type": "Bearer",
"expires_in": 3600
}Save the access_token. Use it in the Authorization header for subsequent API requests.
Authorization: Bearer your-access-tokenIf the request fails, you will receive an error response. For example:
{
"error": "invalid_client",
"error_description": "Client authentication failed"
}Ensure your **Client ID** and **Client Secret** are correct and that you are using the correct Base64-encoded format.
Now that you have your access token, you can start making API requests. Learn how to process payments in the next section.
Proceed to Payment API →Generate a checkout URL to redirect your customers to Bancwild's secure payment page. Use this endpoint to create a payment session.
POST https://stagingapi.bancwild.com/api/payment/checkoutSend a POST request with the following headers and body:
Authorization: Bearer your-access-token
Content-Type: application/json{
"amount": 1000,
"callbackUrl": "https://your-website.com/payment-success",
"webhookUrl": "https://your-website.com/payment-cancel",
"description": "Order #12345",
"reference": "order-12345",
"metadata": {
"order_id": "12345",
"customer_email": "customer@example.com"
}
}Here’s an example using Axios in JavaScript:
import axios from 'axios';
const response = await axios.post(
'https://stagingapi.bancwild.com/api/checkout',
{
amount: 1000,
callbackUrl: 'https://your-website.com/payment-success',
webhookUrl: 'https://your-website.com/payment-cancel',
description: 'Order #12345',
reference: 'order-12345',
metadata: {
order_id: '12345',
customer_email: 'customer@example.com',
},
},
{
headers: {
Authorization: 'Bearer your-access-token',
'Content-Type': 'application/json',
},
}
);
console.log(response.data);If your request is successful, you will receive a response like this:
{
"checkout_url": "https://stagingapi.bancwild.com/checkout/session-id",
"expires_in": 3600,
"status": "pending"
}Redirect your customer to the checkout_url to complete their payment.
If the request fails, you will receive an error response. For example:
{
"error": "invalid_request",
"error_description": "Amount is required"
}Ensure all required fields are provided and correctly formatted.
After the customer completes the payment, you can verify the transaction status by querying the Payment Status API.
Verify Payment Status →Bancwild will send a POST request to the webhook URL you provided during checkout to notify you about payment events. This ensures real-time updates for your transactions.
When creating a checkout session, include your webhook URL in the callback_url field. Bancwild will use this URL to send updates about the payment status.
After a payment is processed, Bancwild will send a POST request to your webhook URL with the following payload structure:
{
"event": "payment_completed",
"data": {
"payment_id": "payment-id-12345",
"status": "success",
"amount": 1000,
"currency": "ZAR",
"description": "Order #12345",
"metadata": {
"order_id": "12345",
"customer_email": "customer@example.com"
},
"created_at": "2025-01-01T12:34:56Z",
"updated_at": "2025-01-01T12:40:00Z"
}
}If your server fails to respond with a 200 OK, Bancwild will retry the webhook delivery up to 3 times with exponential backoff.
Use this endpoint to verify the status of a payment after your customer completes the checkout process.
GET https://stagingapi.bancwild.com/api/payments/{payment_id}Send a GET request with the following headers:
Authorization: Bearer your-access-token
Content-Type: application/jsonReplace `{payment_id}` with the ID of the payment you want to verify. Here’s an example using Axios in JavaScript:
import axios from 'axios';
const response = await axios.get(
'https://stagingapi.bancwild.com/api/payments/payment-id-12345',
{
headers: {
Authorization: 'Bearer your-access-token',
'Content-Type': 'application/json',
},
}
);
console.log(response.data);If your request is successful, you will receive a response like this:
{
"payment_id": "payment-id-12345",
"status": "success",
"amount": 1000,
"currency": "ZAR",
"description": "Order #12345",
"created_at": "2025-01-01T12:34:56Z",
"updated_at": "2025-01-01T12:40:00Z"
}The `status` field will indicate the current status of the payment. Common statuses include:
If the request fails, you will receive an error response. For example:
{
"error": "not_found",
"error_description": "Payment ID does not exist"
}Ensure the `payment_id` is valid and that you have the necessary permissions to access it.