1. Go to this page and download the library: Download digitaltunnel/zatca library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
digitaltunnel / zatca example snippets
use DigitalTunnel\Zatca\Data\CSRDetails;
use DigitalTunnel\Zatca\Facades\ZatcaConnect;
ZatcaConnect::setEnviroment("developer") // developer, simulation, production
->setOtp(123456)
->setCSRDetails(
new CSRDetails(
deviceName: "POS-001",
organizationIdentifier: "399999999900003",
organizationUnitName: "Yasmin Branch",
organizationName: "Digital Tunnel, LLC",
countryName: "SA",
address: "RUH2+XV Riyadh",
businessCategory: "Technology",
)
)
->onBoarding();
use DigitalTunnel\Zatca\Facades\ZatcaConnect;
use DigitalTunnel\Zatca\Data\Invoice;
use DigitalTunnel\Zatca\Data\PartyInformation;
use DigitalTunnel\Zatca\Data\Address;
use DigitalTunnel\Zatca\Data\InvoiceLine;
use DigitalTunnel\Zatca\Data\InvoiceTotals;
use DigitalTunnel\Zatca\Facades\ZatcaConnect;
use DigitalTunnel\Zatca\Enum\TransactionType;
use DigitalTunnel\Zatca\Enum\InvoiceType;
use DigitalTunnel\Zatca\Enum\PaymentMethod;
$zatca = ZatcaConnect::setDeviceUuid("94d71b2f-ee56-4c21-a0a6-4f13d0c84774")
->setInvoice(
new Invoice(
transactionType: TransactionType::Invoice,
invoiceType: InvoiceType::Invoice,
invoiceNumber: "INV-1029912",
invoiceDateTime: "2024-11-25T13:45:00Z",
deliveryDateTime: "2024-11-25T13:45:00Z",
paymentMethod: PaymentMethod::Credit,
company: new PartyInformation(
registrationName: "Maximum Speed Tech Supply LTD",
taxIdentificationNumber: "399999999900003",
identification: "1010010000",
identificationType: IdentificationType::CommercialRegistrationNumber,
address: new Address(
street: "Street Name",
buildingNumber: 2231,
plotIdentification: 123,
city: "Riyadh",
district: "District",
postalCode: "12345",
country: "SA"
)
),
customer: new PartyInformation(
registrationName: "Company Name",
taxIdentificationNumber: "399999999800003",
identification: "1010010000",
identificationType: IdentificationType::NationalID,
address: new Address(
street: "Street Name",
buildingNumber: "123",
plotIdentification: 123,
city: "Riyadh",
district: "District",
postalCode: "12345",
country: "SA"
)
),
lines: [
new InvoiceLine(
id: "1",
name: "Item Name",
quantity: 1,
unitPrice: 2,
unitType: UnitType::Unit,
taxableAmount: 2,
taxAmount: 0.3,
taxPercentage: 15
),
new InvoiceLine(
id: "2",
name: "Item Name",
quantity: 1,
unitPrice: 2,
unitType: UnitType::Unit,
taxableAmount: 2,
taxAmount: 0.3,
taxPercentage: 15
)
],
totals: new InvoiceTotals(
extensionAmount: 4,
taxExclusiveAmount: 4,
taxInclusiveAmount: 4.6,
prepaidAmount: 0,
payableAmount: 4.6,
allowanceTotalAmount: 0
)
)
)
->signInvoice();
use DigitalTunnel\Zatca\Facades\ZatcaConnect;
$zatca = ZatcaConnect::setInvoiceUuid("94d71b2f-ee56-4c21-a0a6-4f13d0c84774")
->reportAndClearInvoices();
use DigitalTunnel\Zatca\Facades\ZatcaConnect;
$zatca = ZatcaConnect::setInvoiceUuid("94d71b2f-ee56-4c21-a0a6-4f13d0c84774")
->getInvoice();
use DigitalTunnel\Zatca\Facades\ZatcaConnect;
ZatcaConnect::setInvoiceUuid('1935e4d3-0375-471d-835f-cc27ea9905ed')
->checkCompliance();