mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-03 08:37:53 +08:00
Add GooglePay onboarding improvements.
This commit is contained in:
parent
bad21380b3
commit
b703f17bbf
7 changed files with 31 additions and 16 deletions
|
@ -37,12 +37,15 @@ return array(
|
|||
|
||||
// If GooglePay is configured.
|
||||
'googlepay.available' => static function ( ContainerInterface $container ): bool {
|
||||
/**
|
||||
* $status = $container->get( 'googlepay.helpers.apm-product-status' );
|
||||
* assert( $status instanceof ApmProductStatus );
|
||||
* return $status->is_active();
|
||||
*/
|
||||
return true; // TODO: must test further.
|
||||
if ( apply_filters( 'woocommerce_paypal_payments_googlepay_validate_product_status', false ) ) {
|
||||
$status = $container->get( 'googlepay.helpers.apm-product-status' );
|
||||
assert( $status instanceof ApmProductStatus );
|
||||
/**
|
||||
* If merchant isn't onboarded by use via /v1/customer/partner-referrals this returns false as the api call fails.
|
||||
*/
|
||||
return apply_filters( 'woocommerce_paypal_payments_googlepay_product_status', $status->is_active() );
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
'googlepay.helpers.apm-product-status' => static function( ContainerInterface $container ): ApmProductStatus {
|
||||
|
@ -61,7 +64,7 @@ return array(
|
|||
* Returns which countries and currency combinations can be used for GooglePay.
|
||||
*/
|
||||
return apply_filters(
|
||||
'woocommerce_paypal_payments_supported_country_currency_matrix',
|
||||
'woocommerce_paypal_payments_googlepay_supported_country_currency_matrix',
|
||||
array(
|
||||
'US' => array(
|
||||
'AUD',
|
||||
|
|
|
@ -16,6 +16,7 @@ use WooCommerce\PayPalCommerce\Vendor\Dhii\Container\ServiceProvider;
|
|||
use WooCommerce\PayPalCommerce\Vendor\Dhii\Modular\Module\ModuleInterface;
|
||||
use WooCommerce\PayPalCommerce\Vendor\Interop\Container\ServiceProviderInterface;
|
||||
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
||||
|
||||
/**
|
||||
* Class GooglepayModule
|
||||
|
@ -77,10 +78,15 @@ class GooglepayModule implements ModuleInterface {
|
|||
// Clear product status handling.
|
||||
add_action(
|
||||
'woocommerce_paypal_payments_clear_apm_product_status',
|
||||
function() use ( $c ): void {
|
||||
function( Settings $settings = null ) use ( $c ): void {
|
||||
$apm_status = $c->get( 'googlepay.helpers.apm-product-status' );
|
||||
assert( $apm_status instanceof ApmProductStatus );
|
||||
$apm_status->clear();
|
||||
|
||||
if ( ! $settings instanceof Settings ) {
|
||||
$settings = null;
|
||||
}
|
||||
|
||||
$apm_status->clear( $settings );
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
@ -121,13 +121,19 @@ class ApmProductStatus {
|
|||
/**
|
||||
* Clears the persisted result to force a recheck.
|
||||
*
|
||||
* @param Settings|null $settings The settings object.
|
||||
* We accept a Settings object to don't override other sequential settings that are being updated elsewhere.
|
||||
* @return void
|
||||
*/
|
||||
public function clear(): void {
|
||||
public function clear( Settings $settings = null ): void {
|
||||
if ( null === $settings ) {
|
||||
$settings = $this->settings;
|
||||
}
|
||||
|
||||
$this->current_status = null;
|
||||
|
||||
$this->settings->set( self::SETTINGS_KEY, self::SETTINGS_VALUE_UNDEFINED );
|
||||
$this->settings->persist();
|
||||
$settings->set( self::SETTINGS_KEY, self::SETTINGS_VALUE_UNDEFINED );
|
||||
$settings->persist();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -134,7 +134,7 @@ class LoginSellerEndpoint implements EndpointInterface {
|
|||
$this->settings->set( 'products_dcc_enabled', null );
|
||||
$this->settings->set( 'products_pui_enabled', null );
|
||||
$this->settings->persist();
|
||||
do_action( 'woocommerce_paypal_payments_clear_apm_product_status' );
|
||||
do_action( 'woocommerce_paypal_payments_clear_apm_product_status', $this->settings );
|
||||
|
||||
$endpoint = $is_sandbox ? $this->login_seller_sandbox : $this->login_seller_production;
|
||||
$credentials = $endpoint->credentials_for(
|
||||
|
|
|
@ -238,7 +238,7 @@ class OnboardingRESTController {
|
|||
|
||||
$settings->set( 'products_dcc_enabled', null );
|
||||
$settings->set( 'products_pui_enabled', null );
|
||||
do_action( 'woocommerce_paypal_payments_clear_apm_product_status' );
|
||||
do_action( 'woocommerce_paypal_payments_clear_apm_product_status', $settings );
|
||||
|
||||
if ( ! $settings->persist() ) {
|
||||
return new \WP_Error(
|
||||
|
|
|
@ -391,7 +391,7 @@ class SettingsListener {
|
|||
if ( self::CREDENTIALS_UNCHANGED !== $credentials_change_status ) {
|
||||
$this->settings->set( 'products_dcc_enabled', null );
|
||||
$this->settings->set( 'products_pui_enabled', null );
|
||||
do_action( 'woocommerce_paypal_payments_clear_apm_product_status' );
|
||||
do_action( 'woocommerce_paypal_payments_clear_apm_product_status', $this->settings );
|
||||
}
|
||||
|
||||
if ( in_array(
|
||||
|
|
|
@ -286,7 +286,7 @@ class WCGatewayModule implements ModuleInterface {
|
|||
$settings->set( 'products_dcc_enabled', false );
|
||||
$settings->set( 'products_pui_enabled', false );
|
||||
$settings->persist();
|
||||
do_action( 'woocommerce_paypal_payments_clear_apm_product_status' );
|
||||
do_action( 'woocommerce_paypal_payments_clear_apm_product_status', $settings );
|
||||
|
||||
// Update caches.
|
||||
$dcc_status = $c->get( 'wcgateway.helper.dcc-product-status' );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue