#hari-developer_webhooks

1 messages ยท Page 1 of 1 (latest)

harsh kettleBOT
#

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

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

jagged agate
languid remnant
#

thank you. Does this api works for events created in test mode? I am getting no such payment_intent

jagged agate
#

Yes it works

languid remnant
#

req_Fxkalna9YoluR1?t=1738581030

jagged agate
#

You are trying to access to the PaymentIntent with the wrong account.

#

Make sure to pass the Connect Account Auth header acct_1QeG284RtBAKhk7Y when retreiving that PaymentIntent

languid remnant
#

How do I pass the value in curl command? I don't see a syntax for the API

jagged agate
#

Choose the curl option in the code snippets in the doc link

languid remnant
#

thank you. I used ruby console to excute it.
Stripe.api_key = 'sk_test_XXXXXXX'

payment_intent = Stripe::PaymentIntent.retrieve({
id: 'pi_XXX',
expand: ['latest_charge.balance_transaction'],
})

fee_details = payment_intent.latest_charge.balance_transaction.fee_details

I am getting payment_intent. latest_charge key has just one value and it is not an array object. getting undefined method `balance_transaction'

jagged agate
#

I am getting payment_intent. latest_charge key has just one value and it is not an array object.
Yes latest_charge is an object and not array.

harsh kettleBOT
languid remnant
#

this is what I am getting in the payment_intent for latest_charge. "latest_charge": "ch_3QoBPi4RtBAKhk7Y1iWLEEbO",

thick pike
languid remnant
#

Ok. My intent is to get the stripe fee for each of the the transaction.

#

I am not sure what method or webhook event that I can use.

thick pike
languid remnant
#

I am using Ruby console to execute the code. I get this error
payment_intent.latest_charge.fee_details
(irb):27:in <main>': undefined method fee_details' for "ch_3QoBPi4RtBAKhk7Y1iWLEEbO":String (NoMethodError)

thick pike
#

Because you need to expansd the balance_transaction field on the Charge

thick pike
languid remnant
#

I was trying different options. I excuted as per the code
payment_intent.latest_charge.balance_transaction.fee_details
(irb):28:in <main>': undefined method balance_transaction' for "ch_3QoBPi4RtBAKhk7Y1iWLEEbO":String (NoMethodError)

thick pike
#

Which version of our Ruby SDK are you on? And what's the exact code you're using the get that error

languid remnant
#

I am using stripe Gem stripe (13.0.0)
payment_intent=Stripe::PaymentIntent.retrieve( "pi_3QoBPi4RtBAKhk7Y1nIHWOhn",{ expand: ['charges.data.balance_transaction'], stripe_account: "acct_1QeG284RtBAKhk7Y" })

thick pike
#

That code is different to the error you shared. Anyway, can you try:

Stripe::PaymentIntent.retrieve({
  id: "pi_3QoBPi4RtBAKhk7Y1nIHWOhn",
  expand: ["latest_charge.balance_transaction"]
}, {
  stripe_account: "acct_1QeG284RtBAKhk7Y"
})
languid remnant
#

that worked. thank you so much.
Will this be available as soon as payment_intent.succeeded event

thick pike
#

charge.updated is the event you want

languid remnant
#

On charges_updated event, I should retrieve payment_intent. when I look at the charges updated event on the dashboard application fee is null

thick pike
#

When you get charge,updated event just retrieve the ch_xxx ID and expand balance_transaction โ€“ no need for the PI

languid remnant
#

Here is the partial event details from the dashboard for charges.updated event. Balance transactions has string value not an object
{
"id": "ch_3QoBPi4RtBAKhk7Y1iWLEEbO",
"object": "charge",
"livemode": false,
"payment_intent": "pi_3QoBPi4RtBAKhk7Y1nIHWOhn",
"status": "succeeded",
"amount": 40000,
"amount_captured": 40000,
"amount_refunded": 0,
"application": "ca_RA44LSyVF3M6bAVIoBzgEarsKPmIF0eQ",
"application_fee": null,
"application_fee_amount": null,
"balance_transaction": "txn_3QoBPi4RtBAKhk7Y1b5ALSif",
"billing_details": {
"address": {
"city": null,
"country": "US",
"line1": null,
"line2": null,
"postal_code": "75019",
"state": null
},

thick pike
languid remnant
#

I am sorry to annoy you, please be patient. How can I expand it?

thick pike
#
Stripe::Charge.retrieve({
  id: "ch_xxx",
  expand: ["balance_transaction"]
}, {
  stripe_account: "acct_1QeG284RtBAKhk7Y"
})
languid remnant
#

thats awesome. Thank you so much

#

that worked. One last question please. should I use charges.balance_transaction.fee or charges.balance_transaction.fee_details.find { |fee| fee.type == 'stripe_fee'}&.amount

jagged agate
languid remnant
#

Thank you