-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
[eCom Tutorial] Refactor to function components and use loadStripe
helper.
#21675
Conversation
Thanks for the PR! We'll want to verify the technical instructions, so I've added this to our list for doing so. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, @thorsten-stripe! I have a few comments and questions and I still need to walk through this but wanted to get an initial round of suggestions in a little faster! Thanks so much for updating this and let me know if I can clarify anything.
|
||
### How does the StripeJS plugin work? | ||
Stripe provides a JavaScript library the allows you to securely redirect your customer to the Stripe hosted checkout page. Due to [PCI compliance requirements](https://stripe.com/docs/security), the Stripe.js library has to be loaded from Stripe's servers. Stripe provides a [loading wrapper](https://github.com/stripe/stripe-js) that allows you to import Stripe.js like an ES module: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stripe provides a JavaScript library the allows you to securely redirect your customer to the Stripe hosted checkout page. Due to [PCI compliance requirements](https://stripe.com/docs/security), the Stripe.js library has to be loaded from Stripe's servers. Stripe provides a [loading wrapper](https://github.com/stripe/stripe-js) that allows you to import Stripe.js like an ES module: | |
Stripe provides a JavaScript library that allows you to securely redirect your customer to the Stripe hosted checkout page. Due to [PCI compliance requirements](https://stripe.com/docs/security), the Stripe.js library has to be loaded from Stripe's servers. Stripe provides a [loading wrapper](https://github.com/stripe/stripe-js) that allows you to import Stripe.js like an ES module: |
``` | ||
|
||
to the end of the `<body>` tag across all of your pages. This helps facilitate Stripe's [fraud detection](https://stripe.com/docs/stripe-js/reference#including-stripejs). | ||
Stripe.js is loaded as a side effect of the `import '@stripe/stripe-js';` statement. To best leverage Stripe’s advanced fraud functionality, ensure that Stripe.js is loaded on every page of your customer's checkout journey, not just your checkout page. This allows Stripe to detect anomalous behavior that may be indicative of fraud as customers browse your website. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be "StripeJS" or "Stripe.js"? Does it matter from your perspective? Even if not, I'd like to pick one to use consistently throughout the tutorial so that the question doesn't come up for readers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, thanks, will update to Stripe.js throughout 👍
--- | ||
|
||
In this advanced tutorial, you’ll learn how to use Gatsby to build the UI for a basic e-commerce site that can accept payments, with [Stripe](https://stripe.com) as the backend for processing payments. | ||
|
||
- Demo running [on Netlify](https://gatsby-ecommerce-stripe.netlify.com/) | ||
- Code hosted [on GitHub](https://github.com/thorsten-stripe/ecommerce-gatsby-tutorial) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this demo was already linked but we (the Learning team) are trying to house example code in the examples
directory. That way, we aren't as reliant on the community to maintain them. Would you mind adding a copy to that directory and linking to that instead?
@@ -12,20 +15,16 @@ Benefits of using Gatsby for e-commerce sites include the following: | |||
- Blazing fast performance when your pages are converted from React into static files | |||
- Easy to host |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't look like this was a change you made but avoiding words like "simple" and "easy" is important for the docs. Would you mind sharing why you think Gatsby + Stripe is a good choice? These are general Gatsby talking points.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, thanks, will update throughout. Yes, these talking points are more about why use Gatsby for eCommerce use cases. I'll add a callout that with the client-only Checkout no server component is needed.
|
||
const containerStyles = { | ||
const conatinerStyles = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const conatinerStyles = { | |
const containerStyles = { |
} | ||
`} | ||
render={({ skus }) => ( | ||
<div style={conatinerStyles}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<div style={conatinerStyles}> | |
<div style={containerStyles}> |
@AishaBlake thanks so much for the review and suggestions :) I've incorporated them and added the sample code to the examples directory. PTAL |
…atsbyjs/gatsby into thorsten-stripe-refactor-ecom-tutorial
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed a few files we didn't need but the rest of this looks good! Thank you for jumping in with this update!
…efactor-ecom-tutorial
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated one of the screenshots but this looks good to go. I'm going to hold off on merging for a bit until I hear back from Core.
…efactor-ecom-tutorial
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to double check that this didn't need direct input from Core and I got my answer, so I'm going to go ahead and merge this in. Thank you again for the contribution!
Thank you, appreciate your help with this! :) |
@thorsten-stripe would you mind verifying my interpretation of "checkout journey"? This sentence could use some clarification either way. I'm happy to write a quick edit but wanted to check with you first! |
@AishaBlake yes, your explanation is spot on. I might include the product catalogue overview and cart pages (if you have any of those). Also, it looks like we need to update https://www.gatsbyjs.org/docs/processing-payments-with-stripe/. I didn't even know that existed 🙈 |
Description
I've updated the demo site to use function components, and use the new
stripe-js
module:Documentation
gatsby-stripe-plugin
see deprecation note: https://www.npmjs.com/package/gatsby-plugin-stripe