Webhook
Webhooks allow you to set up a notification system that can be used to receive updates on certain requests made to the Startbutton API.
With webhooks, Startbutton sends updates to your server when the status of your request changes. You will typically listen to these events on your webhook URL - a POST endpoint, the URL needs to parse a JSON request and return a 200 OK.
We send webhooks for the following transaction types:
Collections
Transfers
Conversions
Supported events for payment collection:
collection.verified
collection.completed
{
"event": "collection.verified",
"data": {
"transaction": {
"_id": "65042a1a0d32920xxxxxxxxx",
"transType": "collection",
"status": "verified",
"merchantId": "64c7bd870821e83xxxxxxxxx",
"transactionReference": "be6eaxxxxxxx",
"customerEmail": "test@customer.com",
"userTransactionReference": "aedxxxx",
"paymentCode": "a78a18df1fdc1fa7f2fb665b54afa21cf1c0d81b741f44527989f492e2a6094cdb24281fb7d577c4636978xxxxxxxxxx",
"isRecurrent": false,
"postProcess": null,
"gatewayReference": null,
"createdAt": "2023-09-15T09:55:38.492Z",
"updatedAt": "2023-09-15T09:57:30.522Z",
"feeAmount": 115500,
"narration": "Approved",
"amount": 1030000,
"currency": "ZAR"
},
"authorizationCode": null
}
}Webhook for DVA top-up:
When top-up is done to you DVA, you should expect this webhook format:
Supported events for transfer:
transfer.pending
transfer.successful
transfer.failed
transfer.reversed
Supported events for Conversion :
conversion.successful
conversion.pending
conversion.failed
Supported events for Disputes:
dispute.created
dispute.declined
dispute.processed
Webbook Samples for Under and Overpaid transactions:
Webhook Verification
To ascertain that the request you received on your webhook is legit and not a bad actor, it's recommended that the webhook response is verified.
Events sent from Startbutton carry the x-startbutton-signature header. The value of this header is a HMAC SHA512 signature of the event payload signed using your secret key. Verifying the header signature should be done before processing the event.
Here is a sample code showing the webhook verification
}
Final Notes
To wrap up your webhook implementation, here is the ideal flow your webhook endpoint should follow
Verify request is from us using secret key and payload sent
Re-query transaction status after hit
Send 200 status back immediately and handle complex logic on your end
Ensure webhook responses are idempotent. Save the response and ensure value isn't give twice. since you can get multiple calls for a transaction.
Last updated