questionmark
questionmark

Reputation: 1

Handling Customizable Products with Stripe

So far, I have been able to create a checkout session and make successful payments using react and node. But I can't figure out how to pass in attributes like the color and size of the order, and then displaying the images accordingly. So far, I have my cart items stored in an object and managed by redux. How would I use the information in this object to make stripe payments? Would it be better for me to connect this information to a database?

Upvotes: 0

Views: 121

Answers (1)

koopajah
koopajah

Reputation: 25602

The best option here is to store this as metadata on each Price object. You can have a Product that is your t-shirt and then have one Price per version of the t-shirt that has metadata keys such as the size and the color. That way when you look at a Session that was completed after a payment, you can look at each LineItem and check with Price is associated with it and its metadata for the size or color!

So if someone orders a red Large t-shirt you pass price_123 while the blue one would be price_ABC and you store that mapping in your own database for example.

Upvotes: 1

Related Questions