#nicus_api

1 messages · Page 1 of 1 (latest)

north talonBOT
#

👋 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.

balmy karma
#

hello there

bitter fable
#

Hello, are you a developer here with an API question?

balmy karma
#

yes

bitter fable
#

Gotcha, how can I help?

balmy karma
#

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,
},
)

bitter fable
#

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

balmy karma
#

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)

bitter fable
#

Ah you want to know how much was reversed from the Connected Account

#

Not the actual refund amount to the end-customer

balmy karma
#

exactly

bitter fable
#

Gotcha

#

Oh actually you can do this right from the refund

#

No need to retrieve the PaymentIntent

balmy karma
#

that sounds interesting, how can I¨?

bitter fable
#

Just expand charge.transfer

#

Or

#

Both give you the same info overall

balmy karma
#

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, }, )

bitter fable
#

Yep

balmy karma
#

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)?

north talonBOT
bitter fable
#

You would get the associated transfer reversal each time

#

Would recommend testing this out!

balmy karma
#

I can try now

#

yes it works fine, thank you