zatbridge_zatca 0.1.0
zatbridge_zatca: ^0.1.0 copied to clipboard
ZATCA Phase 2 offline signing for simplified-subtype (B2C) documents. Signs and produces the QR entirely on-device so a till can issue a compliant document with no connectivity, then forwards it to Za [...]
example/zatbridge_zatca_example.dart
import 'package:zatbridge_zatca/zatbridge_zatca.dart';
/// Enroll once while online using a short-lived code supplied by the vendor
/// administrator. Never hardcode the code in the application.
Future<void> enrollDevice(String enrollmentCode) async {
final zatbridge = await ZatBridge.open(baseUrl: 'https://api.zatbridge.com');
try {
await zatbridge.enroll(
code: enrollmentCode,
appFingerprint: 'your-stable-app-installation-fingerprint',
appVersion: 'your-pos-app/1.0.0',
);
} finally {
await zatbridge.close();
}
}
/// Issue a simplified invoice offline. The returned TLV payload is ready to
/// render as a QR code with the QR widget or renderer used by the host app.
Future<IssueResult> issueSale() async {
final zatbridge = await ZatBridge.open(baseUrl: 'https://api.zatbridge.com');
try {
final issuedAt = DateTime.now().toUtc();
return await zatbridge.issueSimplified(
InvoiceRequest.deviceSimplified(
documentKind: DocumentKind.invoice,
invoiceNumber: 'POS-2026-000001',
issueDate: issuedAt,
issueTime: issuedAt,
lines: const [
InvoiceLine(
id: '1',
name: 'Retail item',
quantity: '1.00',
lineAmount: '100.00',
taxAmount: '15.00',
priceAmount: '100.00',
),
],
taxableAmount: '100.00',
taxPercent: '15.00',
taxTotal: '15.00',
payableAmount: '115.00',
),
);
} finally {
await zatbridge.close();
}
}