Jump to content
Craft

Auto Accept Order

Recommended Posts

Hi
I would like to auto accept any order on payment, so I did the following:
General Settings >> Ordering >> Auto Provision
Products/Services >> Module Settings >> Auto setup as soon as first payment is received
I added this hook (jetserver_AutoAcceptOrders.php) and I set everything to true (Check the screenshot)

When I Pay using (promo code with amount ZERO) or (amount $$ but paid from my account balance), I see the hosting is setup successfully, the order is accepted and status is Active.
But when I pay using Paypal, I see the hosting is setup successfully and order status is Pending. (Order Accepted is not mentioned at the Activity log).

jetserverauto.png

payment from credit.png

Payment from paypal.png

Pending Order.png

Share this post


Link to post
Share on other sites

which PHP version are you using? i'm not entirely sure that this is PHP7 compatible.

Share this post


Link to post
Share on other sites
Posted (edited)
1 hour ago, brian! said:

which PHP version are you using? i'm not entirely sure that this is PHP7 compatible.

@brian! Yea I'm using php 7.0

But I couldn't change to php 5.6 as WHMCS won't work :)

So what we should do now? :)

How can we make this file (jetserver_AutoAcceptOrders.php) compatible with php 7.0? Is there an alternative solution?

Edited by Craft

Share this post


Link to post
Share on other sites
10 hours ago, VanguardOne said:

Hello,

I was searching for a similar solution. I found this thread - https://whmcs.community/topic/274669-auto-accept-orders/ - I wonder if the hook called out here from a few years ago, still works? Can a mod confirm for us?

Thank you!

I did all the steps exactly as your mentioned old thread but it's not working.

Maybe the php file is not compatible any more with php 7.0

Share this post


Link to post
Share on other sites
16 hours ago, Craft said:

But I couldn't change to php 5.6 as WHMCS won't work 🙂

really? for simplicity sake, I tend to keep my 7.7.1 dev in 5.6 - seems to work without issue, though maybe you have addons that require PHP7.

16 hours ago, Craft said:

So what we should do now? 🙂

well from your screenshots, you can tell that it fundamentally works with credit balances, or I assume, 0.00 discounted invoices..... i'd be tempted to try it with bank transfer/mail-in payment to see if this is purely a PayPal issue, or if it doesn't like gateways in general.

16 hours ago, Craft said:

How can we make this file (jetserver_AutoAcceptOrders.php) compatible with php 7.0?

in that thread from @VanguardOne others have stated that it works with PHP7, so i'm inclined to think it's more an issue with PayPal or its configuration at your end - but without testing this locally myself, I can't know for sure.

17 hours ago, Craft said:

Is there an alternative solution?

if you want a commercial solution, Order Assistant from BusyRack is available from the Marketplace - it's $20 per year, or $80 to buy it.

12 hours ago, VanguardOne said:

Can a mod confirm for us?

I doubt that any moderator here (who will all be staff I assume) would comment on that unless they have used it themselves - they probably wouldn't comment on the status of a live third-party project, let alone an archived one.

2 hours ago, Craft said:

I did all the steps exactly as your mentioned old thread but it's not working.

but your screenshots show that it partially is, just not in your case for that PayPal order... so possibly something different with the variable values in the hook using PHP7 rather than 5.6 ?

2 hours ago, Craft said:

Maybe the php file is not compatible any more with php 7.0

I would suggest that you do one of two things (or both)...

  1. post the issue on their GitHub site as that's where anyone familiar with this will see it and may already have a solution.
  2. perhaps it just needs to use OrderPaid or InvoicePaid instead of the current hook point - there's a post with updated code here, but I haven't tried it.

Share this post


Link to post
Share on other sites
Posted (edited)
5 hours ago, brian! said:

I would suggest that you do one of two things (or both)...

  1. post the issue on their GitHub site as that's where anyone familiar with this will see it and may already have a solution.
  2. perhaps it just needs to use OrderPaid or InvoicePaid instead of the current hook point - there's a post with updated code here, but I haven't tried it.

@brian! I solved it.

The old github php file is really not compatible with the new version of WHMCS 7.7

So I used the modified code at the link you sent me and now it's working fine, thank you :)

https://github.com/Jetserver/WHMCS-Auto-Accept-Orders/issues/1#issuecomment-412626577

 

Edited by Craft

Share this post


Link to post
Share on other sites
7 hours ago, Craft said:

@brian! I solved it.

The old github php file is really not compatible with the new version of WHMCS 7.7

So I used the modified code at the link you sent me and now it's working fine, thank you :)

https://github.com/Jetserver/WHMCS-Auto-Accept-Orders/issues/1#issuecomment-412626577

 

Awesome, Craft. Do you mind sharing the code you created via Github that's working for you in whmcs 7.7 with the modifications you made? 

Share this post


Link to post
Share on other sites
15 hours ago, VanguardOne said:

Awesome, Craft. Do you mind sharing the code you created via Github that's working for you in whmcs 7.7 with the modifications you made? 

@VanguardOne Yea sure, the new code is here: https://github.com/Jetserver/WHMCS-Auto-Accept-Orders/issues/1#issuecomment-412626577

I tested it and it's working fine for WHMCS 7.7

here you are the code again

function AutoAcceptOrders_settings()
{
return array(
'apiuser'	=> '', // one of the admins username
'autosetup' => true, // determines whether product provisioning is performed
'sendregistrar' => false, // 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
);
}

function AutoAcceptOrders_accept($vars)
{
$settings = AutoAcceptOrders_settings();

$ispaid = true;

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

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

}
logActivity("Order isPaid: ".$ispaid,0);

if(( $settings['ispaid'] && $ispaid))
{
    $result = localAPI('AcceptOrder', array(
        'orderid' => $vars['orderId'],
        'autosetup'	=> $settings['autosetup'],
        'sendemail' => $settings['sendemail'],
    ), $settings['apiuser']);
    logActivity("Order Accept", 0);
    if(is_array($result)){
        foreach($result as $index=>$value){
            logActivity("$index:$value",0);
        }
    }

}
}
add_hook('OrderPaid', 1, 'AutoAcceptOrders_accept');

 

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