We have successfully generated e-invoice, and XML also complies with ZATCA guidelines. But when we scan the QR code, we get only 5 fields, i.e. Seller name, VRN, timestamp, Invoice amount, and tax amount.
But as per the guidelines, Invoice hash, ECDSA signature, and public key should also be a part of the QR code.
Please guide me if the invoice hash and ECDSA are not coming on the QR code then the QR code is valid or not.
Dear Shivangi, Invoice hash, ECDSA signature, and public key is mandatory to be the part of QR code, if it is not in the QR code, then QR code will not be consider as a valid QR for Phase-II. For creating the rest 4 fields of QR code please Follow the SDK.
@shivangi.garg , how did you get the error resolved. I am trying to create ECDSA signature using the function below but am still facing validation errors: public class ZatcaSignature
{
public static void Main()
{
// Sample XML invoice content
string invoiceXml = “Name”;
// Step 1: Compute SHA256 hash of the XML
byte[] invoiceBytes = Encoding.UTF8.GetBytes(invoiceXml);
byte[] invoiceHash;
using (SHA256 sha256 = SHA256.Create())
{
invoiceHash = sha256.ComputeHash(invoiceBytes);
}
// Step 2: Generate ECDSA key (P-256) - in production, use a pre-generated private key
using (ECDsa ecdsa = ECDsa.Create(ECCurve.NamedCurves.nistP256))
{
// Step 3: Sign the hash
byte[] signature = ecdsa.SignHash(invoiceHash);
// Step 4: Convert to Base64 for QR Tag 7
string tag7SignatureBase64 = Convert.ToBase64String(signature);
// Output
Console.WriteLine("Tag 7 - ECDSA Signature (Base64):");
Console.WriteLine(tag7SignatureBase64);
}
}