Tinypesa will forward the STK callback to your configured webhook in the following JSON format.
The resulting code in the request body should guide you.
Success-"ResultCode": 0
. The CallbackMetadata-> Item
list may be of varied length and is mapped directly as-is from Safaricom.
{
"Body": {
"stkCallback": {
"MerchantRequestID": "26773-830618-1",
"CheckoutRequestID": "ws_CO_21042021114416028704",
"ResultCode": 0,
"ResultDesc": "The service request is processed successfully.",
"CallbackMetadata": {
"Item": [
{
"Name": "Amount",
"Value": 1
},
{
"Name": "MpesaReceiptNumber",
"Value": "PDL72WRAVZ"
},
{
"Name": "TransactionDate",
"Value": 20210421114425
},
{
"Name": "PhoneNumber",
"Value": 254718942538
}
]
},
"TinyPesaID": "c002f860-a27d-11eb-a7f4-c141263d7c15",
"ExternalReference": "customacct",
"Amount": 1,
"Msisdn": "254718942538"
}
}
}
{
"Body": {
"stkCallback": {
"MerchantRequestID": "25395-1644131-1",
"CheckoutRequestID": "ws_CO_26022021085632641774",
"ResultCode": 1031,
"ResultDesc": "Request cancelled by user",
"TinyPesaID": "f8ac0d60-7a14-11eb-ba1d-e3a49273aa65",
"ExternalReference": "customacct",
"Amount": 1,
"Msisdn": "254718942538"
}
}
}