Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(plus): load stripe.js for fraud prevention #9318

Merged
merged 2 commits into from
Oct 30, 2023

Conversation

fiji-flo
Copy link
Contributor

Summary

Internal requirement by SubPlat: https://mozilla-hub.atlassian.net/browse/MP-455

@fiji-flo fiji-flo requested a review from LeoMcA July 17, 2023 12:19
@github-actions github-actions bot added dependencies Pull requests that update a dependency file plus work around features related to MDN Plus labels Jul 17, 2023
Copy link
Member

@LeoMcA LeoMcA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of nits, looks good overall.

Another question I'm not sure about, do we want to turn this off if DEV_MODE or WRITER_MODE are set? Will loading this script locally when not necessary throw off the fraud detection? I guess we have to load it for local dev to ensure it doesn't break anything, but it doesn't need to load with WRITER_MODE set, though do we already turn off plus features in the yari we ship to npm for content?

@@ -0,0 +1,4 @@
import "@stripe/stripe-js";
export default function Stripe() {
return <></>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think generally better:

Suggested change
return <></>;
return null;

@@ -167,6 +170,7 @@ function OfferDetails({
}).format(monthlyPrice / 100);
return (
<section className="subscribe-detail" id={offerDetails.id}>
<Stripe></Stripe>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<Stripe></Stripe>
<Stripe />

@@ -0,0 +1,4 @@
import "@stripe/stripe-js";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it's better to use an async import() rather than React.lazy. I'm unsure how something like:

export default function Stripe() {
  (async () => {
    await import("@stripe/stripe-js");
  })()
  return null
}

behaves with re-renders. I guess you could wrap it in a useCallback, but then is it any less "reacty" than just using React.lazy?

@github-actions github-actions bot added the merge conflicts 🚧 Please rebase onto or merge the latest main. label Jul 19, 2023
@github-actions
Copy link
Contributor

This pull request has merge conflicts that must be resolved before it can be merged.

@caugner caugner requested review from mdn-bot and a team as code owners October 27, 2023 10:48
@github-actions github-actions bot removed the merge conflicts 🚧 Please rebase onto or merge the latest main. label Oct 27, 2023
Copy link
Contributor

@caugner caugner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, let's merge this on Monday as is.

@caugner caugner merged commit 88f000e into main Oct 30, 2023
16 checks passed
@caugner caugner deleted the MP-455-improve-fraud-resistance branch October 30, 2023 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file internal plus work around features related to MDN Plus
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants