#tungtn1099
1 messages ยท Page 1 of 1 (latest)
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).
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
it depends on what exactly the old and new plans are. There are classes of updates that do require an immediate payment : https://stripe.com/docs/billing/subscriptions/upgrade-downgrade#immediate-payment but not all them do, the ones that don't instead generate proration that is charged in the next invoice.
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
And there is no need for a payment link
Alright thanks!
Oh wait I have one more question
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
What is the latest_invoice about? The old planId or the new one
oh wait
it's about paying the prorated difference between them
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?
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
alternatively there is a feature https://stripe.com/docs/billing/subscriptions/pending-updates that allows for the change to only take effect when the payment succeeds
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?
I don't think it's exactly like that(there's no alignment to the billing dates I think); what happens depends on what settings you have on https://dashboard.stripe.com/settings/billing/automatic for "Manage failed payments"
I can always set the planId back to the original one if they fail to pay for the new one right?
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
If its monthly customer.subscription.updated, the pending_update is null right?
that would make sense to me
I'll give it a try, thanks
@sage lark How can I help?
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?
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
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
As my colleague explained, if payment fails on the invoice generated from your upgrade to the new package, then updates won't be applied and we'll revert back to the old package: https://stripe.com/docs/billing/subscriptions/pending-updates
Will pending_update go back to null after a fail payment or will it stays there and have no effect?
You mean this field? https://stripe.com/docs/api/subscriptions/object#subscription_object-pending_update
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Yes
My understanding is it would revert to null if/once the payment for the update fails and we revert
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?
Is this in the pending_updates scenario?
Yes
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.updatedfires andpending_updates: null - If payment attempts fail,
pending_updateshash is set until you cancel the update
Ignore this part, I was wrong
All explained here: https://stripe.com/docs/billing/subscriptions/pending-updates
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?
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.
Alright, got it! If I want Stripe not to automatically charge then I just have to cancel the update myself?
Not sure what you mean
Until the expiry_date, will Stripe continue attempting payment?
Unless I cancel the update myself
I believe the regular retries would apply yes
Got it, thanks for your time ๐
np