Dear @suhailkk
Why you need to regenerate QRcode and Hash?
Its all done when Invoice was successfuly Signed.
We can get all information, Hash and QRcode inside the SignedXML.
We just need create RequestApi from SignedXML and send as Payload to Fatoora Portal.
Based on code in this thread,
This sniped code, how you can extract base64QrCode from SignResult
//Get Invoice Hash for Next PIH
var SignedInvoiceHash = GetInvoiceHash(result);
Console.WriteLine($"Invoice Hash : {SignedInvoiceHash}\n");
//Get QRCode from SignedInvoice
var Base64QrCode = GetBase64QrCode(result);
Console.WriteLine($"Base64 QRCode : {Base64QrCode}\n");
public static string GetInvoiceHash(SignResult signResult)
{
var step = signResult.Steps
.FirstOrDefault(s => s.StepName == "Generate EInvoice Hash");
return step?.ResultedValue ?? "Invoice Hash not found";
}
public static string GetBase64QrCode(SignResult signResult)
{
XmlDocument xmlDoc = new XmlDocument() { PreserveWhitespace = true };
xmlDoc.LoadXml(signResult.SignedEInvoice.OuterXml);
XmlNamespaceManager nsManager = new XmlNamespaceManager(xmlDoc.NameTable);
nsManager.AddNamespace("cbc", "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2");
nsManager.AddNamespace("cac", "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2");
// Find the QR code <cbc:EmbeddedDocumentBinaryObject>
XmlNode qrNode = xmlDoc.SelectSingleNode("//cac:AdditionalDocumentReference[cbc:ID='QR']//cbc:EmbeddedDocumentBinaryObject", nsManager);
return qrNode.InnerText.ToString();
}