# Invalid OTPs in Simulation Env

**URL:** <https://zatca1.discourse.group/t/invalid-otps-in-simulation-env/3765>\
**Category:** FATOORA portal and Simulation portal\
**Created:** [October 21, 2024, 2:57pm UTC](https://zatca1.discourse.group/t/invalid-otps-in-simulation-env/3765 "2024-10-21T14:57:53Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Madleen](https://avatars.discourse-cdn.com/v4/letter/m/fbc32d/32.png) [@Madleen](https://zatca1.discourse.group/u/Madleen)\
**Post date:** [October 21, 2024, 2:57pm UTC](https://zatca1.discourse.group/t/invalid-otps-in-simulation-env/3765/1 "2024-10-21T14:57:54Z")

</div>

Is there any other way I can obtain the OTP for the simulation platform? When I click “Onboard New Solution Unit/Device” and try to test it using the following link:  
[https://gw-fatoora.zatca.gov.sa/e-invoicing/simulation/compliance](https://gw-fatoora.zatca.gov.sa/e-invoicing/simulation/compliance)

The result I receive is:

> { “errors”: [  
> { “code”: “Invalid-OTP”,  
> “message”: “The provided OTP is invalid” }  
> ] }

This happens when I attempt to use the OTP. Could you please advise on how to resolve this issue or suggest an alternative method for obtaining the OTP?

---

<div class="post-metadata">

**Author:** ![eCloud](https://dub1.discourse-cdn.com/flex013/user_avatar/zatca1.discourse.group/ecloud/32/629_2.png) [@eCloud](https://zatca1.discourse.group/u/eCloud)\
**Post date:** [October 21, 2024, 3:38pm UTC](https://zatca1.discourse.group/t/invalid-otps-in-simulation-env/3765/2 "2024-10-21T15:38:15Z")

</div>

Did you try [Fatoora\_Portal\_User\_Manual\_English](https://zatca.gov.sa/en/E-Invoicing/Introduction/Guidelines/Documents/Fatoora_Portal_User_Manual_English.pdf)?

Page 17 to 20

---

<div class="post-metadata">

**Author:** ![arjun\_tech24](https://avatars.discourse-cdn.com/v4/letter/a/7993a0/32.png) [@arjun\_tech24](https://zatca1.discourse.group/u/arjun_tech24)\
**Post date:** [October 21, 2024, 4:01pm UTC](https://zatca1.discourse.group/t/invalid-otps-in-simulation-env/3765/3 "2024-10-21T16:01:31Z")

</div>

@eCloud  
I have a question regarding the process of signing XML documents during onboarding versus signing invoices for reporting or clearance after onboarding.

Is there any difference in the method of signing XML to obtain the PCSID using the CCSID during onboarding, compared to signing invoices for reporting or clearance after onboarding using the PCSID?

I’m asking because the code works correctly for signing and submitting invoices using the PCSID, but the same code does not work for signing invoices with the CCSID during onboarding.

---

<div class="post-metadata">

**Author:** ![eCloud](https://dub1.discourse-cdn.com/flex013/user_avatar/zatca1.discourse.group/ecloud/32/629_2.png) [@eCloud](https://zatca1.discourse.group/u/eCloud)\
**Post date:** [October 21, 2024, 5:35pm UTC](https://zatca1.discourse.group/t/invalid-otps-in-simulation-env/3765/4 "2024-10-21T17:35:03Z")

</div>

@arjun_tech24

From my experience,  
For Compliance Check, Use Certificate from Compliance CSID and for Reporting/Clearance, we must use Certificate from Procuction CSID.

> [@arjun\_tech24](#):
>
> but the same code does not work for signing invoices with the CCSID during onboarding

You may need to double check the certificate you are using. You must also ensure that you use the ID and secret from Compliance CSID to perform the Compliance Check.

Logically, it is impossible for us to get PCSID, if Compliance Check is not Passed.  
_Except for Standard Invoices which do not require signing the Invoice._

---

<div class="post-metadata">

**Author:** ![arjun\_tech24](https://avatars.discourse-cdn.com/v4/letter/a/7993a0/32.png) [@arjun\_tech24](https://zatca1.discourse.group/u/arjun_tech24)\
**Post date:** [October 21, 2024, 7:09pm UTC](https://zatca1.discourse.group/t/invalid-otps-in-simulation-env/3765/5 "2024-10-21T19:09:47Z")

</div>

@eCloud  
I manually generate the private key and CSR using OpenSSL in the terminal, then retrieve an OTP from the Fatoora portal. After that, I use Postman to obtain the CCSID. Using the ZATCA SDK and CCSID, Private key I sign the sample invoices through SDK commands and submit each type of invoice to complete the compliance checks, eventually receiving the PCSID. For the next steps, I’ve already coded the process to sign invoices and submit them to the reporting or clearance API using the PCSID, and that part is working correctly.

Now, I need to automate the first part in my code. I tried using the same functions to sign the sample invoices with the CCSID in my code, but encountered some errors. Could someone help me resolve this issue or guide me on how to properly sign invoices using the CCSID in code?

---

<div class="post-metadata">

**Author:** ![eCloud](https://dub1.discourse-cdn.com/flex013/user_avatar/zatca1.discourse.group/ecloud/32/629_2.png) [@eCloud](https://zatca1.discourse.group/u/eCloud)\
**Post date:** [October 22, 2024, 12:10am UTC](https://zatca1.discourse.group/t/invalid-otps-in-simulation-env/3765/6 "2024-10-22T00:10:21Z")

</div>

@arjun_tech24

You should share the code snippet you used and what errors you encountered, so that others can try to help you.

---

<div class="post-metadata">

**Author:** ![Aturkistani](https://avatars.discourse-cdn.com/v4/letter/a/8baadc/32.png) [@Aturkistani](https://zatca1.discourse.group/u/Aturkistani)\
**Post date:** [October 22, 2024, 12:54am UTC](https://zatca1.discourse.group/t/invalid-otps-in-simulation-env/3765/7 "2024-10-22T00:54:23Z")

</div>

Dear @Madleen,

Please ensure the following:

1- obtain an OTP from Fatoora simulation not production, you can change the environment by pressing the icon on the top right of the page

2- In your CSR config file, make sure that the VAT number in the organization identifier field is identical to the VAT number in the Fatoora portal that you obtained the OTP from, if it differs, then you need to correct the config file & re-generate the CSR.

Note: if you are using OpenSSL, then the field will be UID.

3- the OTP is valid only for one-time transaction, so if you have called the API regardless of whether it’s a successful call or not, you need to obtain a new one for every call

4- OTP is timeboxed with 1 hour, make sure to use it before it expires.

---

<div class="post-metadata">

**Author:** ![James](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@James](https://zatca1.discourse.group/u/James)\
**Post date:** [November 25, 2024, 12:47pm UTC](https://zatca1.discourse.group/t/invalid-otps-in-simulation-env/3765/8 "2024-11-25T12:47:42Z")

</div>

Hi,  
Our CSR was generated through Zatca sandbox and was accepted in Developer portal.  
I have ensured that the VAT No = csr.organization.identifier. and generated the OTP on simulation mode.  
I am using the link : [https://gw-fatoora.zatca.gov.sa/e-invoicing/simulation/compliance](https://gw-fatoora.zatca.gov.sa/e-invoicing/simulation/compliance)

In am ensuring all headers are there

Accept:application/json  
OTP: 247886  
Accept-Version :V2  
Content-Type:application/json

When I try, First am getting : invalid OTP error - ( 2 mins after generating it)  
On trying with another OTP, I am getting error 409 (conflict) : Compliance transaction was submitted/generated before.

Please assist

---

<div class="post-metadata">

**Author:** ![James](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@James](https://zatca1.discourse.group/u/James)\
**Post date:** [November 25, 2024, 1:53pm UTC](https://zatca1.discourse.group/t/invalid-otps-in-simulation-env/3765/9 "2024-11-25T13:53:32Z")

</div>

I have also recreated CSR using the following command : fatoora -Sim -csr -csrConfig csr-config-example.properties -privateKey Key1 -generatedCsr CSR1-pem . Still not working.

---

<div class="post-metadata">

**Author:** ![Aturkistani](https://avatars.discourse-cdn.com/v4/letter/a/8baadc/32.png) [@Aturkistani](https://zatca1.discourse.group/u/Aturkistani)\
**Post date:** [November 27, 2024, 8:17am UTC](https://zatca1.discourse.group/t/invalid-otps-in-simulation-env/3765/10 "2024-11-27T08:17:53Z")

</div>

Dear @James,

transaction was submitted/generated before,means that you have already made a successful request using the same CSR.

If you were unable to save it, then please re-generate the CSR and kick off the process again from the beginning with a new OTP.

Thank you,
