Search code examples
stripe-paymentslaravel-cashier

How to process unsuccessful subcription upgrade with Stripe


I am new to Stripe and I can't figure out how to handle the such situation:

  • A client has an active subscription. It is paid for N days
  • Before ending this subscription, the clients try to upgrade it to a more advanced
  • Stripe tries to make a payment but it fails
  • After several fails stripe cancels the subscription

Instead of this, I want to revert the subscription to the previous one, because there are still N paid days of the previous subscription.


Solution

  • I'm going to restate your issue here to make sure we are on the same page and provide context for my answer

    Problem

    • A customer attempts to update their subscription, which requires a new payment
    • The update succeeds (the Subscription is upgraded) but the new payment fails.
    • The subscription cancels after repeated failed payment attempts

    Solution

    You can configure how a modified Subscription responds to a payment failure by changing the payment_behavior parameter when making the the Update API request. In your case you want to provide pending_if_incomplete.

    This will only change the Subscription if payment succeeds. You can read the overview here and get details about parameter restrictions and the lifecycle of pending updates here