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

Offline Initialization Issue with Wisepad 3

Open jongbelegen opened this issue 10 months ago • 2 comments

Hey Stripe Team,

I'm encountering an issue with the Stripe Terminal React Native SDK on iOS for offline payments on the Wisepad 3. Offline payments work awesome when initializing the SDK when the device is online.

When starting the app without an internet connection I get the following error:

ERROR Couldn't fetch connection token. Please check your tokenProvider method

The hook also keeps returningisInitialized to false. I'm experiencing this behavior in dev mode. On production builds it seems to get initialized as you would expect. (Maybe some HTTP caching?)

Here's what I need to know:

Should I be caching the last successful requested token for offline use in my fetchTokenProvider function like this pseudo code, or should the stripe SDK handle this internally?

const fetchTokenProvider= async () => {
  try {
    const response = await fetch(`api/stripe-terminal`, { method: "POST", headers: { "Content-Type": "application/json" } });
    const { secret } = await response.json();
    lastSecret = secret;
    return secret;
  } catch (e) {
    return lastSecret;
  }
};

Some documentation about this would also be helpful I think.

Thanks in advance!

jongbelegen avatar Apr 11 '24 20:04 jongbelegen

hey @jongbelegen are you still running into this issue?

nazli-stripe avatar Jun 12 '24 05:06 nazli-stripe

I guess by trail and error we figured it out. It seems that stripe SDK always prefers to do caching itself (because otherwise ill get an error that the token was already used). But it could be a bit better described in the docs that its ok for fetchTokenProvider to fail on prod.

Is it correct that the location of the terminal needs to be in proximity for this caching mechanism to work?

jongbelegen avatar Jun 12 '24 10:06 jongbelegen