Adding one off charges to recurring invoices

Hello,

I run a small telecoms company and have used quickfile in the past for my old company however i would like to implement it for the telecoms but i cant seem to find a way of adding a one off charge to an reoccuring invoice as call costs change monthly.

Is this possible? If not does anyone know a work around?

Hi @xzit

Unfortunately a recurring invoice is for a fixed amount. The only way you could do this would to edit it after it’s been created.

Another option would be to use our API and perhaps create invoices through that method instead. This does however require a bit of a coding knowledge.

Hello

Thanks for the info is there an up to date php example for your api as I know the one I used previously no longer works as you upgraded your api

I’ll see if I can put an example together for you later today and update my post :slight_smile:

Thanks :slight_smile:

Apologies - a bit later than anticipated, but hopefully this will help. I’ve used the “Invoice_Create” method as an example and added a few comments to help. This uses the JSON endpoints rather than the XML ones.

This hasn’t been tested and only created fairly quickly, so there may be errors. Hopefully it’ll point you in the right direction though :slight_smile:

<?php

$accountNumber		= '6131400001';		// QuickFile account number
$applicationID		= 'ABCD-100-EFGH';	// Application ID
$apiKey				= 'HGFE-001-DCBA';	// Account API Key
$submissionCode  	= uniqid();			// Randomly generated submission number, but this can be anything unique

// End point
$endPoint         	= 'https://api.quickfile.co.uk/1_2/invoice/create';

// The data to be sent via the API
$data 	= [
	'payload'		=> [
		'Header'		=> [
			'MessageType'       => 'Request',
			'SubmissionNumber'  => $submissionCode,
			'Authentication'    => [
				'AccNumber'         => $accountNumber,
				'MD5Value'          => md5($accountNumber . $apiKey . $submissionCode),
				'ApplicationID'     => $applicationID
			]
		],
		'Body'			=> [
			'InvoiceData'	=> [
				'InvoiceType'	=> 'INVOICE',
				'ClientID'		=> 12345,
				'ClientAddress'	=> [
					'Address'		=> '123 High Street<br>London<br>AA1 1AA<br>United Kingdom',
					'CountryISO'	=> 'GB'
				],
				'Currency'		=> 'GBP',
				'TermDays'		=> 14,
				'Language'		=> 'en',
				'InvoiceLines'	=> [
					'ItemLines'		=> [
						'ItemLine'		=> [
							'ItemID'			=> 0,
							'ItemName'		 	=> 'USB Cable',
							'ItemDescription'	=> '2.5m USD Cable (Blue)',
							'ItemNominalCode'	=>	4000,
							'Tax1'		=> [
								'TaxName'	 	=> 'VAT',
								'TaxPercentage'	=> '20.00',
								'TaxAmount'		=> '2'
							],
							'UnitCost'	=> '10.00',
							'Qty'		=> 1
						]
					]
				],
				'Scheduling'	=> [
					'SingleInvoiceData'	=> [
						'IssueDate'			=> '2018-01-25'
					]
				]
			]
		]		
	]
];

// Set up the cURL handler
$ch = curl_init($endPoint);

// Set up options, including data
curl_setopt_array($ch, array(
	CURLOPT_POST                => TRUE,
	CURLOPT_RETURNTRANSFER      => TRUE,
	CURLOPT_HTTPHEADER          => array(
		'Content-Type: text/json'
	),
	CURLINFO_HEADER_OUT         => TRUE,            
	CURLOPT_POSTFIELDS          => json_encode($data),
	CURLOPT_SSL_VERIFYPEER      => TRUE // This may need to be false if testing from localhost
));

// Send the request
$response               = curl_exec($ch);

// Get HTTP Code
$httpCode               = curl_getinfo($ch, CURLINFO_HTTP_CODE);

// Decode the returned JSON
$return                 = json_decode($response);

// Check for errors
if($httpCode != 200)
{
	// Something didn't go right
	// $return->Errors contains the errors returned
}
else
{
	// All good!
	// $return will contain the returned data inline with the API Docs
}

// Note: Not tested, but hopefully it'll point you in the right direction if nothing else

Full documentation for this function can be found here:
https://api.quickfile.co.uk/d/v1_2/Invoice_Create

This topic was automatically closed after 7 days. New replies are no longer allowed.