Bezza API Documentation
Your Gateway to Seamless API Integration
How It Works
The Bezza API enables seamless integration for handling payments, balances, and customer data.
- Authentication: Use your API key to authenticate requests.
- Endpoints: Access multiple endpoints like
/pay_api_meterIdand/payment_status. - Real-time Updates: Track payment statuses in real time.
How to Integrate Bezza API
Follow these steps to integrate the Bezza API into your application:
- Obtain your API key from the Bezza dashboard.
- Use the API key to authenticate your requests.
- Start sending requests to Bezza endpoints based on your requirements.
Example Code
Node.js
const axios = require('axios');
const apiKey = 'YOUR_API_KEY';
const url = 'https://api.bezza.io/pay_api_meterId';
const data = {
amount: '10.50',
phone: '123456789',
meterId: 'METER_ID',
paymentType: 'Zaad'
};
axios.post(url, data, {
headers: { 'Authorization': `Bearer ${apiKey}` }
})
.then(response => {
console.log('Payment initiated:', response.data);
})
.catch(error => {
console.error('Error:', error.response.data);
});
Python
import requests
api_key = 'YOUR_API_KEY'
url = 'https://api.bezza.io/pay_api_meterId'
data = {
"amount": "10.50",
"phone": "123456789",
"meterId": "METER_ID",
"paymentType": "Zaad"
}
headers = {
"Authorization": f"Bearer {api_key}"
}
response = requests.post(url, json=data, headers=headers)
if response.status_code == 200:
print("Payment initiated:", response.json())
else:
print("Error:", response.json())
Bezza Checkout
Bezza Checkout is a flexible, secure, and seamless way to integrate payment processing into your application.
Features:
- Initiate payments with USSD codes.
- Track real-time payment statuses.
- Supports multiple payment methods and card payments via DPO.
To integrate Bezza Checkout, use the following API endpoints:
1. USSD Payment Initiation
POST /pay_api_meterId
Request Parameters:
- amount: Payment amount.
- phone: Customer phone number.
- meterId: Unique meter identifier.
- paymentType: Type of payment (e.g., Zaad).
- apiKey: Your Bezza API key.
Example Response:
{
"message": "Payment Initiated. Dial USSD to proceed.",
"ussdCode": "*789*630533*10*50#",
"meterId": "METER_ID"
}
2. DPO Card Payment Initiation
POST /dpo_createToken
Request Parameters:
- companyId: Your Bezza companyId.
- amount: Payment amount.
- firstName: Customer first name.
- lastName: Customer last name.
- email: Customer email.
- phone: Customer phone number.
- city: Customer city.
- country: ISO 2-letter country code (e.g. "BW").
- apiKey: Your Bezza API key.
Example Response:
{
"message": "Token created and updated successfully.",
"redirectUrl": "https://secure.3gdirectpay.com/payv3.php?ID=...",
"token": "DPO_TRANSACTION_TOKEN"
}
3. DPO Transaction Verification
GET /dpo_verifyToken?token=...
Use this to confirm whether a DPO transaction has been paid. Redirects to:
/payment_successif payment is successful/payment_failedif payment fails
DPO Integration
Integrate with Direct Pay Online (DPO) to accept card and mobile money payments. You will create a transaction token, update it with customer details, redirect users to pay, and verify the payment status.
Tokens have a 30 minute TTL before it expires.
1. Create Transaction Token
POST /dpo_createToken
Request Headers:
Content-Type: application/json
Request Body (JSON):
| Parameter | Type | Required | Description |
|---|---|---|---|
| companyId | string | Yes | Your Bezza companyId |
| amount | string | Yes | Payment amount in BWP |
| firstName | string | Yes | Customer first name |
| lastName | string | Yes | Customer last name |
| string | Yes | Customer email address | |
| phone | string | Yes | Customer phone number (international format) |
| city | string | Yes | Customer city |
| country | string | Yes | ISO 2-letter country code (e.g., "BW") |
| apiKey | string | Yes | Your Bezza API key |
Sample Request:
curl -X POST https://api.bezza.io/dpo_createToken \
-H "Content-Type: application/json" \
-d '{
"companyId": "YOUR_COMPANYID",
"amount": "50.00",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@gmail.com",
"phone": "26777453256",
"city": "Gaborone",
"country": "BW",
"apiKey": "YOUR_API_KEY"
}'
Sample Node.js:
const axios = require('axios');
const payload = {companyId: 'YOUR_COMPANYID' , amount: '50.00', firstName: 'John', lastName: 'Smith', email: 'john.smith@gmail.com', phone: '26777453256', city: 'Gaborone', country: 'BW', apiKey: 'YOUR_API_KEY' };
axios.post('https://api.bezza.io/dpo_createToken', payload)
.then(res => console.log(res.data))
.catch(err => console.error(err.response.data));
Successful Response:
{
"message": "Token created and updated successfully.",
"redirectUrl": "https://secure.3gdirectpay.com/payv3.php?ID=TOKEN_ID",
"token": "TOKEN_ID"
}
2. Verify Transaction Token
GET /dpo_verifyToken?companyId=COMPANY_ID&token=TOKEN_ID
Verifies if the DPO transaction has been paid within the 30-minute window.
Sample Request:
curl "https://api.bezza.io/dpo_verifyToken?companyId=COMPANY_ID&token=TOKEN_ID"
Sample Node.js:
axios.get('https://api.bezza.io/dpo_verifyToken', { params: { companyId: 'COMPANY_ID', token: 'TOKEN_ID' } })
.then(res => console.log(res.data))
.catch(err => console.error(err.response.data));
On Success:
User is redirected to /payment_success
On Failure:
User is redirected to /payment_failed