stripe-terminal-react-native icon indicating copy to clipboard operation
stripe-terminal-react-native copied to clipboard

When starting a payment using simulated reader, an expired API key is thrown

Open brunoambr opened this issue 1 year ago • 6 comments

Describe the bug When starting a payment using simulated reader, an expired API key error is thrown. Error occurs sporadically and does not happen in every device. It happens very quickly if simultaneous payments are made.

To Reproduce Steps to reproduce the behavior:

  1. Start "StripeTerminalProvider" with a simulated reader.
  2. Error should occur sporadically.
  3. When trying again, the error is not thrown and Tap to Pay operation completes successfully.

Expected behavior Error should not occur, because it resolves automatically by trying again. I suspect that it is related to StripeTerminalProvider's token auto management.

Screenshots image

Stripe Terminal React Native SDK version

  • ^0.0.1-beta.14

Smartphone (please complete the following information):

  • Device: iPhone 11
  • OS: iOS 17.2.1

brunoambr avatar Jan 04 '24 19:01 brunoambr

@brunoambr is this your simulated reader for Tap to Pay on iPhone? I wasn't able to repro it on my device. Can you try it out with the latest version 0.0.1-beta.15 or using our example or dev-app, and let us know if you run into the issue there as well?

nazli-stripe avatar Jan 17 '24 19:01 nazli-stripe

@nazli-stripe Yes, it is my simulated reader (iPhone device). But it happens using an iOS simulator too.

I was able to reproduce using dev-app and 0.0.1-beta.15.

Screenshot 2024-01-19 at 14 12 01

Steps to reproduce:

  • Run two projects instances (for example, a simulator and a physical device) and try to start a payment simultaneously (using the same API test key).

  • Sometimes, one of the readers will disconnect unexpectedly (it could happen at any step, I was able to reproduce while creating a payment intent or processing it) and the expired API key error should be the cause.

Maybe it will only happen when using a simulated reader? I wasn't able to reproduce without it.

brunoambr avatar Jan 19 '24 17:01 brunoambr

Run two projects instances (for example, a simulator and a physical device) and try to start a payment simultaneously (using the same API test key).

Do you mean the same connection token? Each token is only supposed to be used with one instance. Your tokenProvider should return a new ConnectionToken every time it's called

nazli-stripe avatar Feb 08 '24 21:02 nazli-stripe

@nazli-stripe No, tokenProvider function is implemented in back-end (.NET) as follows: Set up the connection token endpoint.

I was referring to Stripe's account key when (API test key) (StripeConfiguration.ApiKey) which is the same (because it is the same account).

I can confirm, after more tests, that this behavior is only happening when using Stripe's simulated reader.

brunoambr avatar Feb 20 '24 12:02 brunoambr

Hello @brunoambr, I'm experiencing the same issue. After completing a payment and waiting for about one minute, attempting to make another payment results in the following error:

[Error: Expired API Key provided: pss_test_YW*********************************************************************_******kinr]

This consistently occurs after the mentioned time interval.

Did you manage to resolve this?

Brunowilliang avatar Mar 14 '24 14:03 Brunowilliang

@Brunowilliang I'm not using the simulated reader anymore, so the error does not occur. I couldn't find another alternative.

brunoambr avatar Mar 25 '24 16:03 brunoambr

Hi @brunoambr , we will be closing this ticket for now since we cannot reproduce. Feel free to reopen if this becomes a pressing issue again.

dmatthews-stripe avatar May 07 '24 18:05 dmatthews-stripe