Idempotency key and retrying charge end point

Hi square support team

 

I got the payment API working, but what I dont quite understand is how should I use Idempotency key, this also related to how to properly reattempt charging the customer again. The question boils down to . Is it Per key per transaction. or per key per attempt at charging the card, or reuse the same key only there is a system error, so I am retrying the charge without user entering any new information? 

 

For example. I currently assign an Idempotency key when to each shoppingcart, the shoppingcart is unique for each session.  so during testing if a user's card was denied for say wrong CVV. user is redirected back and told to try again after re-entering their correct card info. Then do I charge the card again using the same Idempotency key. or assign a new Idempotency key? 

 

 

Tags (1)
1,525 Views
Message 1 of 3
Report
2 REPLIES 2

This is OP.  Felt the above is too confusing. in short my question is. should I assign new Idempotency key for each attempt at charging the card; if the card or order information has been updated. (such as CVV is updated or order total is updated). 

 

in an other word, only use the same idempotency key to re attempt charging if square did not respond anything after the first attempt. 

 

 

1,522 Views
Message 2 of 3
Report
Alumni

I think you've got the right idea. 

 

You should use a different idempotency key for each "conceptual" charge. So if somebody comes to your site, and tries to buy something, that would be one idempotency key. If they change their order or credit card information, then you would need a new key. You really only need to use the same key with a request when you for some reason don't retrieve (or forget) what your response from Square is. 

1,514 Views
Message 3 of 3
Report