From e71c34913f2dab05fa6e614bd67645dfea8cfa72 Mon Sep 17 00:00:00 2001
From: Pedro Silva
Date: Tue, 13 Feb 2024 14:37:50 +0000
Subject: [PATCH] Implement AXO settings
---
modules/ppcp-axo/src/AxoModule.php | 8 ++++++--
modules/ppcp-axo/src/Gateway/AxoGateway.php | 16 +++++++++++++++-
.../ppcp-wc-gateway/resources/css/common.scss | 9 +++++++++
3 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/modules/ppcp-axo/src/AxoModule.php b/modules/ppcp-axo/src/AxoModule.php
index b9c952f18..3561c707b 100644
--- a/modules/ppcp-axo/src/AxoModule.php
+++ b/modules/ppcp-axo/src/AxoModule.php
@@ -36,8 +36,12 @@ class AxoModule implements ModuleInterface {
add_filter(
'woocommerce_payment_gateways',
- function ( $methods ): array {
- $methods[] = new AxoGateway();
+ function ( $methods ) use ( $c ): array {
+ $settings = $c->get( 'wcgateway.settings' );
+
+ $methods[] = new AxoGateway(
+ $settings
+ );
return $methods;
},
1,
diff --git a/modules/ppcp-axo/src/Gateway/AxoGateway.php b/modules/ppcp-axo/src/Gateway/AxoGateway.php
index f40508672..9e8bd5817 100644
--- a/modules/ppcp-axo/src/Gateway/AxoGateway.php
+++ b/modules/ppcp-axo/src/Gateway/AxoGateway.php
@@ -10,6 +10,7 @@ declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\Axo\Gateway;
use WC_Payment_Gateway;
+use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
/**
* Class AXOGateway.
@@ -18,11 +19,23 @@ class AxoGateway extends WC_Payment_Gateway {
const ID = 'ppcp-axo-gateway';
+ /**
+ * The settings.
+ *
+ * @var ContainerInterface
+ */
+ protected $config;
+
/**
* AXOGateway constructor.
+ *
+ * @param ContainerInterface $config The settings.
*/
public function __construct(
+ ContainerInterface $config
) {
+ $this->config = $config;
+
$this->id = self::ID;
$this->method_title = __( 'Fastlane Debit & Credit Cards', 'woocommerce-paypal-payments' );
@@ -51,7 +64,8 @@ class AxoGateway extends WC_Payment_Gateway {
// $this->icon = esc_url( $this->module_url ) . 'assets/images/axo.svg'; // TODO
// $this->environment = $environment;
- $this->update_option( 'enabled', 'yes' ); // TODO : depend on settings
+ $is_axo_enabled = $this->config->has( 'axo_enabled' ) && $this->config->get( 'axo_enabled' );
+ $this->update_option( 'enabled', $is_axo_enabled ? 'yes' : 'no' );
}
/**
diff --git a/modules/ppcp-wc-gateway/resources/css/common.scss b/modules/ppcp-wc-gateway/resources/css/common.scss
index 6ab2f4a56..8217bd3b3 100644
--- a/modules/ppcp-wc-gateway/resources/css/common.scss
+++ b/modules/ppcp-wc-gateway/resources/css/common.scss
@@ -39,3 +39,12 @@
font-weight: bold;
}
}
+
+.ppcp-field-indent {
+ background-color: #f9f9f9;
+ border: 1px solid #c3c4c7;
+
+ & + .ppcp-field-indent {
+ border-top: 2px solid transparent;
+ }
+}