Add Fastlane settings to the AXO payment gateway settings screen

This commit is contained in:
Daniel Dudzic 2024-04-29 14:38:43 +02:00
parent 92a7747ae0
commit 6fbd4f3890
No known key found for this signature in database
GPG key ID: 31B40D33E3465483
5 changed files with 51 additions and 24 deletions

View file

@ -57,9 +57,9 @@ return array(
State::STATE_ONBOARDED,
),
'requirements' => array(
'dcc',
array('dcc', 'axo'),
),
'gateway' => 'dcc',
'gateway' => array('dcc', 'axo'),
),
'axo_enabled' => array(
'title' => __( 'Fastlane', 'woocommerce-paypal-payments' ),
@ -75,7 +75,7 @@ return array(
. '</p>',
'default' => 'yes',
'screens' => array( State::STATE_ONBOARDED ),
'gateway' => 'dcc',
'gateway' => array('dcc', 'axo'),
'requirements' => array(),
'custom_attributes' => array(
'data-ppcp-display' => wp_json_encode(
@ -129,7 +129,7 @@ return array(
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'dcc',
'gateway' => array('dcc', 'axo'),
),
'axo_privacy' => array(
'title' => __( 'Privacy', 'woocommerce-paypal-payments' ),
@ -145,7 +145,7 @@ return array(
'default' => 'yes',
'options' => PropertiesDictionary::privacy_options(),
'screens' => array( State::STATE_ONBOARDED ),
'gateway' => 'dcc',
'gateway' => array('dcc', 'axo'),
'requirements' => array(),
),
'axo_style_heading' => array(
@ -179,9 +179,9 @@ return array(
State::STATE_ONBOARDED,
),
'requirements' => array(
'dcc',
array('dcc', 'axo'),
),
'gateway' => 'dcc',
'gateway' => array('dcc', 'axo'),
),
'axo_style_root_heading' => array(
@ -193,8 +193,8 @@ return array(
),
'classes' => array( 'ppcp-field-indent' ),
'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'dcc' ),
'gateway' => 'dcc',
'requirements' => array( array('dcc', 'axo') ),
'gateway' => array('dcc', 'axo'),
),
'axo_style_root_bg_color' => array(
'title' => __( 'Background Color', 'woocommerce-paypal-payments' ),
@ -204,7 +204,7 @@ return array(
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'dcc',
'gateway' => array('dcc', 'axo'),
),
'axo_style_root_error_color' => array(
'title' => __( 'Error Color', 'woocommerce-paypal-payments' ),
@ -214,7 +214,7 @@ return array(
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'dcc',
'gateway' => array('dcc', 'axo'),
),
'axo_style_root_font_family' => array(
'title' => __( 'Font Family', 'woocommerce-paypal-payments' ),
@ -224,7 +224,7 @@ return array(
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'dcc',
'gateway' => array('dcc', 'axo'),
),
'axo_style_root_font_size_base' => array(
'title' => __( 'Font Size Base', 'woocommerce-paypal-payments' ),
@ -234,7 +234,7 @@ return array(
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'dcc',
'gateway' => array('dcc', 'axo'),
),
'axo_style_root_padding' => array(
'title' => __( 'Padding', 'woocommerce-paypal-payments' ),
@ -244,7 +244,7 @@ return array(
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'dcc',
'gateway' => array('dcc', 'axo'),
),
'axo_style_root_primary_color' => array(
'title' => __( 'Primary Color', 'woocommerce-paypal-payments' ),
@ -254,7 +254,7 @@ return array(
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'dcc',
'gateway' => array('dcc', 'axo'),
),
'axo_style_input_heading' => array(
'heading' => __( 'Input Settings', 'woocommerce-paypal-payments' ),
@ -265,8 +265,8 @@ return array(
),
'classes' => array( 'ppcp-field-indent' ),
'screens' => array( State::STATE_ONBOARDED ),
'requirements' => array( 'dcc' ),
'gateway' => 'dcc',
'requirements' => array( array('dcc', 'axo') ),
'gateway' => array('dcc', 'axo'),
),
'axo_style_input_bg_color' => array(
'title' => __( 'Background Color', 'woocommerce-paypal-payments' ),
@ -276,7 +276,7 @@ return array(
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'dcc',
'gateway' => array('dcc', 'axo'),
),
'axo_style_input_border_radius' => array(
'title' => __( 'Border Radius', 'woocommerce-paypal-payments' ),
@ -286,7 +286,7 @@ return array(
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'dcc',
'gateway' => array('dcc', 'axo'),
),
'axo_style_input_border_color' => array(
'title' => __( 'Border Color', 'woocommerce-paypal-payments' ),
@ -296,7 +296,7 @@ return array(
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'dcc',
'gateway' => array('dcc', 'axo'),
),
'axo_style_input_border_width' => array(
'title' => __( 'Border Width', 'woocommerce-paypal-payments' ),
@ -306,7 +306,7 @@ return array(
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'dcc',
'gateway' => array('dcc', 'axo'),
),
'axo_style_input_text_color_base' => array(
'title' => __( 'Text Color Base', 'woocommerce-paypal-payments' ),
@ -316,7 +316,7 @@ return array(
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'dcc',
'gateway' => array('dcc', 'axo'),
),
'axo_style_input_focus_border_color' => array(
'title' => __( 'Focus Border Color', 'woocommerce-paypal-payments' ),
@ -326,7 +326,7 @@ return array(
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'dcc',
'gateway' => array('dcc', 'axo'),
),
)

View file

@ -63,6 +63,7 @@ return array(
'axo.gateway' => static function ( ContainerInterface $container ): AxoGateway {
return new AxoGateway(
$container->get( 'wcgateway.settings.render' ),
$container->get( 'wcgateway.settings' ),
$container->get( 'wcgateway.url' ),
$container->get( 'wcgateway.order-processor' ),

View file

@ -21,18 +21,27 @@ use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory;
use WooCommerce\PayPalCommerce\ApiClient\Factory\ShippingPreferenceFactory;
use WooCommerce\PayPalCommerce\Onboarding\Environment;
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\GatewaySettingsRendererTrait;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\TransactionUrlProvider;
use WooCommerce\PayPalCommerce\WcGateway\Processor\OrderMetaTrait;
use WooCommerce\PayPalCommerce\WcGateway\Processor\OrderProcessor;
use WooCommerce\PayPalCommerce\WcGateway\Settings\SettingsRenderer;
/**
* Class AXOGateway.
*/
class AxoGateway extends WC_Payment_Gateway {
use OrderMetaTrait;
use OrderMetaTrait, GatewaySettingsRendererTrait;
const ID = 'ppcp-axo-gateway';
/**
* The Settings Renderer.
*
* @var SettingsRenderer
*/
protected $settings_renderer;
/**
* The settings.
*
@ -106,6 +115,7 @@ class AxoGateway extends WC_Payment_Gateway {
/**
* AXOGateway constructor.
*
* @param SettingsRenderer $settings_renderer The settings renderer.
* @param ContainerInterface $ppcp_settings The settings.
* @param string $wcgateway_module_url The WcGateway module URL.
* @param OrderProcessor $order_processor The Order processor.
@ -118,6 +128,7 @@ class AxoGateway extends WC_Payment_Gateway {
* @param LoggerInterface $logger The logger.
*/
public function __construct(
SettingsRenderer $settings_renderer,
ContainerInterface $ppcp_settings,
string $wcgateway_module_url,
OrderProcessor $order_processor,
@ -131,6 +142,7 @@ class AxoGateway extends WC_Payment_Gateway {
) {
$this->id = self::ID;
$this->settings_renderer = $settings_renderer;
$this->ppcp_settings = $ppcp_settings;
$this->wcgateway_module_url = $wcgateway_module_url;
$this->order_processor = $order_processor;
@ -181,6 +193,9 @@ class AxoGateway extends WC_Payment_Gateway {
'desc_tip' => true,
'description' => __( 'Enable/Disable AXO payment gateway.', 'woocommerce-paypal-payments' ),
),
'ppcp' => array(
'type' => 'ppcp',
),
);
}
@ -321,4 +336,12 @@ class AxoGateway extends WC_Payment_Gateway {
return parent::get_title();
}
/**
* Returns the settings renderer.
*
* @return SettingsRenderer
*/
protected function settings_renderer(): SettingsRenderer {
return $this->settings_renderer;
}
}

View file

@ -195,6 +195,7 @@ return array(
CardButtonGateway::ID,
OXXOGateway::ID,
Settings::PAY_LATER_TAB_ID,
AxoGateway::ID,
),
true
);

View file

@ -9,6 +9,7 @@ declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\WcGateway\Settings;
use WooCommerce\PayPalCommerce\Axo\Gateway\AxoGateway;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\CardButtonGateway;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\CreditCardGateway;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
@ -37,6 +38,7 @@ trait PageMatcherTrait {
Settings::PAY_LATER_TAB_ID => Settings::PAY_LATER_TAB_ID,
CreditCardGateway::ID => 'dcc', // TODO: consider using just the gateway ID for PayPal and DCC too.
CardButtonGateway::ID => CardButtonGateway::ID,
AxoGateway::ID => 'axo',
);
return array_key_exists( $current_page_id, $gateway_page_id_map )
&& in_array( $gateway_page_id_map[ $current_page_id ], $allowed_gateways, true );