BR-KSA-27: Mandatory QR Code (KSA-14) Missing or Malformed
BR-KSA-27: رمز الاستجابة السريعة (QR Code / KSA-14) مفقود أو غير مطابق
The document must contain a QR code (KSA-14), and this code must be base64Binary encoded TLV containing all mandatory tags.
/ubl:Invoice/cac:AdditionalDocumentReference[cbc:ID='QR']/cac:Attachment/cbc:EmbeddedDocumentBinaryObject 📌 Overview & Impact
The document must contain a Base64-encoded TLV QR Code (KSA-14) formatted according to ZATCA Phase 2 security specifications.
⚠️ Common Causes for Rejection
- ✕ Missing <cac:AdditionalDocumentReference> with <cbc:ID>QR</cbc:ID>
- ✕ QR string is URL or plain text instead of Base64-encoded TLV bytes
- ✕ Missing Phase 2 TLV Tags: Tag 5 (ECDSA Signature), Tag 6 (Public Key), or Tag 7 (Certificate Signature)
- ✕ TLV byte lengths encoded as ASCII numbers rather than raw byte counts
✅ How to Fix & Resolve
Encode All 9 TLV Tags
Build TLV buffer: Tag 1 (Seller Name), Tag 2 (VAT No), Tag 3 (Timestamp), Tag 4 (Invoice Total), Tag 5 (VAT Total), Tag 6 (Invoice Hash), Tag 7 (ECDSA Signature), Tag 8 (ECDSA Public Key), Tag 9 (ZATCA Stamp).
Convert to Base64 String
Convert the concatenated binary TLV buffer to a Base64 string and embed inside the QR document reference node.
💻 Code Comparison: Invalid vs Compliant UBL 2.1 XML
<cac:AdditionalDocumentReference>
<cbc:ID>QR</cbc:ID>
<cac:Attachment>
<cbc:EmbeddedDocumentBinaryObject mimeCode="text/plain">https://example.com/invoice/123</cbc:EmbeddedDocumentBinaryObject>
</cac:Attachment>
</cac:AdditionalDocumentReference> <cac:AdditionalDocumentReference>
<cbc:ID>QR</cbc:ID>
<cac:Attachment>
<cbc:EmbeddedDocumentBinaryObject mimeCode="text/plain">AQhNZXJjaGFudAIPMzAwMDAwMDAwMDAwMDAzAxgyMDI2LTA4LTI5VDE0OjMwOjAwWgQFMTAwLjAFATE1LjA=</cbc:EmbeddedDocumentBinaryObject>
</cac:Attachment>
</cac:AdditionalDocumentReference> Verify Your Invoice XML Online
Use Qeemah's free developer tools to inspect transforms, C14N digests, and Phase 2 QR codes.
❓ Frequently Asked Questions
What is the difference between Phase 1 and Phase 2 QR codes?
Phase 1 QR codes only required tags 1-5 (Seller Name, VAT Number, Timestamp, Total, VAT Amount). Phase 2 requires ECDSA cryptographic tags (Tags 6-9) for tamper-evident verification.
Stop Fighting Cryptic ZATCA XML Errors
Qeemah handles Phase 2 e-invoicing, cryptographic signing, and real-time clearance automatically. Integrate in minutes.