Jump to content

How to write API code to automatically set new orders to Active instead of Pending


docex

Recommended Posts

Yes, yes, yes I know the "security" issues of instant setup on new hosting accounts I've read about over and over but I have decided that I need all new orders once the first payment is received to be set as "Active".

 

(Just another way of automating the system for me)

 

Can someone help me out on how to do this? I would REALLY appreciate it.

 

 

**NOTE: In the product server settings, I have "automatically create the account as soon as the order is placed", but the status still remains "Pending" until I manually go in and approve it.

 

I need to automate this process somehow.

Link to comment
Share on other sites

So far, this is the API code that I have, but it still keeps the orders as pending:

 

<?php

function none_ConfigOptions() {
   $configarray = array();
   return $configarray;
}

function none_CreateAccount($params) {
return "success";
}

function none_SuspendAccount($params) {
return "success";
}

function none_UnsuspendAccount($params) {
return "success";
}

function none_TerminateAccount($params) {
return "success";
}

?>

 

P.S.- Im not trying to setup an account on a server, just using WHMCS to keep track of clients/billing/etc. I have an external script that I use in conjunction with WHMCS.

Link to comment
Share on other sites

you can NOT do this using the API. You also don't ever need to change that flag, the account works fine and get created. There's no API function to even check any other values in the database to see if the customer's account is active, paid-up, and ready. I had to write a few extra API functions that directly accessed my WHMCS MySQL database and checked a whole bunch of stuff to work it out.

 

In any case, why do you wanna change them from "Pending" to "Active"?

Link to comment
Share on other sites

basically, use this to get an array of orders that are currently set to "Pending"

function whmcs_useridToPendingordersArray($whatUserId)
{
	global $db_host, $db_user, $db_pass, $db_name;
	$conne = mysql_connect($db_host, $db_user, $db_pass) or die ('Error connecting to mysql');

	mysql_select_db($db_name);

	$query  = "SELECT invoiceid FROM tblorders WHERE userid = '". $whatUserId ."' AND status = 'Pending'";
	$result = mysql_query($query);
	$hatten = 0;
	while($row = mysql_fetch_array( $result )) {
		$dome[$hatten] = $row['invoiceid'];
		$hatten++;
	}

	mysql_close($conne);

	return($dome);

}

 

and then this to get an array of orders that are overdue in payment

 

function whmcs_useridToUnpaidinvoiceidArray($whatUserId)
{
	global $db_host, $db_user, $db_pass, $db_name;
	$conne = mysql_connect($db_host, $db_user, $db_pass) or die ('Error connecting to mysql');

	mysql_select_db($db_name);

	$query  = "SELECT id FROM tblinvoices WHERE userid = '". $whatUserId ."' AND status = 'Unpaid'";
	$result = mysql_query($query);
	$hatten = 0;
	while($row = mysql_fetch_array( $result )) {
		$dome[$hatten] = $row['id'];
		$hatten++;
	}

	mysql_close($conne);

	return($dome);

}

 

then, if an order is "Pending" but is NOT "Overdue", then it must be active and working fine.

Link to comment
Share on other sites

The reason I want to set the account status to "Active" is because for some reason no matter what I select the welcome email for each product, the default "Order Confirmation" email is sent.

 

I DO NOT WANT THE DEFAULT ORDER CONFIRMATION EMAIL SENT!

 

The only way I can get the custom welcome emails to be sent is if the product is set to "Active" and you have the button to send welcome email, in which case, the proper welcome email is sent.

 

I'm going above and beyond the necessary requirements just to get the custom welcome email to be sent, thats all.

Link to comment
Share on other sites

You can disable the order confirmation email when you edit the email template.

 

 

Right, and since the order confirmation email is the only one thats sent, when I disable it the customer does not receive the default order conformation emai OR my custom welcome email, so Im screwed.

Link to comment
Share on other sites

um, just use the API's "send email" function? That's pretty obvious to me.

 

Yes, but I do not know how to do that. Ive read the wiki, documentation,etc.

 

If someone could just write and API send email function I would have this issue fixed and be extremely greateful!

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