Developer Documentation
Webhooks
Listen for asynchronous events from external payment providers. Nexbit provides a universal webhook endpoint that normalizes data from various gateways.
Gateway Webhook
POST /v1/webhooks/{provider}This public endpoint receives callbacks from payment gateways. You should configure this URL in your provider's dashboard.
Supported Providers: stripe, mpesa, paypal, flutterwave, paystack, razorpay, gopay, pix.
Path Parameters
provider(string, required): The name of the payment provider (e.g., 'mpesa', 'stripe').
Request Body
{
"Body": {
"stkCallback": {
"MerchantRequestID": "12345-67890",
"CheckoutRequestID": "ws_CO_DERR_1234567890",
"ResultCode": 0,
"ResultDesc": "The service request is processed successfully.",
"CallbackMetadata": {
"Item": [
{ "Name": "Amount", "Value": 100.00 },
{ "Name": "MpesaReceiptNumber", "Value": "SAB123DEFG" },
{ "Name": "TransactionDate", "Value": 20251026120100 },
{ "Name": "PhoneNumber", "Value": 254712345678 }
]
}
}
}
}
Body Parameters
The body structure depends on the provider (e.g., M-Pesa, Stripe). See provider documentation for details.
Test Request
Response
{
"status": "success"
}
M-Pesa STK Push Callback Example
When a user completes a deposit initiated via M-Pesa, Safaricom sends a POST request to `.../v1/webhooks/mpesa`.
Request Body (from M-Pesa)
{
"Body": {
"stkCallback": {
"MerchantRequestID": "12345-67890",
"CheckoutRequestID": "ws_CO_DERR_1234567890",
"ResultCode": 0,
"ResultDesc": "The service request is processed successfully.",
"CallbackMetadata": {
"Item": [
{ "Name": "Amount", "Value": 100.00 },
{ "Name": "MpesaReceiptNumber", "Value": "SAB123DEFG" },
{ "Name": "TransactionDate", "Value": 20251026120100 },
{ "Name": "PhoneNumber", "Value": 254712345678 }
]
}
}
}
}
Response (to M-Pesa)
{
"ResultCode": 0,
"ResultDesc": "Accepted"
}
Note: Upon receiving this webhook, Nexbit updates the corresponding transaction status to `settled` and credits the user's wallet.