I've been working on a web-based system using PHP. The system is linking to the payment gateway using API and webhooks for payment notification. I've worked on everything else but webhooks are foreign to me. I've subscribed to webhooks and the payment gateway is supposed to send in JSON via the url submitted when creating webhooks. Below is the sample JSON.
{
"topic": "buygoods_transaction_received",
"id": "2133dbfb-24b9-40fc-ae57-2d7559785760",
"created_at": "2020-10-22T10:43:20+03:00",
"event": {
"type": "Buygoods Transaction",
"resource": {
"id": "458712f-gr76y-24b9-40fc-ae57-2d35785760",
"amount": "100.0",
"status": "Received",
"system": "Lipa Na M-PESA",
"currency": "KES",
"reference": "OJM6Q1W84K",
"till_number": "000000",
"sender_phone_number": "+254999999999",
"origination_time": "2020-10-22T10:43:19+03:00",
"sender_last_name": "Doe",
"sender_first_name": "Jane",
"sender_middle_name": null
}
},
"_links": {
"self": "https://sandbox.kopokopo.com/webhook_events/2133dbfb-24b9-40fc-ae57-2d7559785760",
"resource": "https://sandbox.kopokopo.com/financial_transaction/458712f-gr76y-24b9-40fc-ae57-2d35785760"
}
}
I need to capture some fields like OJM6Q1W84K,100.0 etc
and store them into my db. How do I capture the JSON? The rest will be easy for me once I figure out that one. Thanks guys.