mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
Add mock PPEC gateway
This commit is contained in:
parent
4973f9bc7f
commit
9ca0394d80
2 changed files with 64 additions and 1 deletions
|
@ -9,4 +9,18 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace WooCommerce\PayPalCommerce\Compat;
|
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 );
|
||||||
|
},
|
||||||
|
|
||||||
|
);
|
||||||
|
|
49
modules/ppcp-compat/src/PPEC/class-mockgateway.php
Normal file
49
modules/ppcp-compat/src/PPEC/class-mockgateway.php
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Mock PayPal Express Checkout class.
|
||||||
|
*
|
||||||
|
* @package WooCommerce\PayPalCommerce\Compat\PPEC
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace WooCommerce\PayPalCommerce\Compat\PPEC;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mocks the PayPal Express Checkout gateway.
|
||||||
|
*/
|
||||||
|
class MockGateway extends \WC_Payment_Gateway {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param string $title Gateway title.
|
||||||
|
*/
|
||||||
|
public function __construct( $title ) {
|
||||||
|
$this->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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue