An implementation of Saudi Arabia ZATCA's E-Invoicing requirements, processes, and standards in PHP.
If you plan on using the built in EGS module to generate keys, and CSR. The EGS module in the package is dependent
on OpenSSL being installed in the system it's running on. It's being used to
generate an ECDSA key pair using the secp256k1 curve. also to generate and sign a CSR.
All other parts of the package will work fine without OpenSSL. (meaning it supports react-native and other frameworks)
All tha main futures required to on-board a new EGS. Create, sign, and report a simplified tax invoice are currently supported.
composer update or composer install to install dependencies.php -S localhost:8000View full example at phase-1.php and phase-2.php.
// New Invoice and EGS Unit
$egs = new ZATCAEGS($egsUnit);
$egs->production = false;
// New Keys & CSR for the EGS
list($privateKey, $csr) = $egs->generateNewKeysAndCSR('solution_name');
// Issue a new compliance cert for the EGS
list($requestId, $binarySecurityToken, $secret) = $egs->issueComplianceCertificate('123345', $csr);
// Sign invoice
list($signedInvoiceString, $invoiceHash, $qr) = $egs->signInvoice($invoice, $egsUnit, $binarySecurityToken, $privateKey);
// Check invoice compliance
echo($egs->checkInvoiceCompliance($signedInvoiceString, $invoiceHash, $binarySecurityToken, $secret));
echo PHP_EOL;zatca-qr is influenced by zatca-xml-php that not affiliated, associated, authorized, endorsed by, or in any way officially connected with ZATCA (
Zakat, Tax and Customs Authority), or any of its subsidiaries or its affiliates. The official ZATCA website can be found
at https://zatca.gov.sa.
All contributions are appreciated.
I'm not planning on supporting Tax Invoices (Not simplified ones). If any one wants to tackle that part.