question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Are SubscriptionItems supposed to sync automatically?

See original GitHub issue

Describe the bug

Thank you for creating this library. My issue is that SubscriptionItems don’t seem to automatically sync through any webhook from Stripe, even with all webhook events enabled, and no errors thrown during webhook event processing or validation.

Quick question

As a first pass, can you please clarify if we’re expected to sync updates to these nested structures (e.g. SubscriptionItem) on our own, or if they’re expected to be handled by the library automatically.

Details / Longer question

I spent some time looking through the djstripe code and could not find where the nested objects (e.g. SubscriptionItem or InvoiceItems) are updated. I did find where SubscriptionItems are retrieved which is used as part of the _attach_objects_post_save_hook() call here. But based on my understanding of the code, since the SubscriptionItem already exists in the database, we will just return early here with the value that is already in the database, and never sync the latest SubscriptionItem. Please let me know if i’ve misunderstood the code.

I can of course manually sync the subscription items with SubscriptionItem.sync_from_stripe() in my own webhook handler, but I can’t find it documented anywhere that it is expected for the client to do this manually.

My app is using subscription items to show the user the current product they are subscribed to, by using something like subscription.items.first().price.product.name. A workaround would be instead to use the deprecated plan value, which does get synced correctly into the subscription, with something like Price.objects.get(id=subscription.plan.id).product.name. The other alternative is my own webhook handler as well.

Software versions

  • dj-stripe version: 2.4.3
  • Python version: 3.9.5
  • Django version: 3.1.4
  • Stripe API version: 2.56.0
  • Database type and version: Postgres 11.2

Can you reproduce the issue with the latest version of master? I haven’t had a chance to try yet, but I will in the next day or two.

Expected Behavior SubscriptionItems automatically syncing when a subscription is updated in Stripe.

Actual Behavior SubscriptionItems are not syncing at all automatically. I confirmed there were no errors via the webhookeventtrigger Django admin page.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
vedrancommented, Jun 23, 2021

Thank you!

0reactions
arnav13081994commented, Jun 14, 2021

@vedran You were right. SubscriptionItem objects were not getting synced due to the exact reason you mentioned. I just raised a PR that should fix this issue: https://github.com/dj-stripe/dj-stripe/pull/1376

Read more comments on GitHub >

github_iconTop Results From Across the Web

Stripe API reference – Subscription Items – curl
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries....
Read more >
stripe api: multiple plans / subscriptions, single invoice
Your customer can have has much subscriptionItems as needed. He will be billed once on the subscription recurring basis, and have only one...
Read more >
Laravel Cashier (Stripe)
For convenience, Cashier will automatically sync your customer's information with Stripe on the initial creation of the customer.
Read more >
Subscriptions & Subscription Items - Objects & Stripe Modeling
After pushing to Stripe, a Subscription Item will be auto-created for the single Stripe Price and updated in Salesforce.
Read more >
Fulfillment for prepaid subscriptions
Changes to fulfillment orders aren't automatically reflected on subscription ... A customer might add multiple prepaid subscription items to their order.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found