Skip to content

Conversation

@jamesrkiger
Copy link
Contributor

@jamesrkiger jamesrkiger commented Dec 15, 2025

🗒️ Checklist

  1. run linter locally
  2. update developer docs (API, README, inline, etc.), if any
  3. for user-facing doc changes create a Zulip thread at #Support Docs Updates, if any
  4. draft PR with a title <type>(<scope>)<!>: <title> DEV-1234
  5. assign yourself, tag PR: at least Front end and/or Back end or workflow
  6. fill in the template below and delete template comments
  7. review thyself: read the diff and repro the preview as written
  8. open PR & confirm that CI passes & request reviewers, if needed
  9. delete this section before merging

📣 Summary

Overhauls handling of Stripe billing portal configurations for more control over product options in the Stripe portal.

💭 Notes

The end goal here was to enable us to have some more nuanced rules for when to apply a customer's requested plan change (see related task DEV-1225). We also want to restrict which products on the Stripe portal are listed as upgrade/downgrade options for a given user based on their current subscription.

Our previous code relied on us using one default portal configuration and then creating new configurations with different product offerings (sometimes on the fly in the code). This resulted in us creating large numbers of portal configurations that are difficult to manage. With this PR, we will operate with a small, predetermined set of configs on the portal. The billing portal view code checks a user's current subscription and requested price (if any) to determine which config should be used.

Unfortunately, portal configurations are not handled by djstripe. Ideally I think we would want to add a db model for these and keep them synced with Stripe. But that would be more time intensive. For now, we will select configs based on hardcoded slugs matching their metadata.

👀 Preview steps

  1. On a Stripe-enabled and synced instance, create a new user and sign up for an annual 50gb storage addon.
  2. After syncing again, navigate to plans page and attempt to upgrade to a monthly professional plan
  3. You should be taken to the Stripe billing portal and asked to confirm the change. If you click on "additional details" you should see that this change will be applied immediately and you will receive credit for the remaining time on your annual plan. For testing purposes, don't actually confirm the purchase.
  4. On addons page, click "manage" button.
  5. You should be taken to the the billing portal where you can change your billing details or change your plan. Click "upgrade plan".
  6. The only available plan options should be storage addons.
  7. On a new, separate user account, sign up for an annual professional plan and sync Stripe subscriptions.
  8. Attempt to downgrade to a monthly professional plan.
  9. You should be taken to the Stripe billing portal and asked to confirm the change. If you click on "additional details" you should see that this change will be applied at the end of your current billing period (a year from now).

@jamesrkiger jamesrkiger marked this pull request as draft December 15, 2025 12:11
@jamesrkiger jamesrkiger self-assigned this Dec 15, 2025
required=False,
allow_empty=True,
)
quantity = serializers.IntegerField(required=False, default=1, min_value=1)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not directly related to the other work here, but we don't support varying product "quantities" anymore so I decided to remove it while I was in here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants