static function ( ContainerInterface $container ): bool {
$eligibility_check = $container->get( 'axo.eligibility.check' );
return $eligibility_check();
},
'axo.eligibility.check' => static function ( ContainerInterface $container ): callable {
$axo_applies = $container->get( 'axo.service.axo-applies' );
assert( $axo_applies instanceof AxoApplies );
return static function () use ( $axo_applies ) : bool {
return $axo_applies->for_country_currency() && $axo_applies->for_merchant();
};
},
'axo.service.axo-applies' => static function ( ContainerInterface $container ) : AxoApplies {
return new AxoApplies(
$container->get( 'axo.supported-country-currency-matrix' ),
$container->get( 'api.shop.currency.getter' ),
$container->get( 'api.shop.country' ),
$container->get( 'wcgateway.configuration.card-configuration' ),
$container->get( 'wc-subscriptions.helper' )
);
},
'axo.helpers.compatibility-checker' => static function ( ContainerInterface $container ) : CompatibilityChecker {
return new CompatibilityChecker(
$container->get( 'axo.fastlane-incompatible-plugin-names' ),
$container->get( 'wcgateway.configuration.card-configuration' )
);
},
// If AXO is configured and onboarded.
'axo.available' => static function ( ContainerInterface $container ): bool {
$settings = $container->get( 'wcgateway.settings' );
assert( $settings instanceof Settings );
return $settings->has( 'axo_enabled' ) && $settings->get( 'axo_enabled' );
},
'axo.url' => static function ( ContainerInterface $container ): string {
return plugins_url( '/modules/ppcp-axo/', $container->get( 'ppcp.path-to-plugin-main-file' ) );
},
'axo.manager' => static function ( ContainerInterface $container ): AxoManager {
return new AxoManager(
$container->get( 'axo.url' ),
$container->get( 'ppcp.asset-version' ),
$container->get( 'session.handler' ),
$container->get( 'wcgateway.settings' ),
$container->get( 'settings.environment' ),
$container->get( 'axo.insights' ),
$container->get( 'wcgateway.settings.status' ),
$container->get( 'api.shop.currency.getter' ),
$container->get( 'woocommerce.logger.woocommerce' ),
$container->get( 'wcgateway.url' ),
$container->get( 'axo.supported-country-card-type-matrix' )
);
},
'axo.gateway' => static function ( ContainerInterface $container ): AxoGateway {
return new AxoGateway(
$container->get( 'wcgateway.settings.render' ),
$container->get( 'wcgateway.settings' ),
$container->get( 'wcgateway.configuration.card-configuration' ),
$container->get( 'wcgateway.url' ),
$container->get( 'session.handler' ),
$container->get( 'wcgateway.order-processor' ),
$container->get( 'wcgateway.credit-card-icons' ),
$container->get( 'api.endpoint.order' ),
$container->get( 'api.factory.purchase-unit' ),
$container->get( 'api.factory.shipping-preference' ),
$container->get( 'wcgateway.transaction-url-provider' ),
$container->get( 'settings.environment' ),
$container->get( 'woocommerce.logger.woocommerce' ),
$container->get( 'wcgateway.builder.experience-context' ),
$container->get( 'settings.data.settings' )
);
},
// Data needed for the PayPal Insights.
'axo.insights' => static function ( ContainerInterface $container ): array {
$settings = $container->get( 'wcgateway.settings' );
assert( $settings instanceof Settings );
$currency = $container->get( 'api.shop.currency.getter' );
assert( $currency instanceof CurrencyGetter );
$session_id = '';
if ( isset( WC()->session ) && method_exists( WC()->session, 'get_customer_unique_id' ) ) {
$session_id = substr(
md5( WC()->session->get_customer_unique_id() ),
0,
16
);
}
return array(
'enabled' => defined( 'WP_DEBUG' ) && WP_DEBUG,
'client_id' => ( $settings->has( 'client_id' ) ? $settings->get( 'client_id' ) : null ),
'session_id' => $session_id,
'amount' => array(
'currency_code' => $currency->get(),
),
'payment_method_selected_map' => $container->get( 'axo.payment_method_selected_map' ),
'wp_debug' => defined( 'WP_DEBUG' ) && WP_DEBUG,
);
},
// The mapping of payment methods to the PayPal Insights 'payment_method_selected' types.
'axo.payment_method_selected_map' => static function ( ContainerInterface $container ): array {
return array(
'ppcp-axo-gateway' => 'card',
'ppcp-credit-card-gateway' => 'card',
'ppcp-gateway' => 'paypal',
'ppcp-googlepay' => 'google_pay',
'ppcp-applepay' => 'apple_pay',
'ppcp-multibanco' => 'other',
'ppcp-trustly' => 'other',
'ppcp-p24' => 'other',
'ppcp-mybank' => 'other',
'ppcp-ideal' => 'other',
'ppcp-eps' => 'other',
'ppcp-blik' => 'other',
'ppcp-bancontact' => 'other',
'ppcp-card-button-gateway' => 'card',
);
},
/**
* The matrix which countries and currency combinations can be used for AXO.
*/
'axo.supported-country-currency-matrix' => static function ( ContainerInterface $container ) : array {
$matrix = array(
'US' => array(
'AUD',
'CAD',
'EUR',
'GBP',
'JPY',
'USD',
),
);
if ( $container->get( 'axo.uk.enabled' ) ) {
$matrix['GB'] = array( 'GBP' );
}
if ( $container->get( 'axo.au.enabled' ) ) {
$matrix['AU'] = array( 'AUD' );
}
/**
* Returns which countries and currency combinations can be used for AXO.
*/
return apply_filters(
'woocommerce_paypal_payments_axo_supported_country_currency_matrix',
$matrix
);
},
/**
* The matrix which countries and card type combinations can be used for AXO.
*/
'axo.supported-country-card-type-matrix' => static function ( ContainerInterface $container ) : array {
$matrix = array(
'US' => array(
'VISA',
'MASTERCARD',
'AMEX',
'DISCOVER',
),
'CA' => array(
'VISA',
'MASTERCARD',
'AMEX',
'DISCOVER',
),
);
if ( $container->get( 'axo.uk.enabled' ) ) {
$matrix['GB'] = array(
'VISA',
'MASTERCARD',
'AMEX',
'DISCOVER',
);
}
if ( $container->get( 'axo.au.enabled' ) ) {
$matrix['AU'] = array(
'VISA',
'MASTERCARD',
'AMEX',
);
}
/**
* Returns which countries and card type combinations can be used for AXO.
*/
return apply_filters(
'woocommerce_paypal_payments_axo_supported_country_card_type_matrix',
$matrix
);
},
'axo.settings-conflict-notice' => static function ( ContainerInterface $container ) : string {
$compatibility_checker = $container->get( 'axo.helpers.compatibility-checker' );
assert( $compatibility_checker instanceof CompatibilityChecker );
return $compatibility_checker->generate_settings_conflict_notice();
},
'axo.checkout-config-notice' => static function ( ContainerInterface $container ) : string {
$compatibility_checker = $container->get( 'axo.helpers.compatibility-checker' );
assert( $compatibility_checker instanceof CompatibilityChecker );
return $compatibility_checker->generate_checkout_notice();
},
'axo.checkout-config-notice.raw' => static function ( ContainerInterface $container ) : string {
$compatibility_checker = $container->get( 'axo.helpers.compatibility-checker' );
assert( $compatibility_checker instanceof CompatibilityChecker );
return $compatibility_checker->generate_checkout_notice( true );
},
'axo.incompatible-plugins-notice' => static function ( ContainerInterface $container ) : string {
$settings_notice_generator = $container->get( 'axo.helpers.compatibility-checker' );
assert( $settings_notice_generator instanceof CompatibilityChecker );
return $settings_notice_generator->generate_incompatible_plugins_notice();
},
'axo.incompatible-plugins-notice.raw' => static function ( ContainerInterface $container ) : string {
$settings_notice_generator = $container->get( 'axo.helpers.compatibility-checker' );
assert( $settings_notice_generator instanceof CompatibilityChecker );
return $settings_notice_generator->generate_incompatible_plugins_notice( true );
},
'axo.smart-button-location-notice' => static function ( ContainerInterface $container ) : string {
$dcc_configuration = $container->get( 'wcgateway.configuration.card-configuration' );
assert( $dcc_configuration instanceof CardPaymentsConfiguration );
if ( $dcc_configuration->use_fastlane() ) {
$fastlane_settings_url = admin_url(
sprintf(
'admin.php?page=wc-settings&tab=checkout§ion=%1$s&ppcp-tab=%2$s#field-axo_heading',
PayPalGateway::ID,
CreditCardGateway::ID
)
);
$notice_content = sprintf(
/* translators: %1$s: URL to the Checkout edit page. */
__(
'Important: The Cart
& Classic Cart
Smart Button Locations cannot be disabled while Fastlane is active.',
'woocommerce-paypal-payments'
),
esc_url( $fastlane_settings_url )
);
} else {
return '';
}
return '
' . $notice_content . '