mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-31 06:52:50 +08:00
Merge branch 'trunk' of github.com:woocommerce/woocommerce-paypal-payments into PCP-3770-fastlane-implement-insights-sdk-for-block-checkout-ver2
This commit is contained in:
commit
d84f29a274
111 changed files with 5597 additions and 2508 deletions
|
@ -85,6 +85,8 @@ class AxoManager {
|
|||
},
|
||||
};
|
||||
|
||||
this.cardOptions = this.getCardOptions();
|
||||
|
||||
this.enabledShippingLocations =
|
||||
this.axoConfig.enabled_shipping_locations;
|
||||
|
||||
|
@ -670,6 +672,9 @@ class AxoManager {
|
|||
await this.fastlane.connect( {
|
||||
locale: this.locale,
|
||||
styles: this.styles,
|
||||
cardOptions: {
|
||||
allowedBrands: this.cardOptions,
|
||||
},
|
||||
shippingAddressOptions: {
|
||||
allowedLocations: this.enabledShippingLocations,
|
||||
},
|
||||
|
@ -1247,6 +1252,31 @@ class AxoManager {
|
|||
return this.axoConfig?.widgets?.email === 'use_widget';
|
||||
}
|
||||
|
||||
getCardOptions() {
|
||||
const DEFAULT_ALLOWED_CARDS = [
|
||||
'VISA',
|
||||
'MASTERCARD',
|
||||
'AMEX',
|
||||
'DISCOVER',
|
||||
];
|
||||
const merchantCountry = this.axoConfig.merchant_country || 'US';
|
||||
|
||||
const allowedCards = new Set(
|
||||
this.axoConfig.allowed_cards?.[ merchantCountry ] ||
|
||||
DEFAULT_ALLOWED_CARDS
|
||||
);
|
||||
|
||||
const disabledCards = new Set(
|
||||
( this.axoConfig.disable_cards || [] ).map( ( card ) =>
|
||||
card.toUpperCase()
|
||||
)
|
||||
);
|
||||
|
||||
return [ ...allowedCards ].filter(
|
||||
( card ) => ! disabledCards.has( card )
|
||||
);
|
||||
}
|
||||
|
||||
deleteKeysWithEmptyString = ( obj ) => {
|
||||
for ( const key of Object.keys( obj ) ) {
|
||||
if ( obj[ key ] === '' ) {
|
||||
|
|
|
@ -70,6 +70,7 @@ return array(
|
|||
$container->get( 'api.shop.currency.getter' ),
|
||||
$container->get( 'woocommerce.logger.woocommerce' ),
|
||||
$container->get( 'wcgateway.url' ),
|
||||
$container->get( 'axo.supported-country-card-type-matrix' ),
|
||||
$container->get( 'axo.shipping-wc-enabled-locations' )
|
||||
);
|
||||
},
|
||||
|
@ -162,7 +163,31 @@ return array(
|
|||
)
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* The matrix which countries and card type combinations can be used for AXO.
|
||||
*/
|
||||
'axo.supported-country-card-type-matrix' => static function ( ContainerInterface $container ) : array {
|
||||
/**
|
||||
* Returns which countries and card type combinations can be used for AXO.
|
||||
*/
|
||||
return apply_filters(
|
||||
'woocommerce_paypal_payments_axo_supported_country_card_type_matrix',
|
||||
array(
|
||||
'US' => array(
|
||||
'VISA',
|
||||
'MASTERCARD',
|
||||
'AMEX',
|
||||
'DISCOVER',
|
||||
),
|
||||
'CA' => array(
|
||||
'VISA',
|
||||
'MASTERCARD',
|
||||
'AMEX',
|
||||
'DISCOVER',
|
||||
),
|
||||
)
|
||||
);
|
||||
},
|
||||
'axo.settings-conflict-notice' => static function ( ContainerInterface $container ) : string {
|
||||
$settings_notice_generator = $container->get( 'axo.helpers.settings-notice-generator' );
|
||||
assert( $settings_notice_generator instanceof SettingsNoticeGenerator );
|
||||
|
|
|
@ -29,28 +29,28 @@ class AxoManager {
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
private $module_url;
|
||||
private string $module_url;
|
||||
|
||||
/**
|
||||
* The assets version.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $version;
|
||||
private string $version;
|
||||
|
||||
/**
|
||||
* The settings.
|
||||
*
|
||||
* @var Settings
|
||||
*/
|
||||
private $settings;
|
||||
private Settings $settings;
|
||||
|
||||
/**
|
||||
* The environment object.
|
||||
*
|
||||
* @var Environment
|
||||
*/
|
||||
private $environment;
|
||||
private Environment $environment;
|
||||
|
||||
/**
|
||||
* Data needed for the PayPal Insights.
|
||||
|
@ -78,22 +78,27 @@ class AxoManager {
|
|||
*
|
||||
* @var LoggerInterface
|
||||
*/
|
||||
private $logger;
|
||||
private LoggerInterface $logger;
|
||||
|
||||
/**
|
||||
* Session handler.
|
||||
*
|
||||
* @var SessionHandler
|
||||
*/
|
||||
private $session_handler;
|
||||
private SessionHandler $session_handler;
|
||||
|
||||
/**
|
||||
* The WcGateway module URL.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $wcgateway_module_url;
|
||||
|
||||
private string $wcgateway_module_url;
|
||||
/**
|
||||
* The supported country card type matrix.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private array $supported_country_card_type_matrix;
|
||||
/**
|
||||
* The list of WooCommerce enabled shipping locations.
|
||||
*
|
||||
|
@ -114,6 +119,7 @@ class AxoManager {
|
|||
* @param CurrencyGetter $currency The getter of the 3-letter currency code of the shop.
|
||||
* @param LoggerInterface $logger The logger.
|
||||
* @param string $wcgateway_module_url The WcGateway module URL.
|
||||
* @param array $supported_country_card_type_matrix The supported country card type matrix for Axo.
|
||||
* @param array $enabled_shipping_locations The list of WooCommerce enabled shipping locations.
|
||||
*/
|
||||
public function __construct(
|
||||
|
@ -127,20 +133,22 @@ class AxoManager {
|
|||
CurrencyGetter $currency,
|
||||
LoggerInterface $logger,
|
||||
string $wcgateway_module_url,
|
||||
array $supported_country_card_type_matrix,
|
||||
array $enabled_shipping_locations
|
||||
) {
|
||||
|
||||
$this->module_url = $module_url;
|
||||
$this->version = $version;
|
||||
$this->session_handler = $session_handler;
|
||||
$this->settings = $settings;
|
||||
$this->environment = $environment;
|
||||
$this->insights_data = $insights_data;
|
||||
$this->settings_status = $settings_status;
|
||||
$this->currency = $currency;
|
||||
$this->logger = $logger;
|
||||
$this->wcgateway_module_url = $wcgateway_module_url;
|
||||
$this->module_url = $module_url;
|
||||
$this->version = $version;
|
||||
$this->session_handler = $session_handler;
|
||||
$this->settings = $settings;
|
||||
$this->environment = $environment;
|
||||
$this->insights_data = $insights_data;
|
||||
$this->settings_status = $settings_status;
|
||||
$this->currency = $currency;
|
||||
$this->logger = $logger;
|
||||
$this->wcgateway_module_url = $wcgateway_module_url;
|
||||
$this->enabled_shipping_locations = $enabled_shipping_locations;
|
||||
$this->supported_country_card_type_matrix = $supported_country_card_type_matrix;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -193,6 +201,8 @@ class AxoManager {
|
|||
'insights' => ( function( array $data ): array {
|
||||
$data['amount']['value'] = WC()->cart->get_total( 'numeric' );
|
||||
return $data; } )( $this->insights_data ),
|
||||
'allowed_cards' => $this->supported_country_card_type_matrix,
|
||||
'disable_cards' => $this->settings->has( 'disable_cards' ) ? (array) $this->settings->get( 'disable_cards' ) : array(),
|
||||
'enabled_shipping_locations' => $this->enabled_shipping_locations,
|
||||
'style_options' => array(
|
||||
'root' => array(
|
||||
|
@ -231,6 +241,7 @@ class AxoManager {
|
|||
'logging_enabled' => $this->settings->has( 'logging_enabled' ) ? $this->settings->get( 'logging_enabled' ) : '',
|
||||
'wp_debug' => defined( 'WP_DEBUG' ) && WP_DEBUG,
|
||||
'billing_email_button_text' => __( 'Continue', 'woocommerce-paypal-payments' ),
|
||||
'merchant_country' => WC()->countries->get_base_country(),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -386,11 +386,15 @@ class AxoModule implements ServiceModule, ExtendingModule, ExecutableModule {
|
|||
$dcc_configuration = $c->get( 'wcgateway.configuration.dcc' );
|
||||
assert( $dcc_configuration instanceof DCCGatewayConfiguration );
|
||||
|
||||
$subscription_helper = $c->get( 'wc-subscriptions.helper' );
|
||||
assert( $subscription_helper instanceof SubscriptionHelper );
|
||||
|
||||
return ! is_user_logged_in()
|
||||
&& CartCheckoutDetector::has_classic_checkout()
|
||||
&& $dcc_configuration->use_fastlane()
|
||||
&& ! $this->is_excluded_endpoint()
|
||||
&& is_checkout();
|
||||
&& is_checkout()
|
||||
&& ! $subscription_helper->cart_contains_subscription();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue