Example 2: Full Options

Complete example using all available SDK options.

About this example

This example demonstrates all available options including callbacks, logo, and button customization.

Payment Button

Configuration

  • Amount: 15 000 XOF
  • Country: BF
  • Company: TechStore Africa
  • Show Countries: Yes
  • Notify URL: https://your-site.com/webhook/afribapay
  • Return URL: https://your-site.com/payment/success
  • Cancel URL: https://your-site.com/payment/cancel

Code Example


$request = new AfribaPayRequest();
$request->amount = 15000;
$request->currency = "XOF";
$request->country = "BF";
$request->order_id = "ORDER-" . time();
$request->reference_id = "REF-" . uniqid();
$request->description = "Purchase of electronic products";
$request->company = "TechStore Africa";
$request->checkout_name = "TechStore - Secure Payment";

// Callback URLs
$request->notify_url = "https://your-site.com/webhook/afribapay";
$request->return_url = "https://your-site.com/payment/success";
$request->cancel_url = "https://your-site.com/payment/cancel";

// Logo (optional)
// $request->logo_url = "https://your-site.com/logo.png";

$request->showCountries = true;

$buttonHtml = $sdk->createCheckoutButton(
    $request,
    "Pay Now",
    "#007bff",
    "large"
);