Overview
Sends a USSD push prompt to the customer’s phone, asking them to authorize a payment from their mobile money wallet. Supports M-Pesa, Airtel Money, Halopesa, Mixx by Yas, and TIPS Dynamic QR.
Endpoint
Authentication
Requires a Bearer token in the Authorization header.
Authorization: Bearer {{api_key}}
| Header | Value |
|---|
Accept | application/json |
Content-Type | application/json |
Request Body
| Field | Type | Required | Description |
|---|
amount | integer | required | Amount to charge in the specified currency |
currency | string | required | Currency code (e.g., TZS) |
phone_number | string | required | Customer’s phone number (e.g., 07XXXXXXXX) |
metadata | object | optional | Arbitrary key-value pairs for your reference, maximum of 3 items with length of less that 100 characters each |
Example Request
curl -X POST https://pesahub.test/api/v1/payments/ussd \
-H "Authorization: Bearer {{api_key}}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"amount": 1000,
"currency": "TZS",
"phone_number": "07XXXXXXXX",
"metadata": {
"order_id": "order_001",
"customer_note": "Payment for services"
}
}'
const response = await fetch('https://pesahub.test/api/v1/payments/ussd', {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
amount: 1000,
currency: 'TZS',
phone_number: '07XXXXXXXX',
metadata: {
order_id: 'order_001',
customer_note: 'Payment for services',
},
}),
});
const data = await response.json();
import requests
response = requests.post(
'https://pesahub.test/api/v1/payments/ussd',
headers={
'Authorization': 'Bearer YOUR_API_KEY',
'Accept': 'application/json',
'Content-Type': 'application/json',
},
json={
'amount': 1000,
'currency': 'TZS',
'phone_number': '07XXXXXXXX',
'metadata': {
'order_id': 'order_001',
'customer_note': 'Payment for services',
},
},
)
Request Body Example
{
"amount": 1000,
"currency": "TZS",
"phone_number": "07XXXXXXXX",
"metadata": {
"order_id": "order_001",
"customer_note": "Payment for services"
}
}
The customer will receive a USSD prompt on their phone to confirm the payment. Ensure the phone number matches an active mobile money account.