Skip to content Skip to sidebar Skip to footer

Stripe Connected Calls From The Front End, Change The Stripe Connected Id Programatically

I'm trying to solve this proble that I cant seem to solve with stripe's API's So when creating a charge with their new version API they say that in the front end we should call loa

Solution 1:

Answered the same as your duplicate question: How to properly load global variable with async values(Reactjs)?

Generally, you'd want to have this account ID available in your app. But if you need to retrieve it, that's fine, but make sure the stripePromise is what you think it is. For example, I can make this work here with a simulated fetch call here: https://codesandbox.io/s/stripe-connect-w-resolve-wts34

Note that I'm managing the Promise explicitly:

const stripePromise = newPromise((resolve, reject) => {
  fetch(...)
  .then(data => data.json())
  .then(result => {
    resolve(
      loadStripe(STRIPE_PUBKEY, { stripeAccount: "acct_xxx" })
    );
  });
});

The fact that you describe this breaking with navigation suggests you might be routing incorrectly. If this is a single page app, the navigation shouldn't cause the App component to re-render.

Solution 2:

You're declaring a const

const stripePromise = const stripePromise = fetch(...

It should be

const stripePromise = fetch(...

This is what I saw at first glance.

Post a Comment for "Stripe Connected Calls From The Front End, Change The Stripe Connected Id Programatically"