Download the PHP package khaledhajsalem/laravel-zatca-phase2 without Composer

On this page you can find all versions of the php package khaledhajsalem/laravel-zatca-phase2. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-zatca-phase2

Laravel ZATCA Phase 2 Integration

Latest Version on Packagist Total Downloads

A comprehensive Laravel package for integrating with ZATCA (Saudi Arabia Tax Authority) Phase 2 e-invoicing requirements. This package provides tools for generating, reporting, and clearing invoices and credit notes according to ZATCA Phase 2 specifications.

Table of Contents

Features

Requirements

Installation

Composer Installation

You can install the package via composer:

Package Setup

After installing the package, run the installation command:

This will:

Run Migrations

Run the migrations to add ZATCA fields to your database tables:

Configuration

Basic Configuration

After installation, configure the package in your .env file:

Model Integration

The package works with your existing invoice and credit note models. Specify the models and table names in the configuration file:

Add ZATCA functionality to your models with the HasZatcaSupport trait:

Field Mapping

The package uses field mapping to adapt to your existing database schema:

This configuration allows the package to work with your existing database structure without requiring schema changes beyond the ZATCA-specific fields added through migrations.

Credit Note Configuration

Credit notes require special handling for ZATCA compliance. Configure how your system handles credit notes:

This flexibility supports different implementation approaches:

  1. Separate Models: If your credit notes and invoices are separate models
  2. Type Field: If you use a single model with a type field to distinguish credit notes
  3. Separate Tables: If you store credit notes and invoices in different tables

Sandbox Mode

The package supports ZATCA's sandbox environment for testing purposes before moving to production.

Configuration

Add these settings to your .env file:

Usage

Invoice Reporting and Clearance

To report and clear invoices with ZATCA:

Credit Note Handling

Handling credit notes follows a similar pattern:

Webhooks

The package sets up a route for handling ZATCA callbacks. Configure this URL in your ZATCA portal settings:

When ZATCA sends a callback to this URL, the package will update the document status automatically.

To customize the webhook handling, you can extend the ZatcaCallbackController class and update the route registration in your RouteServiceProvider.

QR Code Display

Display the QR code on your invoices:

The QR code contains the required ZATCA data in TLV (Tag-Length-Value) format, including:

Certificate Management

Generate a certificate for ZATCA compliance:

This creates a certificate request (CSR) that you submit to the ZATCA portal. After obtaining the signed certificate, save it in the configured certificates path.

Advanced Usage

PDF Generation

Generate professional PDF documents for invoices and credit notes:

The package includes default templates for both invoices and credit notes, but you can create your own custom templates:

Queue Integration

Process documents asynchronously using Laravel's queue system:

Batch Processing

For batch processing of invoices or credit notes with queue support:

Custom XML Generation

To customize the XML generation process:

Event Handling

The package dispatches events that you can listen for:

Commands

The package provides several useful Artisan commands:

The status checking command helps you monitor and update the status of documents submitted to ZATCA. It can be scheduled to run automatically to keep statuses up to date.

Testing

Run the package tests with:

The test suite includes:

Best Practices

Regular Testing

Regularly test your integration using the zatca:test-connection command to ensure your connectivity to the ZATCA API remains active.

Certificate Management

Logging and Monitoring

Fallback Mechanisms

Data Validation

Common Issues and Solutions

Certificate Issues

Issue: Certificate errors during API calls

Solution:

API Connection Issues

Issue: Unable to connect to ZATCA API

Solution:

Data Mapping Issues

Issue: Invalid data in ZATCA submissions

Solution:

Credit Note Issues

Issue: Credit notes rejected by ZATCA

Solution:

Upgrading

From Version 1.x to 2.x

If you're upgrading from version 1.x:

  1. Update your dependencies: composer require khaledhajsalem/laravel-zatca-phase2:^2.0
  2. Run the upgrade command: php artisan zatca:upgrade
  3. Check the updated configuration file for new options
  4. Review the changes in field mapping structure
  5. Update any custom implementations to match the new API

Enhanced Features

I've implemented additional improvements to make the package more powerful and user-friendly:

Improved QR Code Generation

The package now includes enhanced QR code generation that follows ZATCA's TLV (Tag-Length-Value) format requirements precisely:

The QR code includes all required ZATCA fields:

PDF Generation Support

Generate professional PDF documents for both invoices and credit notes:

Customization options:

Queue Integration

Process invoices asynchronously using Laravel's queue system:

Batch processing features:

Document Routes

The package now comes with built-in routes for document downloads:

Security

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

Credits

License

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


All versions of laravel-zatca-phase2 with dependencies

PHP Build Version
Package Version
Requires guzzlehttp/guzzle Version ^7.0
spatie/array-to-xml Version ^3.0
simplesoftwareio/simple-qrcode Version ^4.2
php Version ^8.1|^8.2
laravel/framework Version ^9.0|^10.0|^11.0
robrichards/xmlseclibs Version ^3.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package khaledhajsalem/laravel-zatca-phase2 contains the following files

Loading the files please wait ....