Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offline Initialization Issue with Wisepad 3 #668

Open
jongbelegen opened this issue Apr 11, 2024 · 2 comments
Open

Offline Initialization Issue with Wisepad 3 #668

jongbelegen opened this issue Apr 11, 2024 · 2 comments

Comments

@jongbelegen
Copy link

jongbelegen commented Apr 11, 2024

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!

@nazli-stripe
Copy link
Collaborator

hey @jongbelegen are you still running into this issue?

@jongbelegen
Copy link
Author

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?

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

No branches or pull requests

2 participants