PHP code example of zaycon / taxify

1. Go to this page and download the library: Download zaycon/taxify 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/ */

    

zaycon / taxify example snippets


$taxify = new ZayconTaxify\Taxify( '[YOUR_API_KEY]', ZayconTaxify\Taxify::ENV_DEV, TRUE );

$origin_address = new ZayconTaxify\Address();
$origin_address
    ->setStreet1( '16201 E Indiana Ave' )
    ->setCity( 'Spokane Valley' )
    ->setState( 'WA' )
    ->setPostalCode( '99216' );

$destination_address = new ZayconTaxify\Address();
$destination_address
    ->setStreet1( '16201 E Indiana Ave' )
    ->setCity( 'Spokane Valley' )
    ->setState( 'WA' )
    ->setPostalCode( '99216' );

$line = new ZayconTaxify\TaxLine();
$line
    ->setQuantity( 1 )
    ->setItemKey( 'SKU001' )
    ->setActualExtendedPrice( 100 )
    ->setItemDescription( 'Some Product' )
    ->setItemTaxabilityCode( ZayconTaxify\Code::CODE_FOOD );

$tax = new ZayconTaxify\Tax( $taxify );
$tax
    ->setDocumentKey( 'Order001' )
    ->setTaxDate( time() )
    ->setIsCommitted( TRUE )
    ->setOriginAddress( $origin_address )
    ->setDestinationAddress( $destination_address )
    ->addLine( $line );
$tax_response = $tax->calculateTax();

$tax = new ZayconTaxify\Tax( $taxify );
$tax->setDocumentKey( 'Order001' );
$tax_response = $tax->commitTax();

$tax = new ZayconTaxify\Tax( $taxify );
$tax->setDocumentKey( 'Order001' );
$tax_response = $tax->cancelTax();

$address = new ZayconTaxify\Address( $taxify );
$address
	->setStreet1( '16201 E Indiana Ave' )
	->setCity( 'Spokane Valley' )
	->setState( 'WA' )
	->setPostalCode( '99216' )
	->verifyAddress();

$account = new ZayconTaxify\Account( $taxify );
$code_types = $account->getCodes();