Jump to content

Free API to invisible autoorder for existing customers.


Recommended Posts

Api: A way to develope things outside where you have your whcms installed, it can work in joomla with jumi for example.

 

What we did is a php where by opening it your customer will add an order automatically (pid)

 

In our case for example we configured the whmcs email marketer for:

 

after 20 days of being customer we send an email "invitation to activate service trial xxx"

 

Within the template has a simple email link to "activate service here" rutaaestephp.php?clientid=xx where:

 

xx: each customer id

pid: below code according to the service you want to autocreate, autoactivate.

 

 

The first part of this code is to define the connection

 

$url = "http://www.MIWHCMS.com/includes/api.php"; # URL to WHMCS API file
$username = "JUANGUERRA"; # Admin username goes here
$password = "BACHATAROSA"; # Admin password goes here

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

//
$salidaok = 'clientes/api-ok.php'; // php a lo mando si sale ok

 

Then we define clientid sent by url and ip for security

 

//variables de URL
$postfields["clientid"] = $_GET['clientid'];
$postfields["clientip"] = $_SERVER["REMOTE_ADDR"];

 

and the rest of php to create order

 

//que hace el api
$postfields["action"] = "addorder";
$postfields["pid"] = "xxxxxx"; //for example 123 is pid=123 your service number.
$postfields["billingcycle"] = "monthly";
$postfields["promocode"] = "EM-Correton"; // offer a discount if you want
$postfields["paymentmethod"] = "paypal";
$postfields["autosetup"] = "true"; // if not it will be as pending..

//sobre emails que envia
$postfields["sendemail"] = "true";//true= it sends setup of service
$postfields["noemail"] = "true"; //true=dont send order email
$postfields["noinvoiceemail"] = "true";//true= dont send invoice

$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 = explode(";",$data);
foreach ($data AS $temp) {
$temp = explode("=",$temp);
$results[$temp[0]] = $temp[1];
}

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

$host = $_SERVER['HTTP_HOST'];
//$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\'); NO LO USO POR AHORA, hace que quedes ene l mismo directorio

echo "LOADING...".PHP_EOL;
echo "".PHP_EOL;

} else {
# An error occured
echo "The following error occured: ".$results["message"];
echo "para cliente".$clientid;
}

 

If you want custom API or develope, just contact us and we quote in hours, we can develope for $30 by hour.

 

you can see more detaiils in our blog here http://www.argentina--software.com.ar/index.php/2012/08/01/api-autocrear-pedido-para-clientes

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