dj-stripe 3.0.0 (unreleased)

Breaking Changes

  • The Source and SourceTransaction models have been removed. The Stripe Sources API was deprecated in favour of the PaymentMethods API, and Source was deprecated in dj-stripe 2.11.0. Use the PaymentMethod model instead. This also removes the Customer.sources relation and the Customer.customer_payment_methods property; use Customer.payment_methods (the reverse relation of PaymentMethod.customer) instead. A database migration drops the djstripe_source and djstripe_sourcetransaction tables.

  • The DJSTRIPE_WEBHOOK_EVENT_CALLBACK setting has been removed. It was deprecated in 2.8.0 in favour of the webhook signals. If you used it to take control of webhook processing, connect to the relevant signal instead:

    • djstripe.signals.webhook_pre_validate
    • djstripe.signals.webhook_post_validate
    • djstripe.signals.webhook_pre_process
    • djstripe.signals.webhook_post_process
    • djstripe.signals.webhook_processing_error
  • Removed subscription helpers that applied conflicting definitions of "active", "current", and "valid":

    • Customer.subscription
    • Customer.active_subscriptions
    • Customer.valid_subscriptions
    • Customer.has_any_active_subscription()
    • Customer.is_subscribed_to()
    • Subscription.is_status_current()
    • Subscription.is_status_temporarily_current()
    • Subscription.is_valid()
    • MultipleSubscriptionException

    Applications must now define their own access policy by composing explicit filters on Subscription.objects or customer.subscriptions. The new with_status(), period_current(), scheduled_for_cancellation(), and for_product() queryset filters can be combined with the existing status filters. For example:

    from djstripe.enums import SubscriptionStatus
    
    SERVICE_STATUSES = {
        SubscriptionStatus.trialing,
        SubscriptionStatus.active,
        SubscriptionStatus.past_due,
    }
    
    service_subscriptions = (
        customer.subscriptions.with_status(*SERVICE_STATUSES).period_current()
    )
    has_access = service_subscriptions.exists()
    

    Subscription.is_period_current() remains available for individual subscriptions, and Subscription.is_scheduled_for_cancellation() replaces the ambiguously named is_status_temporarily_current(). This leaves choices such as whether a past_due, paused, or unpaid subscription grants service to the application rather than dj-stripe. SubscriptionMixin now adds a subscriptions queryset to the template context instead of the policy-dependent singular subscription (#490).

Bug Fixes

  • Price.create() now passes unit_amount to Stripe unchanged, using Stripe's minor currency units instead of incorrectly multiplying the value by 100 (#1941).