question

qualwebs avatar image
qualwebs asked David Marginian Deactivated edited

Private token changing on every payment

Hello,

We are facing a strange issue with API token, Created a token for online payment and able to do payment with that. The strange thing is, After every payment, the private token getting changed automatically.

We tried 4-5 payments on sandbox, It changing everytime and returns error below

{

"message": "400 Bad Request",

"error": {

"code": "processing_error",

"message": "Keys for idempotent requests can only be used with the same parameters they were first used with.Try using a different key."

}

}


And it works only after changing the key.

Now, The question is, How to do multiple payments with this case.


Thanks,
Dev

Paymentse-commerce apiAPI Token
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

David Marginian avatar image
David Marginian Deactivated answered David Marginian Deactivated converted comment to answer

I don't know what you mean by API token in this context. The message you attached indicates you are trying to use the same idempotent key with a request that was different than the original. An idempotent key is NOT and shoud NOT be the API token. It is a unique id PER transaction that should be passed to prevent duplicate transactions if the transaction needs to be retried due to network failures, etc. For example, if you initiated a charge but never received a response because the network dropped out. In this case you would retry the same request, with the same idempotency key and it would not result in a duplicate - https://docs.clover.com/docs/ecommerce-accepting-payments#using-idempotency-keys.

4 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

qualwebs avatar image qualwebs commented ·

Hi,

This private token getting changed everytime:
https://i.postimg.cc/yYVvSTgG/screenshot-1422.png

This token we are using to make payment as auth bearer token.


Thanks

0 Likes 0 ·
David Marginian avatar image David Marginian ♦♦ qualwebs commented ·

That token does not change.

0 Likes 0 ·
qualwebs avatar image qualwebs David Marginian ♦♦ commented ·

Hi David,

This is the strange thing, It's changing after every payment.


0 Likes 0 ·
Show more comments
David Marginian avatar image
David Marginian Deactivated answered David Marginian Deactivated edited

Yes, this has nothing to do with access tokens, as I indicated in my original response. I watched your video, and looked at the requests you are making in our logs. I urge you to read about what idempotency keys are. You are making subsequent requests that are different (one is for 200, the next is for 300) with the SAME idempotency key ("idempotency-key": "sdfsfsdhhfsdhjdsjhdshjds"). This value is passed in the requests headers (check the Headers tab in POSTMAN).

https://docs.clover.com/docs/ecommerce-accepting-payments#using-idempotency-keys

An idempotency key is a value that MUST BE UNIQUE PER UNIQUE CHARGE REQUEST. It is used to prevent you from making duplicate charges if for example you didn't receive a response for a charge. In that case you can try the SAME EXACT charge request again with the SAME idempotency key and you will be returned the response that that charge returned without making an additional charge. In your case you are making two DIFFERENT charges (one for 200 and the next for 300) which is NOT allowed.

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community