Skip to main content

benecaster_should_create_donation_intent

Filter Free

Fires before the Stripe PaymentIntent is created for a listener donation, after amount validation and before Stripe is touched. Return false to block the payment. Use for geographic restrictions, currency restrictions, or maintenance windows. When returning false, pair with benecaster_before_donation_form to surface a visible explanation to the donor — the endpoint answers 403 with no message the donor can act on.

The filter passes four parameters, and $amount is an int in MINOR units (cents), not a float. A callback registered with an accepted-args count of 3 never receives $currency, and a floor written against major units — $amount < 1.0 against the integer 500 — never fires.

To enforce a donation floor, do not use this filter. Set minimum_custom_amount (Settings → Listener Support → Donation amounts, with a per-show override), or filter it with benecaster_donation_minimum_amount. The setting refuses with benecaster_amount_below_minimum and returns the floor, so the donor is told what would work; a bare false here tells them nothing. Use this filter for what the amount cannot express.

Parameters

Name Type Default Description
$create bool — Whether to create the PaymentIntent; default true
$show_id int — ID of the show
$amount int — Donation amount in MINOR units (cents for USD, yen for JPY). Not a float and not dollars — minor units are not always hundredths, so read the currency rather than dividing by 100.
$currency string — Uppercase ISO currency code for the donation

Returns: bool

Example

add_filter( 'benecaster_should_create_donation_intent', function( $create, $show_id, $amount, $currency ) {
    // This show only accepts donations in its own currency.
    return 'USD' === $currency ? $create : false;
}, 10, 4 );

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