API:Add Order

Home / Support / Documentation
From WHMCS Documentation
Jump to: navigation, search

Purpose

This command is used to add a new order to the system.

Attributes

  • clientid - client id for order
  • pid - product id
  • domain - domain name
  • billingcycle - onetime, monthly, quarterly, semiannually, etc..
  • domaintype - set for domain registration - register or transfer
  • regperiod = 1,2,3,etc...
  • eppcode - if domain transfer
  • nameserver1 - first nameserver (req for domain reg only)
  • paymentmethod - paypal, authorize, etc...

Optional Attributes

  • customfields - a base64 encoded serialized array of custom field values
  • configoptions - a base64 encoded serialized array of configurable product options
  • priceoverride - allows you to pass in a custom price override for the product (domains are not products)
  • promocode - pass coupon code to apply to the order
  • promooverride - pass this to override the products a coupon applies to (like through the admin area)
  • affid - affiliate ID if you want to assign the order to an affiliate
  • noinvoice - set true to not generate an invoice for this order
  • noinvoiceemail - set true to generate but not send the invoice notification email
  • noemail - set true to surpress the order confirmation email
  • clientip - can be used to pass the customers IP
  • addons - comma seperated list of addon ids

For VPS/Dedicated Server Orders only

  • hostname - The hostname of the server. This will be added to domain automatically
  • ns1prefix - the prefix to be used for the NS1 nameserver
  • ns2prefix - the prefix to be used for the NS2 nameserver
  • rootpw - The root password for the server

For domain reg only

  • contactid - the ID of a contact to use for the domain registrant details
  • dnsmanagement - true to enable
  • domainfields - a base64 encoded serialized array of the TLD specific field values
  • emailforwarding - true to enable
  • idprotection - true to enable
  • nameserver2 - second nameserver
  • nameserver3 - third nameserver
  • nameserver4 - fourth nameserver

For domain renewals

  • domainrenewals - This is a name -> value array of domain -> regperiod

Example Commands

Single Product

This is an example order for product ID 1 on a monthly billing cycle, with addons and custom fields specified, plus domain registration of whmcs.com via the Mail in Payment method.

External API

 $postfields["action"] = "addorder";
 $postfields["clientid"] = "1";
 $postfields["pid"] = "1";
 $postfields["domain"] = "whmcs.com";
 $postfields["billingcycle"] = "monthly";
 $postfields["addons"] = "1,3,9";
 $postfields["customfields"] = base64_encode(serialize(array("1"=>"Google")));
 $postfields["domaintype"] = "register";
 $postfields["regperiod"] = "1";
 $postfields["paymentmethod"] = "mailin";

Internal API

 $command = "addorder";
 $adminuser = "admin";
 $values["clientid"] = "1";
 $values["pid"] = 1;
 $values["domain"] = "whmcs.com";
 $values["billingcycle"] = "monthly";
 $values["addons"] = "1,3,9";
 $values["customfields"] = base64_encode(serialize(array("1"=>"Google")));
 $values["domaintype"] = "register";
 $values["regperiod"] = 1;
 $values["paymentmethod"] = "mailin";
 
 $results = localAPI($command,$values,$adminuser);

Multiple Products no email

This is an example of an order for multiple products and not sending an order confirmation to the customer:

External API

 $postfields["action"] = "addorder";
 $postfields["clientid"] = "1";
 $postfields["pid[0]"] = "1";
 $postfields["domain[0]"] = "whmcs.com";
 $postfields["billingcycle[0]"] = "monthly";
 $postfields["pid[1]"] = "1";
 $postfields["domain[1]"] = "whmcs2.com";
 $postfields["billingcycle[1]"] = "monthly";
 $postfields["pid[2]"] = "5";
 $postfields["domain[2]"] = "whmcs3.com";
 $postfields["billingcycle[2]"] = "annually";
 $postfields["noemail"] = "true";
 $postfields["paymentmethod"] = "authorize";

Internal API

 $command = "addorder";
 $adminuser = "admin";
 $values["clientid"] = 1;
 $values["pid"] = array(1,1,5);
 $values["domain"] = array("whmcs.com","whmcs2.com","whmcs3.com");
 $values["billingcycle"] = array("monthly","monthly","annually");
 $values["noemail"] = true;
 $values["paymentmethod"] = "authorize";
 
 $results = localAPI($command,$values,$adminuser);

Domain Only with promo

This is an example of a domain only order specifying a promotion code and nameservers for the domains to be assigned to:

External API

 $postfields["action"] = "addorder";
 $postfields["clientid"] = "1";
 $postfields["domaintype[0]"] = "register";
 $postfields["domain[0]"] = "whmcs.com";
 $postfields["regperiod[0]"] = "1";
 $postfields["dnsmanagement[0]"] = "on";
 $postfields["idprotection[0]"] = "on";
 $postfields["domaintype[1]"] = "register";
 $postfields["domain[1]"] = "whmcs.co.uk";
 $postfields["regperiod[1]"] = "2";
 $postfields["nameserver1"] = "ns1.demo.com";
 $postfields["nameserver2"] = "ns2.demo.com";
 $postfields["nameserver3"] = "ns3.demo.com";
 $postfields["nameserver4"] = "ns4.demo.com";
 $postfields["promocode"] = "demopromo";
 $postfields["paymentmethod"] = "quantumgateway";

Internal API

 $command = "addorder";
 $adminuser = "admin";
 $values["clientid"] = "1";
 $values["domaintype"] = array("register","register");
 $values["domain"] = array("whmcs.com","whmcs.co.uk");
 $values["regperiod"] = array(1,2);
 $values["dnsmanagement"] = array("on");
 $values["idprotection"] = array("on");
 $values["nameserver1"] = "ns1.demo.com";
 $values["nameserver2"] = "ns2.demo.com";
 $values["nameserver3"] = "ns3.demo.com";
 $values["nameserver4"] = "ns4.demo.com";
 $values["promocode"] = "demopromo";
 $values["paymentmethod"] = "quantumgateway";
 
 $results = localAPI($command,$values,$adminuser);

Addon Only

This is an example order call to add an addon to service ID 5:

External API

 $postfields["action"] = "addorder";
 $postfields["clientid"] = "1";
 $postfields["addonid"] = "5";
 $postfields["serviceid"] = "19";
 $postfields["paymentmethod"] = "paypal";

Internal API

 $command = "addorder";
 $adminuser = "admin";
 $values["clientid"] = 1;
 $values["addonid"] = 5;
 $values["serviceid"] = 19;
 $values["paymentmethod"] = "paypal";
 
 $results = localAPI($command,$values,$adminuser);

Domain Renewal Only

This is an example order call to add a domain renewal order:

External API

 $postfields["action"] = "addorder";
 $postfields["clientid"] = "1";
 $postfields["domainrenewals[domain1.com]"] = 1; #renew for 1 year
 $postfields["domainrenewals[domain2.com]"] = 2; #renew for 2 years
 $values["paymentmethod"] = "paypal";

Internal API

 $command = "addorder";
 $adminuser = "admin";
 $values["clientid"] = 1;
 $values["domainrenewals"] = array("domain1.com" => 1, "domain2.com" => 2);
 $values["paymentmethod"] = "paypal";
 
 $results = localAPI($command,$values,$adminuser);

You must also send your API username & password with all of the above example requests for them to work

Successful Response

 result = success
 orderid = xxx # Order ID
 invoiceid = xxx # Invoice ID
 productids = comma separated list of service IDs created by the order
 addonids = comma separated list of addon IDs created by the order
 domainids = comma separated list of domain IDs created by the order

Error Response

result=error&message=Client ID not found # Given Client ID is not found in the database.
result=error&message=Invalid Payment Method # Payment method not found.
result=error&message=No items added to cart so order cannot proceed #No added item.

API Functions
Client Management
Add Client - Update Client - Delete Client - Close Client - Get Clients
Get Clients Details - Get Clients Products - Get Clients Password - Add Contact - Update Contact
Delete Contact - Update Client Product - Upgrade Product - Validate Login - Send Email
Support Tickets
Get Support Departments - Get Support Statuses - Get Tickets - Get Ticket - Get Ticket Predefined Cats
Get Ticket Predefined Replies - Open Ticket - Reply Ticket - Add Ticket Note - Delete Ticket - Update Ticket
Quotes
Create Quote - Update Quote - Delete Quote - Send Quote - Accept Quote
Module Commands
Module Create - Module Suspend - Module Unsuspend - Module Terminate
Domain Commands
Renew Domain - Get Domain Lock - Get Nameservers - Get WHOIS - Request EPP
Update Lock - Update Nameservers - Update WHOIS - Domain WHOIS Lookup
Order Handling
Get Orders - Get Order Statuses - Add Order - Accept Order - Pending Order - Cancel Order - Fraud Order - Delete Order
Payments/Billing
Get Invoice - Get Payment Methods - Create Invoice - Update Invoice - Add Billable Item - Add Invoice Payment
Add Transaction - Add Credit - Capture Payment
Miscellaneous
Get Activity Log - Get Admin Details - Update Admin Notes - Get Currencies - Get Email Templates
Get To-Do Items - Get To-Do Item Statuses - Get Staff Online - Get Stats - Encrypt Password - Decrypt Password