Merge branch 'PCP-1393-acdc-vault-v3' into PCP-1393-update-to-vault-v-3

This commit is contained in:
Emili Castells Guasch 2023-12-05 09:35:34 +01:00
commit 826a691e1a
3 changed files with 35 additions and 16 deletions

View file

@ -644,7 +644,7 @@ document.querySelector("#payment").before(document.querySelector("#ppcp-messages
return $this->settings->has( 'dcc_enabled' ) && $this->settings->get( 'dcc_enabled' )
&& $this->settings->has( 'client_id' ) && $this->settings->get( 'client_id' )
&& $this->dcc_applies->for_country_currency()
&& in_array( $this->context(), array( 'checkout', 'pay-now' ), true );
&& in_array( $this->context(), array( 'checkout', 'pay-now', 'add-payment-method' ), true );
}
/**

View file

@ -94,6 +94,10 @@ trait ContextTrait {
return 'checkout';
}
if ( $this->is_add_payment_method_page() ) {
return 'add-payment-method';
}
return 'mini-cart';
}
@ -147,4 +151,16 @@ trait ContextTrait {
return true;
}
/**
* Checks whether current page is Add payment method.
*
* @return bool
*/
private function is_add_payment_method_page(): bool {
global $wp;
$page_id = wc_get_page_id( 'myaccount' );
return $page_id && is_page( $page_id ) && isset( $wp->query_vars['add-payment-method'] );
}
}

View file

@ -18,6 +18,7 @@ use WooCommerce\PayPalCommerce\ApiClient\Entity\Order;
use WooCommerce\PayPalCommerce\ApiClient\Entity\PaymentSource;
use WooCommerce\PayPalCommerce\ApiClient\Exception\PayPalApiException;
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
use WooCommerce\PayPalCommerce\Button\Helper\ContextTrait;
use WooCommerce\PayPalCommerce\SavePaymentMethods\Endpoint\CaptureCardPayment;
use WooCommerce\PayPalCommerce\SavePaymentMethods\Endpoint\CreatePaymentToken;
use WooCommerce\PayPalCommerce\SavePaymentMethods\Endpoint\CreateSetupToken;
@ -33,6 +34,8 @@ use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
*/
class SavePaymentMethodsModule implements ModuleInterface {
use ContextTrait;
/**
* {@inheritDoc}
*/
@ -191,7 +194,7 @@ class SavePaymentMethodsModule implements ModuleInterface {
add_action(
'wp_enqueue_scripts',
function() use ( $c ) {
if ( ! is_user_logged_in() || ! is_add_payment_method_page() ) {
if ( ! is_user_logged_in() || ! $this->is_add_payment_method_page() ) {
return;
}