#andre-sourcetransaction-charge

1 messages · Page 1 of 1 (latest)

leaden grailBOT
high yoke
#

andre-sourcetransaction-charge

#

@tawny spindle a PaymentIntent has the latest_charge property so you can use that

tawny spindle
#

so the latest charge gives me the charge id that I need to create a transfer?

high yoke
#

if that PaymentIntent is in status: 'succeeded' then yes

tawny spindle
#

I just found a bit weird that I only got the error through a try catch method, but I couldn't find the details of that attempt of transfer creation anywhere else. But this is just because I was not passing the correct charge id probably, right?

high yoke
#

Yeah it's what we call an "invalid request error". I assumed you passed source_transaction: 'pi_123' and it said "No such charge: pi_123"

tawny spindle
#

Got it! So I just tried that with this code:
const transfer = await stripe.transfers.create({
amount: amount * 100,
currency: 'brl',
destination: accountId,
source_transaction: paymentIntent.latest_charge,
});
I retrieved the payment intent and to access the lastest_charge parameters, but I'm still getting the same error (the status of the payment intent is succeeded)

high yoke
#

Then I need more details than "the same error". I need to see an exact request so that I can look at it. In the error response there should be a req_123 somewhere (in a dashboard_url property)

tawny spindle
#

Right! So this is the request for creating a transfer

#

This iswhere that payment intent id came from

high yoke
#

those are pictures

#

I just want a req_123 that you get back in the API response when the call fails

#

or the PaymentIntent id pi_123 in text here, so that I can look up your logs and figure out what's wrong

tawny spindle
#

ahh okay!

#

pi_3MZGu9IXmdKwNYjD1sZ3TJ1O

#

here's the payment intent id

high yoke
#

so really add clear logs to your log, checkout what paymentIntent.latest_charge returns for example and log the exact response/error too

tawny spindle
#

Got it! Will do that! Thank you very much for your help and time! It was really helpful

high yoke
#

do you want to try now?

#

I can help make this work if you do it in real time right now

tawny spindle
#

Unfortunately I gotta go do some other businesses rn, but will come back in a few hours

high yoke
#

sounds good

tawny spindle
#

So I'll try it again and if I get the error again, I'll reach u guys here again

high yoke
#

but really as long as you properly pass source_transaction: 'ch_123' it should work so if you log your params you should be able to debug this easily!

#

have a great rest of the day 🙂