#morunas - Adding subscription items
1 messages ยท Page 1 of 1 (latest)
Happy to help but I am still a bit unclear on the situation. So you want to add some or all of the rest of your products but do not have Price objects for them?
Hmm allow me to reiterate and explain step by step, perhaps it's easier to explain this way:
- Customer A buys an yearly subscription on Product P1
- Customer A buys another yearly subscription on Product P2
- Half a year later Customer A decides to buy a "full plan" subscription, there is 50% left on P1 and P2 subscriptions, so P1 and P2 should be cancelled, the unused time on those subscriptions prorated into the full plan subscription
In other words, Stripe's offering only covers changing from 1 Subscription to another Subscription... but doesn't cover changing from N subscriptions to 1 "master" subscription.
I am already using the Invoice::upcoming to correctly preview an invoice with the 50% on P1 and P2 for example (as negative amounts / credit).
My issue is when I now want to create the new "full plan" subscription... how do I credit back the remainder amount from the other subscriptions.
The "full plan" also has a product... but what I want is to add "credit back" for the ongoing subscriptions that will be cancelled, in favor of the master subscription
Perhaps I need to use "Credit Notes"?
I think you should be able to do that with a subscription update call. Checking in to the syntax of that
Perhaps I should have clarified that the subscriptions on P1 and P2 don't necessarily have the same billing anchor
So it's not going from one subscription with 2 items, to another subscription with 1 item... it's going from 2 subscriptions, each with 1 item, to another subscription
Imagine that on Disney+ you could subscribe to Marvel... and then later you subscribe to National Geographic as well on Disney+... and then at a point you want "a full plan" with proration on the remaining time for each of the other subscriptions
Gotcha. Unfortunately I don't think we have a built in solution for consolidating two separate subscriptions in to one like that. You could preview the prorations for each and use what you find there to discount the initial period on your new subscription, but unfortunately I don't think you can do all of this with one call
ya, now we are aligned ๐
thing is... when I run Invoice::upcoming, I can add invoice_items... and as I calculate the "multi-proration" on our side... it works fine for previewing such a change
what I need to know then is how can I credit back the customer... and that seems to be with credit notes
however, when I create a subscription... and invoice is also created and attempted to be charged immediately
is there a way to "create a subscription but not charge it" so I can add a credit note to its first invoice?
subscription.collection_method is either "chage_automatically" or "send_invoice"... none of which tells it to not run yet
ah! I found something... https://stripe.com/docs/billing/invoices/subscription#first-invoice-extra
Learn how to manage subscription invoices.
So... it seems a bit overkill... but I could "create new one-time prices" and use the add_invoice_items
Hello! Taking over and catching up, hang on...
Have you tried setting payment_behavior to default_incomplete? https://stripe.com/docs/api/subscriptions/create#create_subscription-payment_behavior
Heh hi ๐ thanks and good luck catching up ๐ this one ain't easy (at least for me)
I have not tried anything... just been digging trying to find a solution instead of trying things ๐
(I know sometimes "trying" is a faster way... but bare with me)
so if I set payment_behavior to default_incomplete... I understand the subscription status will be incomplete until the payment succeeds... but Stripe would still automatically create the invoice and attempt to charge it when I call Subscription::create, correct? Or did I misunderstand
No, if you use default_incomplete the Invoice and Payment Intent will be created, but payment won't be immediately attempted by Stripe. You would need to trigger confirmation of the Payment Intent yourself.
Before that happens you could add a credit note to the Invoice.
Ahhh ok, so
- create subscription w/ default_incomplete
- fetch upcoming invoice for that subscription
- create credit note on that invoice
- attempt to charge the invoice
Yes, I think that's what you should try, to see if it fits your use case as expected.
will do, thanks ๐
Hi again @blazing venture, the default_incomplete works as you described, but then it seems that when I get the subscription upcoming invoice, I don't get its ID, which I need for creating a credit note
The upcoming Invoice API is a preview of the next Invoice that will be created. The Invoice doesn't actually exist yet, so there's no ID for it.
What exactly are you trying to do?
I am trying to implement the steps I described above (1-4)
I am confused sorry. When I create the subscription with default_incomplete... how do I then get the pending invoice to add the credit note to it?
The upcoming invoice endpoint is not involved in this process at all.
ok
When the Subscription is created it will immediately create the first Invoice, which you can find in the Subscription's latest_invoice property.
That Invoice will have a Payment Intent, and the Payment Intent needs to be successfully confirmed to start the Subscription.
Ok. I didn't see the latest_invoice. Sorry and thank you