#hari-developer_webhooks
1 messages ยท Page 1 of 1 (latest)
๐ 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.
In order to get Stripe fees you need to make this API call:
https://docs.stripe.com/expand/use-cases#stripe-fee-for-payment
thank you. Does this api works for events created in test mode? I am getting no such payment_intent
Yes it works
Can you share the ID (req_xxx) of the failing API request?
https://support.stripe.com/questions/finding-the-id-for-an-api-request
req_Fxkalna9YoluR1?t=1738581030
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
How do I pass the value in curl command? I don't see a syntax for the API
Choose the curl option in the code snippets in the doc link
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'
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.
this is what I am getting in the payment_intent for latest_charge. "latest_charge": "ch_3QoBPi4RtBAKhk7Y1iWLEEbO",
Seems expected, yep as per the API reference: https://docs.stripe.com/api/payment_intents/object#payment_intent_object-latest_charge
nullable string
There used to be a charges field on the Payment Intent object which was a list/array of all charges, but we changed that: https://docs.stripe.com/changelog/2022-11-15/removes-charges-attribute-paymentintent
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.
Can you share the ID (req_xxx) of the API request? https://support.stripe.com/questions/finding-the-id-for-an-api-request
Because the code you shared above should work: https://docs.stripe.com/expand/use-cases#stripe-fee-for-payment
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)
Because you need to expansd the balance_transaction field on the Charge
fee_details is on the BT object, not the Charge: https://docs.stripe.com/api/balance_transactions/object#balance_transaction_object-fee_details
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
The guide I linked explains this
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)
Which version of our Ruby SDK are you on? And what's the exact code you're using the get that error
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" })
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"
})
that worked. thank you so much.
Will this be available as soon as payment_intent.succeeded event
charge.updated is the event you want
On charges_updated event, I should retrieve payment_intent. when I look at the charges updated event on the dashboard application fee is null
When you get charge,updated event just retrieve the ch_xxx ID and expand balance_transaction โ no need for the PI
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
},
Yes because you need to expand it as I just said
I am sorry to annoy you, please be patient. How can I expand it?
Stripe::Charge.retrieve({
id: "ch_xxx",
expand: ["balance_transaction"]
}, {
stripe_account: "acct_1QeG284RtBAKhk7Y"
})
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
You ned to use the second one:
https://docs.stripe.com/expand/use-cases?lang=node#stripe-fee-for-payment
Thank you