An unofficial package maintained by Salla to help developers to implement ZATCA (Fatoora) QR code easily which required for e-invoicing

Overview

ZATCA (Fatoora) QR-Code Implementation

An unofficial package maintained by Salla to help developers to implement ZATCA (Fatoora) QR code easily which required for e-invoicing

Requirements

  • PHP >= 7.2
  • An mbstring extension

Installation

You can install the package via composer:

$ composer require salla/zatca

Usage

Generate Base64

use Salla\ZATCA\GenerateQrCode;
use Salla\ZATCA\Tags\InvoiceDate;
use Salla\ZATCA\Tags\InvoiceTaxAmount;
use Salla\ZATCA\Tags\InvoiceTotalAmount;
use Salla\ZATCA\Tags\Seller;
use Salla\ZATCA\Tags\TaxNumber;

$generatedString = GenerateQrCode::fromArray([
    new Seller('Salla'), // seller name        
    new TaxNumber('1234567891'), // seller tax number
    new InvoiceDate('2021-07-12T14:25:09Z'), // invoice date as Zulu ISO8601 @see https://en.wikipedia.org/wiki/ISO_8601
    new InvoiceTotalAmount('100.00'), // invoice total amount
    new InvoiceTaxAmount('15.00') // invoice tax amount
    // TODO :: Support others tags
])->toBase64();

// > Output
// AQVTYWxsYQIKMTIzNDU2Nzg5MQMUMjAyMS0wNy0xMlQxNDoyNTowOVoEBjEwMC4wMAUFMTUuMDA=

Generate Plain

use Salla\ZATCA\GenerateQrCode;
use Salla\ZATCA\Tags\InvoiceDate;
use Salla\ZATCA\Tags\InvoiceTaxAmount;
use Salla\ZATCA\Tags\InvoiceTotalAmount;
use Salla\ZATCA\Tags\Seller;
use Salla\ZATCA\Tags\TaxNumber;

$generatedString = GenerateQrCode::fromArray([
    new Seller('Salla'), // seller name        
    new TaxNumber('1234567891'), // seller tax number
    new InvoiceDate('2021-07-12T14:25:09Z'), // invoice date as Zulu ISO8601 @see https://en.wikipedia.org/wiki/ISO_8601
    new InvoiceTotalAmount('100.00'), // invoice total amount
    new InvoiceTaxAmount('15.00') // invoice tax amount
    // TODO :: Support others tags
])->toTLV();

Render A QR Code Image

You can render the tags as QR code image easily

use Salla\ZATCA\GenerateQrCode;
use Salla\ZATCA\Tags\InvoiceDate;
use Salla\ZATCA\Tags\InvoiceTaxAmount;
use Salla\ZATCA\Tags\InvoiceTotalAmount;
use Salla\ZATCA\Tags\Seller;
use Salla\ZATCA\Tags\TaxNumber;

// data:image/png;base64, .........
$displayQRCodeAsBase64 = GenerateQrCode::fromArray([
    new Seller('Salla'), // seller name        
    new TaxNumber('1234567891'), // seller tax number
    new InvoiceDate('2021-07-12T14:25:09Z'), // invoice date as Zulu ISO8601 @see https://en.wikipedia.org/wiki/ISO_8601
    new InvoiceTotalAmount('100.00'), // invoice total amount
    new InvoiceTaxAmount('15.00') // invoice tax amount
    // TODO :: Support others tags
])->render();

// now you can inject the output to src of html img tag :)
// <img src="$displayQRCodeAsBase64" alt="QR Code" />

TODO

We'll continue work on this package until support the whole cycle of QR code implementation.

  • Support the digital signature for the QR code.

Testing

composer test

Support

Please don't hesitate to contact us using the </Salla Developers> at telegram

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Comments
  • Qr code not readable in VAT app

    Qr code not readable in VAT app

    when I try to read the QR code at https://play.google.com/store/apps/details?id=com.zatca.vat it shows that the invoice is not registered while the all invoices at salla merchants are readable and show registered at the the ap

    opened by osamatoama 6
  • QR image generated displays base64 encoded data not the actual data

    QR image generated displays base64 encoded data not the actual data

    Hello, the qr image generated displays the base64 encoded data not the actual data?

    i have used the code you provided to display it in an image tag

     $displayQRCodeAsBase64 = GenerateQrCode::fromArray([
                    new Seller('Salla'), // seller name
                    new TaxNumber('1234567891'),
                    new InvoiceDate('2021-07-12T14:25:09Z'),
                    new InvoiceTotalAmount('100.00'),
                    new InvoiceTaxAmount('15.00')
    ])->render();
    
    <img src="<?php echo $displayQRCodeAsBase64;?>" alt="QR Code" />
    

    this is the qr code generated by the code above you can scan it and see for yourself

    https://ibb.co/3cMjybb

    am i missing something?

    opened by AbdelRahman-Elshafai 4
  • Enable file save in render method

    Enable file save in render method

    What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

    • Adding file save feature

    What is the current behaviour? (You can also link to an open issue here)

    • the current behaviour it recieve array of options without argument for saving file which provided by chillerlan/php-qrcode

    What is the new behaviour? (You can also link to the ticket here)

    • I edit render method of GenerateQrCode class, to accept mixed arguments, I only process on two arguments, if each of one arguments is string I consider it file path, otherwise I consider it array argument for QROptions class.
    • arrangement of two arguments ignored, and more than 2 arguments also ignored.
    • I use this way to make render call clean and to avoid breaking of previous behaviour.

    Does this PR introduce a breaking change?

    • No
    opened by ayaseensd 3
  • Allow passing mutliple QROptions

    Allow passing mutliple QROptions

    I have seen #7 which is great 👍🏼 However, it would be more efficient passing all the options according to the user needs (since QROptions has multiple options). Also, this allows the user to utilize any added features to the chillerlan\QRCode package in the future 💡

    An example for scale would be:

    $displayQRCodeAsBase64 = GenerateQrCode::fromArray([
    .....
    ])->render(['scale' => 3]);
    

    PS. Thanks for this simple yet elegant solution .. you saved a lot of time for many developers including myself ❤️

    opened by ali-alharthi 3
  • Grey screen when trying to scan it in VAT app!

    Grey screen when trying to scan it in VAT app!

    Hi, this is my code I just copied it from your blog image when trying to scan the qr in VAT app it gives a Grey screen, I've created a nodejs service to generate the base64 TLV, it works fine untill the seller name is arabic I'm using utf8 in encoding but still the same result, is their any solution in both approaches? PHP/Nodej?

    opened by ZED-Magdy 2
  • SALLA/ZATCA PHP minimum version  is 7.4

    SALLA/ZATCA PHP minimum version is 7.4

    i was trying to implement the package with 7.3.x php version , based on the documentation it support 7.2> but unfortunately im getting error with composer :

    chillerlan/php-qrcode[4.3.0, ..., 4.3.2] require php ^7.4 || ^8.0 -> your php version (7.3.28) does not satisfy that requirement. - Root composer.json requires chillerlan/php-qrcode ^4.3 -> satisfiable by chillerlan/php-qrcode[4.3]

    is there version that support lower version?

    opened by ARemaity 2
  • Not readable by zatca app

    Not readable by zatca app

    Hi! There is issue on this code is not readable by zatca app can you please update

    https://play.google.com/store/apps/details?id=com.zatca.vat

    https://apps.apple.com/sa/app/%D8%A7%D9%84%D8%B6%D8%B1%D9%8A%D8%A8%D8%A9-%D8%A7%D9%84%D9%85%D8%B6%D8%A7%D9%81%D8%A9/id1328845826

    opened by elvessisante024 2
  • Is there a C# version of the code?

    Is there a C# version of the code?

    Thanks for the code to help developers get up-to-speed with the requirements,

    Is there a way to use it in a .Net desktop environment?

    If not, could you please point me to the right direction to meet the requirements in a .Net desktop application?

    opened by AhmadKelany 1
  • ZATCA specifications Phase two

    ZATCA specifications Phase two

    Generating CSR content, based on parameters

    
    $xmlInvoice = 'xml invoice text';
    
    $certificate = new \Salla\ZATCA\Helpers\Certificate(
                'certificate plain text (base64 decoded)',
                'private key plain text'
    );
    
    $invoice = (new InvoiceSign($xmlInvoice, $certificate))->sign();
    
    // invoice Hash: $invoice->getHash()
    // invoice signed as XML: $invoice->getInvoice()
    // Invoice QR code as base64: $invoice->getQRCode()
    
    opened by thaifanisalla 0
Releases(2.0.2)
Owner
Salla
Salla is an e-commerce platform designed to help set up e-commerce stores
Salla
With the help of QR code technologies, digital entry passes can be created, which a user can show at the entry point to pass the door.

Navratri_Entry With the help of QR code technologies, digital entry passes can be created, which a user can show at the entry point to pass the door.

Kushang Shah 5 Aug 7, 2022
PHPExif is a library which gives you easy access to the EXIF meta-data of an image

PHPExif v0.6.4 PHPExif is a library which gives you easy access to the EXIF meta-data of an image. PHPExif serves as a wrapper around some native or C

null 135 Dec 4, 2022
Easily convert images with Glide

Easily convert images with Glide This package provides an easy to use class to manipulate images. Under the hood it leverages Glide to perform the man

Spatie 374 Dec 30, 2022
PHP library to easily edit image with GD extension. Resize, crop, merge, draw, and many more options !

PHP Image Editor PHP library to easily edit image with GD extension. Resize, crop, merge, draw, and many more options ! ✨ Supporting ⭐ Star this repos

Franck Alary 17 Nov 13, 2022
This is a class of php QR Code, This library helps you generate QR codes in a jiffy.

This is a class of php QR Code, This library helps you generate QR codes in a jiffy.

null 59 Oct 5, 2022
QR Code Generator

QR Code By endroid If you like my work you can show appreciation by sponsoring via Github Sponsors or send me some ADA at DdzFFzCqrhszSwiFWMBQomfv6mkD

Jeroen van den Enden 3.9k Dec 30, 2022
BaconQrCode is a port of QR code portion of the ZXing library

QR Code generator Introduction BaconQrCode is a port of QR code portion of the ZXing library. It currently only features the encoder part, but could l

Bacon 1.5k Jan 6, 2023
EPC-QR-Code - REDAXO-Addon für GiroCode-kompatible EPC-QR-Codes

Generiert QR-Codes, die von GiroCode®️ kompatiblen Banking-Apps in einer Überweisung genutzt werden können.

alex+ Informationsdesign 4 Apr 12, 2022
This package provides an integration with FFmpeg for Laravel. Laravel's Filesystem handles the storage of the files.

Laravel FFMpeg This package provides an integration with FFmpeg for Laravel 6.0 and higher. Laravel's Filesystem handles the storage of the files. Fea

Protone Media 1.3k Jan 7, 2023
Laravel Package for making thumbnails instantly

Laravel Thumbnail Generator Package for uploading the image and saving that image along with it's thumbnail. What does it do ? Uploads Image Make its

DRH2SO4 50 Dec 5, 2022
Laravel Optical Character Reader(OCR) package using ocr engines like Tesseract

LaraOCR Laravel Optical Character Reader(OCR) package using ocr engines like Tesseract under the hood. Features Read text from image using WebUI/Progr

Al Imran Ahmed 100 Jan 4, 2023
Picasso is a Laravel Image Management and Optimization Package

Picasso is a Laravel Image Management and Optimization Package. Define image dimensions and options, store uploaded image in multiple dimensions with or without a watermark and retrieve optimized images on your website when needed.

Laravelista 82 Nov 24, 2022
A Laravel Gravatar package for retrieving gravatar image URLs or checking the existance of an image.

Gravatar for Laravel 5.x, 6, 7 and 8 Installation First, pull in the package through Composer via the command line: composer require creativeorange/gr

Creativeorange 477 Dec 1, 2022
The Salla OAuth Client library is designed to provide client applications with secure delegated access to Salla Merchant stores.

Salla Provider for OAuth 2.0 Client This package provides Salla OAuth 2.0 support for the PHP League's OAuth 2.0 Client. To use this package, it will

Salla 14 Nov 27, 2022
Laravel package a helper to Generate the QR code and signed it for ZATCA E-invoicing

Laravel ZATCA E-invoicing Introduction Laravel package a helper to Generate the QR code and signed it for ZATCA E-invoicing Installation To get the la

Ayman Alaiwah 8 Aug 17, 2022
Laravel helper to generate the QRcode for ZATCA E-Invoicing system

Laravel-ZATCA Unofficial package to implement ZATCA QRcode for E-Invoicing. Requirements PHP >= 7.4 An mbstring extension Dependencies chillerlan/php-

Moh. Php Master .. 3 Aug 16, 2022
A simple package that helps PHP developers to generate the QR code signature as per Zakat authority (ZATCA) requirements of Saudi Arabia.

A PHP package that implements the e-invoice QR code signature requirements as designed by the Zakat authority of Saudi Arabia. How to install? compose

Muktar Sayed Saleh 5 Jun 13, 2022
laravel package help you to implement geographical calculation, with several algorithms that help you deal with coordinates and distances.

Geographical Calculator Geographical Calculator was developed for laravel 5.8+ to help you to implement geographical calculation, with With several al

karam mustafa 342 Dec 31, 2022
An awesome starter template to create your Salla Apps today! 🚀

Salla Apps Starter Kit An awesome starter template to create your Salla Apps today! Explore our blogs » Report Bug · Request Feature . </Salla Develop

Salla 17 Dec 14, 2022