#g105b
1 messages · Page 1 of 1 (latest)
I think I'm misunderstanding how prices and products relate.
Hello! Looking...
Sorry to bombard you, but I think I can refine my question. It seems I was mistaking unit_amount for the number of items being purchased, but I think unit_amount should actually be the price, in cents? The problem I'm having is that I already have a Product in the Stripe dashboard, with an associated Price. I don't want to be hard-coding prices in my code, as it's already defined in the dashboard.
Ah, yep, that's correct.
You should pass the Price ID instead of specifying price_data in that case.
Oh, that sounds like a simple fix.
Oh, I picked price_data because it was the only way to supply a product_id... but do I not need to reference the product if I reference the price?
Yep, you want to set price to the ID of your Price: https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items-price
You do not specify the Product ID. The Price is nested under the Product and, thus, specifies the Product implicitly.