#Geilt

1 messages · Page 1 of 1 (latest)

pliant estuaryBOT
swift socket
#

👋 I can help

#

What's your question?

gusty adder
#

When we do a charge via an invoice and bill to the card on file, how can we capture the STRIPE FEE, meaning, the amount that stripe is deducting from the invoice as a fee from stripe, meaning the usual .05 % or whatever + .30 c pe rtransaction off the total amount.

#

Meaning, the money that Stripe takes from US when we bill an invoice, so we can figure out how much we are actually making.

#

As an example when we charge through the portal we get a return value of how much of a fee stripe charged us, I can't find thi sin the API

swift socket
gusty adder
#

How do we relate this back to the Charge? Is there no easier way to do this without mutliple API calls? Can it be send via webhook?

#

I see so the charge object has the balance transaction ID and thats where we get the datra.

#

on webhook

swift socket
#

Yeah so if you're starting from the Invoice ID, you can retrieve it and expand payment_intent.charges.data.balance_transaction (or payment_intent.latest_charge.balance_transaction if you're on the most recent API version) to get it in the same request - I'm fairly sure this will work, but definitely test this out.

Alternatively, you can get the BalanceTransaction ID from the charge.succeeded webhook event and retrieve the Balance Transaction from there

gusty adder
#

I got it working by grabbing the charge id then getting the balance_tranasction with that charge id.

#

case 'invoice.paid':
try {
$charge = $this->getCharge( $invoice->charge );
$balancetx = $this->getBalanceTransaction( $charge->balance_transaction );
$fee = $balancetx->fee;

#

Which is basically what we need since we are trying to only deal with invoices.

#

Otherwise I need to revers elookup the invoice from the charge layer to connect it.