# Failed to validate QR code (QRCODE\_INVALID)

**URL:** <https://zatca1.discourse.group/t/failed-to-validate-qr-code-qrcode-invalid/7221>\
**Category:** QR code\
**Created:** [May 29, 2025, 9:44am UTC](https://zatca1.discourse.group/t/failed-to-validate-qr-code-qrcode-invalid/7221 "2025-05-29T09:44:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ezinvoice](https://avatars.discourse-cdn.com/v4/letter/e/7ea924/32.png) [@ezinvoice](https://zatca1.discourse.group/u/ezinvoice)\
**Post date:** [May 29, 2025, 9:44am UTC](https://zatca1.discourse.group/t/failed-to-validate-qr-code-qrcode-invalid/7221/1 "2025-05-29T09:44:48Z")

</div>

We are implementing the QR code logic for Phase 2 (Simplified Invoice – B2C) and are encountering the following error during testing:

{  
“type”: “ERROR”,  
“code”: “QRCODE\_INVALID”,  
“category”: “QRCODE\_VALIDATION”,  
“message”: “Failed to validate QR code”,  
“status”: “ERROR”  
}

We are following the TLV structure as specified in the Phase 2 QR Code Specification, including all nine(9) tags in the correct order. The QR code is Base64-encoded and structured as follows using UTF-8 and Base64 where applicable.

Code Snippet Used:

// Sample Data:  
const data = {  
sellerName: ‘Maximum Speed Tech Supply LTD’,  
vatNumber: ‘399999999900003’,  
timestamp: ‘2025-05-23T11:30:00Z’,  
totalWithVAT: ‘231.15’,  
vatTotal: ‘30.15’,  
xmlHash: ‘gNbPvzpBTouG/38v+kvMnu9JYsICf1LTmJGh7bsxFd8=’,  
ecdsaSignature: ‘MEYCIQD/4zOGvJ1yXDSBA1zfpaF8pEUndHJepPByFv3u6oQfjwIhALVuk0pegtwN5hqhTkNe6qRHcEVSHiPumhQYeQJ33EH2’,  
ecdsaPublicKey: ‘MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEa1wc5vpwETzYoXTXPXMSzdzW8z5/aNXdRh/zoemvzlZ4clR5fvvQzvwMfr7WM9v0dDkoet6MIiETSWUMrrK0VQ==’,  
certificateSignature: ‘3045022100b13f89c8669d65c250a51b71adf2722f28ab068bbc574756342bbde23dbaa01b02203d842e0cf2380c0400cf4b399ddae88f240ea0291dcb134dd4ef97aa6c2feb5c’,  
}

// output data in base64  
const outputQRcode = ‘AR1NYXhpbXVtIFNwZWVkIFRlY2ggU3VwcGx5IExURAIPMzk5OTk5OTk5OTAwMDAzAxQyMDI1LTA1LTIzVDExOjMwOjAwWgQGMjMxLjE1BQUzMC4xNQYsZ05iUHZ6cEJUb3VHLzM4ditrdk1udTlKWXNJQ2YxTFRtSkdoN2JzeEZkOD0HYE1FWUNJUUQvNHpPR3ZKMXlYRFNCQTF6ZnBhRjhwRVVuZEhKZXBQQnlGdjN1Nm9RZmp3SWhBTFZ1azBwZWd0d041aHFoVGtOZTZxUkhjRVZTSGlQdW1oUVllUUozM0VIMghYMFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEa1wc5vpwETzYoXTXPXMSzdzW8z5/aNXdRh/zoemvzlZ4clR5fvvQzvwMfr7WM9v0dDkoet6MIiETSWUMrrK0VQlq3045022100b13f89c8669d65c250a51b71adf2722f28ab068bbc574756342bbde23dbaa01b02203d842e0cf2380c0400cf4b399ddae88f240ea0291dcb134dd4ef97aa6c2feb5Q==’

generateQRCode(data: {  
sellerName: string;  
vatNumber: string;  
timestamp: string;  
totalWithVAT: string;  
vatTotal: string;  
xmlHash?: string; // hex string  
ecdsaSignature?: string; // base64 string  
ecdsaPublicKey?: string; // base64 string (not PEM)  
certificateSignature?: string; // base64 string  
}): string {  
const tlvBuffers: Buffer = ;  
console.log(‘Generating QR Code with data:’, data); // Debugging line  
// Tags 1-5: UTF-8  
tlvBuffers.push(this.encodeTLV(1, Buffer.from(data.sellerName, ‘utf-8’)));  
tlvBuffers.push(this.encodeTLV(2, Buffer.from(data.vatNumber, ‘utf-8’)));  
tlvBuffers.push(this.encodeTLV(3, Buffer.from(data.timestamp, ‘utf-8’)));  
tlvBuffers.push(this.encodeTLV(4, Buffer.from(data.totalWithVAT, ‘utf-8’)));  
tlvBuffers.push(this.encodeTLV(5, Buffer.from(data.vatTotal, ‘utf-8’)));

```
// Tag 6: Invoice Hash (hex string to Buffer)
if (data.xmlHash) {
  tlvBuffers.push(this.encodeTLV(6, Buffer.from(data.xmlHash, 'utf-8')));
}

// Tag 7: ECDSA Signature (utf-8 string to Buffer)
if (data.ecdsaSignature) {
  tlvBuffers.push(this.encodeTLV(7, Buffer.from(data.ecdsaSignature, 'utf-8')));
}

// Tag 8: ECDSA Public Key (utf-8 string to Buffer, remove PEM headers if present)
if (data.ecdsaPublicKey) {
  tlvBuffers.push(this.encodeTLV(8, Buffer.from(data.ecdsaPublicKey, 'base64')));
}

// Tag 9: Certificate signature (base64 string to Buffer)
if (data.certificateSignature) {
  const buffer = Buffer.from(data.certificateSignature, 'base64');
  const base64 = buffer.toString('base64');
  tlvBuffers.push(this.encodeTLV(9, Buffer.from(base64, 'base64')));
}
const qrCodeBase64 = Buffer.concat(tlvBuffers).toString('base64');
return qrCodeBase64;

```

}

private encodeTLV(tag: number, value: Buffer): Buffer {  
// if (value.length \> 255) throw new Error(‘TLV value too long for 1-byte length’);  
// return Buffer.concat([Buffer.from([tag]), Buffer.from([value.length]), value]);  
const {length} = value;  
const tagBuffer = Buffer.alloc(1);  
const lengthBuffer = Buffer.alloc(1);

```
tagBuffer.writeUInt8(tag);
lengthBuffer.writeUInt8(length);

return Buffer.concat([tagBuffer, lengthBuffer, value]);

```

}

// xml file data  
ext:UBLExtensions  
ext:UBLExtension  
ext:ExtensionURIurn:oasis:names:specification:ubl:dsig:enveloped:xades\</ext:ExtensionURI\>  
ext:ExtensionContent  
\<sig:UBLDocumentSignatures xmlns:sac=“urn:oasis:names:specification:ubl:schema:xsd:SignatureAggregateComponents-2” xmlns:sbc=“urn:oasis:names:specification:ubl:schema:xsd:SignatureBasicComponents-2” xmlns:sig=“urn:oasis:names:specification:ubl:schema:xsd:CommonSignatureComponents-2”\>  
sac:SignatureInformation  
cbc:IDurn:oasis:names:specification:ubl:signature:1\</cbc:ID\>  
sbc:ReferencedSignatureIDurn:oasis:names:specification:ubl:signature:Invoice\</sbc:ReferencedSignatureID\>  
\<ds:Signature xmlns:ds=“[XML-Signature Syntax and Processing](http://www.w3.org/2000/09/xmldsig#)” Id=“signature”\>  
ds:SignedInfo  
\<ds:CanonicalizationMethod Algorithm=“[Canonical XML 1.1](http://www.w3.org/2006/12/xml-c14n11)”\>\</ds:CanonicalizationMethod\>  
\<ds:SignatureMethod Algorithm=“[xmldsig-more namespace](http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256)”\>\</ds:SignatureMethod\>  
\<ds:Reference Id=“invoiceSignedData” URI=“”\>  
ds:Transforms  
\<ds:Transform Algorithm=“[XML Path Language (XPath)](http://www.w3.org/TR/1999/REC-xpath-19991116)”\>  
ds:XPathnot(//ancestor-or-self::ext:UBLExtensions)\</ds:XPath\>  
\</ds:Transform\>  
\<ds:Transform Algorithm=“[XML Path Language (XPath)](http://www.w3.org/TR/1999/REC-xpath-19991116)”\>  
ds:XPathnot(//ancestor-or-self::cac:Signature)\</ds:XPath\>  
\</ds:Transform\>  
\<ds:Transform Algorithm=“[XML Path Language (XPath)](http://www.w3.org/TR/1999/REC-xpath-19991116)”\>  
ds:XPathnot(//ancestor-or-self::cac:AdditionalDocumentReference[cbc:ID=‘QR’])\</ds:XPath\>  
\</ds:Transform\>  
\<ds:Transform Algorithm=“[Canonical XML 1.1](http://www.w3.org/2006/12/xml-c14n11)”\>\</ds:Transform\>  
\</ds:Transforms\>  
\<ds:DigestMethod Algorithm=“[XML Encryption Syntax and Processing](http://www.w3.org/2001/04/xmlenc#sha256)”\>\</ds:DigestMethod\>  
ds:DigestValuegNbPvzpBTouG/38v+kvMnu9JYsICf1LTmJGh7bsxFd8=\</ds:DigestValue\>  
\</ds:Reference\>  
\<ds:Reference Type=“[XML-Signature Syntax and Processing](http://www.w3.org/2000/09/xmldsig#SignatureProperties)” URI=“#xadesSignedProperties”\>  
\<ds:DigestMethod Algorithm=“[XML Encryption Syntax and Processing](http://www.w3.org/2001/04/xmlenc#sha256)”\>\</ds:DigestMethod\>  
ds:DigestValue08OWLR0gy7dJP2azB2Wl58iprwlbkj8AQbN/EnCuYWg=\</ds:DigestValue\>  
\</ds:Reference\>  
\</ds:SignedInfo\>  
ds:SignatureValueMEYCIQD/4zOGvJ1yXDSBA1zfpaF8pEUndHJepPByFv3u6oQfjwIhALVuk0pegtwN5hqhTkNe6qRHcEVSHiPumhQYeQJ33EH2\</ds:SignatureValue\>  
ds:KeyInfo  
ds:X509Data  
ds:X509CertificateTUlJRDNqQ0NBNFNnQXdJQkFnSVRFUUFBT0FQRjkwQWpzL3hjWHdBQkFBQTRBekFLQmdncWhrak9QUVFEQWpCaU1SVXdFd1lLQ1pJbWlaUHlMR1FCR1JZRmJHOWpZV3d4RXpBUkJnb0praWFKay9Jc1pBRVpGZ05uYjNZeEZ6QVZCZ29Ka2lhSmsvSXNaQUVaRmdkbGVIUm5ZWHAwTVJzd0dRWURWUVFERXhKUVVscEZTVTVXVDBsRFJWTkRRVFF0UTBFd0hoY05NalF3TVRFeE1Ea3hPVE13V2hjTk1qa3dNVEE1TURreE9UTXdXakIxTVFzd0NRWURWUVFHRXdKVFFURW1NQ1FHQTFVRUNoTWRUV0Y0YVcxMWJTQlRjR1ZsWkNCVVpXTm9JRk4xY0hCc2VTQk1WRVF4RmpBVUJnTlZCQXNURFZKcGVXRmthQ0JDY21GdVkyZ3hKakFrQmdOVkJBTVRIVlJUVkMwNE9EWTBNekV4TkRVdE16azVPVGs1T1RrNU9UQXdNREF6TUZZd0VBWUhLb1pJemowQ0FRWUZLNEVFQUFvRFFnQUVvV0NLYTBTYTlGSUVyVE92MHVBa0MxVklLWHhVOW5QcHgydmxmNHloTWVqeThjMDJYSmJsRHE3dFB5ZG84bXEwYWhPTW1Obzhnd25pN1h0MUtUOVVlS09DQWdjd2dnSURNSUd0QmdOVkhSRUVnYVV3Z2FLa2daOHdnWnd4T3pBNUJnTlZCQVFNTWpFdFZGTlVmREl0VkZOVWZETXRaV1F5TW1ZeFpEZ3RaVFpoTWkweE1URTRMVGxpTlRndFpEbGhPR1l4TVdVME5EVm1NUjh3SFFZS0NaSW1pWlB5TEdRQkFRd1BNems1T1RrNU9UazVPVEF3TURBek1RMHdDd1lEVlFRTURBUXhNVEF3TVJFd0R3WURWUVFhREFoU1VsSkVNamt5T1RFYU1CZ0dBMVVFRHd3UlUzVndjR3g1SUdGamRHbDJhWFJwWlhNd0hRWURWUjBPQkJZRUZFWCtZdm1tdG5Zb0RmOUJHYktvN29jVEtZSzFNQjhHQTFVZEl3UVlNQmFBRkp2S3FxTHRtcXdza0lGelZ2cFAyUHhUKzlObk1Ic0dDQ3NHQVFVRkJ3RUJCRzh3YlRCckJnZ3JCZ0VGQlFjd0FvWmZhSFIwY0RvdkwyRnBZVFF1ZW1GMFkyRXVaMjkyTG5OaEwwTmxjblJGYm5KdmJHd3ZVRkphUlVsdWRtOXBZMlZUUTBFMExtVjRkR2RoZW5RdVoyOTJMbXh2WTJGc1gxQlNXa1ZKVGxaUFNVTkZVME5CTkMxRFFTZ3hLUzVqY25Rd0RnWURWUjBQQVFIL0JBUURBZ2VBTUR3R0NTc0dBUVFCZ2pjVkJ3UXZNQzBHSlNzR0FRUUJnamNWQ0lHR3FCMkUwUHNTaHUyZEpJZk8reG5Ud0ZWbWgvcWxaWVhaaEQ0Q0FXUUNBUkl3SFFZRFZSMGxCQll3RkFZSUt3WUJCUVVIQXdNR0NDc0dBUVVGQndNQ01DY0dDU3NHQVFRQmdqY1ZDZ1FhTUJnd0NnWUlLd1lCQlFVSEF3TXdDZ1lJS3dZQkJRVUhBd0l3Q2dZSUtvWkl6ajBFQXdJRFNBQXdSUUloQUxFL2ljaG1uV1hDVUtVYmNhM3ljaThvcXdhTHZGZEhWalFydmVJOXVxQWJBaUE5aEM0TThqZ01CQURQU3ptZDJ1aVBKQTZnS1IzTEUwM1U3NWVxYkMvclhBPT0=\</ds:X509Certificate\>  
\</ds:X509Data\>  
\</ds:KeyInfo\>  
ds:Object  
\<xades:QualifyingProperties xmlns:xades=“[Assigned ETSI XML URIs](http://uri.etsi.org/01903/v1.3.2#)” Target=“signature”\>  
\<xades:SignedProperties Id=“xadesSignedProperties”\>  
xades:SignedSignatureProperties  
xades:SigningTime2024-01-14T10:26:49\</xades:SigningTime\>  
xades:SigningCertificate  
xades:Cert  
xades:CertDigest  
\<ds:DigestMethod Algorithm=“[XML Encryption Syntax and Processing](http://www.w3.org/2001/04/xmlenc#sha256)”\>\</ds:DigestMethod\>  
ds:DigestValue0wK0EVdclWWYxeiKu0hWRSVWpauKAfesuVoGnUZmJIU=\</ds:DigestValue\>  
\</xades:CertDigest\>  
xades:IssuerSerial  
ds:X509IssuerNameCN=PRZEINVOICESCA4-CA, DC=extgazt, DC=gov, DC=local\</ds:X509IssuerName\>  
ds:X509SerialNumber379112742831380471835263969587287663520528387\</ds:X509SerialNumber\>  
\</xades:IssuerSerial\>  
\</xades:Cert\>  
\</xades:SigningCertificate\>  
\</xades:SignedSignatureProperties\>  
\</xades:SignedProperties\>  
\</xades:QualifyingProperties\>  
\</ds:Object\>  
\</ds:Signature\>  
\</sac:SignatureInformation\>  
\</sig:UBLDocumentSignatures\>  
\</ext:ExtensionContent\>  
\</ext:UBLExtension\>  
\</ext:UBLExtensions\>

```
<cbc:ProfileID>reporting:1.0</cbc:ProfileID>
<cbc:ID>SME00010</cbc:ID>
<cbc:UUID>8e6000cf-1a98-4174-b3e7-b5d5954bc10d</cbc:UUID>
<cbc:IssueDate>2025-05-23</cbc:IssueDate>
<cbc:IssueTime>11:30:00</cbc:IssueTime>
<cbc:InvoiceTypeCode name="0200000">388</cbc:InvoiceTypeCode>
<cbc:Note languageID="ar">ABC</cbc:Note>
<cbc:DocumentCurrencyCode>SAR</cbc:DocumentCurrencyCode>
<cbc:TaxCurrencyCode>SAR</cbc:TaxCurrencyCode>
<cac:AdditionalDocumentReference>
    <cbc:ID>ICV</cbc:ID>
    <cbc:UUID>10</cbc:UUID>
</cac:AdditionalDocumentReference>
<cac:AdditionalDocumentReference>
    <cbc:ID>PIH</cbc:ID>
    <cac:Attachment>
        <cbc:EmbeddedDocumentBinaryObject mimeCode="text/plain">NWZlY2ViNjZmZmM4NmYzOGQ5NTI3ODZjNmQ2OTZjNzljMmRiYzIzOWRkNGU5MWI0NjcyOWQ3M2EyN2ZiNTdlOQ==</cbc:EmbeddedDocumentBinaryObject>
    </cac:Attachment>
</cac:AdditionalDocumentReference>

<cac:AdditionalDocumentReference>
    <cbc:ID>QR</cbc:ID>
    <cac:Attachment>
        <cbc:EmbeddedDocumentBinaryObject mimeCode="text/plain">AR1NYXhpbXVtIFNwZWVkIFRlY2ggU3VwcGx5IExURAIPMzk5OTk5OTk5OTAwMDAzAxQyMDI1LTA1LTIzVDExOjMwOjAwWgQGMjMxLjE1BQUzMC4xNQYsZ05iUHZ6cEJUb3VHLzM4ditrdk1udTlKWXNJQ2YxTFRtSkdoN2JzeEZkOD0HYE1FWUNJUUQvNHpPR3ZKMXlYRFNCQTF6ZnBhRjhwRVVuZEhKZXBQQnlGdjN1Nm9RZmp3SWhBTFZ1azBwZWd0d041aHFoVGtOZTZxUkhjRVZTSGlQdW1oUVllUUozM0VIMghYMFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEa1wc5vpwETzYoXTXPXMSzdzW8z5/aNXdRh/zoemvzlZ4clR5fvvQzvwMfr7WM9v0dDkoet6MIiETSWUMrrK0VQlq3045022100b13f89c8669d65c250a51b71adf2722f28ab068bbc574756342bbde23dbaa01b02203d842e0cf2380c0400cf4b399ddae88f240ea0291dcb134dd4ef97aa6c2feb5Q==</cbc:EmbeddedDocumentBinaryObject>
    </cac:Attachment>

```

\</cac:AdditionalDocumentReference\>cac:Signature  
cbc:IDurn:oasis:names:specification:ubl:signature:Invoice\</cbc:ID\>  
cbc:SignatureMethodurn:oasis:names:specification:ubl:dsig:enveloped:xades\</cbc:SignatureMethod\>  
\</cac:Signature\>cac:AccountingSupplierParty  
cac:Party  
cac:PartyIdentification  
\<cbc:ID schemeID=“CRN”\>1010010000\</cbc:ID\>  
\</cac:PartyIdentification\>  
cac:PostalAddress  
cbc:StreetNamePrince Sultan\</cbc:StreetName\>  
cbc:BuildingNumber2322\</cbc:BuildingNumber\>  
cbc:CitySubdivisionNameAl-Murabba\</cbc:CitySubdivisionName\>  
cbc:CityNameRiyadh\</cbc:CityName\>  
cbc:PostalZone23333\</cbc:PostalZone\>  
cac:Country  
cbc:IdentificationCodeSA\</cbc:IdentificationCode\>  
\</cac:Country\>  
\</cac:PostalAddress\>  
cac:PartyTaxScheme  
cbc:CompanyID399999999900003\</cbc:CompanyID\>  
cac:TaxScheme  
cbc:IDVAT\</cbc:ID\>  
\</cac:TaxScheme\>  
\</cac:PartyTaxScheme\>  
cac:PartyLegalEntity  
cbc:RegistrationNameMaximum Speed Tech Supply LTD\</cbc:RegistrationName\>  
\</cac:PartyLegalEntity\>  
\</cac:Party\>  
\</cac:AccountingSupplierParty\>  
cac:AccountingCustomerParty  
cac:Party  
cac:PostalAddress  
cbc:StreetNameSalah Al-Din\</cbc:StreetName\>  
cbc:BuildingNumber1111\</cbc:BuildingNumber\>  
cbc:CitySubdivisionNameAl-Murooj\</cbc:CitySubdivisionName\>  
cbc:CityNameRiyadh\</cbc:CityName\>  
cbc:PostalZone12222\</cbc:PostalZone\>  
cac:Country  
cbc:IdentificationCodeSA\</cbc:IdentificationCode\>  
\</cac:Country\>  
\</cac:PostalAddress\>  
cac:PartyTaxScheme  
cbc:CompanyID399999999800003\</cbc:CompanyID\>  
cac:TaxScheme  
cbc:IDVAT\</cbc:ID\>  
\</cac:TaxScheme\>  
\</cac:PartyTaxScheme\>  
cac:PartyLegalEntity  
cbc:RegistrationNameFatoora Samples LTD\</cbc:RegistrationName\>  
\</cac:PartyLegalEntity\>  
\</cac:Party\>  
\</cac:AccountingCustomerParty\>  
cac:PaymentMeans  
cbc:PaymentMeansCode10\</cbc:PaymentMeansCode\>  
\</cac:PaymentMeans\>  
cac:AllowanceCharge  
cbc:ChargeIndicatorfalse\</cbc:ChargeIndicator\>  
cbc:AllowanceChargeReasondiscount\</cbc:AllowanceChargeReason\>  
\<cbc:Amount currencyID=“SAR”\>0.00\</cbc:Amount\>  
cac:TaxCategory  
\<cbc:ID schemeAgencyID=“6” schemeID=“UN/ECE 5305”\>S\</cbc:ID\>  
cbc:Percent15\</cbc:Percent\>  
cac:TaxScheme  
\<cbc:ID schemeAgencyID=“6” schemeID=“UN/ECE 5153”\>VAT\</cbc:ID\>  
\</cac:TaxScheme\>  
\</cac:TaxCategory\>  
cac:TaxCategory  
\<cbc:ID schemeAgencyID=“6” schemeID=“UN/ECE 5305”\>S\</cbc:ID\>  
cbc:Percent15\</cbc:Percent\>  
cac:TaxScheme  
\<cbc:ID schemeAgencyID=“6” schemeID=“UN/ECE 5153”\>VAT\</cbc:ID\>  
\</cac:TaxScheme\>  
\</cac:TaxCategory\>  
\</cac:AllowanceCharge\>  
cac:TaxTotal  
\<cbc:TaxAmount currencyID=“SAR”\>30.15\</cbc:TaxAmount\>  
\</cac:TaxTotal\>  
cac:TaxTotal  
\<cbc:TaxAmount currencyID=“SAR”\>30.15\</cbc:TaxAmount\>  
cac:TaxSubtotal  
\<cbc:TaxableAmount currencyID=“SAR”\>201.00\</cbc:TaxableAmount\>  
\<cbc:TaxAmount currencyID=“SAR”\>30.15\</cbc:TaxAmount\>  
cac:TaxCategory  
\<cbc:ID schemeAgencyID=“6” schemeID=“UN/ECE 5305”\>S\</cbc:ID\>  
cbc:Percent15.00\</cbc:Percent\>  
cac:TaxScheme  
\<cbc:ID schemeAgencyID=“6” schemeID=“UN/ECE 5153”\>VAT\</cbc:ID\>  
\</cac:TaxScheme\>  
\</cac:TaxCategory\>  
\</cac:TaxSubtotal\>  
\</cac:TaxTotal\>  
cac:LegalMonetaryTotal  
\<cbc:LineExtensionAmount currencyID=“SAR”\>201.00\</cbc:LineExtensionAmount\>  
\<cbc:TaxExclusiveAmount currencyID=“SAR”\>201.00\</cbc:TaxExclusiveAmount\>  
\<cbc:TaxInclusiveAmount currencyID=“SAR”\>231.15\</cbc:TaxInclusiveAmount\>  
\<cbc:AllowanceTotalAmount currencyID=“SAR”\>0.00\</cbc:AllowanceTotalAmount\>  
\<cbc:PrepaidAmount currencyID=“SAR”\>0.00\</cbc:PrepaidAmount\>  
\<cbc:PayableAmount currencyID=“SAR”\>231.15\</cbc:PayableAmount\>  
\</cac:LegalMonetaryTotal\>  
cac:InvoiceLine  
cbc:ID1\</cbc:ID\>  
\<cbc:InvoicedQuantity unitCode=“PCE”\>33.000000\</cbc:InvoicedQuantity\>  
\<cbc:LineExtensionAmount currencyID=“SAR”\>99.00\</cbc:LineExtensionAmount\>  
cac:TaxTotal  
\<cbc:TaxAmount currencyID=“SAR”\>14.85\</cbc:TaxAmount\>  
\<cbc:RoundingAmount currencyID=“SAR”\>113.85\</cbc:RoundingAmount\>  
\</cac:TaxTotal\>  
cac:Item  
cbc:Nameكتاب\</cbc:Name\>  
cac:ClassifiedTaxCategory  
cbc:IDS\</cbc:ID\>  
cbc:Percent15.00\</cbc:Percent\>  
cac:TaxScheme  
cbc:IDVAT\</cbc:ID\>  
\</cac:TaxScheme\>  
\</cac:ClassifiedTaxCategory\>  
\</cac:Item\>  
cac:Price  
\<cbc:PriceAmount currencyID=“SAR”\>3.00\</cbc:PriceAmount\>  
cac:AllowanceCharge  
cbc:ChargeIndicatortrue\</cbc:ChargeIndicator\>  
cbc:AllowanceChargeReasondiscount\</cbc:AllowanceChargeReason\>  
\<cbc:Amount currencyID=“SAR”\>0.00\</cbc:Amount\>  
\</cac:AllowanceCharge\>  
\</cac:Price\>  
\</cac:InvoiceLine\>  
cac:InvoiceLine  
cbc:ID2\</cbc:ID\>  
\<cbc:InvoicedQuantity unitCode=“PCE”\>3.000000\</cbc:InvoicedQuantity\>  
\<cbc:LineExtensionAmount currencyID=“SAR”\>102.00\</cbc:LineExtensionAmount\>  
cac:TaxTotal  
\<cbc:TaxAmount currencyID=“SAR”\>15.30\</cbc:TaxAmount\>  
\<cbc:RoundingAmount currencyID=“SAR”\>117.30\</cbc:RoundingAmount\>  
\</cac:TaxTotal\>  
cac:Item  
cbc:Nameقلم\</cbc:Name\>  
cac:ClassifiedTaxCategory  
cbc:IDS\</cbc:ID\>  
cbc:Percent15.00\</cbc:Percent\>  
cac:TaxScheme  
cbc:IDVAT\</cbc:ID\>  
\</cac:TaxScheme\>  
\</cac:ClassifiedTaxCategory\>  
\</cac:Item\>  
cac:Price  
\<cbc:PriceAmount currencyID=“SAR”\>34.00\</cbc:PriceAmount\>  
cac:AllowanceCharge  
cbc:ChargeIndicatortrue\</cbc:ChargeIndicator\>  
cbc:AllowanceChargeReasondiscount\</cbc:AllowanceChargeReason\>  
\<cbc:Amount currencyID=“SAR”\>0.00\</cbc:Amount\>  
\</cac:AllowanceCharge\>  
\</cac:Price\>  
\</cac:InvoiceLine\>

We kindly request your assistance in identifying what might be causing this QRCODE\_INVALID response. Please let us know if anything is missing or if additional formatting is required.

---

<div class="post-metadata">

**Author:** ![sarahtaylor](https://avatars.discourse-cdn.com/v4/letter/s/ac8455/32.png) [@sarahtaylor](https://zatca1.discourse.group/u/sarahtaylor)\
**Post date:** [August 26, 2025, 6:19pm UTC](https://zatca1.discourse.group/t/failed-to-validate-qr-code-qrcode-invalid/7221/2 "2025-08-26T18:19:26Z")

</div>

Hi @ezinvoice  
I’m also facing the same issue right now while working with Laravel integration. I have double-checked every detail regarding the QR code generation:

- The QR is built in **TLV format** and then **base64-encoded**.

- All required fields for both Standard and Simplified invoices are included.

- Even after validating with Swagger (sandbox APIM), I still get the same error:

```auto
{
  "type": "ERROR",
  "code": "QRCODE_INVALID",
  "category": "QRCODE_VALIDATION",
  "message": "Failed to validate QR code",
  "status": "ERROR"
}

```

So it looks like either we are missing some small detail in the TLV order/encoding, or there might still be an issue on the sandbox side.

Can anyone confirm if you’re still experiencing this QR validation error on Sandbox? Or if you have a working payload example that passed the validation, it would be really helpful.

Thanks!

---

<div class="post-metadata">

**Author:** ![sarahtaylor](https://avatars.discourse-cdn.com/v4/letter/s/ac8455/32.png) [@sarahtaylor](https://zatca1.discourse.group/u/sarahtaylor)\
**Post date:** [September 7, 2025, 2:02pm UTC](https://zatca1.discourse.group/t/failed-to-validate-qr-code-qrcode-invalid/7221/3 "2025-09-07T14:02:32Z")

</div>

Hi @ezinvoice

I hope you’re doing well. I’m awaiting your response on this matter and would appreciate your guidance whenever you have a chance.
