#frallain_api

1 messages ยท Page 1 of 1 (latest)

obtuse condorBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1318887702497591307

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

vague creek
#

Any idea? Could it be related to the Stripe API version used?

#

(the second request is on our Production account)

#

In both envs, we've set the API to use 2024-04-10

#

Oh, but in fact it's set for the API, not the dashboard..

#

nevermind, we have the same behavior in our backend code with the API, so there is something strange still

idle kelp
#

Yes that should be a different API version used.

vague creek
#

can you tell me the behavior of the v2024-04-10 of the API?

idle kelp
#

I'm not sure I understand what you are looking for exactly ?

vague creek
#

Both envs use the same API version (2024-04-10) but give different output

elder sand
#

Are you looking at API calls that the Dashboard makes?

vague creek
#

No, I am looking at the calls made by our SDK to the API, but I can confirm that the dashboard behaves the same

elder sand
#

Why is the URL https://dashboard.stripe.com...?

vague creek
#

OK let met get the exact request IDs

#

In fact there is no logs for successful GET calls...

elder sand
#

You should change the filters in the list of logs

vague creek
#

OK this is https://dashboard.stripe.com/logs/req_lXvJGS5vmdGjCx that I am calling this way

        upcoming_invoice = stripe_client.get_upcoming_invoice(
            customer_stripe_id,
            expand=[
                # payment methods
                "customer.invoice_settings.default_payment_method",  # Stripe PaymentMethod API
                "customer.default_source",  # deprecated Stripe Source API
                # coupons
                "customer.discount.coupon.applies_to",
                "discounts.coupon.applies_to",
                "subscription.discounts.coupon.applies_to",
                # schedule
                "subscription.schedule",
            ],
        )
elder sand
#

And what about the other request?

vague creek
#

Trying to find it

#

called the same way

#

Do you have the Response body in the logs for GET on your side?

#

because on my side I get a "We do not save the response body for successful GET requests."

elder sand
vague creek
#

from our logs, it does a GET https://api.stripe.com/v1/invoices/upcoming with

customer=cus_NGXwuNvFgaJDur&expand%5B0%5D=customer.invoice_settings.default_payment_method&expand%5B1%5D=customer.default_source&expand%5B2%5D=customer.discount.coupon.applies_to&expand%5B3%5D=discounts.coupon.applies_to&expand%5B4%5D=subscription.discounts.coupon.applies_to&expand%5B5%5D=subscription.schedule,
elder sand
#

Okay, I can see the default_source properties of different types, which is why they have a different structure:

  • cus_NGXwuNvFgaJDur has default_source=src_1Mcc7jI9qXomtXqSTSy54Xmq which is a Source object.
  • cus_RQBCnW8cRtx7xm has default_source=card_1QXKpcH2GG3UYmlxSjYbeulM which is a Card object.
#

Sources is a deprecated concept, and this wouldn't be the issue with PaymentMethods. I suggest you to migrate to PaymentMethods as soon as possible.

vague creek
#

Alright I see, thank you very much!

elder sand
#

Happy to help.

vague creek
#

last question, in tests

#

to setup a merchant with a source, this is the code I use:

        stripe_customer = stripe.Customer.create(
            email="legacy_credit_card_customer@test.fixture",
            source="tok_visa",
            coupon=customer_coupon_id,
            metadata=metadata,
            **additional_kwargs,
        )
#

but, as we found out, this create a source of type Card

#

How to create a source of type Source?

elder sand
#

Please don't use Sources. I don't think it's possible.
You can achieve the same by using payment_methods:

payment_method: 'pm_card_visa`
invoice_settings: {
   default_payment_method: 'pm_card_visa'
}
obtuse condorBOT
vague creek
#

Yes but it's for testing purpose : we have many customers on sources, we need to support them.

#

Don't worry, we do not create sources anymore but payment methods

heavy gazelle
#

๐Ÿ‘‹ taking over for my colleague. Let me catch up.

vague creek
#

OK I could make it work and reproduce the original bug with

        stripe_customer = stripe.Customer.create(
            email="legacy_credit_card_customer@test.fixture",
            coupon=customer_coupon_id,
            metadata=metadata,
            **additional_kwargs,
        )
        source = stripe.Source.create(
            type=StripePaymentMethodType.CARD,
            currency="usd",
            owner={"email": "card_source@test.fixture"},
            token="tok_visa",
        )
        stripe.Customer.create_source(stripe_customer["id"], source=source["id"])
heavy gazelle
#

sources for non-card payment method is deprecated and it's no longer possible to create these

elder sand
#

Yeah, I don't know if it's possible to create anything except what tok_visa does.

vague creek
#

Interestingly, the customer fixture was previously written this way

        stripe_customer = stripe.Customer.create(
            email="legacy_credit_card_customer@test.fixture",
            source="tok_visa",
            coupon=customer_coupon_id,
            metadata=metadata,
            **additional_kwargs,
        )

which was creating a Card object as the default source