Comments (9)
@arnav13081994 sorry for the delayed response here. We just had another come through that is failing to sync. Here is what the item json looks like:
{ amount: -20807, amount_excluding_tax: -20807, currency: 'usd', description: 'Unused time on Basic after 26 Jan 2023', discount_amounts: [ { amount: 0, discount: 'di_1MUcN9BrbFy7JWmB6zU6YBv7' } ], discountable: False, discounts: [], id: 'il_1MUcN9BrbFy7JWmBGWNb4Zt9', invoice_item: 'ii_1MUcN9BrbFy7JWmBCYdLtzTl', object: 'line_item' }
In the same error stack, the api is returning that the invoice is not existent as well. This is 100% related to proration line items that stripe automatically generates.
from dj-stripe.
@dustinblanchard Turns out the root cause of this issue is that the SubscriptionItem
s referred in the JSON are actually deleted and hence the sync was failing as it should have. Raised a PR to just ignore such errors so at least the sync will no longer fail.
from dj-stripe.
@jleclanche Any thoughts here? If there is an easy way to identify these special Subscription Items, @stanmattingly and I can potentially work on a PR.
from dj-stripe.
Very difficult to say without access to the stripe account.
from dj-stripe.
@stanmattingly What dj-stripe version are you on?
from dj-stripe.
@arnav13081994 We are on 2.8.3
from dj-stripe.
@stanmattingly Not able to reproduce this issue. Please share the SubscriptionItem
json if possible. It might be some case that we might have missed.
from dj-stripe.
I'm getting a sync failure as well from any event that is attached to a customer that changed their subscription (so there is a proration amount). The error from dj-stripe is:
InvalidRequestError at /stripe/webhook/<wh_id>/
Request req_<req_id>: Invalid subscription_item id: si_<si_id>
Some of the data looks like:
"object": "line_item",
"amount": -917,
"amount_excluding_tax": -917,
"currency": "usd",
"description": "Unused time on <product> after 11 Dec 2023",
I'm using version 2.8.3
from dj-stripe.
We've ended up monkey patching StripeModel._stripe_object_to_line_items
to ignore any with "unused time" in the description. This feels like a hacky approach but we couldn't find anything else to key off of.
@classmethod
def presshook_stripe_object_to_line_items(
cls, target_cls, data, invoice, api_key=djstripe_settings.STRIPE_SECRET_KEY
):
lines = data.get("lines")
if not lines:
return []
lineitems = []
for line in lines.auto_paging_iter():
# Skip line items that cause errors from proration
if "unused time" in line.get("description", "").lower():
continue
if invoice.id:
save = True
line.setdefault("invoice", invoice.id)
else:
# Don't save invoice items for ephemeral invoices
save = False
line.setdefault("customer", invoice.customer.id)
line.setdefault("date", int(dateformat.format(invoice.created, "U")))
item, _ = target_cls._get_or_create_from_stripe_object(
line, refetch=False, save=save, api_key=api_key
)
lineitems.append(item)
return lineitems
StripeModel._stripe_object_to_line_items = presshook_stripe_object_to_line_items
from dj-stripe.
Related Issues (20)
- value too long for type character varying(9) when processing checkout.session.completed webhook (possible stripe API version 2024-04-10 issue) HOT 17
- When installing for the first time and running migrate: AttributeError: module 'stripe' has no attribute 'Order' HOT 6
- ProgrammingError: column djstripe_product.default_price_id does not exist HOT 7
- Use case for multiple API Keys? HOT 9
- Plugin 'mkdocstrings' option 'watch' is breaking the docs HOT 2
- Failing webhook events in dj-stripe regarding Plan and Price HOT 2
- Having multiple projects breaks the webhook HOT 1
- The stripe api key placement is very confusing HOT 14
- Use AbstractModels HOT 1
- Webhook doesn't work if API keys removed from .env HOT 2
- Current state of the projects Documentation/Website
- v2.9 Release Checklist HOT 2
- Sync only Subscriptions with specific status HOT 2
- Initial Sync Fails to Import Charge data from Connect Express Accounts
- Re-enable Migration Check in Linter Action for Release 3.0
- Support an upgrade from 2.X HOT 4
- Webhooks for some users are failing after library update from 2.5 to 2.8 HOT 2
- Errors when manually running djstripe_sync_models
- API change for Sepa payments in their source api HOT 1
- Enhance Admin Interface to Dynamically Include All Properties as Read-Only Fields HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dj-stripe.