🔀 Merge branch 'trunk'

# Conflicts:
#	modules/ppcp-button/resources/js/modules/ContextBootstrap/CheckoutBootstap.js
#	modules/ppcp-button/resources/js/modules/Helper/CheckoutMethodState.js
This commit is contained in:
Philipp Stracker 2024-07-24 18:42:57 +02:00
commit 9f39a58f07
No known key found for this signature in database
26 changed files with 662 additions and 110 deletions

View file

@ -188,10 +188,6 @@ document.addEventListener( 'DOMContentLoaded', () => {
}
function shouldDisableCardButton() {
if ( currentTabId() === 'ppcp-card-button-gateway' ) {
return false;
}
return (
PayPalCommerceGatewaySettings.is_acdc_enabled ||
jQuery( '#ppcp-allow_card_button_gateway' ).is( ':checked' )
@ -230,6 +226,14 @@ document.addEventListener( 'DOMContentLoaded', () => {
}
if ( shouldDisableCardButton() ) {
const standardCardButtonInput = document.querySelector(
'#woocommerce_ppcp-card-button-gateway_enabled'
);
if ( standardCardButtonInput ) {
standardCardButtonInput.disabled = true;
}
disabledSources = disabledSources.concat( 'card' );
}

View file

@ -20,6 +20,7 @@ use WooCommerce\PayPalCommerce\ApiClient\Helper\DccApplies;
use WooCommerce\PayPalCommerce\Axo\Gateway\AxoGateway;
use WooCommerce\PayPalCommerce\Button\Helper\MessagesDisclaimers;
use WooCommerce\PayPalCommerce\Common\Pattern\SingletonDecorator;
use WooCommerce\PayPalCommerce\Googlepay\GooglePayGateway;
use WooCommerce\PayPalCommerce\Onboarding\Environment;
use WooCommerce\PayPalCommerce\Onboarding\Render\OnboardingOptionsRenderer;
use WooCommerce\PayPalCommerce\Onboarding\State;
@ -196,6 +197,7 @@ return array(
OXXOGateway::ID,
Settings::PAY_LATER_TAB_ID,
AxoGateway::ID,
GooglePayGateway::ID,
),
true
);
@ -217,6 +219,7 @@ return array(
CardButtonGateway::ID,
Settings::PAY_LATER_TAB_ID,
Settings::CONNECTION_TAB_ID,
GooglePayGateway::ID,
),
true
);

View file

@ -106,6 +106,12 @@ class DisableGateways {
return $methods;
}
// phpcs:ignore WordPress.Security.NonceVerification.Missing
$payment_method = wc_clean( wp_unslash( $_POST['payment_method'] ?? '' ) );
if ( $payment_method && is_string( $payment_method ) ) {
return array( $payment_method => $methods[ $payment_method ] );
}
return array( PayPalGateway::ID => $methods[ PayPalGateway::ID ] );
}

View file

@ -19,9 +19,10 @@ use WooCommerce\PayPalCommerce\WcGateway\Helper\SettingsStatus;
* Creates the admin message about the gateway being enabled without the PayPal gateway.
*/
class GatewayWithoutPayPalAdminNotice {
private const NOTICE_OK = '';
private const NOTICE_DISABLED_GATEWAY = 'disabled_gateway';
private const NOTICE_DISABLED_LOCATION = 'disabled_location';
private const NOTICE_OK = '';
private const NOTICE_DISABLED_GATEWAY = 'disabled_gateway';
private const NOTICE_DISABLED_LOCATION = 'disabled_location';
private const NOTICE_DISABLED_CARD_BUTTON = 'disabled_card';
/**
* The gateway ID.
@ -99,6 +100,9 @@ class GatewayWithoutPayPalAdminNotice {
public function message(): ?Message {
$notice_type = $this->check();
$url1 = '';
$url2 = '';
switch ( $notice_type ) {
case self::NOTICE_DISABLED_GATEWAY:
/* translators: %1$s the gateway name, %2$s URL. */
@ -114,6 +118,15 @@ class GatewayWithoutPayPalAdminNotice {
'woocommerce-paypal-payments'
);
break;
case self::NOTICE_DISABLED_CARD_BUTTON:
/* translators: %1$s Standard Card Button section URL, %2$s Advanced Card Processing section URL. */
$text = __(
'The <a href="%1$s">Standard Card Button</a> cannot be used while <a href="%2$s">Advanced Card Processing</a> is enabled.',
'woocommerce-paypal-payments'
);
$url1 = admin_url( 'admin.php?page=wc-settings&tab=checkout&section=ppcp-card-button-gateway' );
$url2 = admin_url( 'admin.php?page=wc-settings&tab=checkout&section=ppcp-gateway&ppcp-tab=ppcp-credit-card-gateway' );
break;
default:
return null;
}
@ -130,6 +143,15 @@ class GatewayWithoutPayPalAdminNotice {
$name,
admin_url( 'admin.php?page=wc-settings&tab=checkout&section=ppcp-gateway' )
);
if ( $notice_type === self::NOTICE_DISABLED_CARD_BUTTON ) {
$message = sprintf(
$text,
$url1,
$url2
);
}
return new Message( $message, 'warning' );
}
@ -160,6 +182,13 @@ class GatewayWithoutPayPalAdminNotice {
return self::NOTICE_DISABLED_LOCATION;
}
$is_dcc_enabled = $this->settings->has( 'dcc_enabled' ) && $this->settings->get( 'dcc_enabled' ) ?? false;
$is_card_button_allowed = $this->settings->has( 'allow_card_button_gateway' ) && $this->settings->get( 'allow_card_button_gateway' );
if ( $is_dcc_enabled && $is_card_button_allowed ) {
return self::NOTICE_DISABLED_CARD_BUTTON;
}
return self::NOTICE_OK;
}

View file

@ -528,6 +528,14 @@ class WCGatewayModule implements ModuleInterface {
return $methods;
}
$is_dcc_enabled = $settings->has( 'dcc_enabled' ) && $settings->get( 'dcc_enabled' ) ?? false;
$standard_card_button = get_option( 'woocommerce_ppcp-card-button-gateway_settings' );
if ( $is_dcc_enabled && isset( $standard_card_button['enabled'] ) ) {
$standard_card_button['enabled'] = 'no';
update_option( 'woocommerce_ppcp-card-button-gateway_settings', $standard_card_button );
}
$dcc_applies = $container->get( 'api.helpers.dccapplies' );
assert( $dcc_applies instanceof DccApplies );