An implementation of Saudi Arabia ZATCA's E-Invoicing requirements, processes, and standards in PHP.
[![GitHub license](https://badgen.net/github/license/wes4m/zatca-xml-js?v=0.1.0)](https://github.com/wes4m/zatca-xml-js/blob/main/LICENSE)
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)
Run this project on linux OS, openSSL conversation very from OS to OS basis.
All tha main futures required to on-board a new EGS. Create, sign, and report a simplified tax invoice are currently supported.
composer install
to install dependencies.php -S localhost:8000
View full example at phase-1.php and phase-2.php.
// New Invoice and EGS Unit
$egs = new \ZATCA\EGS($egsUnit);
$egs->production = false;
// Generate private key & csr
list($privateKey, $csr) = $egs->generateNewKeysAndCSR('QR');
// Make an request to issue compliance certificate
list($requestId, $binarySecurityToken, $secret) = $egs->issueComplianceCertificate('123345', $csr);
// Sing invoice xml
list($signedInvoiceString, $invoiceHash, $qr) = $egs->signInvoice($invoice, $egsUnit, $binarySecurityToken, $privateKey);
// Check fatoora is created invoice is correct or not.
$response =$egs->checkInvoiceCompliance($signedInvoiceString, $invoiceHash, $binarySecurityToken, $secret);
//echo '<pre>'; //un-comment if you want to see compliance result
//print_r(json_decode($response)); //un-comment if you want to see compliance result
//dd(""); //un-comment if you want to see compliance result
If checkInvoiceCompliance looks like mention response, so, means your invoice is validated or good to submit to Zacta
stdClass Object
(
[validationResults] => stdClass Object
(
[infoMessages] => Array
(
[0] => stdClass Object
(
[type] => INFO
[code] => XSD_ZATCA_VALID
[category] => XSD validation
[message] => Complied with UBL 2.1 standards in line with ZATCA specifications
[status] => PASS
)
)
[warningMessages] => Array
(
)
[errorMessages] => Array
(
)
[status] => PASS
)
[reportingStatus] => REPORTED
[clearanceStatus] =>
[qrSellertStatus] =>
[qrBuyertStatus] =>
)
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, For more information please visit Complete Guidance