The Subscription model now has a foreign key pointing to the StripeUser model instead of the Django User model. This reduces the coupling across the application.
Migrating from older version: you will need to drop all drf-stripe tables and run Django migrate command again to recreate new ones.
Added convenience methods to the StripUser model:
property
def subscription_items(self):
"""Returns a set of SubscriptionItem instances associated with the StripeUser"""
property
def current_subscription_items(self):
"""Returns a set of SubscriptionItem instances that grants current access."""
property
def subscribed_products(self):
"""Returns a set of Product instances the StripeUser currently has"""
return {item.price.product for item in self.current_subscription_items}
property
def subscribed_features(self):
"""Returns a set of Feature instances the StripeUser has access to."""
return set(chain.from_iterable(item.price.product.linked_features.all().prefetch_related("feature") for item in
self.current_subscription_items))