Skip to main content

benecaster_stripe_keyset_configured

Action Premium

Fires when a Stripe mode starts resolving to a different, usable secret key — the moment there is an account to create Products and Prices in that was not there before. Benecaster listens to it to sweep the active paid tiers and mint whatever that mode is missing.

The trigger is not “this mode became configured”, and the difference is the whole point. That narrower reading looks equivalent and is not: on an install with site-wide keys, every mode already reads as configured for every show — so a show taking live over onto its own Stripe account would fire nothing, while its Products sit in the site’s account, absent from the one it will actually charge through. Keying on the resolved credential covers both cases with one rule: gaining a mode, and moving a mode to a different account.

Clearing a keyset fires nothing. A mode that resolves to no key has no account to provision into.

Parameters

Name Type Default Description
$mode string `test` or `live` — the mode whose credential just changed.
$show_id int|null The show that gained the credential, or `null` when it is the site-wide keyset. A listener that ignores this will provision the wrong account on a multi-show install.

Examples

Provision your own add-on's Stripe objects when a keyset appears

add_action( 'benecaster_stripe_keyset_configured', function ( string $mode, ?int $show_id ): void {
    // Resolve the SDK for the same scope the hook fired for — never the site-wide one,
    // or you will create objects in an account this show does not charge through.
    $stripe = benecaster_container()->make( \Benecaster\Payment\StripeClient::class );
    $sdk    = $stripe->sdk_for_show_mode( $show_id, $mode );
    if ( null === $sdk ) {
        return;
    }

    my_addon_mint_missing_products( $sdk, $mode, $show_id );
}, 10, 2 );

Notes

The Benecaster listener fills only what is MISSING. A tier that already holds Stripe IDs for a mode is left alone, so pointing a mode at a different Stripe account does not re-mint anything — the old account's IDs stay on the tier and do not exist in the new one, and checkout fails against them. If you write your own listener, decide deliberately whether it should behave the same way; the Benecaster rule is a safety choice, not an oversight.

Episode buy-ups are not swept by the Benecaster listener. They are provisioned when the buy-up itself is created or edited.

Fires once per mode, not once per save. Saving a keyset that changes both modes fires twice, once for each, and a save that changes neither fires not at all.

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