mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +08:00
♻️ Switch gateways to use new configuration class
This commit is contained in:
parent
8712e37587
commit
0adc8ae4ba
6 changed files with 41 additions and 6 deletions
|
@ -35,6 +35,7 @@ return array(
|
|||
$container->get( 'axo.gateway' ),
|
||||
fn() : SmartButtonInterface => $container->get( 'button.smart-button' ),
|
||||
$container->get( 'wcgateway.settings' ),
|
||||
$container->get( 'wcgateway.configuration.dcc' ),
|
||||
$container->get( 'onboarding.environment' ),
|
||||
$container->get( 'wcgateway.url' )
|
||||
);
|
||||
|
|
|
@ -16,6 +16,7 @@ use WooCommerce\PayPalCommerce\Button\Assets\SmartButtonInterface;
|
|||
use WooCommerce\PayPalCommerce\Onboarding\Environment;
|
||||
use WooCommerce\PayPalCommerce\Axo\Gateway\AxoGateway;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Helper\DCCGatewayConfiguration;
|
||||
|
||||
/**
|
||||
* Class AxoBlockPaymentMethod
|
||||
|
@ -57,6 +58,13 @@ class AxoBlockPaymentMethod extends AbstractPaymentMethodType {
|
|||
*/
|
||||
protected $settings;
|
||||
|
||||
/**
|
||||
* The DCC gateway settings.
|
||||
*
|
||||
* @var DCCGatewayConfiguration
|
||||
*/
|
||||
protected DCCGatewayConfiguration $dcc_configuration;
|
||||
|
||||
/**
|
||||
* The environment object.
|
||||
*
|
||||
|
@ -80,6 +88,7 @@ class AxoBlockPaymentMethod extends AbstractPaymentMethodType {
|
|||
* @param SmartButtonInterface|callable $smart_button The smart button script loading
|
||||
* handler.
|
||||
* @param Settings $settings The settings.
|
||||
* @param DCCGatewayConfiguration $dcc_configuration The DCC gateway settings.
|
||||
* @param Environment $environment The environment object.
|
||||
* @param string $wcgateway_module_url The WcGateway module URL.
|
||||
*/
|
||||
|
@ -89,6 +98,7 @@ class AxoBlockPaymentMethod extends AbstractPaymentMethodType {
|
|||
WC_Payment_Gateway $gateway,
|
||||
$smart_button,
|
||||
Settings $settings,
|
||||
DCCGatewayConfiguration $dcc_configuration,
|
||||
Environment $environment,
|
||||
string $wcgateway_module_url
|
||||
) {
|
||||
|
@ -98,6 +108,7 @@ class AxoBlockPaymentMethod extends AbstractPaymentMethodType {
|
|||
$this->gateway = $gateway;
|
||||
$this->smart_button = $smart_button;
|
||||
$this->settings = $settings;
|
||||
$this->dcc_configuration = $dcc_configuration;
|
||||
$this->environment = $environment;
|
||||
$this->wcgateway_module_url = $wcgateway_module_url;
|
||||
|
||||
|
@ -215,7 +226,7 @@ class AxoBlockPaymentMethod extends AbstractPaymentMethodType {
|
|||
'focusBorderColor' => $this->settings->has( 'axo_style_input_focus_border_color' ) ? $this->settings->get( 'axo_style_input_focus_border_color' ) : '',
|
||||
),
|
||||
),
|
||||
'name_on_card' => $this->settings->has( 'axo_name_on_card' ) ? $this->settings->get( 'axo_name_on_card' ) : '',
|
||||
'name_on_card' => $this->dcc_configuration->show_name_on_card(),
|
||||
'woocommerce' => array(
|
||||
'states' => array(
|
||||
'US' => WC()->countries->get_states( 'US' ),
|
||||
|
|
|
@ -74,6 +74,7 @@ return array(
|
|||
return new AxoGateway(
|
||||
$container->get( 'wcgateway.settings.render' ),
|
||||
$container->get( 'wcgateway.settings' ),
|
||||
$container->get( 'wcgateway.configuration.dcc' ),
|
||||
$container->get( 'wcgateway.url' ),
|
||||
$container->get( 'session.handler' ),
|
||||
$container->get( 'wcgateway.order-processor' ),
|
||||
|
|
|
@ -29,6 +29,7 @@ use WooCommerce\PayPalCommerce\WcGateway\Settings\SettingsRenderer;
|
|||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\ProcessPaymentTrait;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Exception\GatewayGenericException;
|
||||
use WooCommerce\PayPalCommerce\Session\SessionHandler;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Helper\DCCGatewayConfiguration;
|
||||
|
||||
/**
|
||||
* Class AXOGateway.
|
||||
|
@ -52,6 +53,13 @@ class AxoGateway extends WC_Payment_Gateway {
|
|||
*/
|
||||
protected $ppcp_settings;
|
||||
|
||||
/**
|
||||
* Gateway configuration object, providing relevant settings.
|
||||
*
|
||||
* @var DCCGatewayConfiguration
|
||||
*/
|
||||
protected DCCGatewayConfiguration $dcc_configuration;
|
||||
|
||||
/**
|
||||
* The WcGateway module URL.
|
||||
*
|
||||
|
@ -127,6 +135,7 @@ class AxoGateway extends WC_Payment_Gateway {
|
|||
*
|
||||
* @param SettingsRenderer $settings_renderer The settings renderer.
|
||||
* @param ContainerInterface $ppcp_settings The settings.
|
||||
* @param DCCGatewayConfiguration $dcc_configuration The DCC Gateway configuration.
|
||||
* @param string $wcgateway_module_url The WcGateway module URL.
|
||||
* @param SessionHandler $session_handler The Session Handler.
|
||||
* @param OrderProcessor $order_processor The Order processor.
|
||||
|
@ -141,6 +150,7 @@ class AxoGateway extends WC_Payment_Gateway {
|
|||
public function __construct(
|
||||
SettingsRenderer $settings_renderer,
|
||||
ContainerInterface $ppcp_settings,
|
||||
DCCGatewayConfiguration $dcc_configuration,
|
||||
string $wcgateway_module_url,
|
||||
SessionHandler $session_handler,
|
||||
OrderProcessor $order_processor,
|
||||
|
@ -156,6 +166,7 @@ class AxoGateway extends WC_Payment_Gateway {
|
|||
|
||||
$this->settings_renderer = $settings_renderer;
|
||||
$this->ppcp_settings = $ppcp_settings;
|
||||
$this->dcc_configuration = $dcc_configuration;
|
||||
$this->wcgateway_module_url = $wcgateway_module_url;
|
||||
$this->session_handler = $session_handler;
|
||||
$this->order_processor = $order_processor;
|
||||
|
@ -167,9 +178,7 @@ class AxoGateway extends WC_Payment_Gateway {
|
|||
$is_axo_enabled = $this->ppcp_settings->has( 'axo_enabled' ) && $this->ppcp_settings->get( 'axo_enabled' );
|
||||
$this->update_option( 'enabled', $is_axo_enabled ? 'yes' : 'no' );
|
||||
|
||||
$this->title = $this->ppcp_settings->has( 'axo_gateway_title' )
|
||||
? $this->ppcp_settings->get( 'axo_gateway_title' )
|
||||
: $this->get_option( 'title', $this->method_title );
|
||||
$this->title = $this->dcc_configuration->gateway_title( $this->get_option( 'title', $this->method_title ) );
|
||||
|
||||
$this->description = __( 'Enter your email address above to continue.', 'woocommerce-paypal-payments' );
|
||||
|
||||
|
|
|
@ -79,6 +79,7 @@ use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
|||
use WooCommerce\PayPalCommerce\WcGateway\Settings\SettingsListener;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Settings\SettingsRenderer;
|
||||
use WooCommerce\PayPalCommerce\Applepay\ApplePayGateway;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Helper\DCCGatewayConfiguration;
|
||||
|
||||
return array(
|
||||
'wcgateway.paypal-gateway' => static function ( ContainerInterface $container ): PayPalGateway {
|
||||
|
@ -123,6 +124,7 @@ return array(
|
|||
$order_processor = $container->get( 'wcgateway.order-processor' );
|
||||
$settings_renderer = $container->get( 'wcgateway.settings.render' );
|
||||
$settings = $container->get( 'wcgateway.settings' );
|
||||
$dcc_configuration = $container->get( 'wcgateway.configuration.dcc' );
|
||||
$module_url = $container->get( 'wcgateway.url' );
|
||||
$session_handler = $container->get( 'session.handler' );
|
||||
$refund_processor = $container->get( 'wcgateway.processor.refunds' );
|
||||
|
@ -138,6 +140,7 @@ return array(
|
|||
$settings_renderer,
|
||||
$order_processor,
|
||||
$settings,
|
||||
$dcc_configuration,
|
||||
$icons,
|
||||
$module_url,
|
||||
$session_handler,
|
||||
|
|
|
@ -35,6 +35,7 @@ use WooCommerce\PayPalCommerce\WcGateway\Processor\TransactionIdHandlingTrait;
|
|||
use WooCommerce\PayPalCommerce\WcGateway\Settings\SettingsRenderer;
|
||||
use WooCommerce\PayPalCommerce\WcSubscriptions\FreeTrialHandlerTrait;
|
||||
use WooCommerce\PayPalCommerce\WcSubscriptions\Helper\SubscriptionHelper;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Helper\DCCGatewayConfiguration;
|
||||
|
||||
/**
|
||||
* Class CreditCardGateway
|
||||
|
@ -73,6 +74,13 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
|
|||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* The DCC Gateway Configuration.
|
||||
*
|
||||
* @var DCCGatewayConfiguration
|
||||
*/
|
||||
protected DCCGatewayConfiguration $dcc_configuration;
|
||||
|
||||
/**
|
||||
* The vaulted credit card handler.
|
||||
*
|
||||
|
@ -191,6 +199,7 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
|
|||
* @param SettingsRenderer $settings_renderer The Settings Renderer.
|
||||
* @param OrderProcessor $order_processor The Order processor.
|
||||
* @param ContainerInterface $config The settings.
|
||||
* @param DCCGatewayConfiguration $dcc_configuration The DCC Gateway Configuration.
|
||||
* @param array $card_icons The card icons.
|
||||
* @param string $module_url The URL to the module.
|
||||
* @param SessionHandler $session_handler The Session Handler.
|
||||
|
@ -212,6 +221,7 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
|
|||
SettingsRenderer $settings_renderer,
|
||||
OrderProcessor $order_processor,
|
||||
ContainerInterface $config,
|
||||
DCCGatewayConfiguration $dcc_configuration,
|
||||
array $card_icons,
|
||||
string $module_url,
|
||||
SessionHandler $session_handler,
|
||||
|
@ -233,6 +243,7 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
|
|||
$this->settings_renderer = $settings_renderer;
|
||||
$this->order_processor = $order_processor;
|
||||
$this->config = $config;
|
||||
$this->dcc_configuration = $dcc_configuration;
|
||||
$this->module_url = $module_url;
|
||||
$this->session_handler = $session_handler;
|
||||
$this->refund_processor = $refund_processor;
|
||||
|
@ -269,8 +280,7 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
|
|||
'Accept debit and credit cards, and local payment methods with PayPal’s latest solution.',
|
||||
'woocommerce-paypal-payments'
|
||||
);
|
||||
$this->title = $this->config->has( 'dcc_gateway_title' ) ?
|
||||
$this->config->get( 'dcc_gateway_title' ) : $this->method_title;
|
||||
$this->title = $this->dcc_configuration->gateway_title();
|
||||
$this->description = $this->config->has( 'dcc_gateway_description' ) ?
|
||||
$this->config->get( 'dcc_gateway_description' ) : $this->method_description;
|
||||
$this->card_icons = $card_icons;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue