I am testing out my web payments sdk connecting to create payment from the payments api, and when I test for an error using incorrect cvc or zip code, and then correct it and try again I get an error returned rror: The provided idempotency key has already been used.
How can I get a new one if someone changes info in the payment form after getting an error?
Idempotency keys can be anything, but they need to be unique. Virtually all popular programming languages provide a function for generating unique strings. You should use one of these language calls.
I get that. I am using a function for that, but then I guess I need to call it again if they provide an incorrect zip code and then correct it? Cause I get an error on the key when trying to resubmit.
As a work around, I ended up creating a new idempotency key for every call to CreatePayment, It only seems to matter at this point. Testing continues!!
I found a rather simple solution for me. In the ‘sq-payment-flow.js’ file I added this to line 30 (may be slightly different in yours )
window.paymentFlowMessageEl.innerText = message + ‘\r\n\r\n please edit errors and re-send’;
The card window remains unchanged with this message under the send button. I find they can edit any portion of the entry then hit ‘pay’ and it works