Skip to main content

Add a new payment processor alongside Stripe

Free Advanced Since v1.0.0

Implement PodcastPaymentGateway and register your gateway with PaymentGatewayRegistry during benecaster_boot. is_test_mode(): bool is mandatory — a class missing it raises a PHP fatal at load (the interface declares it with no default body). Returning true makes the admin TEST MODE badge and subscriber-facing test-mode banner light up across the install. Use benecaster_payment_test_mode_active() from your own templates to mirror core’s badge — it aggregates across every registered gateway and is safe to call before plugin boot.

Code

<?php
add_action( 'benecaster_boot', function ( \Benecaster\Container $container ): void {
    $container->bind( My\PayPalGateway::class, fn() => new My\PayPalGateway() );
    $container->make( \Benecaster\Payment\PaymentGatewayRegistry::class )
        ->register( $container->make( My\PayPalGateway::class ) );
} );

class PayPalGateway implements \Benecaster\Payment\PodcastPaymentGateway {
    public function get_gateway_slug(): string { return 'benecaster_paypal'; }
    public function is_test_mode(): bool { return (bool) get_option( 'my_paypal_sandbox_mode', false ); }
    // … subscription lifecycle methods …
}

View on GitHub →