Skip to main content

benecaster_payment_gateways

Filter Premium

Registers payment gateways. Each key is a gateway slug and each value is an object implementing PodcastPaymentGateway. Benecaster ships StripeGateway (benecaster_stripe).

A registered gateway takes no payments yet. Benecaster’s checkout, renewals, account page and webhooks bill through Stripe directly and never call a registered gateway’s methods; today registration affects only test-mode reporting (the TEST MODE badge and benecaster_payment_test_mode_active()). The interface is being redesigned around the operations built-in membership really performs, so do not build a gateway against these signatures yet. A gateway add-on that calls its own processor should still guard every charge with the clone guard.

The filter is applied lazily, on first read rather than at plugin load, so a gateway registered from a benecaster_boot callback is already attached by the time it fires.

Parameters

Name Type Default Description
$gateways array — Keyed array of gateway instances: slug => PodcastPaymentGateway.

Returns: array

Example

add_filter( 'benecaster_payment_gateways', function ( array $gateways ): array {
    $gateways['my_processor'] = new My_Processor_Gateway();

    return $gateways;
} );

Notes

This is the one registration filter in Benecaster that passes objects, and that is deliberate. The two strategy filters — benecaster_related_episodes_query_types and benecaster_member_thanks_query_types — take a label and a single callback, because that is all a strategy is. A gateway is a seven-method lifecycle contract: the methods that authorize, charge, refund and report test mode have to agree with each other, and an array of loose callables cannot hold them together. Do not read the asymmetry as an oversight in either direction.

is_test_mode() is mandatory on the interface — omitting it is a PHP fatal at class load, not a runtime warning.

Gateway slugs must be unique across every registered gateway. The convention is benecaster_{processor} for built-in and add-on gateways; a third-party gateway should use its own vendor prefix so it cannot collide with one Benecaster adds later.

Affects

  • TEST MODE badge

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