# QR code issue for simlified B2C invoice

**URL:** <https://zatca1.discourse.group/t/qr-code-issue-for-simlified-b2c-invoice/2598>\
**Category:** General\
**Created:** [August 25, 2024, 8:52am UTC](https://zatca1.discourse.group/t/qr-code-issue-for-simlified-b2c-invoice/2598 "2024-08-25T08:52:31Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Haseeb\_35](https://avatars.discourse-cdn.com/v4/letter/h/57b2e6/32.png) [@Haseeb\_35](https://zatca1.discourse.group/u/Haseeb_35)\
**Post date:** [August 25, 2024, 8:52am UTC](https://zatca1.discourse.group/t/qr-code-issue-for-simlified-b2c-invoice/2598/1 "2024-08-25T08:52:31Z")

</div>

Hi

I have successfully generated and posted the XML for a B2B invoice without any issues. However, when attempting to validate XML format for a B2C invoice on zatca xml validator, I am encountering errors related to the QR code and digital signature validation.

Could you please provide guidance on the appropriate approach to validate the XML for a B2C invoice? I would appreciate recommendations you can offer to resolve these validation errors.

---

<div class="post-metadata">

**Author:** ![halrashidy](https://avatars.discourse-cdn.com/v4/letter/h/3bc359/32.png) [@halrashidy](https://zatca1.discourse.group/u/halrashidy)\
**Post date:** [August 26, 2024, 4:52am UTC](https://zatca1.discourse.group/t/qr-code-issue-for-simlified-b2c-invoice/2598/2 "2024-08-26T04:52:54Z")

</div>

Dear @Haseeb_35,

Can you please share with us the error that appear to you

Thanks

---

<div class="post-metadata">

**Author:** ![Haseeb\_35](https://avatars.discourse-cdn.com/v4/letter/h/57b2e6/32.png) [@Haseeb\_35](https://zatca1.discourse.group/u/Haseeb_35)\
**Post date:** [August 26, 2024, 7:42am UTC](https://zatca1.discourse.group/t/qr-code-issue-for-simlified-b2c-invoice/2598/3 "2024-08-26T07:42:05Z")

</div>

Hi @halrashidy

Thank you for your assistance thus far. I am currently encountering an issue when validating the XML on the ZATCA XML validator. The validator responds with errors, particularly regarding the QR code.

I am somewhat confused about the process of encoding the QR code, particularly in steps 6 and 7, where the hash is already in Base64 format. Should I convert this Base64 string directly to hexadecimal, or should I first convert the original string to hexadecimal?

For instance, if my hash is `"pWOjDxZDtaw1zJ0PovA8afdcFxJbhuhKhUMTC3IxZ/w="`, what would be the correct hexadecimal representation of this hash?

Additionally, I would appreciate some clarification on the “ECDSA signature” mentioned in step 7. Could you please explain where I can obtain this signature and how it should be used in the validation process?

Thank you for your guidance.

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/zatca1/original/1X/57ddaabb1a1ed9ddf4c5962bdf2219f7f2123b13.png)

---

<div class="post-metadata">

**Author:** ![Embro](https://avatars.discourse-cdn.com/v4/letter/e/bc79bd/32.png) [@Embro](https://zatca1.discourse.group/u/Embro)\
**Post date:** [August 26, 2024, 7:44am UTC](https://zatca1.discourse.group/t/qr-code-issue-for-simlified-b2c-invoice/2598/4 "2024-08-26T07:44:34Z")

</div>

Atually B2B is easy because ZATCA is creating sign & Qr (depending on your valid XML)

for B2C you suppose to do Everything and zatca is depending on you for that.

make search for articles… you will find many helpful answers

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/zatca1/original/1X/c9feda4d7f53a98c38a9aed726e488dff02e4d29.png)

---

<div class="post-metadata">

**Author:** ![Haseeb\_35](https://avatars.discourse-cdn.com/v4/letter/h/57b2e6/32.png) [@Haseeb\_35](https://zatca1.discourse.group/u/Haseeb_35)\
**Post date:** [August 27, 2024, 9:14am UTC](https://zatca1.discourse.group/t/qr-code-issue-for-simlified-b2c-invoice/2598/5 "2024-08-27T09:14:12Z")

</div>

Hi @Embro

Thank you for your previous assistance, which has helped clarify many of my doubts regarding QR codes. However, I am still in need of guidance on obtaining the ECDSA (Elliptic Curve Digital Signature Algorithm) signature. I currently have the hash, public key, and private key, but I am unsure how to proceed in generating the ECDSA signature.

I would greatly appreciate any further assistance you could provide on this matter.

Thank you once again for your support.

---

<div class="post-metadata">

**Author:** ![Ather](https://dub1.discourse-cdn.com/flex013/user_avatar/zatca1.discourse.group/ather/32/848_2.png) [@Ather](https://zatca1.discourse.group/u/Ather)\
**Post date:** [August 27, 2024, 9:41am UTC](https://zatca1.discourse.group/t/qr-code-issue-for-simlified-b2c-invoice/2598/6 "2024-08-27T09:41:15Z")

</div>

Which SDK are you using?  
did you try to sign the invoice using FatooraNet?  
I was having similar issue when using SDK 3.3.3, Now i am signing and validating invoices using FatooraNet and they are getting cleared and reported without any issue.

---

<div class="post-metadata">

**Author:** ![abdelrahman](https://avatars.discourse-cdn.com/v4/letter/a/b782af/32.png) [@abdelrahman](https://zatca1.discourse.group/u/abdelrahman)\
**Post date:** [August 27, 2024, 9:50am UTC](https://zatca1.discourse.group/t/qr-code-issue-for-simlified-b2c-invoice/2598/7 "2024-08-27T09:50:59Z")

</div>

you can use the.provided sdk of signing the xml .you will generate the xml normally then you will use the sdk to sign the invoice then send the signed invoice to zatca . the sdk will sign the invoice and generate a valid qr code

---

<div class="post-metadata">

**Author:** ![Haseeb\_35](https://avatars.discourse-cdn.com/v4/letter/h/57b2e6/32.png) [@Haseeb\_35](https://zatca1.discourse.group/u/Haseeb_35)\
**Post date:** [August 27, 2024, 12:25pm UTC](https://zatca1.discourse.group/t/qr-code-issue-for-simlified-b2c-invoice/2598/8 "2024-08-27T12:25:25Z")

</div>

As i want to post B2C invoice i think the requirment is to generate qrcode by my self then zatca can validate the xml.  
Now the issue is whenever i validate the xml it always return the error as  
 ![image](https://europe1.discourse-cdn.com/flex013/uploads/zatca1/original/1X/8c9d01b50af021ac3e875b755bba8a20af53c6af.png)

is there any valid method ? to resolve the issue

---

<div class="post-metadata">

**Author:** ![Embro](https://avatars.discourse-cdn.com/v4/letter/e/bc79bd/32.png) [@Embro](https://zatca1.discourse.group/u/Embro)\
**Post date:** [August 27, 2024, 12:25pm UTC](https://zatca1.discourse.group/t/qr-code-issue-for-simlified-b2c-invoice/2598/9 "2024-08-27T12:25:31Z")

</div>

If you need detailed information about Elliptic Curve go to

# [ECDSA and Custom XML Signatures in .NET](https://www.scottbrady91.com/c-sharp/ecdsa-xml-dotnet)

My self (not using sdk) I am signing manually step by step  
signing an invoice using this command openssl

hash in file XmlInitial\_Sha256.txt  
output in file sign\_sha256\_base64.txt  
**openssl dgst -sign privatekey.pem XmlInitial\_Sha256.txt | openssl base64 -e -A \> sign\_sha256\_base64.txt**

---

<div class="post-metadata">

**Author:** ![abdelrahman](https://avatars.discourse-cdn.com/v4/letter/a/b782af/32.png) [@abdelrahman](https://zatca1.discourse.group/u/abdelrahman)\
**Post date:** [August 28, 2024, 10:34am UTC](https://zatca1.discourse.group/t/qr-code-issue-for-simlified-b2c-invoice/2598/10 "2024-08-28T10:34:53Z")

</div>

Zatca has an offline sdk both in java and .net .This sdk contains much of the steps related to signing and generating the qr code . the problem you are facing is because the signature is not included in the qr cide it self . and it is quiet not easy task to do. but you can simply use the offline sdk before sending the xml document to zatca. by using the offline sdk you will be able to sign and generate a valid qr code. after that you send the documentt to zatca and it will not show the error

---

<div class="post-metadata">

**Author:** ![Haseeb\_35](https://avatars.discourse-cdn.com/v4/letter/h/57b2e6/32.png) [@Haseeb\_35](https://zatca1.discourse.group/u/Haseeb_35)\
**Post date:** [August 28, 2024, 10:57am UTC](https://zatca1.discourse.group/t/qr-code-issue-for-simlified-b2c-invoice/2598/11 "2024-08-28T10:57:04Z")

</div>

Hi @Ather @abdelrahman  
Thank you for your thoughtful response. I have reviewed all of the answers provided, but I would like to inquire specifically about the ECDSA signature. Could you please guide me on how to generate this signature and validate it? Additionally, I would appreciate your advice on where exactly this signature should be used within an XML document, as I have not been able to find a clear explanation on this matter.However i have generated it online and make a QR code it works fine but when I procced it with xml and validate that xml from zatca website i gives an error as  
" \* **category :** SIGNATURE\_ERROR

- \*\*code :\*\*signatureValue
- **message :** wrong signature Value"

---

<div class="post-metadata">

**Author:** ![MGawad](https://avatars.discourse-cdn.com/v4/letter/m/7bcc69/32.png) [@MGawad](https://zatca1.discourse.group/u/MGawad)\
**Post date:** [September 3, 2024, 11:40am UTC](https://zatca1.discourse.group/t/qr-code-issue-for-simlified-b2c-invoice/2598/12 "2024-09-03T11:40:15Z")

</div>

@halrashidy Is there an issue with printing the QR code for Phase One on simplified invoices? Sometimes, I need to review the invoice before sending it, and there is no internet in the branches, so I want to send it from the head office. However, I want to print a barcode on the invoice. Can I initially print the QR code for Phase One until the invoice is sent to the authority?

Are there any fines or penalties for doing so?
