Compliance Invoice

Dear All,
How can fix this problem
“errorMessages”: [
{
“type”: “ERROR”,
“code”: “invalid-invoice-hash”,
“category”: “INVOICE_HASHING_ERRORS”,
“message”: “The invoice hash API body does not match the (calculated) Hash of the XML”,
“status”: “ERROR”
}
] "
used SDK 3.3.4 (.NET)

The main issue is that you are sending a different hash. After signing the invoice, you need to extract the hash and send it again.

    public RequestResult GetSignedInvoiceRequest(XmlDocument eInvoice, string binarySecurityToken, string privateKey)
    {
        privateKey = System.IO.File.ReadAllText("PrivateKey.pem");



        IEInvoiceQRGenerator eInvoiceQRGenerator = new EInvoiceQRGenerator();
        QRResult qRResult = eInvoiceQRGenerator.GenerateEInvoiceQRCode(eInvoice);



        SignResult signedResult = _eInvoiceSigner.SignDocument(eInvoice, Base64Converter.Base64Decode(binarySecurityToken), privateKey);
        var asda = signedResult.SignedEInvoice;
        string xmlString = XmlToString(signedResult.SignedEInvoice);
        RequestResult request = _requestGenerator.GenerateRequest(signedResult.SignedEInvoice);
        HashResult hashInvoice = _eInvoiceHashGenerator.GenerateEInvoiceHashing(signedResult.SignedEInvoice);
        request.InvoiceRequest.InvoiceHash = hashInvoice.Hash;

        var body = JsonConvert.SerializeObject(request.InvoiceRequest);

        return request;

    }

copy the body var and send again to zatca

if the problem still >> send you function to update it

Dear @Madleen ,

Thank you for reaching out.

Please be informed that the error you encountered may indicate that the data within the invoice has been altered; however, the invoice was not signed following the modification. It is essential to sign the simplified invoice and generate a new hash for the standard invoice after any changes are made. Please refer to the steps of manual signing using ZATCA’s JAVA SDK below:
1- After sending the CSR in the Compliance request CSID API, a Binarytoken & secret will be returned
2- Take the Binarytoken output, and decode it using base64 decoder, the decoded value is the x.509 certificate
3- Go to the SDK file to the following path: SDK/Data/Certificates/Cert.pem
4- Replace the value with your obtained x.509 certificate
5- Go to the JAVA SDK and use the command: fatooranet sign -invoice “invoice.xml”
6- Generate the JSON file using this command: fatooranet invoiceRequest -invoice “invoice.xml”
7- The request body is generated, use it in the API request