Skip to main content

PodcastPaymentGateway

\Benecaster\Payment\PodcastPaymentGateway

Interface Free

The payment gateway contract all gateway implementations must satisfy. Benecaster ships StripeGateway (slug benecaster_stripe); the PayPal Gateway add-on ships PayPalGateway. Third-party developers implement this interface and register the instance through the benecaster_payment_gateways filter. is_test_mode() is mandatory — omitting it raises a PHP fatal at class load.

benecaster_payment_gateways passes objects, and it is the only registration filter in Benecaster that does. The two strategy filters — benecaster_related_episodes_query_types and benecaster_member_thanks_query_types — take a label and one callback each, because that is all a strategy is. A gateway is a seven-method lifecycle contract whose methods have to move together, and an array of loose callables cannot hold that. The asymmetry is deliberate.

Methods

Method Visibility Since Description
get_gateway_slug(): string Public Returns the stable slug identifying this gateway. Convention: benecaster_{processor}. Must be unique across all registered gateways.
is_test_mode(): bool Public Mandatory — omitting raises a PHP fatal. Returns whether the gateway is in test mode. Drives the persistent TEST MODE badge on all Benecaster admin screens and the subscriber account page banner.
create_subscription(): \Stripe\Subscription Public Creates a new subscription for a subscriber.
cancel_subscription(): \Stripe\Subscription Public Cancels an existing subscription. Default for StripeGateway: cancel_at_period_end = true so feed access continues through the current billing period.
update_payment_method(): void Public Updates the payment method on a subscriber's account.
get_billing_history(): array Public Returns a paginated list of invoices or billing events. Each entry must include at minimum: date, amount, currency, status, invoice_url.
handle_webhook( \Stripe\Event $event ): void Public Handles a raw event from the payment provider. For StripeGateway, fires the appropriate benecaster_stripe_membership_* routing action.