# Clearance QR CODE ISSUES

**URL:** <https://zatca1.discourse.group/t/clearance-qr-code-issues/6137>\
**Category:** QR code\
**Created:** [March 5, 2025, 8:34am UTC](https://zatca1.discourse.group/t/clearance-qr-code-issues/6137 "2025-03-05T08:34:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![moalnatour](https://avatars.discourse-cdn.com/v4/letter/m/9dc877/32.png) [@moalnatour](https://zatca1.discourse.group/u/moalnatour)\
**Post date:** [March 5, 2025, 8:34am UTC](https://zatca1.discourse.group/t/clearance-qr-code-issues/6137/1 "2025-03-05T08:34:24Z")

</div>

> 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

```auto
        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;
            }
        }

```

---

<div class="post-metadata">

**Author:** ![bahaeddine](https://avatars.discourse-cdn.com/v4/letter/b/3ec8ea/32.png) [@bahaeddine](https://zatca1.discourse.group/u/bahaeddine)\
**Post date:** [March 6, 2025, 8:08am UTC](https://zatca1.discourse.group/t/clearance-qr-code-issues/6137/2 "2025-03-06T08:08:08Z")

</div>

@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 .

---

<div class="post-metadata">

**Author:** ![Madleen](https://avatars.discourse-cdn.com/v4/letter/m/fbc32d/32.png) [@Madleen](https://zatca1.discourse.group/u/Madleen)\
**Post date:** [May 25, 2025, 12:09pm UTC](https://zatca1.discourse.group/t/clearance-qr-code-issues/6137/3 "2025-05-25T12:09:37Z")

</div>

@bahaeddine ,  
Are you sure this working? If yes, What should do in b2c Invoices?
