Jump to content

API issue with domainregister


Recommended Posts

I'm writing a API based order flow process.

 

A user fills out a custom order form and this creates a WHMCS account.

 

My code then adds an order and uses "autoauth" to forward them to the new invoice to pay.

 

Once PayPal payment is made then can then go to our main site and login (the login details are matched off their WHMCS user account)

 

During the actual login process I run a little MySQL query to see if a record is present in a NON WHMCS database. If there is a record then its assumed this client is a returning client and they can login and use our platform / service.

 

However !

 

If NO record exists then the script assumes this is the users first time logging in. So the script gos into WHMCS and finds the domain name that was assigned during the initial signup process and goes and auto registeres the domain uses NameCheap

 

Everything is setup correctly with the NameCheap API Plugin. The domain costs $1.00 but a promo code returns that value to $0.00 so the client doesnt actually pay for the domain to be registered, we pay for that.

 

The problem is, nothing happens, the domain is NOT registered but I dont get ANY ERRORS

 

I used the following API code

 

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

$postfields["username"] = "remove_for_security"; # Admin username goes here

$postfields["password"] = md5("remove_for_security"); # Admin password goes here

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

$postfields["clientid"] = $userid;

$postfields["responsetype"] = "json";

$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, $postfields);

$data = curl_exec($ch);

curl_close($ch);

 

$data = json_decode($data);

$result = $data->result;

$domain_id = $data->domains->domain[0]->id;

echo 'domain_id = '.$domain_id.'<br>';

$domain_name = $data->domains->domain[0]->domainname;

echo 'domain_name = '.$domain_name.'<br>';

 

###########

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

$postfields["username"] = "remove_for_security"; # Admin username goes here

$postfields["password"] = md5("remove_for_security"); # Admin password goes here

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

$postfields["domainid"] = $domain_id;

$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, $postfields);

$data = curl_exec($ch);

curl_close($ch);

 

echo '<hr>';

var_dump($data);

echo '<hr>';

 

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

// print_r($data).'<hr>';

foreach ($data AS $temp) {

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

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

}

 

var_dump($results);

echo '<hr>';

 

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

# Result was OK!

echo "$domain has been registered";

} else {

# An error occured

echo "domainregister ERROR: ".$results["message"].'<br><br>Please email this error report to admin@genexnet.com';

die();

}

 

 

Here is the output when that code is ran

 

 

domain_id = 4

domain_name = 4-251515810-893555342.info

string(0) ""

array(4) { ["result"]=> string(7) "success" ["userid"]=> string(1) "4" ["passwordhash"]=> string(32) "fa9f1e77941a82ee751e5e042eddf5f2" [""]=> NULL }

 

 

So it appears the namecheap api / module is not firing.

 

I have the namecheap module setup with my API details and the server's IP is working / added correctly

 

I've setup the domain pricing for a .info and followed all setup steps to the letter.

 

Please could someone help !!!

 

I know $userid and $domain_id and $domain_name are correct and populated so thats not the issue !

 

Cheers

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