Unable to change plan if the current plan has been deleted in Recurly

Created on 27 November 2023, over 1 year ago
Updated 8 December 2023, over 1 year ago

Problem/Motivation

I have a client who has deleted a few plans in their Recurly account that they no longer want to offer.

There are still some accounts with active subscriptions to this plan and Recurly still bills for them, which is what we would expect and want.

However on our Drupal site, when a user with one of these deleted plans attempts to change their plan they get a 404 page with a status message "Plan code DELETED-PLAN-ID not found." instead of the change plan confirmation form.

Steps to reproduce

  1. Subscribe to a plan in Drupal
  2. In your Recurly account delete that plan
  3. In Drupal go to the change plan page, and select a new plan
  4. 404 error is thrown.

Proposed resolution

Don't return a 404 page if the old subscriptions plan is not found.

In RecurlySubscriptionChangeController we have a valid Recurly Subscription object, but when we attempt to load the Plan from the plan code in the subscription object it is not found, since it was deleted.

We should rely on the subscription object, which has all the info we need (price, interval, etc) rather than attempting to load the plan from the active subscription.

I will try to provide a patch.

πŸ› Bug report
Status

Needs review

Version

5.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States loze Los Angeles

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @loze
  • πŸ‡ΊπŸ‡ΈUnited States loze Los Angeles
  • Status changed to Needs review over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States loze Los Angeles

    This MR allows users to change from a plan that has been removed from Recurly.

  • πŸ‡ΊπŸ‡ΈUnited States loze Los Angeles

    The failed test here is due to the test checking for a valid old plan, which I suppose should be removed if we allow changing from a deleted plan.

    Perhaps it should check for a valid subscription (not a valid old plan) when switching plans?

  • πŸ‡ΊπŸ‡ΈUnited States eojthebrave Minneapolis, MN

    If we're not using the old plan for anything I can think we can probably just remove that from the test? Or maybe update the test so that it will verify that you can change your subscription both with an existing old plan, and a deleted old plan. Which would help to ensure we don't re-introduce this bug in the future.

  • πŸ‡ΊπŸ‡ΈUnited States loze Los Angeles

    Thanks for looking at it, @eojthebrave. I removed the loading of the old plan and added a comment as you suggested.

    Still need to work out the tests. Im not particularly good with tests but I'll try to figure it out when I get some more time.

  • πŸ‡ΊπŸ‡ΈUnited States loze Los Angeles

    That was easier than I thought it would be. I got the test to go green.

Production build 0.71.5 2024