PHP code example of picqer / xero-php-client

1. Go to this page and download the library: Download picqer/xero-php-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

picqer / xero-php-client example snippets


$xero = new Picqer\Xero\Xero('--api key--', '--api secret--', '--path to private key file--');

$invoices = $xero->getInvoices();

$contact = new Picqer\Xero\Entities\Contact();
$contact->Name = 'Casper Bakker Demo';
    
$address = new Picqer\Xero\Entities\ContactAddress();
$address->City = 'Doesburg';
$contact->Addresses = [ $address ];
    
$response = $xero->create($contact);

$invoice = new Picqer\Xero\Entities\Invoice();
$invoice->Type = 'ACCREC';
$invoice->LineAmountTypes = 'Exclusive';
$invoice->Date = new DateTime();
$invoice->DueDate = new DateTime('+2 weeks');
    
$lineitem = new Picqer\Xero\Entities\InvoiceLineItem();
$lineitem->Description = 'Subscription';
$lineitem->UnitAmount = 12.95;
$lineitem->AccountCode = '8100';
$lineitem->Quantity = 2;
    
$invoice->addLineItem($lineitem);
    
$invoice->Contact = $xero->getContact('--existing customer id--');

$response = $xero->create($invoice);