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); the PayPal Gateway add-on ships PayPalGateway.

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 core and add-on gateways; a third-party gateway should use its own vendor prefix so it cannot collide with one Benecaster adds later.

Affects

  • Listener Support checkout
  • Built-in membership checkout
  • Settings → Payments gateway picker

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