#jeanbaptisten
1 messages ยท Page 1 of 1 (latest)
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
alternatively there can be more complex solutions like using Connect to connect the two accounts together and then using https://stripe.com/docs/payments/payment-methods/connect#cloning-payment-methods to clone a given PaymentMethod but it really depends on the specifics
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 ?
no there isn't a clean way of doing that, it's a common ask though
another option is creating multiple instances though
And it is possible ?
Using loadStripe method will simply return the same instance
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)
Ahah it's that simple then
I'm not sure how to do that with loadStripe and the React wrapper
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 ?
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
Oh I see, thank you for the information