Jump to content

generate Invoice API question.


kurbot

Recommended Posts

Is anyone else having trouble utalizing the Invoice Generation Api?

 

What i have is the following

 

<?php

$whmcsurl = "http://mydomain.com/includes/api.php"; # URL to WHMCS API file

$username = "myadminuser"; # Admin username goes here

$password = "myadminpass"; # Admin password goes here

 

$postfields["action"] = "createinvoice";

$postfields["userid"] = "8";

$postfields["date"] = "2008/12/03";

$postfields["duedate"] = "2008/12/30";

$postfields["paymentmethod"] = "paypal";

$postfields["sendinvoice"] = false;

$postfields["itemdescription1"] = "(".date("m/d/Y").") Phone Service Performed";

$postfields["itemamount1"] = "10.00";

$postfields["itemtaxed1"] = 0;

 

 

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $whmcsurl);

curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);

curl_setopt($ch, CURLOPT_TIMEOUT, 30);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$data = curl_exec($ch);

curl_close($ch);

 

$data = explode(";",$data);

foreach ($data AS $temp) {

$temp = explode("=",$temp);

 

$results[$temp[0]] = $temp[1];

 

}

 

if ($results["result"]=="success") {

echo "Invoice Generated Successfully<br /><br />";

} else {

# An error occured

echo "The following error occured: ".$results["message"];

}

 

 

?>

 

Now the above is pulling ffrom a PHP form created then submitting results im using the abov as a sample submition..

 

When viewing the form and after submitting i receive and error of : authentication failed.

 

If anyone has any suggestions that would be helpful, im trying to generate a neat little time counter tool for hte support tickets, where when on the phone or when performing a service i can start a counter which ive already created utalizing the addon manager. It uses a product i created, with configurations set for time purchased and time left.. it updates all of it correctly, the last step was having it create an invoice if they didnt have a service plan..

 

To cut this short, im just having trouble with the API.

 

Let me know.

Link to comment
Share on other sites

The admin and pass im using is the primary administrator for accessing the administration panel of WHMCS.

 

IT seems the api file is not cooperating with any type of scripts, i was reviewing the whmcs documentation on API, and i even tested some of there examples.. those also dont work..

 

If this helps.. im using the Licensing Module and that works just fine this module utalizes API also, if i remember correctly it had me swap out the includes/api.php file to one that was allowed to use licensing.. maybe there is a restriction or a bug in the "new api.php file"?

 

Thanks for you help so far..

Link to comment
Share on other sites

thats what the example showed in the api documentation.. ive tried it all ways though.. 2008/m/d yyyymmdd dd/mm/yyyy etc..

 

I wish i could turn on a debugging mode or something however the api.php file is encrypted.. so i can not find out why persay or what line its failing on in the api..

 

Im looking through google too no one else seems to have this issue.. but i havent seen anyone elses examples yet..

 

ill see what i can figure out here..

Link to comment
Share on other sites

Yea, that did not work, i was matching structure to what was in my DB already.. and all entry itself matches the SQL table structure.. I've even tried created an new administrative user, starting with FULL rights testing and working all the way down the chain to no rights.. still no avail.

 

I do beleive the API error is related to authenticating the Admin User.. Something in the API blocking or not actually validating users.

Edited by kurbot
wanted to make a new note
Link to comment
Share on other sites

Kurbot here is your problem, surprisingly I didn't notice it and no one else did. Your username and password aren't being passed along. You need to add this:

 

$postfields["username"] = $username;

$postfields["password"] = md5($password);

Look at post #2

Link to comment
Share on other sites

Try adding www to the front of the domain. That was also suggested to me from WHMCS support.

 

Also, are you sure that you have API turned on? By default it's turned on but double check, go to Configuration -> Administration Roles -> Full Administrator -> and make sure that API Access has a checkmark beside it.

Edited by VirtualSims
Link to comment
Share on other sites

  • 1 month later...

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