Jump to content

API - Make Custom Invoice


designpc

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated