Craft 8 Posted November 24 (edited) 38 minutes ago, aissa el youssfu said: thanks for your response this isthe code <?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' =>myadminusername '', // 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('paypal','amazonsimplepay') ); } /********************/ 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'); Yea this is the old hook which working on the old versions on WHMCS But you need to replace this code with the updated one to be compatible with the new version of WHMCS But take care, it's working only for hosting orders not for domain registration/transfer orders Here is the update code: <?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 AutoAcceptOrders_settings() { return array( 'apiuser' => 'admin', // 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'); ?> Reference: https://github.com/Jetserver/WHMCS-Auto-Accept-Orders/issues/1 Edited November 24 by Craft 1 Share this post Link to post Share on other sites
Craft 8 Posted November 24 14 minutes ago, aissa el youssfu said: under which name should i save this same file .. take a backup from your current file then replace the code 1 Share this post Link to post Share on other sites
Craft 8 Posted November 24 34 minutes ago, aissa el youssfu said: oh yeah thank you so much I think it works but he problem is when a client pays i go to my paypal the payment is recieved but at the client dashboard there still an invoice Share a screenshot to understand you better and try to solve the issue 1 Share this post Link to post Share on other sites
Craft 8 Posted November 24 15 minutes ago, aissa el youssfu said: this is the dashboard of one my client, he paid the invoice and the payment is recieved. but as you can see the incoice is still appearing. Yea because (isPaid) function doesn't run successfully. Can you share a screenshot from the Activity log (Utilities >> Log >> Activity Log) 1 Share this post Link to post Share on other sites
Craft 8 Posted November 24 24 minutes ago, aissa el youssfu said: please what causes also those errors with green marks This issue is not related to the hook by the way. Your order is now "Active" or still pending? I'm asking about the Order Status not the Order Item! You can check it from the main page of "Orders" tab >> List All Orders 1 Share this post Link to post Share on other sites
Craft 8 Posted November 25 26 minutes ago, aissa el youssfu said: still pending That’s correct because the order should be paid first then it will accept the order Now you need to solve the payment issue first 1 Share this post Link to post Share on other sites
Craft 8 Posted November 25 1 hour ago, aissa el youssfu said: please what causes also those errors with green marks Make sure that you are using a valid emails here: Setup >> General Settings >> General tab >> (Email Address) field Setup >> General Settings >> Mail tab >> (System Emails From Email) field 1 Share this post Link to post Share on other sites
Bhondawe30 1 Posted November 29 Thanks for sharing your knowledge base, It will be helpful for me. 1 Share this post Link to post Share on other sites