PHP code example of saudiza / zatca-fatoora
1. Go to this page and download the library: Download saudiza/zatca-fatoora 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/ */
saudiza / zatca-fatoora example snippets
use Saudiza\Fatoora\Facades\Fatoora;
// Create invoice
$invoice = Fatoora::invoice();
$invoice->setInvoiceNumber('INV-001')
->setInvoiceUuid(\Illuminate\Support\Str::uuid())
->setInvoiceIssueDate(now()->format('Y-m-d'))
->setInvoiceIssueTime(now()->format('H:i:s'))
->setInvoiceType('0100000', '388') // Standard invoice
->setInvoiceCurrencyCode('SAR')
->setInvoiceTaxCurrencyCode('SAR');
// Configure supplier
$supplier = new \Saudiza\Fatoora\Invoice\Supplier();
$supplier->setVatName('Your Company')
->setVatNumber('300000000000003')
->setCityName('Riyadh')
->setPostalCode('12345')
->setBuildingNumber('1234')
->setStreet('King Fahd Road')
->setDistrict('Al Olaya');
$invoice->setInvoiceSupplier($supplier);
// Add items, totals, etc... (see documentation)
// Submit to ZATCA
$result = $invoice->sendDocument(true);
if ($result['success']) {
echo "✅ Invoice submitted! QR: " . $result['qr_value'];
}
// You can use either:
Fatoora::invoice() // New name
Zatca::invoice() // Backward compatibility
return [
'environment' => env('ZATCA_ENVIRONMENT', 'sandbox'),
'organization' => [
'vat_number' => env('ZATCA_VAT_NUMBER'),
// ... more settings
],
];
bash
# Install package
php artisan zatca:install
# Run onboarding
php artisan zatca:onboarding --otp=YOUR_OTP
# Check configuration
php artisan tinker
>>> Fatoora::config()->get('environment')
bash
php artisan test