<?php
function sendToMobexADR($tx) {

    $payload = [
        "reference" => $tx['reference'],
        "sender" => $tx['sender_msisdn'],
        "recipient" => $tx['receiver_msisdn'],
        "amount" => $tx['send_amount'],
        "currency" => "GHS",
        "destination_country" => $tx['to_country'],
        "callback_url" => "https://yourdomain.com/mobex_adr_callback.php"
    ];

    $ch = curl_init("https://sandbox.mobexapi.com/adr/send");
    curl_setopt_array($ch, [
        CURLOPT_POST => true,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_HTTPHEADER => [
            "Authorization: Bearer YOUR_API_KEY",
            "Content-Type: application/json"
        ],
        CURLOPT_POSTFIELDS => json_encode($payload)
    ]);

    $res = curl_exec($ch);
    curl_close($ch);

    return json_decode($res, true);
}
