Skip to content

Requirements: upgrade dj-stripe #9706

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

Closed
humitos opened this issue Nov 3, 2022 · 3 comments · Fixed by #12148
Closed

Requirements: upgrade dj-stripe #9706

humitos opened this issue Nov 3, 2022 · 3 comments · Fixed by #12148
Assignees
Labels
Accepted Accepted issue on our roadmap

Comments

@humitos
Copy link
Member

humitos commented Nov 3, 2022

There are some extra actions required to upgrade dj-stripe to 2.7.0. They are documented at #9688 (comment). For now, we are sticking to 2.6.3.

@humitos humitos moved this to Planned in 📍Roadmap Nov 3, 2022
@humitos humitos added the Accepted Accepted issue on our roadmap label Nov 29, 2022
humitos added a commit that referenced this issue Apr 29, 2025
We need to upgrade `djstripe` first because the admin is broken otherwise.

See #9706
@humitos
Copy link
Member Author

humitos commented Apr 29, 2025

Django Admin breaks when upgrading to Django 5.2 without upgrading djstripe. See https://read-the-docs.sentry.io/issues/6575661535/

@humitos
Copy link
Member Author

humitos commented Apr 29, 2025

Note that we need to perform the upgrade in two steps: first to 2.7 and then to 2.8. See https://dj-stripe.dev/2.9/upgrade_dj_stripe/

Ideally, we should upgrade to the latest version.

humitos added a commit that referenced this issue Apr 29, 2025
We need to upgrade `djstripe` first because the admin is broken otherwise.

See #9706
humitos added a commit that referenced this issue Apr 29, 2025
We need to upgrade `djstripe` first because the admin is broken otherwise.

See #9706
humitos added a commit that referenced this issue Apr 30, 2025
We need to upgrade `djstripe` first because the admin is broken
otherwise.

See #9706
@humitos
Copy link
Member Author

humitos commented Apr 30, 2025

I started following the djstripe guide:

Migrations

  1. We have only 2 migrations that depend on djstripe migrations
readthedocs/organizations/migrations/0011_add_stripe_subscription_field.py
11:        ("djstripe", "0010_alter_customer_balance"),

readthedocs/organizations/migrations/0010_add_stripe_customer.py
11:        ("djstripe", "0010_alter_customer_balance"),
  1. The latest version of djstripe (2.9.0) has the 0010_alter_customer_balance migration file

When running the migrations locally, I received this message, so we need to update the test keys:

?: (djstripe.I001) You don't have any API Keys in the database. Did you forget to add them?
	HINT: Add STRIPE_TEST_SECRET_KEY and STRIPE_LIVE_SECRET_KEY directly from the Django Admin.

It seems there is nothing we need to do related to the migrations.

Backward incompatibility changes

  • In 2.9.0 deprecates DJSTRIPE_WEBHOOK_VALIDATION setting, which we are currently using. This needs to be configured through the admin when performing the migration.
  • 2.9.0 removes DJSTRIPE_WEBHOOK_SECRET which we are using, but it doesn't say exactly what's the replacement. I understand this is done via the Django Admin now for each webhook.

I checked all release notes from 2.6.x to 2.9.x and I only found these affecting us.


The steps we should follow are described in #9688 (comment). I'm copying them here:

Run the migrations on web extra
Create an API key on the admin (/admin/djstripe/apikey/)
Release the webs
Create a webhook endpoint after the release is done (/admin/djstripe/webhookendpoint/), the webhook will be created on stripe automatically.
Deactivate the old webhook

The old and the new webhook will work at the same time, so we won't lose any events.

The migration is dj-stripe/dj-stripe//blob/bc0bd5c1/djstripe/migrations/0011_2_7.py, there are a couple of new fields that aren't nullable, but if the webhooks fail, stripe will retry them, and by that time the new code would be live.

I think we can target this for the next deploy.

humitos added a commit that referenced this issue Apr 30, 2025
@humitos humitos closed this as completed in 080fdf0 May 6, 2025
@github-project-automation github-project-automation bot moved this from Planned to Done in 📍Roadmap May 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted Accepted issue on our roadmap
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants