[12.x] Implement new proration and pending updates #949
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Provide support for new
always_invoice
proration and subscription pending updates.The proration changes now offer full support for all new Stripe proration options, including
always_invoice
. All of thexAndInvoice
methods have been updated to make use of this option. Using anyxAndInvoice
method will apply thealways_invoice
proration behavior. This reduces the api calls from two to one. There might be some slightly changed behavior in certain situations where you were explicitly expecting the invoice endpoint to be called.This PR also provides support for subscription pending updates. There's three new methods which can be called right before swapping plans, updating quantities, adding or updating subscription items.
allowPaymentFailures
which is the default behavior and will allow subscription changes even when a payment failure occurs.errorIfPaymentFails
which was the past Stripe behavior from before the 2019-03-14 update and will hard fail any update with a failed payment.pendingIfPaymentFails
will place any changes as pending until the payment for the latest invoice was successful.Pending updates can be checked with the new
->pending()
method on the subscription model and they can be cancelled by calling the new->void()
method on the invoice object. The latest invoice of a subscription can be called with the new->latestInvoice()
method on the subscription model.Breaking Changes
noProrate
and using anyxAndInvoice
method afterwards, that usually should not generate a new invoice. With the new behavior anyxAndInvoice
method will always generate a new invoice and undo thenoProrate
behavior.xAndInvoice
method. This is now done in one go with thealways_invoice
proration option. Please make sure to test this scenario before deploying to production to make sure your billing flow works as expected.$prorate
property, this was now renamed to$prorationBehavior
. Similarly, thesetProrate
method has been renamed tosetProrationBehavior
.