mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-30 05:00:51 +08:00
Prevent early is_enabled check for Apple Pay button in new UI
This commit is contained in:
parent
8e1307cae6
commit
f412c507e5
2 changed files with 41 additions and 34 deletions
|
@ -94,21 +94,23 @@ if (
|
|||
features.push( 'subscriptions' );
|
||||
}
|
||||
|
||||
registerExpressPaymentMethod( {
|
||||
name: buttonData.id,
|
||||
title: `PayPal - ${ buttonData.title }`,
|
||||
description: __(
|
||||
'Eligible users will see the PayPal button.',
|
||||
'woocommerce-paypal-payments'
|
||||
),
|
||||
label: <div dangerouslySetInnerHTML={ { __html: buttonData.title } } />,
|
||||
content: <ApplePayComponent isEditing={ false } />,
|
||||
edit: <ApplePayComponent isEditing={ true } />,
|
||||
ariaLabel: buttonData.title,
|
||||
canMakePayment: () =>
|
||||
buttonData.enabled && window.ApplePaySession?.canMakePayments(),
|
||||
supports: {
|
||||
features,
|
||||
style: [ 'height', 'borderRadius' ],
|
||||
},
|
||||
} );
|
||||
if ( buttonConfig?.is_enabled ) {
|
||||
registerExpressPaymentMethod( {
|
||||
name: buttonData.id,
|
||||
title: `PayPal - ${ buttonData.title }`,
|
||||
description: __(
|
||||
'Eligible users will see the PayPal button.',
|
||||
'woocommerce-paypal-payments'
|
||||
),
|
||||
label: <div dangerouslySetInnerHTML={ { __html: buttonData.title } } />,
|
||||
content: <ApplePayComponent isEditing={ false } />,
|
||||
edit: <ApplePayComponent isEditing={ true } />,
|
||||
ariaLabel: buttonData.title,
|
||||
canMakePayment: () =>
|
||||
buttonData.enabled && window.ApplePaySession?.canMakePayments(),
|
||||
supports: {
|
||||
features,
|
||||
style: [ 'height', 'borderRadius' ],
|
||||
},
|
||||
} );
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ use WooCommerce\PayPalCommerce\Applepay\Assets\PropertiesDictionary;
|
|||
use WooCommerce\PayPalCommerce\Button\Assets\ButtonInterface;
|
||||
use WooCommerce\PayPalCommerce\Button\Assets\SmartButtonInterface;
|
||||
use WooCommerce\PayPalCommerce\Applepay\Helper\AvailabilityNotice;
|
||||
use WooCommerce\PayPalCommerce\Settings\SettingsModule;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Helper\Environment;
|
||||
use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Module\ExecutableModule;
|
||||
use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Module\ExtendingModule;
|
||||
|
@ -93,15 +94,17 @@ class ApplepayModule implements ServiceModule, ExtendingModule, ExecutableModule
|
|||
return;
|
||||
}
|
||||
|
||||
if ( $apple_payment_method->is_enabled() ) {
|
||||
$module->load_assets( $c, $apple_payment_method );
|
||||
$module->handle_validation_file( $c, $apple_payment_method );
|
||||
$module->render_buttons( $c, $apple_payment_method );
|
||||
$apple_payment_method->bootstrap_ajax_request();
|
||||
}
|
||||
|
||||
$module->load_admin_assets( $c, $apple_payment_method );
|
||||
$module->load_block_editor_assets( $c, $apple_payment_method );
|
||||
|
||||
if ( SettingsModule::should_use_the_old_ui() && ! $apple_payment_method->is_enabled() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$module->load_assets( $c, $apple_payment_method );
|
||||
$module->handle_validation_file( $c, $apple_payment_method );
|
||||
$module->render_buttons( $c, $apple_payment_method );
|
||||
$apple_payment_method->bootstrap_ajax_request();
|
||||
},
|
||||
1
|
||||
);
|
||||
|
@ -255,13 +258,13 @@ class ApplepayModule implements ServiceModule, ExtendingModule, ExecutableModule
|
|||
* @return void
|
||||
*/
|
||||
public function load_assets( ContainerInterface $c, ApplePayButton $button ): void {
|
||||
if ( ! $button->is_enabled() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
add_action(
|
||||
'wp_enqueue_scripts',
|
||||
function () use ( $c, $button ) {
|
||||
if ( ! $button->is_enabled() ) {
|
||||
return;
|
||||
}
|
||||
$smart_button = $c->get( 'button.smart-button' );
|
||||
assert( $smart_button instanceof SmartButtonInterface );
|
||||
if ( $smart_button->should_load_ppcp_script() ) {
|
||||
|
@ -282,6 +285,9 @@ class ApplepayModule implements ServiceModule, ExtendingModule, ExecutableModule
|
|||
add_action(
|
||||
'enqueue_block_editor_assets',
|
||||
function () use ( $c, $button ) {
|
||||
if ( ! $button->is_enabled() ) {
|
||||
return;
|
||||
}
|
||||
$button->enqueue_admin_styles();
|
||||
}
|
||||
);
|
||||
|
@ -362,9 +368,6 @@ class ApplepayModule implements ServiceModule, ExtendingModule, ExecutableModule
|
|||
* @return void
|
||||
*/
|
||||
public function render_buttons( ContainerInterface $c, ApplePayButton $button ): void {
|
||||
if ( ! $button->is_enabled() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
add_action(
|
||||
'wp',
|
||||
|
@ -372,8 +375,13 @@ class ApplepayModule implements ServiceModule, ExtendingModule, ExecutableModule
|
|||
if ( is_admin() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$button = $c->get( 'applepay.button' );
|
||||
|
||||
if ( ! $button->is_enabled() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Button.
|
||||
*
|
||||
|
@ -392,9 +400,6 @@ class ApplepayModule implements ServiceModule, ExtendingModule, ExecutableModule
|
|||
* @return void
|
||||
*/
|
||||
public function handle_validation_file( ContainerInterface $c, ApplePayButton $button ): void {
|
||||
if ( ! $button->is_enabled() ) {
|
||||
return;
|
||||
}
|
||||
$env = $c->get( 'settings.environment' );
|
||||
assert( $env instanceof Environment );
|
||||
$is_sandbox = $env->current_environment_is( Environment::SANDBOX );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue