Skip to main content

Set a per-show minimum donation, and refuse a donation your own way

Free Intermediate

Benecaster does not require an account or a password to make a donation — the endpoint is open on purpose, so an anonymous listener can tip without signing up first. That openness is exactly why the amount rules are the only cheap lever available on it. minimum_custom_amount is an operator setting (Listener Support → Donation amounts, with a per-show override), and benecaster_donation_minimum_amount overrides the saved value per show at read time.

Minor units, and minor units are not always hundredths. 500 is $5.00 in USD and ¥500 in JPY. Read the currency from the same settings array rather than dividing by 100.

The floor never applies to the show’s own suggested amounts, and your filter cannot make it. Core checks the suggested list first, deliberately: a floor that could veto a suggested amount would disable a button the podcaster can see on their own page, with the explanation nowhere. If you want a suggested amount gone, remove it with benecaster_donation_suggested_amounts — that is the filter that owns the buttons.

A refusal below the floor returns benecaster_amount_below_minimum (HTTP 400) with minimum_custom_amount in the error data, so a custom donation form can tell the supporter what would work. A zero amount, or any amount on a show that takes no custom amounts at all, returns the generic benecaster_invalid_amount instead — do not treat the two as one, or you will tell a donor to try a bigger number on a show where no number can succeed.

For anything the amount cannot express, refuse at benecaster_should_create_donation_intent, which runs after validation and before Stripe is touched.

None of this detects card testing — it only raises the cost. The endpoint’s own rate-limit bucket (listener_support_intent, 10 per 5 minutes per IP) does the same. The thing that recognises an attack is Stripe Radar’s card-testing rules, on the podcaster’s own Stripe account, and no filter here substitutes for it.

Code

<?php
/**
 * A patronage show wants a $25 floor; everything else keeps the site value.
 *
 * @param int $minimum Minor units.
 */
add_filter( 'benecaster_donation_minimum_amount', function ( int $minimum, int $show_id ): int {
    return 42 === $show_id ? 2500 : $minimum;
}, 10, 2 );

/**
 * For anything the amount cannot express, refuse the intent outright.
 * Runs after amount validation and before Stripe is touched.
 */
add_filter( 'benecaster_should_create_donation_intent', function ( bool $create, int $show_id, int $amount, string $currency ): bool {
    return 'USD' === $currency ? $create : false;
}, 10, 4 );

View on GitHub →

Hooks Used