#kamran5446

1 messages · Page 1 of 1 (latest)

sweet coveBOT
rough oak
#

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?

ruby stag
#

Subscription.sync_from_stripe_data(subscription_data)

#

this is the request id : req_GbFlOV3Lenxva8

rough oak
#

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

ruby stag
#

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

rough oak
#

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

ruby stag
#

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

rough oak
#

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

ruby stag
#

but api_subscription data is coming from stripe api .
api_subscription = stripe.Subscription.modify()

rough oak
#

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?

ruby stag
#

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

rough oak
#

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

sweet coveBOT
ruby stag
#

thanks for you help.

ruby stag
#
  1. invoice = stripe.Invoice.retrieve('in_1MuE9TCNCFwAmoZdFQQ2x0uf-il_1MuE9WCNCFwAmoZdBEOdjEyN') (false statement)
  2. invoice = stripe.Invoice.retrieve('in_1MuE9TCNCFwAmoZdFQQ2x0uf') (correct statement)

djstripe is executing the first one
is this statement were valid in previous stripe versions?

sand sky
#

HI 👋

#

when you say "false statement" what do you mean?

ruby stag
#

false statement means it gives an error of 400

sand sky
ruby stag
#

this is the request id : req_GbFlOV3Lenxva8

sand sky
#

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

ruby stag
#

any idea how can i fix this issue?

sand sky
#

ALSO the Line ID is the second one

#

So you would want to pass il_1MuE9WCNCFwAmoZdBEOdjEyN as the value for the starting_after parameter

ruby stag
#

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)

sand sky
#

Okay but that's not the API request you shared. So what happens here?

ruby stag
#

i shared the same request

sand sky
#

Where? The request you provided me was a request for Invoice Items

ruby stag
#

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

sand sky
#

Okay. So that isn't code we control or have insight into

ruby stag
#

alright

sand sky
#

You would need to reach out to DjStripe for support there

ruby stag
#

i am unable to find thier chat support? do you have any idea?