#ryan_paymentintent-latest_charge

1 messages ยท Page 1 of 1 (latest)

worldly zenithBOT
#

๐Ÿ‘‹ 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/1241123665047851170

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

latent ocean
#

This has moved to latest_charge in newer API versions and is not expanded by default, and newer versions of stripe-node now pin to specific API versions

#

You can get this data by using expansion to get the latest_charge object

#

expand[]=latest_charge

exotic arrow
#

I totally missed that field on the payment intent. Thanks for pointing it out. Thanks!

#

Can I cause the payment intent in the response to be expanded when I create it? paymentIntents.create() that doesn't seem to be working.

#

Misplaced the expand option. Working out

latent ocean
#

Yep, that should be working. Let me kow if you have any toruble.

exotic arrow
#

I just misplaced the parameter. I see the latest charge being expanded now. The code also expects a transferId to be a part of the charge, but I don't see a field for it. I see transfer related data, but no transfer id. Did this get moved as well?

latent ocean
#

The code also expects a transferId to be a part of the charge, but I don't see a field for it.
Can you share the code in question?

#

And an example charge?

exotic arrow
#

Do you mean an example charge using the old API version?

latent ocean
#

I mean the code you're looking at that isn't working like you expect, along with an example charge you're trying to process

#

Or share more about what you're trying to do

#

Are you trying to inspect an attribute, or set a parameter?

worldly zenithBOT
exotic arrow
#

I'm trying to get an attribute from the resulting payment intent. The original code (which I inherit) it attempting to access it with paymentIntent.charges.data[0].transfer but this is no longer valid. It is expecting that that attribute contains something like tr_1GaakiB1mmvuUMtBjXq8ydl7

keen sandal
#

ryan_paymentintent-latest_charge

#

@exotic arrow this all still exists but you have to use expansion like my colleague explained

exotic arrow
#

Now, Im getting the latest charge, but I don't see an equivalent for transfer

#

Yes, I am getting the latest charge as synthrider explained. Now I'm trying to track down a piece of data in the response that I can't find

keen sandal
#

You used to get charges as an array of Charge objects right?
Now you get latest_charge: 'ch_123' as a string. But with expansion you can turn it into a full Charge object and if you do you can do payment_intent.latest_charge.transfer as expected

exotic arrow
#

Except that the charge Im getting does not have a transfer field

keen sandal
#

Can you share exact ids?

exotic arrow
#

The payment intent id is pi_3PHXWHB1mmvuUMtB0bB6s0D8

keen sandal
#

looking

#

hum this... shouldn't be possible. Like my quick read is that you use Destination Charges on PaymentIntent and set transfer_data. This means we should be sending funds as a result of that Charge after it succeeds. The PaymentIntent and the Charge are clearly in status: 'succeeded' but the Transfer didn't happen.
Looking into why

exotic arrow
#

Thanks.

keen sandal
#

I see you are using capture_method: 'automatic_async' which defers the real capture to later but it's supposed to be a few minutes not 30+

exotic arrow
#

Let me see i I can track that down. Im not super familiar with this code

#

it doesn't look like we are explicitly specifying capture method.

keen sandal
#

Okay I looked at the Charge internally and it's definitely captured with a Transfer

exotic arrow
#

ok

keen sandal
#

Where did you get that Charge object from? Did you maybe extract it from the charge.succeeded Event?

exotic arrow
#

I got it from the response to paymentIntents.update with expand ste to have latest_charge

keen sandal
#

Sure but when does that Update happen? It likely happened before the Charge was captured by our async systems

exotic arrow
#

Is that automatic_async parameter a default? I dont see us specifying it anywhere

keen sandal
#

did you maybe upgrade your API version and/or SDK without realizing there were breaking changes?

exotic arrow
#

That is the case. They started off at v8 not too long ago and I'm trying to get them on the latest, but there are a lot of changes betwen 8 and 15

#

Looks like i need to read about the capture methods and specify one to suite our needs

keen sandal
#

gotcha so yeah you want to read the migration guides, a lot has changed

#

My gut tells me you want to keep the new default behaviour, it's much better for latency. You'll get the Transfer async with the charge.updated and/or transfer.created Event

exotic arrow
#

We are not hooked up to receive events at all. There are no webhooks configured

#

But Ill take your advice under advisement

keen sandal
exotic arrow
#

I think its alrady doing that.

#

I think its using the api version 2020-08-27

#

Are there older API versions you can't pin to?

keen sandal
#

Gotcha, so there's a bug in your code somewhere. You didn't pin the API version properly at least for the PaymentIntent creation, that's why you got capture_method: 'automatic_async'
See https://dashboard.stripe.com/test/logs/req_sjOwWssuoHpO6m which is your API request and it has the latest API version

exotic arrow
#

ok, i'll take a look and debug. Thanks!

#

Is the version parameter name apiVersion?

keen sandal
exotic arrow
#

sorry, thats what I mean. The spelling of that seems to have changed unless the original authors of my code had a bug

#

They were using stripe-version

keen sandal
#

I don't think we changed this, I looked at all our migration guides and it's not mentioned. What's possible is that this never worked though and you got lucky that it used your default API version on your account
What we did change is that our SDKs now always pin the latest SDK version by default. So now we force that 2024 version until you override it, and maybe your override never worked

exotic arrow
#

That's quite possible. Thanks for all your help. Ill reach out if I need anything more.

#

Have a good weekend

keen sandal
#

sure thing!