skip to content

API - Add New Purchase Order

URL: GenerateNewPurchaseOrder.php

Required Fields:

username
password
data (array containing items) - should be in this format:

data[$i][0] - prod_code
data[$i][1] - qty
data[$i][2] - description
data[$i][3] - amount
data[$i][4] - currency
data[$i][5] - vat_applies //1 or 0
data[$i][6] - vat_percentage //decimal(20,2)
data[$i][7] - amount_includes_vat //1 or 0

SupplierID or these supplier related fields:

supplier_name (255 characters max)
supplier_email (255 characters max)

Optional Supplier Related Fields (If no SupplierID is supplied):

supplier_vat_nr (255 characters max)
supplier_phone_nr (20 characters max)
supplier_phone_nr2 (20 characters max)
supplier_fax_nr (20 characters max)
supplier_postal_address1 (255 characters max)
supplier_postal_address2 (255 characters max)
supplier_postal_address3 (255 characters max)
supplier_postal_address4 (255 characters max)

Optional Fields:

OrderNr (10 characters max)
AdditionalLabel1 (12 characters max)
AdditionalValue1 (32 characters max)
AdditionalLabel2 (12 characters max)
AdditionalValue2 (32 characters max)
AdditionalLabel3 (12 characters max)
AdditionalValue3 (32 characters max)
DiscountAmount (decimal(20,2))
DiscountPercentage (decimal(20,2))
prepend_nr (9 characters max)
append_nr (9 characters max)
EmailToSupplier (true or false)

Returns:

JSON array containing:

$array[url] - the url where the document can be downloaded
$array[purchase_order_nr] - the purchase order number
$array[email_url] - url to open to have the document emailed to the supplier

Example PHP code

$param['username'] = '';
$param['password'] = '';
$param['SupplierID'] = '';
$param['data[0][1]'] = ''; //first product
$param['data[0][2]'] = '';
$param['data[0][3]'] = '';
$param['data[0][4]'] = '';
$param['data[0][5]'] = '';
$param['data[0][6]'] = '';
$param['data[0][7]'] = '';
$param['data[1][1]'] = ''; //second product
$param['data[1][2]'] = '';
$param['data[1][3]'] = '';
$param['data[1][4]'] = '';
$param['data[1][5]'] = '';
$param['data[1][6]'] = '';
$param['data[1][7]'] = '';
	
foreach ($param as $key => $val) {
  $request.= $key . '=' . urlencode($val);
  $request.= '&';
}
$request = substr($request, 0, -1); //remove trailing &

$url = 'https://www.invoicesonline.co.za/api/GenerateNewPurchaseOrder.php';
$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, $request); //set the POST variables
$response = curl_exec($ch); //run the whole process and return the response

 

Updated: Tue, 16 August 2016