#nicus_api
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/1370134990439841863
📝 Have more to share? Add more details, code, screenshots, videos, etc. below.
hello there
Hello, are you a developer here with an API question?
yes
Gotcha, how can I help?
let me give you mreo details
the problem is the following
we are a company with clients, in this case restaurants, each restaurant has it's own connected account.
So when the restaurant charges for a catering order, for example, we have a percentage of that transaction.
Let's say if they sell $1000, we get $30 and the biz gets $1970.
We also provide the feature to the biz to generate a refund.
The problem is that if the biz makes a refund for $100, on the connected account I see there is less money refunded from their account (which makes sense), for example $97 are refunded from their account.
Now I need a way to know effectevly how much money was refunded from their account (in this case the $97) via Stripe's API 'cause I need to save that information on our DB to show some numbers later. But I cannot find a way to get the final amount refunded from that connected account.
I checked the response from the Refund creation, but I only get the requested amount (in this case $100).
How can I get the real amount refunded by the biz?
Here is how we create the refund on our backend
refund = self.stripe.Refund.create(
payment_intent=invoice.stripe_paid_via_payment_intent_id,
amount=amount,
reason=self.RefundReason.REQUESTED_BY_CUSTOMER,
reverse_transfer=True,
expand=["charge"],
metadata={
"revi.refund.request.source": RefundSource.DASHBOARD,
},
)
I'm not sure I understand what you mean? If you trigger a refund for $100 then that is how much is refunded.
Maybe if you provide a specific example we can look at that would help
sure
https://dashboard.stripe.com/acct_1FPDjbBD9A55uQT0/test/payments/py_1RMamBBD9A55uQT0oGCek1lw
Payment id: py_1RMamBBD9A55uQT0oGCek1lw
This is a payment with a refund. As you can see is for $1.940.00
But when I generated with the code I share before, I passed $2000.00 (in fact 200000 since it was in cents)
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Ah you want to know how much was reversed from the Connected Account
Not the actual refund amount to the end-customer
exactly
Gotcha
So you want to retrieve the relevant PaymentIntent and expand its latest_charge.transfer -- then you can look at the amount_reversed for the associated Transfer: https://docs.stripe.com/api/transfers/object?api-version=2025-04-30.preview#transfer_object-amount_reversed
Oh actually you can do this right from the refund
No need to retrieve the PaymentIntent
that sounds interesting, how can I¨?
Just expand charge.transfer
Or
Just expand transfer_reversal: https://docs.stripe.com/api/refunds/object?api-version=2025-04-30.preview#refund_object-transfer_reversal
Both give you the same info overall
I will try
like this right?
refund = self.stripe.Refund.create( payment_intent=invoice.stripe_paid_via_payment_intent_id, amount=amount, reason=self.RefundReason.REQUESTED_BY_CUSTOMER, reverse_transfer=True, expand=["transfer_reversal"], metadata={ "revi.refund.request.source": RefundSource.DASHBOARD, }, )
Yep
you rock, it works
quick question
if they perform 2 refunds, on the same transaction. If I expand this field on the same way on both transaction, will I get the indiviual amount ($1.940) or in the second refund I will get the accumulated amount ($3.880)?