Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Android: Keys for idempotent requests can only be used with the same parameters they were first used with #799

Closed
hariantara opened this issue Jun 29, 2021 · 6 comments

Comments

@hariantara
Copy link

hariantara commented Jun 29, 2021

Step why I got the issue

  1. I have upgrade stripe SDK from 10.4.6 to 16.9.0
  2. and try to update on Java android by following this step Google Play Update #785 (comment)
  3. And try to get token by stripe.createTokenWithCard
  4. after hit that stripe API, I got error response like :

idempotency_error Keys for idempotent requests can only be used with the same parameters they were first used with. Try using a key other than 'Publishable Key Stripe' if you meant to execute a different request.

Environment

  1. "tipsi-stripe": "^9.0.0"
  2. Stripe SDK : 16.9.0

I need your solution how to solve this issue

@suseendiran
Copy link

suseendiran commented Jul 13, 2021

Removing line number 209 in following file can fix this issue.
StripeModule.java

Passing publicKey as idempotentKey cause this error.

Existing code:
mStripe.createCardToken( createCard(cardData), mPublicKey, new ApiResultCallback<Token>() { public void onSuccess(Token token) { promise.resolve(convertTokenToWritableMap(token)); } public void onError(Exception error) { error.printStackTrace(); promise.reject(toErrorCode(error), error.getMessage()); } });

New code: (Removed mPublicKey)
mStripe.createCardToken( createCard(cardData), new ApiResultCallback<Token>() { public void onSuccess(Token token) { promise.resolve(convertTokenToWritableMap(token)); } public void onError(Exception error) { error.printStackTrace(); promise.reject(toErrorCode(error), error.getMessage()); } });

Referral link:
https://stripe.dev/stripe-android/stripe/com.stripe.android/-stripe/create-card-token.html

@ziga-hvalec
Copy link

I have the same problem. Can't add new cards, but can still use them for payment. After removing mPublicKey I can now add cards and everything works. But I don't know if this might break something else. Is this the correct solution? And when will this be fixed? Last update with the 16.10.0 android sdk was on 2021-06-18 almost a month ago? Does no one else have this problem?

@suseendiran
Copy link

suseendiran commented Jul 16, 2021

I hope that doesn't break something, because that is an optional parameter and that parameter is specifically for idempotent key and it must be unique for every different request. So we can't pass public key(same key) for all requests.

You can check the use of idempotent key.

@hariantara
Copy link
Author

Removing line number 209 in following file can fix this issue.
StripeModule.java

Passing publicKey as idempotentKey cause this error.

Existing code:
mStripe.createCardToken( createCard(cardData), mPublicKey, new ApiResultCallback<Token>() { public void onSuccess(Token token) { promise.resolve(convertTokenToWritableMap(token)); } public void onError(Exception error) { error.printStackTrace(); promise.reject(toErrorCode(error), error.getMessage()); } });

New code: (Removed mPublicKey)
mStripe.createCardToken( createCard(cardData), new ApiResultCallback<Token>() { public void onSuccess(Token token) { promise.resolve(convertTokenToWritableMap(token)); } public void onError(Exception error) { error.printStackTrace(); promise.reject(toErrorCode(error), error.getMessage()); } });

Referral link:
https://stripe.dev/stripe-android/stripe/com.stripe.android/-stripe/create-card-token.html

Thanks for your help, I will try first to update tipsi node module first on android side, for first attempt I did add card, and then remove the and, and next once I want to re add again, thats the Idempotency comes out

but currently I move that stripe to Server Side that use uuid v4 to avoid idempotency, it just temporary solution for me

@cybergrind
Copy link
Member

Should work in 9.1.4

@mintheinwin
Copy link

I have the same problem. Can't add new cards, but can still use them for payment. After removing mPublicKey I can now add cards and everything works. But I don't know if this might break something else. Is this the correct solution? And when will this be fixed? Last update with the 16.10.0 android sdk was on 2021-06-18 almost a month ago? Does no one else have this problem?

I had the same this issues in implementation 'com.stripe:stripe-android:20.8.0' version.
But in implementation ('com.stripe:stripe-android:1.0.4@aar'){
transitive=true
} version is fine. What have the problem in the lasted version?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants