Example 5: Callback URLs
Configuration and usage of callback URLs for payment notifications and redirects.
Important
These URLs must be publicly accessible and properly configured on your server to handle the callbacks.
Payment Button
Configured URLs
-
Notify URL:
https://your-site.com/webhook/afribapay
Webhook for payment status -
Return URL:
https://your-site.com/payment/success?order_id=ORDER-CALLBACK-1770200779
After successful payment -
Cancel URL:
https://your-site.com/payment/cancel?order_id=ORDER-CALLBACK-1770200779
If user cancels
Code Example
$request->notify_url = "https://your-site.com/webhook/afribapay";
$request->return_url = "https://your-site.com/payment/success?order_id=" . $request->order_id;
$request->cancel_url = "https://your-site.com/payment/cancel?order_id=" . $request->order_id;
Webhook Handler Example
// Example webhook handler
// File: webhook/afribapay.php
$data = json_decode(base64_decode($_POST["afp_data"]), true);
// Check payment status
if ($data["status"] === "success") {
// Update order in your database
// order_id is available in $data["order_id"]
updateOrderStatus($data["order_id"], "paid");
}