-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Subscriptions: convert Subscription model to use djstripe #9312
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
Comments
Djstripe allows you to attach a subscriber to the readthedocs.org/readthedocs/organizations/models.py Lines 90 to 95 in b0ae8f8
And slowly migrate all mentions of Another approach could be to have an intermediate model with a generic foreign key, something like: class Subscriber(models.Model):
object = GenericForeignKey()
customer = models.ForeignKey(stripe.models.Customer) this way we have the same model for all type of subscribers, and we could attach some metadata if required. |
@humitos ☝️ You're probably the best resource here |
I'd go with the first approach as well. Generic foreign keys are usually too complicated/ambiguous. It seems the first approach covers exactly what we need and it's simpler. |
Once we have djstripe added again, we'll want to start thinking about moving our logic to use djstripe. The easiest piece to update first might be our Subscription model. We aren't doing any real magic here, besides our handling of subscription state.
A few notes:
The logic around how we interpret Stripe's subscription state is a little confusing to follow, because Stripe makes this harder than it should be. Namely, we have to use a Trial plan to create a trial period, and we manually cancel subscription state with application code when we determine the trial period to be over.
We need to monitor this heavily. Any changes to subscription flow need to be monitored on a weekly basis, both in Sentry and in Stripe (see the daily view of new trials and daily view of MRR)
We have had a few transient issues with id lookup on Stripe and organization/subscriptions missing ids. These errors likely are going away with this change. But see also a few related Sentry issues around Subscriptions and id lookup:
The text was updated successfully, but these errors were encountered: