dorzki Posted March 2, 2017 Share Posted March 2, 2017 Hi there, I'm developing a module to integrate WHMCS to my financial service. I'm making an API call to create a new receipt and i get in a response a ticket_id. I'm saving this ticket_id because a few seconds later, the financial service sends me an API call with the ticket_id and a url to download the receipt. I've created a file which catches the API call, however i need access to Capsule, and i don't know which file i need to include in order to include the entire WHMCS library so i can use the functions. Would love to get your help ) 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted March 2, 2017 Share Posted March 2, 2017 do you need to use Capsule outside of the WHMCS directory? 0 Quote Link to comment Share on other sites More sharing options...
dorzki Posted March 2, 2017 Author Share Posted March 2, 2017 It is not outside the WHMCS directory, it is a file which resides inside my module directory under /modules/addons/ 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted March 2, 2017 Share Posted March 2, 2017 if that is the case, then you need to require this file: <?php require_once("{Path-To-WHMCS}/vendor/autoload.php"); then import Capsule class in the same file as below: use WHMCS\Database\Capsule; if you work inside WHMCS directory, I mean if your file require WHMCS's init.php file, or run by WHMCS, then you should use the previous line only 0 Quote Link to comment Share on other sites More sharing options...
dorzki Posted March 2, 2017 Author Share Posted March 2, 2017 It is inside WHMCS directory however the file is called directly so the WHMCS library doesn't load. If i include the autoload.php will it also initiate the database connection? or do i need to create a new one? 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted March 2, 2017 Share Posted March 2, 2017 use the following line only in both (hooks.php, and {module-name}.php) files: use WHMCS\Database\Capsule; if you work with different file where you call it using browser or ajax (not called by WHMCS it self) then you need to include this line too: require_once("../../../init.php"); 0 Quote Link to comment Share on other sites More sharing options...
dorzki Posted March 2, 2017 Author Share Posted March 2, 2017 That works! thanks! 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.