dj-stripe / dj-stripe

dj-stripe automatically syncs your Stripe Data to your local database as pre-implemented Django Models allowing you to use the Django ORM, in your code, to work with the data making it easier and faster.

Home Page:https://dj-stripe.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sync_from_stripe_data syncing incorrect subscriptions

ANG3L0 opened this issue · comments

commented

Describe the bug
sync_from_stripe_data is getting an incorrect subscription of the same name.

To Reproduce

  1. Setup stripe to have plan changes take affect next billing cycle.
  2. Have stripe cancel immediately, instead of end of period
  3. Sign up for a plan (call it plan X)
  4. Cancel that same plan
  5. Sign up for the same plan again (plan X)

execute:

subscription = stripe.Subscription.retrieve(subscription_id) # retrieves correct subscription
djstripe_subscription = Subscription.sync_from_stripe_data(subscription) # gets incorrect, stale subscription

You will observe that sync_from_stripe_data now syncs to the cancelled plan in step 3 as opposed to the newest plan in step. This causes major issues because a renewing customer can now see that they don't have a subscription.

Software versions

  • Dj-Stripe version: 2.6.1
  • Python version: 3.9
  • Django version: 3.2.13
  • Stripe API version: 3.2.0
  • Database type and version: psycopg2-binary==2.9.3