How to Generate Hash?

I Try Alot of Things but i Got This Error The Hash is Not Like Calculated Hash :
i tryed :

1- Sign and Calc Hash By SDK
2- Sign and Calc Hash By Code (Manual)
3- Sign and Calc Hash and Replace the Old Hash With the New One By SDK and Manual

all i got same Error.

This is The Signed Invoice i Use : Can Someone Tell me What is The Hash for it and How he did it ?

PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48SW52b2ljZSB4bWxucz0idXJuOm9hc2lzOm5hbWVzOnNwZWNpZmljYXRpb246dWJsOnNjaGVtYTp4c2Q6SW52b2ljZS0yIiB4bWxuczpjYWM9InVybjpvYXNpczpuYW1lczpzcGVjaWZpY2F0aW9uOnVibDpzY2hlbWE6eHNkOkNvbW1vbkFnZ3JlZ2F0ZUNvbXBvbmVudHMtMiIgeG1sbnM6Y2JjPSJ1cm46b2FzaXM6bmFtZXM6c3BlY2lmaWNhdGlvbjp1Ymw6c2NoZW1hOnhzZDpDb21tb25CYXNpY0NvbXBvbmVudHMtMiIgeG1sbnM6ZXh0PSJ1cm46b2FzaXM6bmFtZXM6c3BlY2lmaWNhdGlvbjp1Ymw6c2NoZW1hOnhzZDpDb21tb25FeHRlbnNpb25Db21wb25lbnRzLTIiPjxleHQ6VUJMRXh0ZW5zaW9ucz48ZXh0OlVCTEV4dGVuc2lvbj48ZXh0OkV4dGVuc2lvblVSST51cm46b2FzaXM6bmFtZXM6c3BlY2lmaWNhdGlvbjp1Ymw6ZHNpZzplbnZlbG9wZWQ6eGFkZXM8L2V4dDpFeHRlbnNpb25VUkk+PGV4dDpFeHRlbnNpb25Db250ZW50PjxzaWc6VUJMRG9jdW1lbnRTaWduYXR1cmVzIHhtbG5zOnNpZz0idXJuOm9hc2lzOm5hbWVzOnNwZWNpZmljYXRpb246dWJsOnNjaGVtYTp4c2Q6Q29tbW9uU2lnbmF0dXJlQ29tcG9uZW50cy0yIiB4bWxuczpzYWM9InVybjpvYXNpczpuYW1lczpzcGVjaWZpY2F0aW9uOn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U0FSIj40LjAwPC9jYmM6TGluZUV4dGVuc2lvbkFtb3VudD48Y2FjOlRheFRvdGFsPjxjYmM6VGF4QW1vdW50IGN1cnJlbmN5SUQ9IlNBUiI+MC42MDwvY2JjOlRheEFtb3VudD48Y2JjOlJvdW5kaW5nQW1vdW50IGN1cnJlbmN5SUQ9IlNBUiI+NC42MDwvY2JjOlJvdW5kaW5nQW1vdW50PjwvY2FjOlRheFRvdGFsPjxjYWM6SXRlbT48Y2JjOk5hbWU+2YLZhNmFINix2LXYp9i1PC9jYmM6TmFtZT48Y2FjOkNsYXNzaWZpZWRUYXhDYXRlZ29yeT48Y2JjOklEPlM8L2NiYzpJRD48Y2JjOlBlcmNlbnQ+MTUuMDA8L2NiYzpQZXJjZW50PjxjYWM6VGF4U2NoZW1lPjxjYmM6SUQ+VkFUPC9jYmM6SUQ+PC9jYWM6VGF4U2NoZW1lPjwvY2FjOkNsYXNzaWZpZWRUYXhDYXRlZ29yeT48L2NhYzpJdGVtPjxjYWM6UHJpY2U+PGNiYzpQcmljZUFtb3VudCBjdXJyZW5jeUlEPSJTQVIiPjIuMDA8L2NiYzpQcmljZUFtb3VudD48Y2FjOkFsbG93YW5jZUNoYXJnZT48Y2JjOkNoYXJnZUluZGljYXRvcj50cnVlPC9jYmM6Q2hhcmdlSW5kaWNhdG9yPjxjYmM6QWxsb3dhbmNlQ2hhcmdlUmVhc29uPmRpc2NvdW50PC9jYmM6QWxsb3dhbmNlQ2hhcmdlUmVhc29uPjxjYmM6QW1vdW50IGN1cnJlbmN5SUQ9IlNBUiI+MC4wMDwvY2JjOkFtb3VudD48L2NhYzpBbGxvd2FuY2VDaGFyZ2U+PC9jYWM6UHJpY2U+PC9jYWM6SW52b2ljZUxpbmU+PC9JbnZvaWNlPg==

Environment : Simulation

I Calculate After Sign. i Use last SDK Version 3.3.6 and i Try Emails Before and no one answer or Replay. and i Put the Invoice as Base64 u Can Check it .

Thanx alot

Morning @aymannagy

Thanks for reaching out,

To ensure comprehensive support as usual, can I kindly ask you to mention all the steps that you are followed in order to sign your invoice?

Thanks,
Ibrahem Daoud.

sdk 3.3.6 .

1- Sign the invoice >>>> Generate Hash .

2- Using This Code :

    //private static string GetBase64InvoiceHash(string eInvoiceXml)
    //{


    //    XmlDocument document = new XmlDocument();
    //    document.LoadXml(eInvoiceXml);

    //    //XmlNamespaceManager xmlNamespaceManager = new XmlNamespaceManager(document.NameTable);
    //    //xmlNamespaceManager.AddNamespace("cac", "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2");
    //    //xmlNamespaceManager.AddNamespace("cbc", "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2");
    //    //xmlNamespaceManager.AddNamespace("ext", "urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2");


    //    //XmlNode nodeUBLExtension = document.SelectSingleNode(@"*[local-name()='Invoice']//*[local-name()='UBLExtensions']", xmlNamespaceManager);
    //    //nodeUBLExtension.RemoveAll();
    //    //XmlNode parentnodeUBLExtension = nodeUBLExtension.ParentNode;
    //    //parentnodeUBLExtension.RemoveChild(nodeUBLExtension);

    //    //XmlNode nodeQR = document.SelectSingleNode(@"//*[local-name()='AdditionalDocumentReference'][cbc:ID[normalize-space(text()) = 'QR']]", xmlNamespaceManager);
    //    //nodeQR.RemoveAll();
    //    //XmlNode parentnodeQR = nodeQR.ParentNode;
    //    //parentnodeQR.RemoveChild(nodeQR);

    //    //XmlNode nodeSignature = document.SelectSingleNode(@"*[local-name()='Invoice']//*[local-name()='Signature']");
    //    //nodeSignature.RemoveAll();
    //    //XmlNode parentnodeSignature = nodeSignature.ParentNode;
    //    //parentnodeSignature.RemoveChild(nodeSignature);

    //    //foreach (XmlNode node in document)
    //    //{
    //    //    if (node.NodeType == XmlNodeType.XmlDeclaration)
    //    //    {
    //    //        document.RemoveChild(node);
    //    //    }
    //    //}
    //    //System.IO.File.WriteAllText(@"D:\AYman\Output\BeforeSign.txt", document.InnerXml.Replace(" />", "/>"));
    //    StringBuilder output = new();
    //    XmlWriterSettings settings = new()
    //    {
    //        OmitXmlDeclaration = true,
    //        Encoding = Encoding.UTF8,
    //        ConformanceLevel = ConformanceLevel.Auto,
    //        Indent = true
    //    };

    //    using (XmlWriter writer = XmlWriter.Create(output, settings))
    //    {
    //        XmlReader stylesheet = XmlReader.Create(new StringReader(ZatcaDataInvoice));
    //        XmlReader input = XmlReader.Create(new StringReader(document.InnerXml.Replace(" />", "/>")));
    //        input.Read();
    //        XslCompiledTransform transform1 = new();
    //        transform1.Load(stylesheet);
    //        transform1.Transform(input, writer);
    //    }


    //    using MemoryStream stream = new(Encoding.UTF8.GetBytes(output.ToString()));
    //    XmlDsigC14NTransform transform2 = new(false);
    //    transform2.LoadInput(stream);
    //    MemoryStream outputMS = transform2.GetOutput() as MemoryStream;
    //    byte[] hashBytes = HashSha256(Encoding.UTF8.GetString(outputMS.ToArray()));
    //    return Convert.ToBase64String(hashBytes);
    //}

Dear @aymannagy

Based on the invoice you shared the Hash is the first DigestValue in the XML, which in your case is “m8eDhcfHw/Nmt9vBYhGLL+fnFUO3q7VQNW7j3sT5X2E=”.

Thanks A lot . Now I’m Done With Simulation environment how i Move to Production Environment ? is There Sandbox On Production also ??

m8eDhcfHw/Nmt9vBYhGLL+fnFUO3q7VQNW7j3sT5X2E=

But this wrong Hash, because your xml is linearized.
try formatting your XML with indentation before Signing using Zatca eInvoice SDK

You should get

O8n3zNR8ADOtD7YasqNlvU4nSnjj+UARU33sTQOeI0g=

and it accepted by Zatca

I tried to Format the xml its give me this :

<Invoice
  xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
  xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
  xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
  xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2">
  <ext:UBLExtensions>
    <ext:UBLExtension>
      <ext:ExtensionURI>urn:oasis:names:specification:ubl:dsig:enveloped:xades</ext:ExtensionURI>
      <ext:ExtensionContent>
        <sig:UBLDocumentSignatures
          xmlns:sig="urn:oasis:names:specification:ubl:schema:xsd:CommonSignatureComponents-2"
          xmlns:sac="urn:oasis:names:specification:ubl:schema:xsd:SignatureAggregateComponents-2"
          xmlns:sbc="urn:oasis:names:specification:ubl:schema:xsd:SignatureBasicComponents-2">
          <sac:SignatureInformation>
            <cbc:ID>urn:oasis:names:specification:ubl:signature:1</cbc:ID>
            <sbc:ReferencedSignatureID>urn:oasis:names:specification:ubl:signature:Invoice</sbc:ReferencedSignatureID>
            <ds:Signature
              Id="signature"
              xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
              <ds:SignedInfo>
                <ds:CanonicalizationMethod
                  Algorithm="http://www.w3.org/2006/12/xml-c14n11" />
                <ds:SignatureMethod
                  Algorithm="http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256" />
                <ds:Reference
                  Id="invoiceSignedData"
                  URI="">
                  <ds:Transforms>
                    <ds:Transform
                      Algorithm="http://www.w3.org/TR/1999/REC-xpath-19991116">
                      <ds:XPath>not(//ancestor-or-self::ext:UBLExtensions)</ds:XPath>
                    </ds:Transform>
                    <ds:Transform
                      Algorithm="http://www.w3.org/TR/1999/REC-xpath-19991116">
                      <ds:XPath>not(//ancestor-or-self::cac:Signature)</ds:XPath>
                    </ds:Transform>
                    <ds:Transform
                      Algorithm="http://www.w3.org/TR/1999/REC-xpath-19991116">
                      <ds:XPath>not(//ancestor-or-self::cac:AdditionalDocumentReference[cbc:ID='QR'])</ds:XPath>
                    </ds:Transform>
                    <ds:Transform
                      Algorithm="http://www.w3.org/2006/12/xml-c14n11" />
                  </ds:Transforms>
                  <ds:DigestMethod
                    Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" />
                  <ds:DigestValue>m8eDhcfHw/Nmt9vBYhGLL+fnFUO3q7VQNW7j3sT5X2E=</ds:DigestValue>
                </ds:Reference>
                <ds:Reference
                  Type="http://www.w3.org/2000/09/xmldsig#SignatureProperties"
                  URI="#xadesSignedProperties">
                  <ds:DigestMethod
                    Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" />
                  <ds:DigestValue>ZTJmNmUxMDUxYzY3NWFmZmRhYmU0ZjkxZWFiYTc1OWE5ZjVkNzY3ZDQ5NTk3M2Y4ZmU2MGM1Y2ZjM2FjN2IzOQ==</ds:DigestValue>
                </ds:Reference>
              </ds:SignedInfo>
              <ds:SignatureValue>MEUCIFlySBUMvr5SFFv0aIMQzqoZCNKhQhgXLqEgCCB16/VUAiEA6Ay/5rONlkUjmnoJDH1eUiBlrWyONh01eNw66QSVVhA=</ds:SignatureValue>
              <ds:KeyInfo>
                <ds:X509Data>
                  <ds:X509Certificate>MIICPTCCAeOgAwIBAgIGAZK+UFaCMAoGCCqGSM49BAMCMBUxEzARBgNVBAMMCmVJbnZvaWNpbmcwHhcNMjQxMDI0MTEzNjI0WhcNMjkxMDIzMjEwMDAwWjB1MQswCQYDVQQGEwJTQTEWMBQGA1UECwwNUml5YWRoIEJyYW5jaDEmMCQGA1UECgwdTWF4aW11bSBTcGVlZCBUZWNoIFN1cHBseSBMVEQxJjAkBgNVBAMMHVRTVC04ODY0MzExNDUtMzk5OTk5OTk5OTAwMDAzMFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAE2OQb6AIrpOz1c9H1l5VhmCyuxt+6WEN+01Vyl92gDfJin4LwhHQ7Raruh3EpNTQgU1VW3CljAaFcwQCNmcmHc6OBwTCBvjAMBgNVHRMBAf8EAjAAMIGtBgNVHREEgaUwgaKkgZ8wgZwxOzA5BgNVBAQMMjEtVFNUfDItVFNUfDMtZWQyMmYxZDgtZTZhMi0xMTE4LTliNTgtZDlhOGYxMWU0NDVmMR8wHQYKCZImiZPyLGQBAQwPMzk5OTk5OTk5OTAwMDAzMQ0wCwYDVQQMDAQxMDAwMREwDwYDVQQaDAhSUlJEMjkyOTEaMBgGA1UEDwwRU3VwcGx5IGFjdGl2aXRpZXMwCgYIKoZIzj0EAwIDSAAwRQIgF8OkqXx7JB8xaUFMZ5MGqs8cbHLgY/aRKBBB5RxOwBECIQDHWq1vw8MM9UsTcxVNl+bhbP+h8oU1jO7UIGIBNSPFPg==</ds:X509Certificate>
                </ds:X509Data>
              </ds:KeyInfo>
              <ds:Object>
                <xades:QualifyingProperties
                  Target="signature"
                  xmlns:xades="http://uri.etsi.org/01903/v1.3.2#">
                  <xades:SignedProperties
                    Id="xadesSignedProperties">
                    <xades:SignedSignatureProperties>
                      <xades:SigningTime>2024-10-29T17:09:44</xades:SigningTime>
                      <xades:SigningCertificate>
                        <xades:Cert>
                          <xades:CertDigest>
                            <ds:DigestMethod
                              Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" />
                            <ds:DigestValue>ZmNiZjIwODA0NmYyMDIzZTQxN2NjODliYjA2MDJiMTFiM2U2ODZlNDNlYmE4MmIwYWZlY2I2ZGI1MTU0YWVhNw==</ds:DigestValue>
                          </xades:CertDigest>
                          <xades:IssuerSerial>
                            <ds:X509IssuerName>CN=eInvoicing</ds:X509IssuerName>
                            <ds:X509SerialNumber>1729769789058</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>SME00023</cbc:ID>
  <cbc:UUID>8d487816-70b8-4ade-a618-9d620b73814a</cbc:UUID>
  <cbc:IssueDate>2022-09-07</cbc:IssueDate>
  <cbc:IssueTime>12:21:28</cbc:IssueTime>
  <cbc:InvoiceTypeCode
    name="0100000">388</cbc:InvoiceTypeCode>
  <cbc:DocumentCurrencyCode>SAR</cbc:DocumentCurrencyCode>
  <cbc:TaxCurrencyCode>SAR</cbc:TaxCurrencyCode>
  <cac:AdditionalDocumentReference>
    <cbc:ID>ICV</cbc:ID>
    <cbc:UUID>23</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">AW/YtNix2YPYqSDYqtmI2LHZitivINin2YTYqtmD2YbZiNmE2YjYrNmK2Kcg2KjYo9mC2LXZiSDYs9ix2LnYqSDYp9mE2YXYrdiv2YjYr9ipIHwgTWF4aW11bSBTcGVlZCBUZWNoIFN1cHBseSBMVEQCDzM5OTk5OTk5OTkwMDAwMwMTMjAyMi0wOS0wN1QxMjoyMToyOAQENC42MAUDMC42BixtOGVEaGNmSHcvTm10OXZCWWhHTEwrZm5GVU8zcTdWUU5XN2ozc1Q1WDJFPQdgTUVVQ0lGbHlTQlVNdnI1U0ZGdjBhSU1RenFvWkNOS2hRaGdYTHFFZ0NDQjE2L1ZVQWlFQTZBeS81ck9ObGtVam1ub0pESDFlVWlCbHJXeU9OaDAxZU53NjZRU1ZWaEE9CFgwVjAQBgcqhkjOPQIBBgUrgQQACgNCAATY5BvoAiuk7PVz0fWXlWGYLK7G37pYQ37TVXKX3aAN8mKfgvCEdDtFqu6HcSk1NCBTVVbcKWMBoVzBAI2ZyYdz</cbc:EmbeddedDocumentBinaryObject>
    </cac:Attachment>
  </cac:AdditionalDocumentReference>
  <cac:Signature>
    <cbc:ID>urn:oasis:names:specification:ubl:signature:Invoice</cbc:ID>
    <cbc:SignatureMethod>urn: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:StreetName>الامير سلطان | Prince Sultan</cbc:StreetName>
        <cbc:BuildingNumber>2322</cbc:BuildingNumber>
        <cbc:CitySubdivisionName>المربع | Al-Murabba</cbc:CitySubdivisionName>
        <cbc:CityName>الرياض | Riyadh</cbc:CityName>
        <cbc:PostalZone>23333</cbc:PostalZone>
        <cac:Country>
          <cbc:IdentificationCode>SA</cbc:IdentificationCode>
        </cac:Country>
      </cac:PostalAddress>
      <cac:PartyTaxScheme>
        <cbc:CompanyID>399999999900003</cbc:CompanyID>
        <cac:TaxScheme>
          <cbc:ID>VAT</cbc:ID>
        </cac:TaxScheme>
      </cac:PartyTaxScheme>
      <cac:PartyLegalEntity>
        <cbc:RegistrationName>شركة توريد التكنولوجيا بأقصى سرعة المحدودة | Maximum Speed Tech Supply LTD</cbc:RegistrationName>
      </cac:PartyLegalEntity>
    </cac:Party>
  </cac:AccountingSupplierParty>
  <cac:AccountingCustomerParty>
    <cac:Party>
      <cac:PostalAddress>
        <cbc:StreetName>صلاح الدين | Salah Al-Din</cbc:StreetName>
        <cbc:BuildingNumber>1111</cbc:BuildingNumber>
        <cbc:CitySubdivisionName>المروج | Al-Murooj</cbc:CitySubdivisionName>
        <cbc:CityName>الرياض | Riyadh</cbc:CityName>
        <cbc:PostalZone>12222</cbc:PostalZone>
        <cac:Country>
          <cbc:IdentificationCode>SA</cbc:IdentificationCode>
        </cac:Country>
      </cac:PostalAddress>
      <cac:PartyTaxScheme>
        <cbc:CompanyID>399999999800003</cbc:CompanyID>
        <cac:TaxScheme>
          <cbc:ID>VAT</cbc:ID>
        </cac:TaxScheme>
      </cac:PartyTaxScheme>
      <cac:PartyLegalEntity>
        <cbc:RegistrationName>شركة نماذج فاتورة المحدودة | Fatoora Samples LTD</cbc:RegistrationName>
      </cac:PartyLegalEntity>
    </cac:Party>
  </cac:AccountingCustomerParty>
  <cac:Delivery>
    <cbc:ActualDeliveryDate>2022-09-07</cbc:ActualDeliveryDate>
  </cac:Delivery>
  <cac:PaymentMeans>
    <cbc:PaymentMeansCode>10</cbc:PaymentMeansCode>
  </cac:PaymentMeans>
  <cac:AllowanceCharge>
    <cbc:ChargeIndicator>false</cbc:ChargeIndicator>
    <cbc:AllowanceChargeReason>discount</cbc:AllowanceChargeReason>
    <cbc:Amount
      currencyID="SAR">0.00</cbc:Amount>
    <cac:TaxCategory>
      <cbc:ID
        schemeID="UN/ECE 5305"
        schemeAgencyID="6">S</cbc:ID>
      <cbc:Percent>15</cbc:Percent>
      <cac:TaxScheme>
        <cbc:ID
          schemeID="UN/ECE 5153"
          schemeAgencyID="6">VAT</cbc:ID>
      </cac:TaxScheme>
    </cac:TaxCategory>
  </cac:AllowanceCharge>
  <cac:TaxTotal>
    <cbc:TaxAmount
      currencyID="SAR">0.6</cbc:TaxAmount>
  </cac:TaxTotal>
  <cac:TaxTotal>
    <cbc:TaxAmount
      currencyID="SAR">0.6</cbc:TaxAmount>
    <cac:TaxSubtotal>
      <cbc:TaxableAmount
        currencyID="SAR">4.00</cbc:TaxableAmount>
      <cbc:TaxAmount
        currencyID="SAR">0.60</cbc:TaxAmount>
      <cac:TaxCategory>
        <cbc:ID
          schemeID="UN/ECE 5305"
          schemeAgencyID="6">S</cbc:ID>
        <cbc:Percent>15.00</cbc:Percent>
        <cac:TaxScheme>
          <cbc:ID
            schemeID="UN/ECE 5153"
            schemeAgencyID="6">VAT</cbc:ID>
        </cac:TaxScheme>
      </cac:TaxCategory>
    </cac:TaxSubtotal>
  </cac:TaxTotal>
  <cac:LegalMonetaryTotal>
    <cbc:LineExtensionAmount
      currencyID="SAR">4.00</cbc:LineExtensionAmount>
    <cbc:TaxExclusiveAmount
      currencyID="SAR">4.00</cbc:TaxExclusiveAmount>
    <cbc:TaxInclusiveAmount
      currencyID="SAR">4.60</cbc:TaxInclusiveAmount>
    <cbc:AllowanceTotalAmount
      currencyID="SAR">0.00</cbc:AllowanceTotalAmount>
    <cbc:PrepaidAmount
      currencyID="SAR">0.00</cbc:PrepaidAmount>
    <cbc:PayableAmount
      currencyID="SAR">4.60</cbc:PayableAmount>
  </cac:LegalMonetaryTotal>
  <cac:InvoiceLine>
    <cbc:ID>1</cbc:ID>
    <cbc:InvoicedQuantity
      unitCode="PCE">2.000000</cbc:InvoicedQuantity>
    <cbc:LineExtensionAmount
      currencyID="SAR">4.00</cbc:LineExtensionAmount>
    <cac:TaxTotal>
      <cbc:TaxAmount
        currencyID="SAR">0.60</cbc:TaxAmount>
      <cbc:RoundingAmount
        currencyID="SAR">4.60</cbc:RoundingAmount>
    </cac:TaxTotal>
    <cac:Item>
      <cbc:Name>قلم رصاص</cbc:Name>
      <cac:ClassifiedTaxCategory>
        <cbc:ID>S</cbc:ID>
        <cbc:Percent>15.00</cbc:Percent>
        <cac:TaxScheme>
          <cbc:ID>VAT</cbc:ID>
        </cac:TaxScheme>
      </cac:ClassifiedTaxCategory>
    </cac:Item>
    <cac:Price>
      <cbc:PriceAmount
        currencyID="SAR">2.00</cbc:PriceAmount>
      <cac:AllowanceCharge>
        <cbc:ChargeIndicator>true</cbc:ChargeIndicator>
        <cbc:AllowanceChargeReason>discount</cbc:AllowanceChargeReason>
        <cbc:Amount
          currencyID="SAR">0.00</cbc:Amount>
      </cac:AllowanceCharge>
    </cac:Price>
  </cac:InvoiceLine>
</Invoice>

and it give me Same Hash :

m8eDhcfHw/Nmt9vBYhGLL+fnFUO3q7VQNW7j3sT5X2E=

Formatting Function is

     static string PrettyXml(string xml)
     {
         var stringBuilder = new StringBuilder();

         var element = XElement.Parse(xml);

         var settings = new XmlWriterSettings();
         settings.OmitXmlDeclaration = true;
         settings.Indent = true;
         settings.NewLineOnAttributes = true;

         using (var xmlWriter = XmlWriter.Create(stringBuilder, settings))
         {
             element.Save(xmlWriter);
         }

         return stringBuilder.ToString();
     }

Did i Do something Wrong ?

Thanks Alot i will work on Your Advice if i Got Problem in B2C but in B2B i just Generate QR and Get the Hash By Xpath .

Make sure you set { PreserveWhitespace = true } on XmlDocument when load xml file content.

try sample code in this thread