#musty
1 messages ยท Page 1 of 1 (latest)
๐ happy to help
Hey thank you, hopefully it makes sense, there's a lot of text haha, let me know if you need anymore context
Hi there! Give me a few minutes to read/understand your question ๐
- When creating our subscription plans, does it make sense to use quantity or pass the number of tokens in as metadata? What is standard practice?
That's completely up to you, both approach work. Using thequantitywould make it easier to increase/decrease the quantity if needed. If this can't happen, thenmetadatamight be simpler.
- My most pressing issue is in regards to upgrading, simple proration won't really help us because the customer may use some of their tokens before they upgrade.
Makes sense, then you shouldn't use Stripe's proration. You can passproration_behavior: nonewhen updating the subscription, and then handle proration on your end by updating the number of remaining tokens in ametadatafield.
ok got you, ideally we want to have fixed number of tokens on each plan and if clients want additional they would have to either upgrade or buy standalone tokens. I just thought quantity would be easier from an upgrade calculation perspective
Ok so in the case of the client having used 3 tokens and they want to upgrade from the $50 plan to $100 plan with 15 tokens. How would we handle this via the Stripe checkout and when would we pass the remaining tokens in via metadata?
Ok so in the case of the client having used 3 tokens and they want to upgrade from the $50 plan to $100 plan with 15 tokens.
The exact logic is completely up to you. For example: do you want to charge the customer immediately to the new price when they upgrade, or charge the new price at the next billing period?
Then just keep track of the quantity of token in metadata. something likemetadata.tokens_current_period: 15andmetadata.tokens_last_period: 2(ormetadata.tokens_proration: 2)
ok cool, that makes sense, I definitely want to charge immediately but how would I handle the custom proration? E.g. since metadata.tokens_last_period: 2, then I want to discount the equivalent value of those 2 tokens. In the end, on my side, the client will only have the new 15 tokens
Since they've paid upfront for the last period, I'm thinking a line item showing a discount makes sense
Hi there ๐ jumping in as my teammate needed to step away.
You will need to calculate those prorations on your end, and then tell us how much you'd like to charge the Customer for. Are you planning to move the Subscription to the next billing cycle as part of the upgrade process? If so, I believe adding an Invoice Item to the Subscription would be a good option, but if you're not moving the Subscription to the next billing period then you'll likely want to process a one-off payment (possibly using an Invoice for that).
Hey toby, I think @oblique cipher and I stepped away at the same time haha, sorry for the delay. By next billing cycle do you mean ending the current billing cycle and starting a new one? If so yes, I intend to do it like this. Ideally when they get a new set of tokens its a fresh billing period. What do you mean by adding an invoice item?
When you create an Invoice Item object, you can provide a subscription parameter to indicate that it should be associated with a specific Subscription. Then when that Subscription generates its next Invoice it will pull in that Invoice Item.
https://stripe.com/docs/api/invoiceitems/create#create_invoiceitem-subscription
When creating the Invoice Item you can provide a negative value to amount to create a discount on the new Invoice to compensate for the previous payment.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Ok got you, so is this done after checkout? When we create the negative amount does this show up on the checkout too?
Ideally the flow would be that user clicks upgrade, gets taken to a stripe checkout page and can see the 'prorated. amount' and how many tokens they will get with a disclaimer
Oh, I didn't realize you were planning on using a Checkout Session for this. Is there a particular reason you're considering doing so? The Subscription should already have details to process a payment and be able to do so without Customer intervention.
Yeah the issue I have is that when using a checkout session, it needs to be clear what happens to the tokens the customer had. And how much they're getting charged. If they purchased a plan 3 days ago and used a few tokens they shouldn't see a completely new payment in full for the upgrade plan
im also looking to have optionality, so some customers can pay via card in a checkout or pay via invoice, is this possible via the checkout page or do I need to handle this before a checkout session is created?
Typically Checkout Sessions are not involved with Subscriptions after the first payment.
oh really
If you're moving Subscriptions to their next billing period, then they will generate an Invoice, and once that Invoice is finalized it will have a link to its Hosted Invoice Page which is kind of like a checkout session for Invoices:
https://stripe.com/docs/api/invoices/object#invoice_object-hosted_invoice_url
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
so how would it work in most cases if a client wants to upgrade via the website
Via what website?
Your site would make a request to update the Subscription, and then the Subscription handles processing the payment.
If you create a Checkout Session, and also move the Subscription to the next billing period at the same time, then you'll end up processing two payments for your Customer. One from the Checkout Session, and another from the automatic process of the Subscription's lifecycle. To avoid this you would need to suppress our default Subscription behavior, which would be a bit complex.
My thinking of how to model the flow that I believe you're describing is:
- Calculate the amount you want to prorate on your end
- Create an Invoice Item with a negative
amountand the ID of the related Subscription in thesubscriptionparameter. - Create a request to update the Subscription to change the Price that the Customer is subscribed to, and set
billing_cycle_anchortonowto move the Subscription to the next billing period. - Allow the Subscription's automatic flows to handle the processing of the payment, with a flow ready to handle the case where that payment fails.
Ok that makes complete sense, so the client just clicks and confirms they want the upgrade and then we sort the rest on our end. The new amount we set gets charged immediately, a new billing cycle begins and we can then issue the invoice with all the information laid out with what was deducted and what was charged?
The Invoice will automatically be created, you do not need to manually issue one.
ahh ok got you, so we update the subscription on our end with the amount then create an InvoiceItem which then links to this subscription?
other way round but yeah
seems pretty clear
if thats correct
Yup, you create the Invoice Item, and it is associated with the Subscription. Then when the Subscription is moved to a new billing period, it begins the automatic process of generating a new Invoice for the new billing period. When doing so, the Invoice will pull in the Invoice Item that you created which will adjust the amount that the new Invoice processes a payment for.
got you!
ok that makes sense man thank you
so if the subscription gets cancelled and then they want to create a new plan again, they'd need to checkout right?
or would it just be a case of us just create a new subscription from our end
If the Payment Method that was being used is fully set up for future payments, then you could create a new Subscription directly. If you want to allow your Customers to also provide a new Payment Method while re-subscribing, then Checkout Sessions may be an easier approach though.