Problem in signing simplified invoice

Hello everyone
I am using the following code to sign invoices , then send to ZATCA for clearance through the following link"https://gw-fatoora.zatca.gov.sa/e-invoicing/simulation/precompliance/invoices"
I am working on simulation Environment . the problem is that Standard invoice , Standard_Credit_Note,Standard_Debit_Note are cleared successfully ,
but Simplified_Invoice and its associated documents gives the following error message

“{“validationResults”:{“infoMessages”:[{“type”:“INFO”,“code”:“XSD_ZATCA_VALID”,“category”:“XSD validation”,“message”:“Complied with UBL 2.1 standards in line with ZATCA specifications”,“status”:“PASS”}],“warningMessages”:,“errorMessages”:[{“type”:“ERROR”,“code”:“signed-properties-hashing”,“category”:“CERTIFICATE_ERRORS”,“message”:“Invalid signed properties hashing, SignedProperties with id=‘xadesSignedProperties’”,“status”:“ERROR”}],“status”:“ERROR”},“reportingStatus”:“NOT_REPORTED”,“clearanceStatus”:null,“qrSellertStatus”:null,“qrBuyertStatus”:null}”

I am using the SDK invoice samples , I changed the tax payer with real data

the code is like the following

Private Sub SignDocumnet(ByVal document As String)


    Dim privateKey As String
    Dim fileprivateKey As System.IO.StreamReader
    fileprivateKey = My.Computer.FileSystem.OpenTextFileReader("Keys\PrivateKey.txt")

    privateKey = fileprivateKey.ReadToEnd
    fileprivateKey.Close()

    Dim certificateContent As String

    Dim filecertificateContent As System.IO.StreamReader
    filecertificateContent = My.Computer.FileSystem.OpenTextFileReader("Keys\CSID.txt")
    certificateContent = filecertificateContent.ReadToEnd
    filecertificateContent.Close()

    Dim XmlDoc As New XmlDocument
    Dim fileReader As String
    fileReader = My.Computer.FileSystem.ReadAllText("invoices\" & document)

    XmlDoc.LoadXml(fileReader)

    Dim ObjEInvoiceSigner As New Zatca.EInvoice.SDK.EInvoiceSigner
    Dim ObjSignResult As New SDK.Contracts.Models.SignResult


    Dim data() As Byte = System.Convert.FromBase64String(certificateContent)

    Dim cert As String = System.Text.ASCIIEncoding.ASCII.GetString(data)

    Dim obj As New SDKNETFrameWorkLib.BLL.EInvoiceSigningLogic

    ObjSignResult = ObjEInvoiceSigner.SignDocument(XmlDoc, cert, privateKey)

    Dim SignedDocument As XmlDocument = ObjSignResult.SignedEInvoice
    invoiceString = SignedDocument.InnerXml.ToString()

    Dim file As System.IO.StreamWriter
    file = My.Computer.FileSystem.OpenTextFileWriter("Invoices\Signed\" & document, True)
    file.Write(invoiceString)
    file.Close()


End Sub

Dear @abdalla12002

Thanks for reaching out.

The provided endpoint “https://gw-fatoora.zatca.gov.sa/e-invoicing/simulation/precompliance/invoices” is not the correct API endpoint for the Simulation environment, this is “https://gw-fatoora.zatca.gov.sa/e-invoicing/simulation/compliance/invoices” Compliance check standard and simplified.

kindly review the materials shared by ZATCA in the (Educational library) and Fatoora Platform for the part (API Documentation) to ensure better understanding of all the requirements, refer back to the Fatoora Simulation Portal and find the tab for API documentation to locate the correct endpoint for each step in the onboarding process.

For sending a simplified invoice, please make sure to check these steps:

  • kindly note that signing function use 3 parameters the encoded XML, Certificate (current CSID) and private key, in ZATCA SDK signing functions you need to send the XML, certificate and private key.
  • The certificate that returned from the compliance API (BinaryToken), you need to Decode the BinaryToken using a base64 decoder. The decoded value will be the x.509 certificate.
  • Use Private key generated along with the CSR generation.
  • after that you need to send to the compliance API “https://gw-fatoora.zatca.gov.sa/e-invoicing/simulation/compliance/invoices” the singed invoice.
  • The invoice will now be signed and can be successfully submitted during the compliance checks phase via the Compliance Invoice API.

Please find the signing document attached for your reference, you can find the Signed Properties tag in slide 7.
SigningProcessUpdated.pdf (927.7 KB)

Kindly review it carefully, and if you faced any challenges, please do not hesitate to reach out with our support team via below emails:

sp_support@zatca.gov.sa
E-invoicing@zatca.gov.sa

Thank you.

Thank you very much everything is fine now

1 Like