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 loadStripe('Pusblishable Key',{'Connected account ID'}) and set that to a const.
now I dont undestand how are we supposed to get the ID that is stored somewhere say a database?
As a reference please look at this and here (In Step 3 ...).
What I'm currently doing is something like this
import React from 'react';
import ReactDOM from 'react-dom';
import {Elements} from '@stripe/react-stripe-js';
import {loadStripe} from '@stripe/stripe-js';
import CheckoutForm from './CheckoutForm';
//btw I have set this to const and to let and none work
const stripePromise =
fetch("url", {
method: "POST",
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
anything:window.sessionStorage.getItem("Variable Account")
//here store something that will tell what account to pull ID data from
})
}).then(data => data.json()).then((result)=>{
return(loadStripe('KEY',{stripeAccount:result}))
})
class App extends React.Component{
render(){
return(
<Elements stripe={stripePromise}>
<CheckoutForm />
</Elements>
)}
}
export default(App)
but the const seems to not load correctly, if one goes with the regular flow of the app say from myapp.com/home -> click myapp.com/home/something-> then myapp.com/home/something/payment stripe is not loading but one refreshes the browser now works but that tells me i'm doing maybe something wrong or I have to make the app refresh in 'componentDidMount()' maybe?
One can set it to be static but connected accounts can be many so if anyone can help me with this I would appreciate it