API:addInvoiceItem - Add invoice line
Add new line/item to invoice
Required parameters
- id
- Invoice ID
- line
- Description of new invoice item
- price
- Price per one item
- qty
- Item QTY, default:1
- tax
- Indicates whether item is taxed (1) or not (0)
Request
GET http://url_to_your_hostbill.com/admin/api.php?api_id=API_ID&api_key=API_KEY&call=addInvoiceItem&id=ID&line=LINE&price=PRICE&qty=QTY&tax=TAX
<?php
include 'class.hbwrapper.php';
HBWrapper::setAPI('http://url_to_hb.com/admin/api.php','API ID','API Key');
$params = array(
'id'=>ID,
'line'=>LINE,
'price'=>PRICE,
'qty'=>QTY,
'tax'=>TAX
);
$return = HBWrapper::singleton()->addInvoiceItem($params);
print_r($return);
?>
<?php
$url = 'http://url_to_hb.com/admin/api.php';
$post = array(
'api_id' => API_ID,
'api_key' => API_Key,
'call' => 'addInvoiceItem',
'id'=>ID,
'line'=>LINE,
'price'=>PRICE,
'qty'=>QTY,
'tax'=>TAX
);
$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, $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);
?>
<?php
/* Use this method to access HostBill api from HostBill modules */
$api = new ApiWrapper();
$params = array(
'id'=>ID,
'line'=>LINE,
'price'=>PRICE,
'qty'=>QTY,
'tax'=>TAX
);
$return = $api->addInvoiceItem($params);
print_r($return);
?>
Response
{
"success": true,
"newline": {
"id": "67",
"invoice_id": "219",
"type": "Other",
"item_id": "0",
"description": "Invoice Item Description",
"amount": "5.50",
"taxed": "0",
"qty": "1",
"linetotal": 1.3
},
"call": "addInvoiceItem",
"server_time": 1317723134
}