Jump to content

API remote order form problems


kmm2908

Recommended Posts

I am having problems with my remote order form script.

I am continuously getting this error message:

array(1) { ["Invalid TLD/Registration Period Supplied for Domain Registration"]=> NULL }

 

I have read the other posts on this error message and they all suggest checking product set up. We are able to process payments fine through the normal interface so there cannot be a problem here; it is only when we access the system through the api we get the problem.

 

I am able to register a new customer but the domain and hosting 'add order' section is posing the problem. The relevant code follows:

// add order details
$postfields= array();
$postfields["username"] = $username;
$postfields["password"] = md5($password);
$postfields["action"] = "addorder";
$postfields["clientid"] = $clientid;
$postfields["pid"] = $pid;
$postfields["domain"] = $domain;
$postfields["paymentmethod"] = $paybytxt;
$postfields["billingcycle"] = $billingcycle;
$postfields["domaintype"] = $domaintype;

$query_string = "";
foreach ($postfields AS $k=>$v) {
$query_string .= "$k=".urlencode($v)."&";
}


// WHMCS invocation call
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $query_string);
$data = curl_exec($ch);
curl_close($ch);

$data = explode(";",$data);
foreach ($data as $temp)
{
$temp = explode("=",$temp);
$results2[$temp[0]] = $temp[1];
}
var_dump($results2);

 

I have had a remote form script working before for non-domain and hosting products, so I am assuming it must be to do with whatever variables I am passing into the api for the domain and/or hosting that is causing the problem.

 

I have checked my script against others posted on the forum and I really cannot see anything to cause this error.

 

Any help greatly appreciated.

Link to comment
Share on other sites

You need to specify

postfields["regperiod"] = NUMBEROFYEARSTOREGISTERDOMAIN;

Hi and thanks for reply logicsurge

 

I have tried it both with and without regperiod code as you suggested and still get same error message.

 

Any other suggestions?

 

Is there a support department at WHMCS that can help with this as I cannot go forward until know what the error is before I can correct it.

 

Very Frustrating!

Link to comment
Share on other sites

I have added a print out of variables I echoed to screen on the error being returned.

 

I have a routine that checks that the customer details have been added successfully and it returns the clientid.

 

Client account for Martin created Client ID: 12799
Billing Cycle: annually
Reg Period: 1
Pay By: tco
Domain: wedsssdrew.com
Domain Type: Register
array(1) { ["Invalid TLD/Registration Period Supplied for Domain Registration"]=> NULL } Latest Inv #:

 

Hope this helps prompt further assistance.

 

Thanks ;)

Link to comment
Share on other sites

You should just need to pass the regperiod as mentioned above, can you post some snippets of your code, maybe it's not getting passed by chance?

 

What other code can I post to help jason?

 

The api call is above and the printout from the echoing of variables is above.

// add order details
$postfields= array();
$postfields["username"] = $username;
$postfields["password"] = md5($password);
$postfields["action"] = "addorder";
$postfields["clientid"] = $clientid;
$postfields["pid"] = $pid;
$postfields["domain"] = $domain;
$postfields["paymentmethod"] = $paybytxt;
$postfields["billingcycle"] = $billingcycle;
$postfields["domaintype"] = $domaintype;
$postfields["regperiod"] = $regperiod;

$query_string = "";
foreach ($postfields AS $k=>$v) {
$query_string .= "$k=".urlencode($v)."&";
}


// WHMCS invocation call
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $query_string);
$data = curl_exec($ch);
curl_close($ch);

$data = explode(";",$data);
foreach ($data as $temp)
{
$temp = explode("=",$temp);
$results2[$temp[0]] = $temp[1];
}
var_dump($results2);

Link to comment
Share on other sites

Can you provide the actual form code? Might be a problem in the form itself? That's the only thing I can think of since your code looks very close to mine.

 

Hi KuJoe, thanks for reply.

 

I've echoed out the form variables to the screen and the screen shot is above.

 

I cannot see any errors myself.

 

Matt is looking at it for me so I'll update if we find anything.

 

Thanks again!

Link to comment
Share on other sites

Thanks Matt for looking. What could the error be?

The regperiod variable passed is the integer 1. I have also passed it as text and neither have worked.

The domain variable is a text variable containing the full domain and extension.

I have used php to separate on the '.' to arrive at an extension of '.com'.

Both of these variables plus the regperiod variable echo out to the screen just before passing to api call correctly.

What could possibly be stopping this from working?

The code I use registers the new client without a problem and the order details are written to tblorders, it just baulks at the domain/tld resulting in - ["Invalid TLD/Registration Period Supplied for Domain Registration"]

There must be a simple explanation - any ideas?

Link to comment
Share on other sites

Ok problem resolved! The regperiod variable was being passed with a capital 1st letter - but not any longer!

 

Thanks to Matt for all the patient help in resolving this.

 

I still have one problem to resolve - the invoice is being created and then tagged as paid when it is not. Can anyone point me at which part of the api call affects this aspect?

Link to comment
Share on other sites

  • 11 months 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