curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_USERPWD, $GATEWAY['private-key'] . ":" . NULL);
    curl_setopt($ch, CURLOPT_TIMEOUT, 5);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
    curl_setopt($ch, CURLOPT_CAINFO, realpath(dirname(__FILE__) . "/cacert.pem"));
    $return = curl_exec($ch);
    curl_close($ch);
    return $return;
}
# Ensure that the module is active before attempting to run any code
$gateway = new Gateway();
if (!$gateway->isActiveGateway($gatewaymodule) || !$gateway->load($gatewaymodule)) {
    Terminus::getInstance()->doDie('Module not Active');
}
$pdo = Capsule::connection()->getPdo();
# Process and store transaction
if (isset($_REQUEST['id']) && !empty($_REQUEST['id'])) {
    $ca = new WHMCS_ClientArea();
    # Check login status
    if ($ca->isLoggedIn()) {
        $invoice_id = (int) $_REQUEST['id'];
        $store_token = $_REQUEST['token'];
        $currency = $_REQUEST['currency'];
        $amount = (int) $_REQUEST['amount'];
        if (preg_match("#^[A-Z]{3}\$#", $currency) && preg_match("#^[a-zA-Z 0-9\\_\\-]*\$#", $store_token)) {
            //Get invoice details
            $sql = "SELECT * FROM tblinvoices WHERE id = '{$invoice_id}'";