designpc Posted June 29, 2007 Share Posted June 29, 2007 Hi, I have a website made in PHP/MySQL, it builds up servers, therefore the price of each configuration is always different. So my questions is: Is it possible to create new products (i.e. a custom server config) on demand by the user, so that I can use the payment gateway process in WHMCS? I think this would be done using the API, however im very new to API... Thanks in advanced 0 Quote Link to comment Share on other sites More sharing options...
WHMCS CEO Matt Posted June 29, 2007 WHMCS CEO Share Posted June 29, 2007 You can create invoices for a user via the API. The instructions for this can be viewed in our online manual here: http://v3manual.whmcs.com/?id=137 Matt 0 Quote Link to comment Share on other sites More sharing options...
designpc Posted July 1, 2007 Author Share Posted July 1, 2007 Thanks Matt for the reply. I did read the manual pages on API, however, I have never used API in anything before. So if you could give me a few pointers that would be great, So just say I have the following variables; <?php $total_cost = 100; $item_desc = "Custom Build"; $client_first = "Joe"; $client_last = "Bloggs"; $client_email = "j.bloggs@domain.com"; ?> I am just a bit unsure how to get the $query_string bit to communicate with WHMCS? Thanks again. 0 Quote Link to comment Share on other sites More sharing options...
WHMCS CEO Matt Posted July 1, 2007 WHMCS CEO Share Posted July 1, 2007 Hi, Please see this manual article on how to connect to the API. It should show you how it has to be done. http://v3manual.whmcs.com/?id=134 Matt 0 Quote Link to comment Share on other sites More sharing options...
brianoz Posted July 1, 2007 Share Posted July 1, 2007 designpc, Re the API -- there's a whole new section in the manual, only a few entries, but you should read the lot! 0 Quote Link to comment Share on other sites More sharing options...
designpc Posted July 1, 2007 Author Share Posted July 1, 2007 Hi, I have read all the manual's info on API, but like I said, I've never used any API before. Ideally, it would be helpful if I could look at an example. You see im unsure what to do with the query_string, I can make the query_string up fine with all the info passed from the variables I already have, its just getting that info into WHMCS... Do I need to make a link do say domain.com/whmcs/order.php?[the query_string] ?? Thats the bit im stuck on. Thanks again 0 Quote Link to comment Share on other sites More sharing options...
WHMCS CEO Matt Posted July 1, 2007 WHMCS CEO Share Posted July 1, 2007 The link above that I gave you explains how to use it. You need to request the file includes/api.php Matt 0 Quote Link to comment Share on other sites More sharing options...
designpc Posted July 1, 2007 Author Share Posted July 1, 2007 Hi Matt, I have read the link you gave me and all the sections under "API" in the manual, and I think I understand it all. The problem is, do I have to send query_string through a form or some other means, a working example if anyone has one would be great. Also does it matter if I am trying to connect from another server? Thanks 0 Quote Link to comment Share on other sites More sharing options...
brianoz Posted July 1, 2007 Share Posted July 1, 2007 Designpc, there actually IS a working example there - you send the query string using curl, exactly as in the example given in the API section in the manual... it couldn't be clearer than being right there in front of you on the page. http://v3manual.whmcs.com/?id=134 Doesn't matter which server you connect from in theory, although in practice WHMCS licencing issues may cause problems depending on what code you pull in. 0 Quote Link to comment Share on other sites More sharing options...
designpc Posted July 1, 2007 Author Share Posted July 1, 2007 LOL, I think I might be looking to much into the whole process here... This is what I have so far, is this correct? <?php $url = "http://My_domain_here.com/whmcs/includes/api.php"; # URL to WHMCS API file goes here $username = "my_user_here"; # Admin username goes here $password = "my_pass_here"; # Admin password goes here $query_string = "username=".$username."&password=".md5($password)."&" $query_string .= "action=addinvoicepayment&invoiceid=15&transid=453685410&amount=40&gateway=paypalinvoices"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url ); curl_setopt($ch, CURLOPT_POST, 1 ); curl_setopt($ch, CURLOPT_POSTFIELDS, $query_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $postresult = curl_exec($ch); if (curl_errno($ch)) { echo curl_error($ch); } curl_close($ch); # Check result here... ?> I called this api.php just to test it, then I run the file, but i get a T_VARIABLE error on line 10? Thanks 0 Quote Link to comment Share on other sites More sharing options...
brianoz Posted July 1, 2007 Share Posted July 1, 2007 If it has a syntax error it's not correct is it I'm not sure if it's right or not, but run it (after putting back the ';' at end of the first query_string line) and see if it works! 0 Quote Link to comment Share on other sites More sharing options...
designpc Posted July 1, 2007 Author Share Posted July 1, 2007 Hi brianoz, I thought the ";" was the error, so I guess the manual should be changed... Right, I have put the ";" back in, ran the script again, and still nothing, I have tried the query_string for creating a new user as well $query_string .= "action=adduser&firstname=Test&lastname=User&email=test@whmcs.com&address1=Demo&city=Test&state=Test&postcode=TT122&country=UK&phonenumber=01234567890&password=temp"; and still no user added to WHMCS? Thanks 0 Quote Link to comment Share on other sites More sharing options...
WHMCS CEO Matt Posted July 1, 2007 WHMCS CEO Share Posted July 1, 2007 You may need to open a ticket and request the latest api file. Matt 0 Quote Link to comment Share on other sites More sharing options...
designpc Posted July 2, 2007 Author Share Posted July 2, 2007 Just an update to this post. I got the latest api.php file from WHMCS support, and I have the API working great now. Thanks all. 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.