Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.x] New subscription behavior #1420

Merged
merged 5 commits into from
Aug 19, 2022

Conversation

driesvints
Copy link
Member

@driesvints driesvints commented Aug 12, 2022

This PR adopts the new recommended default_incomplete payment behavior that Stripe now recommends. The main adjustments here are the transition to the new default_incomplete value when passing the payment_behavior when creating or updating subscriptions or subscription items and confirming the payment intents server-side before throwing the IncompletePayment exception.

I've extracted the logic to handle payment failures in a new HandlesPaymentFailures trait. In here, we'll check if a subscription has a failed payment. If so, we'll check if it needs confirmation and when it does we'll confirm it server-side. If a payment method has been provided as well (usually when creating a subscription) we'll pass it along. After confirming the payment we'll need to update the subscription status. If no confirmation is needed and there is an incomplete payment we'll cascade the exception immediately.

I managed to made this PR backwards compatible for existing integrations. Existing integrations are expected to handle failing payments anyway so it should be a smooth upgrade.

The next step I want to take is to update our docs with the flow of how Stripe recommends to handle collecting payment details which is after a subscription has been already created.

More info: https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=elements#create-subscription

@driesvints driesvints force-pushed the new-subscription-behavior-alternative branch from fe8fad9 to aa679dc Compare August 15, 2022 14:04
@driesvints driesvints changed the title [14.x] New subscription behavior alternative [14.x] New subscription behavior Aug 16, 2022
@@ -11,7 +11,19 @@ trait InteractsWithPaymentBehavior
*
* @var string
*/
protected $paymentBehavior = StripeSubscription::PAYMENT_BEHAVIOR_ALLOW_INCOMPLETE;
protected $paymentBehavior = StripeSubscription::PAYMENT_BEHAVIOR_DEFAULT_INCOMPLETE;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the main change of this PR.

@driesvints driesvints force-pushed the new-subscription-behavior-alternative branch from 7e0ccf3 to 5b25e0c Compare August 18, 2022 15:07
@driesvints driesvints marked this pull request as ready for review August 18, 2022 15:08
@taylorotwell taylorotwell merged commit 6b9b640 into master Aug 19, 2022
@taylorotwell taylorotwell deleted the new-subscription-behavior-alternative branch August 19, 2022 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants