Jump to content

Recommended Posts

Posted (edited)

So Hello Guys if you are facing this issue that your payment is done on your whmcs but still it shows order is pending , I have and complete and permanently solution , I give you a auto accept order hook ... So let's start it....

1. Step One :

Go to your whmcs directory in your cpanel where your whmcs is installed on , now go to includes/hooks , or public_html/includes/hooks

2. Step two :

create a file in your includes/hooks/ folder create a file names ' jetserver_AutoAcceptOrders.php '

3. Step three :

Edit the file you created and paste this below code on jetserver_AutoAcceptOrders.php file :

<?php
/*
*
* Auto Accept Orders
* Created By Idan Ben-Ezra
*
* Copyrights @ Jetserver Web Hosting
* www.jetserver.net
*
* Hook version 1.0.1
*
**/
if (!defined("WHMCS"))
    die("This file cannot be accessed directly");

/*********************
 Auto Accept Orders Settings
*********************/
function jetserverAutoAcceptOrders_settings()
{
    return array(
        'apiuser'        => 'whmcsadminusername', // one of the admins username
        'autosetup'         => true, // determines whether product provisioning is performed
        'sendregistrar'     => true, // determines whether domain automation is performed
        'sendemail'         => true, // sets if welcome emails for products and registration confirmation emails for domains should be sent 
        'ispaid'        => true, // set to true if you want to accept only paid orders
        'paymentmethod'        => array(), // set the payment method you want to accept automaticly (leave empty to use all payment methods) * example array('paytm','Paytm')
    );
}
/********************/

function jetserverAutoAcceptOrders_accept($vars) 
{
    $settings = jetserverAutoAcceptOrders_settings();

    $ispaid = true;

    if($vars['InvoiceID'])
    {
        $result = localAPI('getinvoice', array(
            'invoiceid'         => $vars['InvoiceID'],
        ), $settings['apiuser']);

        $ispaid = ($result['result'] == 'success' && $result['balance'] <= 0) ? true : false;
    }

    if((!sizeof($settings['paymentmethod']) || sizeof($settings['paymentmethod']) && in_array($vars['PaymentMethod'], $settings['paymentmethod'])) && (!$settings['ispaid'] || $settings['ispaid'] && $ispaid))
    {
        $result = localAPI('acceptorder', array(
            'orderid'         => $vars['OrderID'],
            'autosetup'         => $settings['autosetup'],
            'sendregistrar'     => $settings['sendregistrar'],
            'sendemail'         => $settings['sendemail'],
        ), $settings['apiuser']);
    }
}

add_hook('AfterShoppingCartCheckout', 0, 'jetserverAutoAcceptOrders_accept');

?>

 

Step 4

   'apiuser'        => 'whmcsadminusername', // one of the admins username

Replace whmcsadminusername to your admin username of your whmcs...

 

If any issue then comment please

Edited by WHMCS ChrisD
Added code into codebox

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated