The solution for schematrons error is to make sure we copy the ikvm folder from the Test folder (not from the dll folder) to where our application executable file directory is located.
.
@Aturkistani
There is no validation issue on Signed B2C Invoice signed using X509Certificate from CCSID BinarySecurityToken.
Processing Simplified Invoice...
Initialization Step (Simplified EInvoice) : True
Validate XSD : True
Validate EN Schematrons : True
Validate KSA Schematrons : True
Generate EInvoice Hash : True
Parse Certificate : True
Generate EInvoice QR : True
Validate QR Code : True
Validate EInvoice Signature : True
Validate EInvoice PIH : True
Overall Signed Invoice Validation : True!
Simplified Invoice processed successfully
I am still facing Validation issue for Signed B2C Invoice signed using X509Certificate from PCSID BinarySecurityToken ([Error] CODE: signatureValue, MESSAGE: Wrong signature value.).
But this Signed B2C Invoice is approved by Reporting Server without any error or warning.
Initialization Step (Simplified EInvoice) : True
Validate XSD : True
Validate EN Schematrons : True
Validate KSA Schematrons : True
Generate EInvoice Hash : True
Parse Certificate : True
Generate EInvoice QR : True
Validate QR Code : True
Validate EInvoice Signature : False
[Error] CODE: signatureValue, MESSAGE: Wrong signature value.
Validate EInvoice PIH : True
Overall Signed Invoice Validation : False!
Reporting Simplified Invoice
{
"requestType": "Reporting",
"requestUrl": "https://gw-fatoora.zatca.gov.sa/e-invoicing/developer-portal/invoices/reporting/single",
"statusCode": "200-OK",
"reportingStatus": "REPORTED",
"validationResults": {
"status": "PASS",
"infoMessages": [
{
"status": "PASS",
"type": "INFO",
"code": "XSD_ZATCA_VALID",
"category": "XSD validation",
"message": "Complied with UBL 2.1 standards in line with ZATCA specifications"
}
],
"warningMessages": [],
"errorMessages": []
}
}
This is my code to Sign Document and perform Validation Test
public static RequestResult GenerateSignedRequestApi(XmlDocument document, string csidBinaryToken, string privateKey, string pih)
{
string x509CertificateContent = Encoding.UTF8.GetString(Convert.FromBase64String(csidBinaryToken));
SignResult signedInvoiceResult = new EInvoiceSigner().SignDocument(document, x509CertificateContent, privateKey);
// Validate Signed Invoice *** just test ***
EInvoiceValidator eInvoiceValidator = new();
var validationResult = eInvoiceValidator.ValidateEInvoice(signedInvoiceResult.SignedEInvoice, x509CertificateContent, pih);
if (validationResult != null) {
foreach (var e in validationResult.ValidationSteps)
{
Console.WriteLine(e.ValidationStepName + " : " + e.IsValid);
if (!e.IsValid)
{
foreach (var x in e.ErrorMessages)
{
Console.WriteLine(x);
}
}
else
{
foreach (var x in e.WarningMessages)
{
Console.WriteLine(x);
}
//return new RequestGenerator().GenerateRequest(signedInvoiceResult.SignedEInvoice);
}
}
Console.WriteLine($"Overall Signed Invoice Validation : {validationResult.IsValid}!");
}
return new RequestGenerator().GenerateRequest(signedInvoiceResult.SignedEInvoice);
}
Please advise, are there any steps I should take for this Signature Error problem on Validation. Thank you.