diff --git a/modules/ppcp-compat/services.php b/modules/ppcp-compat/services.php index 113d90a0e..f8d4cf29c 100644 --- a/modules/ppcp-compat/services.php +++ b/modules/ppcp-compat/services.php @@ -9,4 +9,18 @@ declare(strict_types=1); namespace WooCommerce\PayPalCommerce\Compat; -return array(); +return array( + + 'compat.ppec.mock-gateway' => static function( $container ) { + $settings = $container->get( 'wcgateway.settings' ); + $title = $settings->has( 'title' ) ? $settings->get( 'title' ) : __( 'PayPal', 'woocommerce-paypal-payments' ); + $title = sprintf( + /* Translators: placeholder is the gateway name. */ + __( '%s (Legacy)', 'woocommerce-paypal-payments' ), + $title + ); + + return new PPEC\MockGateway( $title ); + }, + +); diff --git a/modules/ppcp-compat/src/PPEC/class-mockgateway.php b/modules/ppcp-compat/src/PPEC/class-mockgateway.php new file mode 100644 index 000000000..cc070c048 --- /dev/null +++ b/modules/ppcp-compat/src/PPEC/class-mockgateway.php @@ -0,0 +1,49 @@ +id = PPECHelper::PPEC_GATEWAY_ID; + $this->title = $title; + $this->method_title = $this->title; + $this->description = ''; + $this->supports = array( + 'subscriptions', + 'subscription_cancellation', + 'subscription_suspension', + 'subscription_reactivation', + 'subscription_amount_changes', + 'subscription_date_changes', + 'subscription_payment_method_change', + 'subscription_payment_method_change_customer', + 'subscription_payment_method_change_admin', + 'multiple_subscriptions', + ); + } + + /** + * Check if the gateway is available for use. + * + * @return bool + */ + public function is_available() { + // Hide mock gateway, except on admin. + return is_admin(); + } + +}