#mattia_api

1 messages ยท Page 1 of 1 (latest)

high questBOT
#

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

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

hardy wagon
#

HI ๐Ÿ‘‹

Balances transactions are separated by type so I would not expect payment and refund transactions to be returned together.

What API are you using here?

marsh meadow
#

Using the Java API wrapper to calculate the net amount of an invoice payment by doing the following:

`BalanceTransaction balanceTransaction = invoice.getPaymentIntentObject()
.getLatestChargeObject()
.getBalanceTransactionObject();

and then

balanceTransaction.getNet();`

#

On this payment pi_3PudgiEv6RqipoTE0UH8RdsB, I would expect #getNet to return 4.65, but it instead returns the amount without the refund amount applied.

#

The Stripe Dashboard, however, correctly shows 4.65 as the net amount.

hardy wagon
marsh meadow
#

hm

marsh meadow
#

hm, maybe it was removed?

hardy wagon
#

OH wait...you're on a beta branch

#

com.stripe:stripe-java:25.2.0-beta.1

#

Unfortunately we cannot help with betas here

marsh meadow
#

is 26.10.0 the latest version?

hardy wagon
#

Yes

marsh meadow
#

hope it doesn't break all of my code

hardy wagon
#

I would NOT recommend just YOLO'ing an update.

#

Especially since we pin API versions in our Java SDK

marsh meadow
#

I still see the #getNet method

hardy wagon
#

Ugh, I am not seeing where that is defined in our code though.

#

It's not a straightforward API request since we don't have an API for that

marsh meadow
#

mhm

hardy wagon
marsh meadow
#

not sure what to say honestly

hardy wagon
#

I understand wanting this to work but I'm still confused by this method. Balance Transactions are separate for payments and refunds so I would NOT expect any individual BT to net out refunds, only Stripe fees

#

But since I cannot find any example of how this function operates, I cannot speak to what it is actually doing

high questBOT
hardy wagon
#

Net impact to a Stripe balance (in cents). A positive value represents incrementing a Stripe balance, and a negative value decrementing a Stripe balance. You can calculate the net impact of a transaction on a balance by amount - fee

marsh meadow
#

maybe?

hardy wagon
#

I think that's it and that would explain why it doesn't include the refund

#

I've gotta run but my colleague @finite folio is here for any additional questions.

#

๐Ÿ‘‹

marsh meadow
#

What's the best way then, to get the net amount (excluding stripe/external processor fees, and refunds) received from an invoice payment?

finite folio
#

Hi, stepping in and looking on my end. Hang tight..

#

Balance Transactions, represent funds moving through your Stripe account. Stripe creates them for every type of transaction that enters or leaves your Stripe account balance. For this reason, you would get two different balance transactions one for the payment and another for the refunds. You can track these on your end to attain the net amount.

marsh meadow
#

I see, how do I retrieve refunds for a specific invoice?

finite folio
marsh meadow
#

I need to fetch refunds after payment, even after days

#

pi_3PudgiEv6RqipoTE0UH8RdsB in this payment, I see that I've been refunded 0.36 EUR in PayPal fees, this credit however is not included in the balanceTransaction.getFees, is this intentional?

#

if it is, how can I get it?

finite folio
#

If you listen to charge.refunded, and then track this in your database, you would not need to make another request to GET the refunds.

marsh meadow
#

This 0.36 seems to not be tracked in the API

#

referring to this

#

Stripe -0.20
PayPal -1.04
Taxes -0.04
PayPal (after refund) **+**0.36

#

those 0.36 are not deduced from the fees you can get by doing balanceTransaction.getFees

finite folio
#

What do you see after you retrieve the balance transaction from that refund?

finite folio
#

Yes

marsh meadow
#

if I do: balanceTransaction.getFeeDetails().stream().mapToLong(FeeDetail::getAmount).sum()) to get the total fees I paid, I get 1.28 EUR

#

which doesn't include the **+**0.36 refund I received

finite folio
marsh meadow
#

how do I get the balance transaction id from the dashboard?

#

nvm, there you go:

{ "id": "txn_3PudgiEv6RqipoTE0tnR2TOR", "object": "balance_transaction", "amount": 5200, "available_on": 1725840000, "created": 1725297240, "currency": "eur", "description": "Payment for Invoice", "exchange_rate": null, "fee": 128, "fee_details": [ { "amount": 20, "application": null, "currency": "eur", "description": "Stripe processing fees", "type": "stripe_fee" }, { "amount": 104, "application": null, "currency": "eur", "description": "PayPal fees", "type": "payment_method_passthrough_fee" }, { "amount": 4, "application": null, "currency": "eur", "description": "VAT", "type": "tax" } ], "net": 5072, "reporting_category": "charge", "source": "py_3PudgiEv6RqipoTE0oSslsrT", "status": "pending", "type": "payment" }

#

as you can see, there's no 0.36 EUR

finite folio
#

I think the balance transaction for the refund is: txn_1Pw5fVEv6RqipoTEbZzZv4yT

#

Can you try this?

marsh meadow
#

while the dashboard shows it as a positive one

#

so was it removed or added to my balance?

finite folio
#

I can't speak to what you're seeing on the Dashboard. However, it is deducting funds from the account to it would be negative.

#

If you have additional questions on the Dashboard, please reach out to our support team

marsh meadow
finite folio
marsh meadow
#

while the other fees have it

finite folio