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
Code Example
$request->notify_url = "https://your-site.com/webhook/afribapay";
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");
}