Skip to content

Instantly share code, notes, and snippets.

@TechStreetDev
Last active September 4, 2024 17:57
Show Gist options
  • Save TechStreetDev/92572f0fdc9932b86dccae3cef10bbd4 to your computer and use it in GitHub Desktop.
Save TechStreetDev/92572f0fdc9932b86dccae3cef10bbd4 to your computer and use it in GitHub Desktop.
WHMCS Autoaccept

This script autoaccepts orders when using WHMCS

  1. Replace REPLACE_ME with a username of your admin (API) account.
  2. Upload the content below inside of ../includes/hooks/AutoAcceptOrders.php

Note: I did not make this original script, the original was published under MIT licence on a seperate repo but was later deleted.

<?php
function AutoAcceptOrders_accept($vars)
{
    $command = 'GetInvoice';
    $postData = array(
        'invoiceid' => $vars['invoiceid'],
    );
    $adminUsername = 'REPLACE_ME'; //put here your admin user
    $ispaid = true;

    if ($vars['invoiceid'])
    {
        $resultinvoice = localAPI($command, $postData, $adminUsername);
        $ispaid = ($resultinvoice['result'] == 'success' && $resultinvoice['balance'] <= 0) ? true : false;
    }
    $command = 'AcceptOrder';
    $postData = array(
        'orderid' => $vars['orderId'],
        'autosetup' => true,
        'sendemail' => true,
    );

    if ((true && $ispaid))
    {
        $result = localAPI($command, $postData, $adminUsername);
        print_r($results);
        logActivity("Order Accept", 0);
        if (is_array($result))
        {
            foreach ($result as $index => $value)
            {
                logActivity("$index:$value", 1);
            }
        }
    }

}
add_hook("OrderPaid", 1, "AutoAcceptOrders_accept");
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment