From the course: Next.js Ecommerce: Build a Shopping Platform from Scratch

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Stripe payment component

Stripe payment component

All right, guys. So we left off with this Stripe payment component that's just returning some text in the order page or order table, whatever you want to call it. And then we need to do quite a bit here now. And it's not too bad, but we're using the StripeJS package and the React StripeJS package. And a lot of the stuff we're doing is on this page, just in a different setup. But we're using all the same stuff, loadStripe, which will instantiate a Stripe object that gives us access to the Stripe API. We have this elements, which is a container or a provider, I should say, that wraps around the form. And that takes in a Stripe promise, which is created using load Stripe. And then in the form, we have a payment element component. That's where the credit card input, the expiration date input, all that stuff is placed. What else? when we actually submit the form, we call this stripe.confirmPayment. And that stripe variable comes from the useStripe hook. We also have this elements from…

Contents