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

[eCom Tutorial] Refactor to function components and use loadStripe helper. #21675

Merged
merged 12 commits into from
Mar 5, 2020

Conversation

thorsten-stripe
Copy link
Contributor

Description

I've updated the demo site to use function components, and use the new stripe-js module:

Documentation

@laurieontech
Copy link
Contributor

Thanks for the PR! We'll want to verify the technical instructions, so I've added this to our list for doing so.

@AishaBlake AishaBlake self-assigned this Feb 25, 2020
Copy link

@AishaBlake AishaBlake left a 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:

Choose a reason for hiding this comment

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

Suggested change
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.

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.

Copy link
Contributor Author

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)

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

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.

Copy link
Contributor Author

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 = {

Choose a reason for hiding this comment

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

Suggested change
const conatinerStyles = {
const containerStyles = {

}
`}
render={({ skus }) => (
<div style={conatinerStyles}>

Choose a reason for hiding this comment

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

Suggested change
<div style={conatinerStyles}>
<div style={containerStyles}>

@thorsten-stripe thorsten-stripe requested a review from a team as a code owner March 2, 2020 04:52
@thorsten-stripe
Copy link
Contributor Author

@AishaBlake thanks so much for the review and suggestions :) I've incorporated them and added the sample code to the examples directory. PTAL

@freiksenet freiksenet added the type: documentation An issue or pull request for improving or updating Gatsby's documentation label Mar 2, 2020
AishaBlake
AishaBlake previously approved these changes Mar 4, 2020
Copy link

@AishaBlake AishaBlake left a 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!

AishaBlake
AishaBlake previously approved these changes Mar 4, 2020
Copy link

@AishaBlake AishaBlake left a 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.

Copy link

@AishaBlake AishaBlake left a 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!

@AishaBlake AishaBlake merged commit 8eb238e into master Mar 5, 2020
@delete-merged-branch delete-merged-branch bot deleted the thorsten-stripe-refactor-ecom-tutorial branch March 5, 2020 16:47
@thorsten-stripe
Copy link
Contributor Author

Thank you, appreciate your help with this! :)

@AishaBlake
Copy link

AishaBlake commented Mar 11, 2020

@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!

@thorsten-stripe
Copy link
Contributor Author

thorsten-stripe commented Mar 12, 2020

@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 🙈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: documentation An issue or pull request for improving or updating Gatsby's documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants