PHP code example of prgayman / laravel-zatca

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

    

prgayman / laravel-zatca example snippets


'providers' => [
    Prgayman\Zatca\ZatcaServiceProvider::class,
]

'aliases' => [
  'Zatca' => Prgayman\Zatca\Facades\Zatca::class,
]

$app->register(Prgayman\Zatca\ZatcaServiceProvider::class);

class_alias(\Prgayman\Zatca\Facades\Zatca::class, 'Zatca');

use Prgayman\Zatca\Facades\Zatca;

$base64 = Zatca::sellerName('Zatca')
            ->vatRegistrationNumber("123456789123456")
            ->timestamp("2021-12-01T14:00:09Z")
            ->totalWithVat('100.00')
            ->vatTotal('15.00')
            ->toBase64();
// Output
// AQVaYXRjYQIPMTIzNDU2Nzg5MTIzNDU2AxQyMDIxLTEyLTAxVDE0OjAwOjA5WgQGMTAwLjAwBQUxNS4wMA==

use Prgayman\Zatca\Facades\Zatca;

$tlv = Zatca::sellerName('Zatca')
            ->vatRegistrationNumber("123456789123456")
            ->timestamp("2021-12-01T14:00:09Z")
            ->totalWithVat('100.00')
            ->vatTotal('15.00')
            ->toTLV();

use Prgayman\Zatca\Facades\Zatca;
use Prgayman\Zatca\Utilis\QrCodeOptions; // Optional

// Optional
$qrCodeOptions = new QrCodeOptions;

// Format (png,svg,eps)
$qrCodeOptions->format("svg");

// Color 
$qrCodeOptions->color(255,0,0,1);

// Background Color 
$qrCodeOptions->backgroundColor(0,0,0);

// Size
$qrCodeOptions->size(100);

// Margin 
$qrCodeOptions->margin(0);

// Style (square,dot,round)
$qrCodeOptions->style('square',0.5);

// Eye (square,circle)
$qrCodeOptions->eye('square');

$qrCode = Zatca::sellerName('Zatca')
            ->vatRegistrationNumber("123456789123456")
            ->timestamp("2021-12-01T14:00:09Z")
            ->totalWithVat('100.00')
            ->vatTotal('15.00')
            ->toQrCode($qrCodeOptions);


$base64 = zatca()
            ->sellerName('Zatca')
            ->vatRegistrationNumber("123456789123456")
            ->timestamp("2021-12-01T14:00:09Z")
            ->totalWithVat('100.00')
            ->vatTotal('15.00')
            ->toBase64();
// Output
// AQVaYXRjYQIPMTIzNDU2Nzg5MTIzNDU2AxQyMDIxLTEyLTAxVDE0OjAwOjA5WgQGMTAwLjAwBQUxNS4wMA==


$tlv = zatca()
            ->sellerName('Zatca')
            ->vatRegistrationNumber("123456789123456")
            ->timestamp("2021-12-01T14:00:09Z")
            ->totalWithVat('100.00')
            ->vatTotal('15.00')
            ->toTLV();

$qrCode = zatca()
            ->sellerName('Zatca')
            ->vatRegistrationNumber("123456789123456")
            ->timestamp("2021-12-01T14:00:09Z")
            ->totalWithVat('100.00')
            ->vatTotal('15.00')
            ->toQrCode(
              qrCodeOptions()
                ->format("svg")
                ->color(255,0,0,1)
                ->size(300)
            );