Clearance QR CODE ISSUES

  1. is zatca app scan qr_code outside of KSA region ?

Answer : NO

  1. how i can extract qr_code from clearedInvoice that returned from success clearance api ?

Answer C# Code

        public string ExtractQRCodeValue(string xmlFilePath)
        {
            try
            {
                // Load the XML file
                XDocument xmlDoc = XDocument.Load(xmlFilePath);

                // Define the XML namespaces
                XNamespace ns = "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2";
                XNamespace cbc = "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2";
                XNamespace cac = "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2";

                // Find the QR code embedded document
                var qrCodeElement = xmlDoc.Descendants(cac + "AdditionalDocumentReference")
                                          .FirstOrDefault(e => (string)e.Element(cbc + "ID") == "QR")
                                          ?.Element(cac + "Attachment")
                                          ?.Element(cbc + "EmbeddedDocumentBinaryObject");

                if (qrCodeElement == null)
                {
                    throw new Exception("QR code not found in the XML.");
                }

                string base64String = qrCodeElement.Value;
                return base64String;


            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error: {ex.Message}");
                return null;
            }
        }

@moalnatour after clearing a b2b invoice you will receive the invoice encoded . you need to decode it with base64 . you will get an xml invoice , save it of course as new signed invoice (xml file) . the qr code will be present there , just extract it using any tools .