#tungtn1099

1 messages ยท Page 1 of 1 (latest)

rare arrowBOT
quasi sand
#

hi! hmm, well PaymentLinks aren't really involved here. A PaymentLink is for processing a payment, or starting a subscription. Updating an existing Subscription would be done in other ways(like directly calling the API, or using the CustomerPortal, or some other options).

sage lark
#

If I call this

await this.stripe.subscriptions.update(subscriptionId, {
      items: [{
        id: subscription.items.data[0].id,
        plan: planId,
      }],
      proration_date: prorationDate,
    });

Are they charged immediately?

#

planId is the new package plan

quasi sand
sage lark
#

Mine is the When the billing period changes case

#

Because the interval is different?

quasi sand
#

if that is the case, then that resets the billing date to the time that you make the API call and there's an immediate payment due for the start of the new period

sage lark
#

And there is no need for a payment link

#

Alright thanks!

#

Oh wait I have one more question

quasi sand
#

what would happen is it charges the customer's saved payment method, if that succeeds, great, if it doesn't, then you need to get the new Invoice paid(that will become the latest_invoice:"in_xxx" on the Subscription)

#

possible ways to pay that including sending the customer a link to the invoice->hosted_invoice_url for a Stripe-hosted payment page, for example

sage lark
#

oh wait

quasi sand
#

it's about paying the prorated difference between them

sage lark
#

So once they try to change the package

#

A new invoice will be created

#

But if they failed to pay for it

#

The invoice will be held until paid?

#

I think Stripe will try to charge it automatically right?

quasi sand
#

if they failed to pay, the subscription has still changed/updated, just now they have an unpaid invoice and the subscription becomes past_due and your settings for handling that will kick in

sage lark
#

And the past_due will last until the next billing date (which is the original billing date) plus a few days before the subscription gets cancelled?

quasi sand
sage lark
#

I can always set the planId back to the original one if they fail to pay for the new one right?

quasi sand
#

if you use the Pending Update feature mentoned above that's much easier

#

but yes, you can, just it can get very messy to do those rollbacks and not generate extra proration , it's messy but do-able

sage lark
#

If its monthly customer.subscription.updated, the pending_update is null right?

quasi sand
#

that would make sense to me

sage lark
#

I'll give it a try, thanks

sand saddle
#

@sage lark How can I help?

sage lark
#

but yes, you can, just it can get very messy to do those rollbacks and not generate extra proration , it's messy but do-able

#

I'm having some questions on this

#

Because I'm required to do a rollback if the payment fails

#
await this.stripe.subscriptions.update(subscriptionId, {
      items: [{
        id: subscription.items.data[0].id,
        plan: planId,
      }],
    });

If I call this, does it create a proration date?

sand saddle
#

Catching up on context from the thread

#

Is this your 'rollback' call? Anything preventing you using pending updates? Way easier in this context as we handle the 'rollback' automatically

sage lark
#

Anything preventing you using pending updates?
Sorry but I'm not sure if I'm understanding this :(

#

And its not yet my rollback call

#

I'm going to use it if I dont find another way to

sand saddle
sage lark
sand saddle
sage lark
#

Yes

sand saddle
#

My understanding is it would revert to null if/once the payment for the update fails and we revert

sage lark
#

Thanks ๐Ÿ˜…

#

So here is what I understand

#

When a customer tries to change subscription,
If the payments go through, then customer.subscription.updated is called with a null pending_update field
But if its not, then customer.subscription.updated is called with a pending_update, and then pending_update will be removed later and a rollback is applied?

sand saddle
#

Is this in the pending_updates scenario?

sage lark
#

Yes

sand saddle
#

Ok, here is how it works:

  • You make an API call to upgrade the Subscription, passing payment_behavior: 'pending_if_incomplete'
  • We will generate a new Invoice to reflect that upgrade and attempt payment
  • If successful, customer.subscription.updated fires and pending_updates: null
  • If payment attempts fail, pending_updates hash is set until you cancel the update
sand saddle
sage lark
#

I see there is a expiry_date, then I assume it just stays there and have absolute no effect until its removed on the date?

sand saddle
#

If you donโ€™t take any action after an update fails, the invoice is voided and the pending update is discarded after the expired_at time on the pending_update has passed.

sage lark
#

Alright, got it! If I want Stripe not to automatically charge then I just have to cancel the update myself?

sand saddle
#

Not sure what you mean

sage lark
#

Until the expiry_date, will Stripe continue attempting payment?

#

Unless I cancel the update myself

sand saddle
#

I believe the regular retries would apply yes

sage lark
#

Got it, thanks for your time ๐Ÿ˜…

sand saddle
#

np