Skip to main content

benecaster_donation_amount

Filter Free

Fires immediately before the PaymentIntent amount is passed to Stripe (after the benecaster_should_create_donation_intent check). Stripe enforces its own minimums per currency — returning an amount below the Stripe minimum will result in an API error.

$amount is an int in MINOR units (cents), not a float in dollars. A callback written against major units — max( $amount, 1.00 ) against the integer 50 — returns 50 and enforces nothing, and the mistake fails silently: no warning, no log, a donation that should have been refused goes through.

Do not use this filter to enforce a minimum. It changes what the donor is charged without telling them — somebody who typed 50 cents is billed a dollar and finds out on their statement. Set minimum_custom_amount (Settings → Listener Support → Donation amounts) or filter it with benecaster_donation_minimum_amount instead: that path refuses the donation with an explanation the donor can act on.

Parameters

Name Type Default Description
$amount int — Donation amount in MINOR units (cents for USD, yen for JPY). Minor units are not always hundredths — read the currency rather than dividing by 100.
$show_id int — ID of the show

Returns: int

Example

add_filter( 'benecaster_donation_amount', function( $amount, $show_id ) {
    // Round up to a whole currency unit. Amounts are minor units, so this
    // is 100 for USD -- do NOT assume hundredths for every currency.
    return (int) ( ceil( $amount / 100 ) * 100 );
}, 10, 2 );

Need this built rather than just documented? See our services →