409 status code - Duplicate-Invoice error

Same here bro. and during retries, it will go to failure loop as they might now already have those invoices as reported on their side.

Anyways, treat those invoices as reported (for now) since they’re giving 409 status code [used for conflict] and they do agree in error message that they have received the hash before.

The only problem at this point is:

We don’t have an official API response saying that its reported. Since they have mentioned it before that it’s our only source of truth to prove to client/zatca, that this particular invoice is reported or not.

Don’t think they are going to comment on this issue today as its Friday. Lets see in coming days if they can give a closure on this or change how the API behaves [either reverting the behaviour entirely or making a change in current response acknowledging its current reportingStatus tag as ‘REPORTED’.

From the error, it can be seen that the same invoice has been reported. This is good to prevent double reporting for the same invoice.

If the data with this response is recorded on the server, this means we have to treat it like a Rejected Invoice. We need to save the ICV and InvoiceHash as a reference for the next Invoice.

So far I still use the reportingStatus/clearanceStatus REPORTED, CLEARED, NOT REPORTED and NOT CLEARED as a marker that the invoice is recorded on the server.

@ZatcaTeam, can you explain whether an Invoice with Response Code 409 is recorded on the server or not?

For this error there should be no problem, because there is a NOT REPORTED statement in the ReportingStatus.

Thank you.

“The invoice hash will be duplicated for some reason after processing and removing the signed and cryptographic elements. If you process an invoice with the same UUID key and identical details, it may break the hash chain, causing issues. This happens because it regenerates the same sequence of the hash as earlier.”

Hi ZATCA Team,
Today even one of my client reports 140 transactions and 40 were fine but 100 got message,

{“validationResults”:{“infoMessages”:,“warningMessages”:,“errorMessages”:[{“type”:“ERROR”,“code”:“Invoice-Errors”,“category”:“Duplicate-Invoice”,“message”:“Invoice Hash Previously Submitted”,“status”:“ERROR”}],“status”:“ERROR”},“reportingStatus”:“NOT_REPORTED”}

tried to check if any invoice was duplicated or UUID but all are unique in the data so what type of duplication is there on the ZATCA servers. In last 6 months there was no such issue.

thanks

We started getting the same error recently, especially with clients who have slow/weak internet connection. I would confirm that sending the same invoice before was allowed as I have double checked from many logs in our side , So it might be some new implementation on ZATCA API side to prevent duplication , for now we updated our systems to consider the invoice reported if we get this error.

any update on the issue?

@BEX yes, if you receive a 409 error it means that the invoice corresponding to the invoice hash has been either cleared or reported with a 200 or 202 response code previously.

Please note that ZATCA will be introducing an API to validate if an invoice hash has been previously submited, soon.

Regards

Philip

@Malik if you receive a 409 error it means that the invoice corresponding to the invoice hash has been either cleared or reported with a 200 or 202 response code previously.

Please check the invoice hash inside the XML and also the invoice hash in the request header.

Regards

Philip

@eCloud if the API call returns an 409 response then it has NOT been accpeted by the system. Only 200 and 202 responses indicate that the invoice has been reported or cleared.

If you receive a 409 error it means that the invoice corresponding to the invoice hash has been either cleared or reported with a 200 or 202 response code previously.

Regards

Philip

Dears @mohdzeeshan5c0, @plasker, @pmohdameen, @BEX, @Maala, @Arratech, @eCloud , @Adithya_Raviraja, @mohdzeeshan5c0, @mkw, @rudyzidan,

Thanks all for reaching out, Sorry for being late to reply, please find our response as below:

Regarding the 409 which refer to the case that you are submitting the same invoice with the same invoiceHash twice, this is a new enhancement that prevent the TPs to submit the same invoice two time.

For any changing that happened in the xml you need to generate new hash for the xml,
and then to submit it with the new hash,

Even for the case that the invoice that you already submitted the invoice with some warning 202 this means it’s accepted with warning, and you need to fix that warning for the further invoices, this means that you will do some changes on the xml which means that you need to generate new hash for the XML after fixing the warnings, or Errors .

I hope it’s clear enough now for all of you guys, if not please do not hesitate to reach out to ensure comprehensive support as usual.

Thanks,
Ibrahem Daoud.

1 Like

@psinclair
Actually I never got this response. Using ClearanceStatus and ReportingStatus as markers, it is impossible for me to get this response, even if I resubmit the same invoice. because the ICV will change, and the InvoiceHash will change too.

I just want to make sure, how to handle the response with statuscode 409 because this response is a little different from other Rejected Invoices.

@idaoud
Thank you for your turn around. Appreciate it.

We checked in our system but could not find any duplicate invoice with same invoice hash.

But still if we ASSUME that our system is sending the same invoice twice with the same invoice hash, So can we consider that the same invoice previously submitted in the first attempt was successfully REPORTED or REPORTED_WITH_WARNING?

Dear @mohdzeeshan5c0

You need to check that your system is already saving all the reporting invoice with status 200, 202.
and yes, your consideration is correct, that if the response was 409 this means that the invoice in the body already submitted, and you can check it from your system.

Let us assume I have an invoice generated at my system. I then try to report this saved an invoice and was able to do that successfully with Zatca, but when I attempted to log this in my system, an error occurred at my side.

This means that I still have an invoice generated in my system with pending status waiting to be integrated. Before your enhancement, I will always get the same result, i.e. reported. Now, I receive an exception and itis breaking my application.

Either I handle this exception as always to be reported, or you give us an API to inquire, because this cause could easily occur, either from our side or your side.

@idaoud
yes our system do handle the each API response.

But from last few days, we are getting this issue in ~4-5 B2C invoices among ~2000 B2C invoices.

So as you clarified that if we receive 409 status then we can enhance our system to consider these invoices as either REPORTED or REPORTED_WITH_WARNING.

Dear @y.khraishi

Thanks for reaching out, and welcome at our community,

Please note that your system should follow all ZATCA regulations, which means that your system should rely on the API responses even for (clearance, and Reporting),

In your assuming, you mentioned that the invoice has been reported successfully, this mean that the response code will be either 200, 202 (Reported), 409 only appeared when trying to hit the reporting end point with same invoice that already submitted.

In your system you need to capture the response from the endpoint.

I hope it’s clear now.

Thanks,
Ibrahem Daoud.

Hi,
There were 100 invoices with this response and such issue was never there since March24 only happned today and even these invoices were reported first time so no change of duplication. Now sent officially to ZATCA and also manually reported as in our system there is no duplication reported till date so no idea on ZATCA servers what is the status and we are totally blind about that side untill any API is not provided.
In case any invoice failed/error we submit again with no ICV and UUID so no chances of having duplication invoice hash.
Thanks

{“validationResults”:{“infoMessages”:,“warningMessages”:,“errorMessages”:[{“type”:“ERROR”,“code”:“Invoice-Errors”,“category”:“Duplicate-Invoice”,“message”:“Invoice Hash Previously Submitted”,“status”:“ERROR”}],“status”:“ERROR”},“reportingStatus”:“NOT_REPORTED”}

@idaoud
in that case we inevitably need another endpoint to tell us the status of the invoice…etc to avoid double submission from our side. in the scenario we shared in a lot of threads and yet to get a clear answer that what happens if we couldn’t save ZATCA API response in our datastore from the first attempt? does that mean that we won’t be ever able to see the invoice status?

@idaoud
Thanks for responding.

See the problem is, we are getting this 409 error code of “Already Submitted Hash” on our first try of submitting B2C Signed XMLs. Not 200 or 202.

So if we are getting it on first try itself, the only assurance now that we have is ZATCA says its 409 and so its reported, as we don’t have a valid response from ZATCA that its “REPORTED”.

What are we supposed to do till some kind of cross checking API comes in place?

hi @idaoud , we are facing the same issue in our system as well. The invoice that is sent the first time is receiving this error. So we never have the original reporting status for the affected invoice. It is causing a lot of trouble in our automated flow and taxpayers are getting affected because of this.