Early exit if merchant is not onboarded

This commit is contained in:
Philipp Stracker 2025-03-14 11:38:30 +01:00
parent 0d54c84e66
commit 31686a6214
No known key found for this signature in database
2 changed files with 25 additions and 8 deletions

View file

@ -84,6 +84,7 @@ use WooCommerce\PayPalCommerce\WcGateway\Settings\SettingsRenderer;
use WooCommerce\PayPalCommerce\Axo\Helper\PropertiesDictionary; use WooCommerce\PayPalCommerce\Axo\Helper\PropertiesDictionary;
use WooCommerce\PayPalCommerce\Applepay\ApplePayGateway; use WooCommerce\PayPalCommerce\Applepay\ApplePayGateway;
use WooCommerce\PayPalCommerce\WcGateway\Helper\DCCGatewayConfiguration; use WooCommerce\PayPalCommerce\WcGateway\Helper\DCCGatewayConfiguration;
use WooCommerce\PayPalCommerce\WcGateway\Helper\ConnectionState;
return array( return array(
'wcgateway.paypal-gateway' => static function ( ContainerInterface $container ): PayPalGateway { 'wcgateway.paypal-gateway' => static function ( ContainerInterface $container ): PayPalGateway {
@ -1362,10 +1363,13 @@ return array(
}, },
'wcgateway.configuration.dcc' => static function ( ContainerInterface $container ) : DCCGatewayConfiguration { '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' ); $settings = $container->get( 'wcgateway.settings' );
assert( $settings instanceof 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 { 'wcgateway.helper.dcc-product-status' => static function ( ContainerInterface $container ) : DCCProductStatus {

View file

@ -26,6 +26,13 @@ use WooCommerce\PayPalCommerce\Axo\Helper\PropertiesDictionary;
* DI service: 'wcgateway.configuration.dcc' * DI service: 'wcgateway.configuration.dcc'
*/ */
class DCCGatewayConfiguration { class DCCGatewayConfiguration {
/**
* The connection state.
*
* @var ConnectionState
*/
private ConnectionState $connection_state;
/** /**
* The plugin settings instance. * The plugin settings instance.
* *
@ -80,10 +87,11 @@ class DCCGatewayConfiguration {
/** /**
* Initializes the gateway details based on the provided Settings instance. * Initializes the gateway details based on the provided Settings instance.
* *
* @param ConnectionState $connection_state Connection state instance.
* @param Settings $settings Plugin settings 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->settings = $settings;
$this->refresh(); $this->refresh();
@ -99,11 +107,16 @@ class DCCGatewayConfiguration {
$show_on_card_options = array_keys( PropertiesDictionary::cardholder_name_options() ); $show_on_card_options = array_keys( PropertiesDictionary::cardholder_name_options() );
$show_on_card_value = null; $show_on_card_value = null;
$this->is_enabled = false; $this->is_enabled = false;
$this->use_fastlane = false; $this->use_fastlane = false;
$this->gateway_title = ''; $this->gateway_title = '';
$this->gateway_description = ''; $this->gateway_description = '';
$this->show_name_on_card = $show_on_card_options[0]; $this->show_name_on_card = $show_on_card_options[0];
$this->hide_fastlane_watermark = false;
if ( ! $this->connection_state->is_connected() ) {
return;
}
try { try {
/* /*