MPESA Payments
When hosting a C2B Paybill with us, you are required to register the validation URL for your paybill. To enable validation for your pabill, you can contact Safaricom MPESA team to request them to activate external validation for your paybill via apifeedback@safaricom.co.ke. Once we receive a payment for your shortcode, we will trigger a callback to your validation URL with the following json object.
{
status: 100,
data: {
refId: 'baakp_821887j19d937',
transactionId: 'MKOAH6GAT',
amount: 2000.00,
utilityBalance: 2300191.00,
phoneNumber: '254718XXX989',
name: 'Davis Mbandi'
paybill: 12345,
dateTime: 'YYYY-MM-DD hh:mm:ss',
accountNumber: '87634',
}
}
Upon processing the request, there are two possibilities; you may decide to complete or reject the transaction. Our API completes or cancels the transaction based on the response validation setting. If you reject the transaction, MPESA simply terminates the transaction and the payment is cancelled. If you respond to the API by accepting the transaction, a confirmation request is then sent to the confirmation URL which acknowledges that the payment is completed successfully.
A good scenario as to when to use validation is when you want to accept payments for only clients that exist in your database. In that case, if the user does not exist, you can simply reject the transaction.
If you wish to reject the transaction, simply respond to the API with the following json.
{
"status":"reject"
}
To accept the transaction, respond to the API with the same json but with status "accept" as shown below.
{
"status":"accept"
}
if you dont pass on the status we automatically accept the transaction.