From 31686a6214cac7fe55b21c220f6d22612ee52090 Mon Sep 17 00:00:00 2001
From: Philipp Stracker
Date: Fri, 14 Mar 2025 11:38:30 +0100
Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Early=20exit=20if=20merchant=20is?=
=?UTF-8?q?=20not=20onboarded?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
modules/ppcp-wc-gateway/services.php | 6 ++++-
.../src/Helper/DCCGatewayConfiguration.php | 27 ++++++++++++++-----
2 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/modules/ppcp-wc-gateway/services.php b/modules/ppcp-wc-gateway/services.php
index 43e447f86..d95c84de1 100644
--- a/modules/ppcp-wc-gateway/services.php
+++ b/modules/ppcp-wc-gateway/services.php
@@ -84,6 +84,7 @@ use WooCommerce\PayPalCommerce\WcGateway\Settings\SettingsRenderer;
use WooCommerce\PayPalCommerce\Axo\Helper\PropertiesDictionary;
use WooCommerce\PayPalCommerce\Applepay\ApplePayGateway;
use WooCommerce\PayPalCommerce\WcGateway\Helper\DCCGatewayConfiguration;
+use WooCommerce\PayPalCommerce\WcGateway\Helper\ConnectionState;
return array(
'wcgateway.paypal-gateway' => static function ( ContainerInterface $container ): PayPalGateway {
@@ -1362,10 +1363,13 @@ return array(
},
'wcgateway.configuration.dcc' => static function ( ContainerInterface $container ) : DCCGatewayConfiguration {
+ $connection_state = $container->get( 'settings.connection-state' );
+ assert( $connection_state instanceof ConnectionState );
+
$settings = $container->get( 'wcgateway.settings' );
assert( $settings instanceof Settings );
- return new DCCGatewayConfiguration( $settings );
+ return new DCCGatewayConfiguration( $connection_state, $settings );
},
'wcgateway.helper.dcc-product-status' => static function ( ContainerInterface $container ) : DCCProductStatus {
diff --git a/modules/ppcp-wc-gateway/src/Helper/DCCGatewayConfiguration.php b/modules/ppcp-wc-gateway/src/Helper/DCCGatewayConfiguration.php
index 3cf55c0b3..8781efa74 100644
--- a/modules/ppcp-wc-gateway/src/Helper/DCCGatewayConfiguration.php
+++ b/modules/ppcp-wc-gateway/src/Helper/DCCGatewayConfiguration.php
@@ -26,6 +26,13 @@ use WooCommerce\PayPalCommerce\Axo\Helper\PropertiesDictionary;
* DI service: 'wcgateway.configuration.dcc'
*/
class DCCGatewayConfiguration {
+ /**
+ * The connection state.
+ *
+ * @var ConnectionState
+ */
+ private ConnectionState $connection_state;
+
/**
* The plugin settings instance.
*
@@ -80,10 +87,11 @@ class DCCGatewayConfiguration {
/**
* Initializes the gateway details based on the provided Settings instance.
*
+ * @param ConnectionState $connection_state Connection state instance.
* @param Settings $settings Plugin settings instance.
- * @throws NotFoundException If an expected gateway setting is not found.
*/
- public function __construct( Settings $settings ) {
+ public function __construct( ConnectionState $connection_state, Settings $settings ) {
+ $this->connection_state = $connection_state;
$this->settings = $settings;
$this->refresh();
@@ -99,11 +107,16 @@ class DCCGatewayConfiguration {
$show_on_card_options = array_keys( PropertiesDictionary::cardholder_name_options() );
$show_on_card_value = null;
- $this->is_enabled = false;
- $this->use_fastlane = false;
- $this->gateway_title = '';
- $this->gateway_description = '';
- $this->show_name_on_card = $show_on_card_options[0];
+ $this->is_enabled = false;
+ $this->use_fastlane = false;
+ $this->gateway_title = '';
+ $this->gateway_description = '';
+ $this->show_name_on_card = $show_on_card_options[0];
+ $this->hide_fastlane_watermark = false;
+
+ if ( ! $this->connection_state->is_connected() ) {
+ return;
+ }
try {
/*