#tgalanis_api

1 messages ¡ Page 1 of 1 (latest)

sage quarryBOT
#

👋 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/1267935737953779833

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

sour otter
#

Can you share the request id where this isn't working?

#

As well as your code

gritty coyote
#

this is the checkout session cs_test_b1qkBenwflFjd3FBOov0xGd3ro1S9BOJBWkBCeBV5nPSkBdGndvQqxJ8Q0

sour otter
#

Can you share the request id for the retrieval as well as your code

gritty coyote
#

stripe.Key = os.Getenv(constants.ENV_STRIPE_SECRET_KEY)

params := &stripe.CheckoutSessionParams{
    Expand: []*string{stripe.String("setup_intent")},
}
params.AddExpand("setup_intent")
checkout_session, err := session.Get("cs_test_b1qkBenwflFjd3FBOov0xGd3ro1S9BOJBWkBCeBV5nPSkBdGndvQqxJ8Q0", params)
if err != nil {
    t.Error(err.Error())
    return
}
sour otter
#

That checkout session doesn't have a setupintent by the way

#

So it's null

#

That would be expected

gritty coyote
#

seti_1PiIV9KZjqPsPSFtr8F4v3KF

#

this is the setup intent I see when I retrieve the session on the dashboard

#

stripe checkout sessions retrieve cs_test_b1qkBenwflFjd3FBOov0xGd3ro1S9BOJBWkBCeBV5nPSkBdGndvQqxJ8Q0 -d expand[0]="setup_intent"

#

this yields a setup intent in the cli

sour otter
#

You ran that just now?

#

Can you share the request id?

#

Looking at the checkout session object I see null under setup_intent

gritty coyote
#

nope in the cli I obtain a setup intent in the go code i don;t

#

pardon me what is the request id

sour otter
gritty coyote
#

that you ask?

sour otter
#

That's a subscription checkout session

gritty coyote
#

I will copy the response form the cli

#

or better have the event id

#

evt_1PiIVIKZjqPsPSFtMnACYS1p

sour otter
#

The request id is what i need

#

For the retrieval you keep talking about

gritty coyote
#

give me a second

#

i will find it

#

req_LL9KKsniKjyyuR

#

indeed it does not have one

#

but the dashboard log for the same checkout session does

sour otter
sour otter
#

That's the request id I need

gritty coyote
#

I mean in the events tab

#

in the dashboard

#

and you click the same event checkout_session.completed

#

it displays a setup intent

sour otter
#

I see it in the event

#

But you're saying some requests are returning setup_intent and others aren't

gritty coyote
sour otter
#

What did it show?

gritty coyote
#

it had the setup intent

sour otter
#

Please share the request id

gritty coyote
#

I dont think the cli generates logs

#

the last request that I have logged are the ones from the go test

#

which didnt have the setup intent

sour otter
gritty coyote
#

req_Ew9HonR3gOmgQr

#

there you go

#

it is indeed a bad request

sour otter
#

That's a post request

#

I think that's different

#

I'm talking about the GET request you just made via the cli

gritty coyote
#

yes could be but I sended yyou the last log that is diplayed in the dashboard

#

it was at this time

sour otter
#

It's fine

#

I'm looking into this with a colleague

gritty coyote
#

req_hyRxdS03cIk3Ly

#

this is the last request

#

now that i have refreshed

sour otter
#

yep that's the one I shared above

gritty coyote
#

yeap this is from the stripe cli

#

i dint use go

#

so just to give you some context this was in mode subscription and I put a code fro 100% 7 months

#

after I provided the test card the setup intent was created

#

the subscription didnt have a trial attached to it just a 100%discount

#

for 7 months

sour otter
#

Ah ok we found the reason. This is an API versioning thing. Your account's default api version (which is what the cli uses) is 2020-08-27. On 2022-08-01 we made a change that removes setup_intent from the response for Checkout sessions in Subscription mode: https://docs.stripe.com/upgrades#2022-08-01. Your Go sdk is pinned to version 2024-06-20, so that's why it's not returned there. You should be able to see the api versions used in the dashboard request log for each request.

gritty coyote
#

so how will I be a ble to retrieve it

#

I want the payment method

#

I dont really care about the intent

#

but it is not saved in the subscription default method, I cant retrieve it from the invoice

#

and the customer does display a default payment method, source or whatever.

#

doesn't*

sour otter
#

And I see that's the case with the session you provided

gritty coyote
#

I think the default subscription method becomes null if the customer changes his default payment

#

option

#

but you are correct this is not going to happen right after the session and I can collect the default payment from the webhook

sour otter
gritty coyote
#

yea

#

sorry for the confusion

#

but i was working on this for many hours and lost track of waht i had tried and waht i did not

#

thank you for the help

sour otter
#

No problem. Alternatively, you can force the api version for the retrieve checkout session request to be an earlier api version to get the setup intent

sage quarryBOT
gritty coyote
#

I believe this is not necessary I only need this to be able to update the subscription in the future

#

so from the checkout session I will retrieve it from the default payment method and set it to default for subscirptions since we allow only one at a time

#

and if the customer changes the data then at the update I will only fetch the method from the invoice settings and I am set

#

again thank you very much for the time