skip to content

API - Add Item to Recurring Invoice / Pro-Forma Invoice

URL: AddItemTo.php

JSON Option (recommended):

to use as JSON, append ?apiformat=json to the URL, then send through all variables as a JSON encoded string.

Required Fields:

username
password
IID - the ID of the recurring document to update
type - either recurring_invoices or recurring_pro-forma_invoices
item (array containing single item) - should be in this format:

item['item_code']
item['qty']
item['description']
item['amount']
item['currency'] - currency code like ZAR, must be a supported & used currency under Settings -> Currencies
item['vat_applies'] - vat_applies //1 or 0
item['vat_percentage'] - vat_percentage //decimal(20,2) e.g.: 15.00
item['amount_includes_vat'] - amount_includes_vat //1 or 0

Returns:

JSON array containing:

$array[result] = success - if successful
$array[error] - the type of error if unsuccessful

Example PHP code with JSON

$param['username'] = '';
$param['password'] = '';
$param['IID'] = '';
$param['type'] = '';
$param['item']['item_code'] = ''; //product to add
$param['item']['description'] = '';
$param['item']['amount'] = '';
$param['item']['currency'] = '';
$param['item']['vat_applies'] = '';
$param['item']['vat_percentage'] = '';
$param['item']['amount_includes_vat'] = '';

$url = 'https://www.jobcardsonline.co.za/api/AddItemTo.php?apiformat=json';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url); //set the url
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //return as a variable
curl_setopt($ch, CURLOPT_POST, 1); //set POST method
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($param)); //set the POST variables
$response = curl_exec($ch); //run the whole process and return the response

 

Updated: Sat, 30 May 2020