Integrate Sonic Pesa payments easily using our secure RESTful APIs. Below are the main endpoints for payment integration.
Send a POST request to initiate a payment order.
curl -X POST https://sonicpesa.com/api/payment/create \
-H "Content-Type: application/json" \
-H "Authorization: Bearer pk_YOUR_API_KEY" \
-d '{
"phone": "255657779003",
"amount": 5000,
"name": "Benjamini Omary",
"email": "mfano@gmail.com"
}'
{
"success": true,
"message": "Payment initiated successfully",
"data": {
"transaction_id": "TXN70AB35DEB8A3225C",
"order_id": "SELCOM17604590241571",
"amount": 5000,
"fee": 350.00000000000006,
"net_amount": 4650,
"status": "pending"
}
}
Send a POST request to verify the current payment status.
curl -X POST https://sonicpesa.com/api/payment/status \
-H "Authorization: Bearer pk_d55285b2e4c842549c681721b6b8c" \
-H "Content-Type: application/json" \
-d '{
"order_id": "SELCOM17604590241571"
}'
{
"success": true,
"data": {
"transaction_id": "TXN70AB35DEB8A3225C",
"order_id": "SELCOM17604590241571",
"status": "pending",
"amount": "5000.00",
"fee": "350.00",
"net_amount": "4650.00",
"channel": null,
"reference": "S20240996582"
}
}