#morunas - Adding subscription items

1 messages ยท Page 1 of 1 (latest)

merry hornet
#

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?

muted urchin
#

Hmm allow me to reiterate and explain step by step, perhaps it's easier to explain this way:

  1. Customer A buys an yearly subscription on Product P1
  2. Customer A buys another yearly subscription on Product P2
  3. 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"?

merry hornet
#

I think you should be able to do that with a subscription update call. Checking in to the syntax of that

muted urchin
#

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

merry hornet
#

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

muted urchin
#

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

#

So... it seems a bit overkill... but I could "create new one-time prices" and use the add_invoice_items

blazing venture
#

Hello! Taking over and catching up, hang on...

muted urchin
#

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

blazing venture
#

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.

muted urchin
#

Ahhh ok, so

  1. create subscription w/ default_incomplete
  2. fetch upcoming invoice for that subscription
  3. create credit note on that invoice
  4. attempt to charge the invoice
blazing venture
#

Yes, I think that's what you should try, to see if it fits your use case as expected.

muted urchin
#

will do, thanks ๐Ÿ™‚

muted urchin
#

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

blazing venture
#

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?

muted urchin
#

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?

blazing venture
#

The upcoming invoice endpoint is not involved in this process at all.

muted urchin
#

ok

blazing venture
#

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.

muted urchin
#

Ok. I didn't see the latest_invoice. Sorry and thank you

blazing venture
#

No worries! ๐Ÿ™‚

#

If you need anything else just let us know! ๐Ÿ™‚

muted urchin
#

It worked ๐Ÿ˜„

#

you guys have some awesome dev support right here ๐Ÿ˜‰