- Seller
- Acme Corp
- VAT 300000000000003
- Buyer
- John Doe
- No VAT number
| Item | Qty | Price |
|---|---|---|
| Service A | 1 | 100.00 |
Official-grade implementation of Saudi Arabia's ZATCA Phase 1 & 2 e-invoicing requirements, featuring automated XML generation and cryptographic stamping.
| Item | Qty | Price |
|---|---|---|
| Service A | 1 | 100.00 |
Phase 1 is local: build the XML and the QR code. Phase 2 sends the signed invoice to ZATCA, for clearance or for reporting.
$invoice->generateZatcaXml();$invoice->submitToZatca();The package ships Artisan commands for CSR generation, compliance checks and CSID onboarding.
Seller name, VAT and CR numbers and your organisation details go in config/zatca.php or .env.
php artisan zatca:generate-csr --env=sandbox --save-db creates the CSR and a secp256k1 private key.
Submit the CSR to the ZATCA portal to retrieve an OTP.
Zatca::client()->issueComplianceCsid() issues the compliance CSID; store it in your database.
The README notes that an activate-csid command is planned to store the CSID and secret automatically; until then, call Zatca::client()->issueComplianceCsid() and store the result yourself.
use Hyderkamran\LaravelZatca\Traits\HasZatca;
use Hyderkamran\LaravelZatca\Enums\InvoiceType;
class Invoice extends Model
{
use HasZatca;
public function getZatcaInvoiceType(): InvoiceType
{
return $this->is_b2b ? InvoiceType::STANDARD : InvoiceType::SIMPLIFIED;
}
public function toZatcaSeller(): array
{
return [
'name' => 'Acme Corp',
'vat_number' => '300000000000003',
// ...
];
}
public function toZatcaBuyer(): array
{
return [
'name' => $this->customer->name,
'vat_number' => $this->customer->vat_number,
];
}
public function toZatcaItems(): array
{
return $this->items->map(fn($item) => [
'name' => $item->name,
'quantity' => $item->qty,
'price' => $item->price,
])->toArray();
}
}
Phase 1 & 2 compliant · Cryptographic stamping · XML generation
ECDSA secp256k1 private keys, C14N XML canonicalisation and SHA-256 hashing, built in.
Standard (B2B) and simplified (B2C) invoices.
UBL 2.1 XML, correctly typed and schema-compliant.
TLV Base64 encoding for the mandatory QR code, all 9 tags.
Generate XML and QR codes locally.
Clearance (standard) and reporting (simplified) API workflows.
Switch between the Developer Portal sandbox and the Core API.
Artisan commands for CSR generation, compliance checks and onboarding.
A HasZatca trait for the Invoice model you already have.
Laravel ZATCA E-Invoicing is maintained in the open, versioned semantically, and used in our own client projects — so fixes land upstream rather than in a private fork.
composer require hyderkamran/laravel-zatca
php artisan vendor:publish --tag="zatca-config"
php artisan vendor:publish --tag="zatca-migrations"
# Creates the zatca_certificates and zatca_submissions tables
php artisan migrate
From the package README on GitHub
| Package | hyderkamran/laravel-zatca |
|---|---|
| Licence | MIT |
| Language | PHP / Laravel |
| Requires | PHP 8.1+Laravel 10 or 11ext-opensslext-simplexml |
| Maintained by | ApexlyTech, in the open on GitHub |
Official-grade implementation of Saudi Arabia's ZATCA Phase 1 & 2 e-invoicing requirements, featuring automated XML generation and cryptographic stamping.