#Jonas Reif

1 messages ยท Page 1 of 1 (latest)

junior knollBOT
rose ruin
#

At the moment we listen to the charge_refunded webhook.
There we get the amount_refunded (e.g. 10000 for the 100โ‚ฌ)

But I need to find a way to get the "new" payed tax

elfin saddle
#

Hm you may have to do a manual calculation to get that

#

Can you share an invoice id where you issued a credit note though so I can take a look?

rose ruin
#

in_1NIblnAHqm7DWpwQze6PnaDh

#

thats visible in the stripe dashboard

#

so basically I need the

  • adjusted_total (in that example 248โ‚ฌ)
  • and the adjusted_tax (55.56 - 15.96 --> 39,6)
elfin saddle
#

You can get it from the credit note

#

But you'll need to do the subtraction yourself

rose ruin
#

In the charge.refunded webhook is there also a way to get the credit note id somehow?

elfin saddle
#

Doesn't look like it

#

You can take a look at the event on your dashboard

rose ruin
#

Ok I get list all credit_notes by adding the invoice as parameter

Stripe::CreditNote.list(invoice: charge[:invoice])

And then I could iterate over it.

But I cant imagine that this is the only place where I could find that adjusted tax

elfin saddle
#

AFAIK you need to get it from the credit note

#

It's not on the invoice directly

junior knollBOT
rose ruin
#

Sorry, what do you mean?

elfin saddle
#

You need to get this from the credit note object

rose ruin
#

what do you mean by "this"?

spice cradle
#

HI ๐Ÿ‘‹

I'm stepping in as @elfin saddle needs to go soon. By "this" my colleague means the amount you should refund will be present in the credit note

elfin saddle
#

The data you were asking for @rose ruin

#

But you need to do the subtraction yourself

rose ruin
#

Yes I get the tax from the credit_notes.

But when I listen to the charge.refunded webhook I have to first retrieve all credit_notes of that invoice by searching for all credit_notes of that invoice

elfin saddle
#

Well you could just listen to credit_note.created also

rose ruin
#

Yes that would be also possible. But I dont see any advantage.

If you have 2 credit notes for an invoice (what could happen) then you have to fetch the invoice (to get the total amount) + search again for all other credit_notes of that invoice to get the total_refunded amount and calculate the tax

elfin saddle
#

yeah

#

so in that case listing credit notes by invoice is what you need

rose ruin
#

ok thanks ๐Ÿ™‚
I'll try that