#developer-subscriptions
1 messages ยท Page 1 of 1 (latest)
Yes, when it's first time
and are you using Checkout, or are you creating the Subscriptions directly?
checkout
You can specify these one-time items as line_items when you create the Checkout Session and they'll be automatically pulled into the first Invoice. Subscriptions need to be paid within the first 23 hours otherwise they are automatically cancelled, so if a customer doesn't complete checkout that invoice will eventually be closed
So do I need to create line items and not invoice items?
Yup, that's what you'll want to be doing if you're working with Checkout and it's for subscription creation
I actually already started working on it with invoice items. Could you explain the difference between line items and invoice items and why should I choose one over the other?
I also want to mention that I don't know the items prices in advance - I get the price from a 3rd party api and then set this price for the user
You can use either invoice items or line items, it's just that with Checkout it's usually easier to include any additional one-off prices in line_items to save yourself an API call and guarantee it's on that first invoice of the Subscription
So with line items it will also create an invoice, right?
Yup! An invoice will always be created with Subscriptions in Checkout mode
Is there a difference if the user changes their mind (does not complete session and then go back and chooses another item)? Because with invoice items I understand that the invoice stays for this customer and appears again if I start another checkout for subscription for this customer. So I assume that I need to modify the invoice if they choose another item, or delete it if they don't get an item with their subscription and that's where things get more complicated. (Also, now I understand that this is only for the first 23 hours.) What is the right way to do it? Do I really need to modify the invoice items?
This is another reason why line_items is the cleaner solution - if a user changes their mind and hasn't attempted payment then no Subscription is ever created. If a user does attempt payment then a Subscription will be created and the line items will be on a finalized invoice.
With Invoice Items, if a user changes their mind and hasn't attempt payment then that leaves an Invoice Item on the Customer that you'd have to modify.
If a user changes their mind with line_items I'd suggest expiring the Checkout Session (https://stripe.com/docs/api/checkout/sessions/expire?lang=curl) which will also cancel the subscription if one has already been created, and then create a new Checkout Session
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I think that the reason I chose to go with invoice items when I started working on it is that with line items you need to have a prespecified price (with a price ID), and I don't know the price in advance (I get it from a 3rd party API). Does it make sense or is there a way to specify an amount for line items?
Sorry for all the questions ๐
You can definitely specify an amount for line items using price_data (https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items-price_data)
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
If you also don't have a Product you can set line_items[price_data][product_data] as well to create a product in line
I need to head out, but @ionic remnant can answer any other questions you have!
Sure. Thank you so much!