#kamran5446
1 messages · Page 1 of 1 (latest)
Hello, what call are you making when you get this error?
Can you send me a request ID (req_123) from a time that you got this error?
Subscription.sync_from_stripe_data(subscription_data)
this is the request id : req_GbFlOV3Lenxva8
So I see the ID in_1MuE9TCNCFwAmoZdFQQ2x0uf-il_1MuE9WCNCFwAmoZdBEOdjEyN being passed in, are you getting that from the Stripe API somewhere?
I think just that last part, il_1MuE9WCNCFwAmoZdBEOdjEyN, is the line item ID so I think your code may be combining IDs when that is not what our API expects
but i am getting data from stripe while modification subscription with this code.
api_subscription = stripe.Subscription.modify()
subscription = Subscription.sync_from_stripe_data(api_subscription)
is this a problem from stripe?
i am not playing around with invoice_ids its just stripe data i pass along
Can you show me what is in your sync_from_stripe_data code? That isn't our function so I don't know what it does
sync_from_stripe_data is not my code . I imported from djstripe models
from djstripe.models import Subscription
Subscription.sync_from_stripe_data(api_subscription)
def _stripe_object_to_subscription_items(
cls, target_cls, data, subscription, api_key=djstripe_settings.STRIPE_SECRET_KEY
):
"""
Retrieves SubscriptionItems for a subscription.
If the subscription item doesn't exist already then it is created.
:param target_cls: The target class to instantiate per invoice item.
:type target_cls: Type[djstripe.models.SubscriptionItem]
:param data: The data dictionary received from the Stripe API.
:type data: dict
:param subscription: The subscription object that should hold the items.
:type subscription: djstripe.models.Subscription
"""
items = data.get("items")
if not items:
subscription.items.delete()
return []
pks = []
subscriptionitems = []
for item_data in items.auto_paging_iter():
item, _ = target_cls._get_or_create_from_stripe_object(
item_data, refetch=False, api_key=api_key
)
# sync the SubscriptionItem
target_cls.sync_from_stripe_data(item_data, api_key=api_key)
pks.append(item.pk)
subscriptionitems.append(item)
subscription.items.exclude(pk__in=pks).delete()
return subscriptionitems
btw this isn't my code its djstripe code
In that case you may want to talk to the djstripe dev, I can only really advise on things where you are writing directly to our API. Sounds like they may have a bug if they are passing us the wrong invoice item IDs
but api_subscription data is coming from stripe api .
api_subscription = stripe.Subscription.modify()
Right but that isn't the call that is failing
It is the invoice items retrieve, which is in code that neither of us wrote
It actually doesn't look like it is in that function though
Have you tried stepping through your code to see exactly where that error is thrown?
alright how can i contact djstripe dev?
il_1MuE9WCNCFwAmoZdBEOdjEyN this shoud be the id they have to use according to recent update but they are using this
in_1MuE9TCNCFwAmoZdFQQ2x0uf-il_1MuE9WCNCFwAmoZdBEOdjEyN
So you did step through your code and confirmed this is being thrown by a function that they wrote?
Unfortunately I do not know how to contact them, usually they should have contact info on wherever you installed their code from
thanks for you help.
- invoice = stripe.Invoice.retrieve('in_1MuE9TCNCFwAmoZdFQQ2x0uf-il_1MuE9WCNCFwAmoZdBEOdjEyN') (false statement)
- invoice = stripe.Invoice.retrieve('in_1MuE9TCNCFwAmoZdFQQ2x0uf') (correct statement)
djstripe is executing the first one
is this statement were valid in previous stripe versions?
false statement means it gives an error of 400
Do you. have the request ID for the API request that returned the 400 error?
Here's how you can find a request ID: https://support.stripe.com/questions/finding-the-id-for-an-api-request
this is the request id : req_GbFlOV3Lenxva8
Oh, okay. yes Invoice IDs in Stripe do not include a -
So for that first one, the actual Stripe ID is the first half. So for in_1MuE9TCNCFwAmoZdFQQ2x0uf-il_1MuE9WCNCFwAmoZdBEOdjEyN the valid Stripe ID is in_1MuE9TCNCFwAmoZdFQQ2x0uf
We don't maintain the djstripe package so I can't offer any advice on how they build the IDs stored locally. But it looks like it's concatenating a couple IDs
any idea how can i fix this issue?
ALSO the Line ID is the second one
So you would want to pass il_1MuE9WCNCFwAmoZdBEOdjEyN as the value for the starting_after parameter
problem is i am not playing these ids
i am just trying to sync subscription
api_subscription=stripe.Subscription.retrieve(
"subscription_id",
)
subscription = Subscription.sync_from_stripe_data(api_subscription)
Okay but that's not the API request you shared. So what happens here?
i shared the same request
Where? The request you provided me was a request for Invoice Items
that request was executing inside this 'sync_from_stripe_data" method
sync_from_stripe_data is not my code . I imported from djstripe models
from djstripe.models import Subscription
Subscription.sync_from_stripe_data(api_subscription
Okay. So that isn't code we control or have insight into
alright
You would need to reach out to DjStripe for support there
i am unable to find thier chat support? do you have any idea?