Laravel package a helper to Generate the QR code and signed it for ZATCA E-invoicing

Overview

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 latest version of laravel-zatca on your project, require it from "composer":

$ composer require prgayman/laravel-zatca

Or you can add it directly in your composer.json file:

{
  "require": {
    "prgayman/laravel-zatca": "1.0.0"
  }
}

Laravel

Register the provider directly in your app configuration file config/app.php config/app.php:

Laravel >= 5.5 provides package auto-discovery, thanks to rasmuscnielsen and luiztessadri who help to implement this feature in Zatca, the registration of the provider and the facades should not be necessary anymore.

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

Add the facade aliases in the same file:

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

Lumen

Register the provider in your bootstrap app file boostrap/app.php

Add the following line in the "Register Service Providers" section at the bottom of the file.

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

For facades, add the following lines in the section "Create The Application" .

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

Usage

Generate Base64

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==

Generate Plain

use Prgayman\Zatca\Facades\Zatca;

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

Render A QR Code Image

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);

Generate Base64 Using Function

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

Generate Plain Using Function

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

Render A QR Code Image Using Function

$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)
            );

Testing

composer test

Licence

This library is open-sourced software licensed under the MIT license.

You might also like...
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.

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

Laravel Package for making thumbnails instantly
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

Laravel Optical Character Reader(OCR) package using ocr engines like Tesseract
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

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

Image optimization / compression library. This library is able to optimize png, jpg and gif files in very easy and handy way. It uses optipng, pngquant, pngcrush, pngout, gifsicle, jpegoptim and jpegtran tools.

Image Optimizer This library is handy and very easy to use optimizer for image files. It uses optipng, pngquant, jpegoptim, svgo and few more librarie

Image Cache is a very simple PHP class that accepts an image source and will compress and cache the file, move it to a new directory, and returns the new source for the image.

NO LONGER MAINTAINED!!! Image Cache v. 1.0.0 Image Cache is a very simple PHP class that accepts an image source and will compress and cache the file,

A great looking and easy-to-use photo-management-system you can run on your server, to manage and share photos.
A great looking and easy-to-use photo-management-system you can run on your server, to manage and share photos.

Lychee A great looking and easy-to-use photo-management-system. Since the 1st of April 2018 this project has moved to it's own Organisation (https://g

PHP Exif Library - library for reading and writing Exif headers in JPEG and TIFF files using PHP.

PEL: PHP Exif Library README file for PEL: PHP Exif Library. A library with support for reading and writing Exif headers in JPEG and TIFF images using

Releases(1.0.0)
Owner
Ayman Alaiwah
Ayman Alaiwah
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
A PHP GD + TwitterOAuth demo to dynamically generate Twitter header images and upload them via the API.

A PHP GD + TwitterOAuth demo to dynamically generate Twitter header images and upload them via the API. This enables you to build cool little tricks, like showing your latest followers or sponsors, latest content creted, a qrcode to something, a progress bar for some goal, and whathever you can think of.

Erika Heidi 172 Jan 5, 2023
An easy and elegant way to generate gravatars 🖼

pH2Gravatar The simplest Gravatar PHP package An easy and elegant way to generate gravatar profile photos from email addresses ?? ⛏ Requirements PHP 7

♚ PH⑦ de Soria™♛ 6 Jul 12, 2022
A library using PHP to generate QRCode from https://www.qrcode-monkey.com free

PHP Class Generate Free QRCode ?? A library using PHP to generate QRCode from https://www.qrcode-monkey.com free ✋ NOTE: Do not generate too many QRCo

Nguyen Truong Nguyen 53 Dec 28, 2022
Generate Avatars using Initials, Bears or Kittens

Avatary Simple avatar generator Explore the docs » View Demo · Report Bug · Request Feature Table of Contents About The Project Built With Getting Sta

Prettify Studio 33 Nov 30, 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
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
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