#kasvith-checkout-price_data
1 messages ยท Page 1 of 1 (latest)
Hi there ๐ yes, that is possible. Rather than passing us IDs of existing products/prices, you can pass in the actual amounts via the parameters inside of line_items.price_data
https://stripe.com/docs/api/checkout/sessions/create?lang=python#create_checkout_session-line_items-price_data
in here it says product name is required, does this means stripe will create a product internally with the given name and associate it in future?
Lets say Fruit Cake was used as the name of product and API sets the amount dynamically(5USD)
and next time another customer buy new Fruit Cake for 10USD(API will set price)
or this is only for the record?
It will create a product object within your account, but it won't link that to future purchases based on name. You could reuse that product if you wanted to, but you would need to pass the product's ID for that to occur.
In the scenario you mentioned, at the end of it you would have two distinct product objects with the same name and different prices.
superb, would be cool to mention that in the above API docs ๐ thank you
Thanks for that feedback! Always happy to help ๐
one question, its not possible to set prices for each item with that right? i didnt see a field to set that
It is, line_items is an array of hashes, so you would create an entry in that array for each item and then set the price_datafor each entry accordingly.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Yup. So inside of line_items you'd have an object for each item you're customer is purchasing, and for each of those items you'd specify the amount to charge with the price_data.unit_amount parameter.
Oohh, that I'm not familiar with
thank you for the help btw
Any time!
would be cool to have this as a dedicated article in docs