SchoolBusesC2 Posted May 28, 2019 Share Posted May 28, 2019 Hello All, I am trying to use a hook redirect to make a API request to auto accept the order. I am using GET when redirecting and then using cURL to send an API request but it is currently not working. Please refer to the hook php file and the API file. Thanks, Owen afterConfirmOrder.php orderCreate.php 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted May 28, 2019 Share Posted May 28, 2019 Why don't you directly use localAPI like follows? <?php add_hook('AfterShoppingCartCheckout', 1, function($vars) { $postData = array( 'orderid' => $vars['OrderID'] ); //$adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later $results = localAPI('AcceptOrder', $postData, $adminUsername); }); 0 Quote Link to comment Share on other sites More sharing options...
SchoolBusesC2 Posted May 28, 2019 Author Share Posted May 28, 2019 I plan on it redirecting the person to the main website not the whmcs website 0 Quote Link to comment Share on other sites More sharing options...
SchoolBusesC2 Posted May 29, 2019 Author Share Posted May 29, 2019 When I use localAPI() I get this error: PHP Fatal error: Uncaught Error: Call to undefined function localAPI() Does the file have to be put in a specific directory? Thanks, Owen 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted May 29, 2019 Share Posted May 29, 2019 This one should work. Don't forget to replace the URL. <?php add_hook('AfterShoppingCartCheckout', 1, function($vars) { $postData = array( 'orderid' => $vars['OrderID'] ); //$adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later $results = localAPI('AcceptOrder', $postData, $adminUsername); // Replace the URL header('Location: http://google.it'); die(); }); 0 Quote Link to comment Share on other sites More sharing options...
SchoolBusesC2 Posted May 29, 2019 Author Share Posted May 29, 2019 Thanks! Owen 0 Quote Link to comment Share on other sites More sharing options...
SchoolBusesC2 Posted May 29, 2019 Author Share Posted May 29, 2019 Hello, I am getting a error message: Service Provisioning Failed A new service has failed to provision successfully. Client: Owen Domain: localAPIPowers.site.isodme.com Failure Message: Unknown plan name Status: Pending Thanks, Owen 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted May 29, 2019 Share Posted May 29, 2019 I think the error doesn't involve your action hook and more in general WHMCS. It should be related to the Server Module you use to provision the product/service in question. Probably you didn't configure Setup > Products/Services > {YOUR_PRODUCT} > Modules tab properly. 0 Quote Link to comment Share on other sites More sharing options...
SchoolBusesC2 Posted May 29, 2019 Author Share Posted May 29, 2019 Thanks! Owen 0 Quote Link to comment Share on other sites More sharing options...
SchoolBusesC2 Posted June 10, 2019 Author Share Posted June 10, 2019 Hello, I can't use localAPI. I want to redirect first and on that page to provision the service so there is no delay. Could someone help with the cURL? Thanks, Owen 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.