#jeanbaptisten

1 messages ยท Page 1 of 1 (latest)

terse spindleBOT
frosty edge
#

hi! yes it's a singeton. I think generally the answer is you should determine what Stripe account you're going to use for a given customer interaction before landing on the payment page and then initialise the global Stripe object with the appropriate key

delicate timber
#

I see
For the first question, its kind of what we are doing at the moment
Is there any solution to re-instantiate (is this english ?) or re-define the publishableKey or the singleton ?

frosty edge
#

no there isn't a clean way of doing that, it's a common ask though

#

another option is creating multiple instances though

delicate timber
#

And it is possible ?
Using loadStripe method will simply return the same instance

frosty edge
#

like you can do

var stripeUs = Stripe(pk_test_us_account);
var stripeCa= Stripe(pk_test_ca_account);

...
if(something)
  stripeUs.confirmPayment(pi)
else
  stripeCa.confirmPayment(pi)
delicate timber
#

Ahah it's that simple then

frosty edge
#

I'm not sure how to do that with loadStripe and the React wrapper

delicate timber
#

I'm gonna look forward then, thank you for your help ๐Ÿ™
It looks like we're getting close ! ๐Ÿ˜„

#

Have a nice day too !

#

I have one last question
You're talking about the React Wrapper but we're not using it (or I didn't understood it...)
We're actually using the @stripe/stripe-js module (https://www.npmjs.com/package/@stripe/stripe-js), and a Vue3 application
So... what did you mean ?

frosty edge
#

sorry I assumed you're using React but you're not , so no worries

#

just because loadStripe is often used with React

#

and vanilla JS usually includes the <script> tag

delicate timber
#

Oh I see, thank you for the information