Skip to content

Pass loadedStripe.current to registerWithStripeJs in EmbeddedCheckoutProvider#679

Open
LeSingh1 wants to merge 1 commit into
stripe:masterfrom
LeSingh1:fix-embedded-checkout-register-wrapper
Open

Pass loadedStripe.current to registerWithStripeJs in EmbeddedCheckoutProvider#679
LeSingh1 wants to merge 1 commit into
stripe:masterfrom
LeSingh1:fix-embedded-checkout-register-wrapper

Conversation

@LeSingh1

Copy link
Copy Markdown

The useEffect that registers react-stripe-js as a wrapper on the Stripe instance passed loadedStripe, which is a React.useRef holding the resolved Stripe value, instead of loadedStripe.current. registerWithStripeJs then checks stripe._registerWrapper, which is undefined on the ref object, so the function always early-returns and the wrapper registration never fires for embedded checkout flows. CheckoutProvider already calls this with the resolved Stripe value.

This change passes loadedStripe.current and uses ctx.embeddedCheckout as the dependency, so the registration runs once the embedded checkout instance has been created with a known-good Stripe ref. Added a unit test in EmbeddedCheckoutProvider.test.tsx that asserts _registerWrapper and registerAppInfo are called with the expected react-stripe-js identity.

Also tightened registerWithStripeJs from stripe: any to stripe: stripe-js.Stripe | null. The internal _registerWrapper is not part of the public Stripe.js surface, so it stays behind a typed cast rather than being declared on the public type.

…ipeJs

The useEffect that registers react-stripe-js as a wrapper passed loadedStripe
(a React.useRef holding the Stripe instance) directly to registerWithStripeJs,
which then checked stripe._registerWrapper. The ref object never has that
property so the function always early-returned and the wrapper registration
never fired for embedded checkout flows.

Pass loadedStripe.current and trigger the effect when ctx.embeddedCheckout
resolves, matching the equivalent registration in CheckoutProvider that uses
the resolved Stripe value. Also tighten registerWithStripeJs from any to
stripe-js Stripe | null, using a typed cast for the internal _registerWrapper
escape hatch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant