benecaster_stripe_charge_refunded
Fires when a Stripe charge.refunded webhook event is received, for a full or partial refund of any charge on the podcaster’s webhook endpoint: a built-in membership charge or a Listener Support donation alike. It is not limited to membership charges, which is why its name has no membership.
Benecaster’s own listener records the charge’s refunded total against the revenue-ledger payment for the invoice the charge paid, so benecaster_get_membership_payments() shows the refund on that payment. A charge that matches no recorded payment changes nothing.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$stripe_charge_id |
string |
— | Stripe charge ID |
$event |
\Stripe\Event |
— | Full Stripe event object; its data object is the Charge |
Examples
Keep an external refund total in step
add_action( 'benecaster_stripe_charge_refunded', function ( string $stripe_charge_id, \Stripe\Event $event ): void {
$charge = $event->data->object;
// amount_refunded is the running total so far: set it, never add to it.
my_accounting_set_refunded( $stripe_charge_id, (int) $charge->amount_refunded, strtoupper( $charge->currency ) );
}, 10, 2 );
Notes
amount_refunded on the charge is the cumulative refunded total, not this refund's amount. Stripe can deliver the same event twice, and a second partial refund sends the new running total, so set your own figure from it rather than adding to it.
The event only reaches the site if charge.refunded is selected on the podcaster's Stripe webhook endpoint. The setup wizard's event list includes it; an endpoint created without it does not send refunds until the event is added in the Stripe Dashboard. A Stripe credit note that credits the customer's balance instead of refunding money does not fire this hook.
$event is rendered at the Stripe API version of the webhook endpoint. On an endpoint at 2025-03-31.basil or later a charge carries no invoice; use $stripe_charge_id rather than reading identifiers off $event.
Need this built rather than just documented? See our services →