#blagi.connecto

1 messages · Page 1 of 1 (latest)

topaz tuskBOT
unreal patrol
#

Hello, can you explain the amount_refunded behavior that you are asking about a bit more? Are you saying that the amount always shows the payment total? Or that it is missing for partial refunds?

dense scaffold
#

We have often partially refund. For example, once 5 €, second 3 €. On second charge.refunded, amount refunded is 8. 3 is not 'mentioned' anywhere in paylod charge ocject.

#

amount refunded = amount_refunded field

#

Hi Pompeye thanks for helping.

unreal patrol
#

Can you send me the ID of a charge.refunded event that you saw this with? (evt_123)

dense scaffold
#

ch_3NSJXEHyMHmjD7NO1j5i9QyI

It's a test one. I'm testing changing from live refund to webhook based.

unreal patrol
#

Thanks, looking in to the events for that charge

dense scaffold
#

Sorry I added one letter to your nickname. 😦

unreal patrol
#

Apologies the server is busy so it took me a bit to look in to this. It looks like we do include "amount_refunded": 500, on the charge object itself. The charge.refunded event is still for the full Charge object, so the amount is referring to the overall amount on the charge and amount_refunded is a field we provide to specifically talk about the refund https://dashboard.stripe.com/test/events/evt_3NSJXEHyMHmjD7NO1hElhbdI

dense scaffold
#

So information about one particular refund is missing?

#

In timeline for related payment_intent on dashboard I can that amount, but how to retrieve it?

unreal patrol
#

No it isn't missing

#

It is in the amount_refunded field

#

Which is present in the event that you got

dense scaffold
#

3 € are on the timeline, but I do not have that amount in charge.refunded event payload!?

#

Am I missing some related event type?

unreal patrol
#

I think for charge events you would need to calculate that amount

#

There is a refund.created event that will probably show you this amount more straightforwardly

dense scaffold
#

I thought that all event types are included in test environment!? I didn't got refund.created event!?

unreal patrol
#

My apologies, it looks like that event isn't for this kind of refund scenario:

Occurs whenever a refund from a customer’s cash balance is created.

#

So I think the best way would be to calculate this.

topaz tuskBOT
unreal patrol
#

So in that second event, there is a previous_attributes hash, it tells you what has changed on the charge since the last event. This one says

      "amount_refunded": 500,
      ...
    }```
So your refund amount will be `amount_refunded` - `previous_attributes.amount_refunded`
#

Ex: On the first event previous_attributes.amount_refunded was 0 and amount_refunded was 500. So the refund amount was 500 - 0 = 500

Then on the second event previous_attributes.amount_refunded was 500 and amount_refunded was 800. So the refund amount was 800 - 500 = 300

dense scaffold
#

In event data exists this:
[previous_attributes] => Stripe\StripeObject Object
(
[amount_refunded] => 500
[receipt_url] => https://pay.stripe.com/receipts/payment/CAcaFwoVYWNjdF8xTXlDUUdIeU1IbWpEN05PKK__r6UGMgYvg98fEso6LBafmL9fC326yORuzJmruu-pIU3mvWpX1ET_ONmZ7bqHZhwXmwdeD3b4xwG7
)

API description:

data.previous_attributes
hash
Object containing the names of the updated attributes and their values prior to the event (only included in events of type *.updated). If an array attribute has any updated elements, this object contains the entire array. In Stripe API versions 2017-04-06 or earlier, an updated array attribute in this object includes only the updated array elements.

#

Can I use this data for calculating?

unreal patrol
#

Yes

Ex: On the first event previous_attributes.amount_refunded was 0 and amount_refunded was 500. So the refund amount was 500 - 0 = 500

Then on the second event previous_attributes.amount_refunded was 500 and amount_refunded was 800. So the refund amount was 800 - 500 = 300