#_kevinx
1 messages · Page 1 of 1 (latest)
Yes, you can have one subscription with prices that are all on the same interval. If they ever have different intervals you will need separate subscriptions
Oh also you can have one-time prices on the same session if you have a startup fee or something
Thanks, but when I test the submission from the front end, all items and prices are showing up in the checkout page instead of single item
I have a hidden input with price id when submitting btw
So if I have an array of items in the session API, how does the check out page determine which items to render on the check out page?
I assume it is based on the input value from the front end when submiting the form right? such as input value = price id
Is there any example for mutiple items submission and handling? all the samples in Stripe doc are single item from what I read so far
Hey sorry the server is busy so I am just getting back to this. Can you tell me more about this hidden input? As far as I know Checkout will display all of the items in its line items and that is a list that you pass in from your backend code
Not immediately sure if there is a sample but it really is just a matter of copying what the list item looks like. Ex: const session = await stripe.checkout.sessions.create({ success_url: 'https://example.com/success', line_items: [ {price: 'price_123', quantity: 2}, {price: 'price_456', quantity: 4}, ], mode: 'payment', });
ok, thanks, what do I need to do if the buyer only want price_123 and quantity 1
and the next buyer wants price_456 and quantity 3
How to manage the front end to separate them
do I need to pass price id and quantity number from the front end to the API?
such as priceID = req. body, priceID
quantity = req.body.quantity?
I thought the API looking up the price ID passed to it and react accordingly, but based on what you mentioned, it just take everything from the line_items array and put them on the check out page?
Yes that would be it, your frontend will tell the backend what the user wants and then the backend creates the list of items based on that and passes it to Stripe via the API
And yes, the Checkout Session will display all the items that you tell it to
One other option is adjustable quantities. So you could just send your users to a default Checkout Session and let them choose on the page
Here is the article where I saw the hidden input to pass price id value
Got you, thank you very much @languid canopy
how to add adjustable quanitity to the checkout btw
I don't see it in either product api or checkout session api doc
Gotcha, haven't had time to look at that blog post fully but I think that that HTML was implying that /checkout is a backend endpoint that the value is sent to.
Here is the API reference for adjustable quantities https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items-adjustable_quantity
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Great, thank you @languid canopy !! Have a good day there!