Pass loadedStripe.current to registerWithStripeJs in EmbeddedCheckoutProvider#679
Open
LeSingh1 wants to merge 1 commit into
Open
Pass loadedStripe.current to registerWithStripeJs in EmbeddedCheckoutProvider#679LeSingh1 wants to merge 1 commit into
LeSingh1 wants to merge 1 commit into
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.