#mattia_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/1281681214272442448
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
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?
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.
I'm looking for that method in our Java SDK but I'm not seeing it here: https://github.com/stripe/stripe-java
Hmmmm.... Yes I'm looking here: https://github.com/stripe/stripe-java/blob/master/src/main/java/com/stripe/model/BalanceTransaction.java
hm, maybe it was removed?
OH wait...you're on a beta branch
com.stripe:stripe-java:25.2.0-beta.1
Unfortunately we cannot help with betas here
is 26.10.0 the latest version?
Yes
hope it doesn't break all of my code
I would NOT recommend just YOLO'ing an update.
Especially since we pin API versions in our Java SDK
I still see the #getNet method
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
mhm
not mentioned anywhere in the CHANGELOG https://github.com/stripe/stripe-java/blob/master/CHANGELOG.md
not sure what to say honestly
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
Wait a sec.... I wonder if that is just returning this value?
https://docs.stripe.com/api/balance_transactions/object#balance_transaction_object-net
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
maybe?
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.
๐
What's the best way then, to get the net amount (excluding stripe/external processor fees, and refunds) received from an invoice payment?
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.
I see, how do I retrieve refunds for a specific invoice?
You can listen to the charge.refunded event: https://docs.stripe.com/api/events/types#event_types-charge.refunded and keep track that way.
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?
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.
We talk about fees with refunds here: https://support.stripe.com/questions/understanding-fees-for-refunded-payments
I get this, but I received 0.36 eur in paypal fees refund, as shown in the dashboard.
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
What do you see after you retrieve the balance transaction from that refund?
in regards to what? fees?
Yes
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
Can you share the response from https://docs.stripe.com/api/balance_transactions/retrieve request for that balance transaction?
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
I think the balance transaction for the refund is: txn_1Pw5fVEv6RqipoTEbZzZv4yT
Can you try this?
this contains the 0.36, but it shows it as negative amount
while the dashboard shows it as a positive one
so was it removed or added to my balance?
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
I see this on the dashboard, and as you can notice, there's no min sign
while the other fees have it
We are unable to help with Dashboard quesitons on here as we help with integration related questions. Please reach out to https://support.stripe.com/contact