# API: Order an upgrade
# orderUpgrade
Create upgrade or change billing cycle order
# Required parameters
Parameter | Description |
---|---|
id | Account ID |
new_billing | Billing cycle for account, allowed values: m ,q ,s ,a ,b ,t ,d ,w ,h or Free or Once where m-monthly, q-quarterly etc.. |
# Optional parameters
Parameter | Description |
---|---|
new | Product Id of package we will be upgrading to. If not set you need to send at least new_billing argument |
module | Payment module ID invoice should be generated with |
# Request
GET /admin/api.php?api_id=API_ID&api_key=API_KEY&call=orderUpgrade&id=ID&new_billing=NEW_BILLING
# PHP Samples
$url = 'http://url_to_hb.com/admin/api.php';
$post = [
'call' => 'orderUpgrade',
'api_id' => $API_ID,
'api_key' => $API_KEY,
'id' => $ID,
'new_billing' => $NEW_BILLING,
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$data = curl_exec($ch);
curl_close($ch);
$return = json_decode($data, true);
print_r($return);
include 'class.hbwrapper.php';
HBWrapper::setAPI('http://url_to_hb.com/admin/api.php','API ID','API Key');
$params = [
'id' => $ID,
'new_billing' => $NEW_BILLING,
];
$return = HBWrapper::singleton()->orderUpgrade($params);
print_r($return);
/* Use this method to access HostBill api from HostBill modules */
$api = new ApiWrapper();
$params = [
'id' => $ID,
'new_billing' => $NEW_BILLING,
];
$return = $api->orderUpgrade($params);
print_r($return);
# Response
{
"success": true,
"checkout": {
"invoice_id": "75",
"total": 48,
"gateway": "4",
"order_id": "69",
"order_num": 999054726,
"newtotal": 1376
},
"call": "orderUpgrade",
"server_time": 1344000642,
"info": [
"upgrade_order_success"
]
}