diff --git a/packages/stripe_web/lib/src/web_stripe.dart b/packages/stripe_web/lib/src/web_stripe.dart index 39c1e01d..a33f01f5 100644 --- a/packages/stripe_web/lib/src/web_stripe.dart +++ b/packages/stripe_web/lib/src/web_stripe.dart @@ -55,13 +55,21 @@ class WebStripe extends StripePlatform { bool? setReturnUrlSchemeOnAndroid, }) async { this._urlScheme = urlScheme; + if (__stripe != null) { - __stripe!.stripeAccount = stripeAccountId; + // Check if the new stripeAccountId is different + if (__stripe!.stripeAccount != stripeAccountId) { + // Re-initialize with new stripeAccountId + await stripe_js.loadStripe(); + var stripeOption = stripe_js.StripeOptions(); + stripeOption.stripeAccount = stripeAccountId; + __stripe = stripe_js.Stripe(publishableKey, stripeOption); + } return; } await stripe_js.loadStripe(); - final stripeOption = stripe_js.StripeOptions(); + var stripeOption = stripe_js.StripeOptions(); if (stripeAccountId != null) { stripeOption.stripeAccount = stripeAccountId; }