#developer-subscriptions

1 messages ยท Page 1 of 1 (latest)

marsh lynx
#

You want to add a one-time item when the customer subscribes for the first time?

open ginkgo
#

Yes, when it's first time

marsh lynx
#

and are you using Checkout, or are you creating the Subscriptions directly?

open ginkgo
#

checkout

marsh lynx
#

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

open ginkgo
#

So do I need to create line items and not invoice items?

marsh lynx
#

Yup, that's what you'll want to be doing if you're working with Checkout and it's for subscription creation

open ginkgo
#

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

marsh lynx
#

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

open ginkgo
#

So with line items it will also create an invoice, right?

marsh lynx
#

Yup! An invoice will always be created with Subscriptions in Checkout mode

open ginkgo
#

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?

marsh lynx
#

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.

open ginkgo
#

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 ๐Ÿ™‚

marsh lynx
#

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!

open ginkgo
#

Sure. Thank you so much!