2020-04-02 08:38:00 +03:00
|
|
|
<?php
|
2020-08-31 11:12:46 +03:00
|
|
|
/**
|
|
|
|
* The button module services.
|
|
|
|
*
|
2020-09-11 14:11:10 +03:00
|
|
|
* @package WooCommerce\PayPalCommerce\Button
|
2020-08-31 11:12:46 +03:00
|
|
|
*/
|
2020-04-09 14:36:52 +03:00
|
|
|
|
2020-04-02 08:38:00 +03:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2020-09-11 14:11:10 +03:00
|
|
|
namespace WooCommerce\PayPalCommerce\Button;
|
2020-04-02 08:38:00 +03:00
|
|
|
|
2023-01-05 14:53:23 +01:00
|
|
|
use WooCommerce\PayPalCommerce\Button\Endpoint\ApproveSubscriptionEndpoint;
|
2023-02-15 16:50:34 +02:00
|
|
|
use WooCommerce\PayPalCommerce\Button\Endpoint\CartScriptParamsEndpoint;
|
2023-01-25 09:42:31 +02:00
|
|
|
use WooCommerce\PayPalCommerce\Button\Helper\CheckoutFormSaver;
|
2023-02-07 15:29:53 +02:00
|
|
|
use WooCommerce\PayPalCommerce\Button\Endpoint\SaveCheckoutFormEndpoint;
|
|
|
|
use WooCommerce\PayPalCommerce\Button\Validation\CheckoutFormValidator;
|
|
|
|
use WooCommerce\PayPalCommerce\Button\Endpoint\ValidateCheckoutEndpoint;
|
2023-05-08 14:32:55 +02:00
|
|
|
use WooCommerce\PayPalCommerce\Subscription\Helper\SubscriptionHelper;
|
2022-11-09 10:11:31 +02:00
|
|
|
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
|
2020-09-11 14:11:10 +03:00
|
|
|
use WooCommerce\PayPalCommerce\Button\Assets\DisabledSmartButton;
|
|
|
|
use WooCommerce\PayPalCommerce\Button\Assets\SmartButton;
|
|
|
|
use WooCommerce\PayPalCommerce\Button\Assets\SmartButtonInterface;
|
|
|
|
use WooCommerce\PayPalCommerce\Button\Endpoint\ApproveOrderEndpoint;
|
|
|
|
use WooCommerce\PayPalCommerce\Button\Endpoint\ChangeCartEndpoint;
|
|
|
|
use WooCommerce\PayPalCommerce\Button\Endpoint\CreateOrderEndpoint;
|
|
|
|
use WooCommerce\PayPalCommerce\Button\Endpoint\DataClientIdEndpoint;
|
|
|
|
use WooCommerce\PayPalCommerce\Button\Endpoint\RequestData;
|
2022-04-12 14:59:07 +03:00
|
|
|
use WooCommerce\PayPalCommerce\Button\Endpoint\StartPayPalVaultingEndpoint;
|
2020-09-11 14:11:10 +03:00
|
|
|
use WooCommerce\PayPalCommerce\Button\Exception\RuntimeException;
|
|
|
|
use WooCommerce\PayPalCommerce\Button\Helper\EarlyOrderHandler;
|
|
|
|
use WooCommerce\PayPalCommerce\Button\Helper\MessagesApply;
|
|
|
|
use WooCommerce\PayPalCommerce\Button\Helper\ThreeDSecure;
|
|
|
|
use WooCommerce\PayPalCommerce\Onboarding\Environment;
|
|
|
|
use WooCommerce\PayPalCommerce\Onboarding\State;
|
2020-04-02 08:38:00 +03:00
|
|
|
|
2020-08-31 11:12:46 +03:00
|
|
|
return array(
|
2022-11-09 19:18:16 +04:00
|
|
|
'button.client_id' => static function ( ContainerInterface $container ): string {
|
2020-06-30 11:56:13 +03:00
|
|
|
|
2020-08-31 11:12:46 +03:00
|
|
|
$settings = $container->get( 'wcgateway.settings' );
|
|
|
|
$client_id = $settings->has( 'client_id' ) ? $settings->get( 'client_id' ) : '';
|
|
|
|
if ( $client_id ) {
|
|
|
|
return $client_id;
|
|
|
|
}
|
2020-06-30 11:56:13 +03:00
|
|
|
|
2020-08-31 11:12:46 +03:00
|
|
|
$env = $container->get( 'onboarding.environment' );
|
|
|
|
/**
|
|
|
|
* The environment.
|
|
|
|
*
|
|
|
|
* @var Environment $env
|
|
|
|
*/
|
2020-06-30 11:56:13 +03:00
|
|
|
|
2020-08-31 11:12:46 +03:00
|
|
|
return $env->current_environment_is( Environment::SANDBOX ) ?
|
2020-10-13 09:42:34 +03:00
|
|
|
CONNECT_WOO_SANDBOX_CLIENT_ID : CONNECT_WOO_CLIENT_ID;
|
2020-08-31 11:12:46 +03:00
|
|
|
},
|
2022-11-09 19:18:16 +04:00
|
|
|
'button.client_id_for_admin' => static function ( ContainerInterface $container ): string {
|
2022-11-09 17:57:52 +04:00
|
|
|
$dummy_ids = array(
|
|
|
|
'AU' => 'AQ5yx7aGjD0fWKDMQrngSznDlfSfWvio9j1fCeuLC5foFoimaM_d1AbeRmEvc9jVuJU7BbopMSd4aNPG',
|
|
|
|
'DE' => 'AYZigu5BLwbJ_QKNasp_1k0kJUon7NRyazh8Lo-bthJuKetzXRBEzUlbeUIvUfsBxrcN-K0UEk-V6Lq9',
|
|
|
|
'ES' => 'Aa3A3B4MvF2_Xwoj7kG_4qI_hh2pRmuvjRefIgp8B0HSIIGnqsx2Wd8IGOvhyX1G2WLOMl0xGJsiHpXl',
|
|
|
|
'FR' => 'AYIb1W_LbKGlgpOwk64dGk8PPQnIx0H4wdmQfdNt8M6cCaAsSgQ6O-TwTDF6y9Jpp_5BxtHoYYMQDCb5',
|
|
|
|
'GB' => 'AZvAtq7qHoM0yefv-ptnmAvN3gDm9oNj2A7oDqhw_d-pEdWW5q68b7_xd-U2-dQs_kipnmLhV3-7vWkU',
|
|
|
|
'IT' => 'AZm7Rq3sLabDbtq2vRCRVtMRJ09SLi6HeoRy4JuUdFQ6j0D_x-wEZtRzjBhY4NzAcFC_T7GTBdvSYEwK',
|
2022-11-15 14:35:02 +04:00
|
|
|
'US' => 'Ad5dKzVsWZvPD3YgjhZ24LKNKmJqg2Xo3uKx7yuazPiARFc9xJWg1mM-vy-eJhb1V7xn5mPnp_QjAMaM',
|
2022-11-09 17:57:52 +04:00
|
|
|
);
|
|
|
|
|
|
|
|
$shop_country = $container->get( 'api.shop.country' );
|
|
|
|
|
|
|
|
return $dummy_ids[ $shop_country ] ?? $container->get( 'button.client_id' );
|
|
|
|
},
|
2023-01-04 12:13:26 +01:00
|
|
|
'button.is_paypal_continuation' => static function( ContainerInterface $container ): bool {
|
|
|
|
$session_handler = $container->get( 'session.handler' );
|
|
|
|
|
|
|
|
$order = $session_handler->order();
|
|
|
|
if ( ! $order ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
$source = $order->payment_source();
|
|
|
|
if ( $source && $source->card() ) {
|
|
|
|
return false; // Ignore for DCC.
|
|
|
|
}
|
|
|
|
if ( 'card' === $session_handler->funding_source() ) {
|
|
|
|
return false; // Ignore for card buttons.
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
'button.smart-button' => static function ( ContainerInterface $container ): SmartButtonInterface {
|
2020-08-31 11:12:46 +03:00
|
|
|
$state = $container->get( 'onboarding.state' );
|
2022-01-31 18:16:25 +02:00
|
|
|
if ( $state->current_state() !== State::STATE_ONBOARDED ) {
|
2020-08-31 11:12:46 +03:00
|
|
|
return new DisabledSmartButton();
|
|
|
|
}
|
2023-01-04 12:13:26 +01:00
|
|
|
|
2020-08-31 11:12:46 +03:00
|
|
|
$settings = $container->get( 'wcgateway.settings' );
|
|
|
|
$paypal_disabled = ! $settings->has( 'enabled' ) || ! $settings->get( 'enabled' );
|
2020-09-03 11:25:02 +03:00
|
|
|
if ( $paypal_disabled ) {
|
2020-08-31 11:12:46 +03:00
|
|
|
return new DisabledSmartButton();
|
|
|
|
}
|
2023-01-04 12:13:26 +01:00
|
|
|
|
2020-08-31 11:12:46 +03:00
|
|
|
$payer_factory = $container->get( 'api.factory.payer' );
|
|
|
|
$request_data = $container->get( 'button.request-data' );
|
|
|
|
$client_id = $container->get( 'button.client_id' );
|
|
|
|
$dcc_applies = $container->get( 'api.helpers.dccapplies' );
|
|
|
|
$subscription_helper = $container->get( 'subscription.helper' );
|
|
|
|
$messages_apply = $container->get( 'button.helper.messages-apply' );
|
2020-10-16 13:32:26 +03:00
|
|
|
$environment = $container->get( 'onboarding.environment' );
|
2021-09-17 17:11:36 +02:00
|
|
|
$payment_token_repository = $container->get( 'vaulting.repository.payment-token' );
|
2021-06-17 11:51:43 +02:00
|
|
|
$settings_status = $container->get( 'wcgateway.settings.status' );
|
2021-11-30 10:40:38 +02:00
|
|
|
$currency = $container->get( 'api.shop.currency' );
|
2020-08-31 11:12:46 +03:00
|
|
|
return new SmartButton(
|
|
|
|
$container->get( 'button.url' ),
|
2022-02-17 18:51:24 +02:00
|
|
|
$container->get( 'ppcp.asset-version' ),
|
2020-08-31 11:12:46 +03:00
|
|
|
$container->get( 'session.handler' ),
|
|
|
|
$settings,
|
|
|
|
$payer_factory,
|
|
|
|
$client_id,
|
|
|
|
$request_data,
|
|
|
|
$dcc_applies,
|
|
|
|
$subscription_helper,
|
2020-10-16 13:32:26 +03:00
|
|
|
$messages_apply,
|
2021-03-25 16:11:45 +01:00
|
|
|
$environment,
|
2021-06-17 11:51:43 +02:00
|
|
|
$payment_token_repository,
|
2021-11-30 10:40:38 +02:00
|
|
|
$settings_status,
|
2022-04-12 14:59:07 +03:00
|
|
|
$currency,
|
2022-04-12 15:29:23 +03:00
|
|
|
$container->get( 'wcgateway.all-funding-sources' ),
|
2022-06-28 12:09:18 +03:00
|
|
|
$container->get( 'button.basic-checkout-validation-enabled' ),
|
2023-02-07 15:29:53 +02:00
|
|
|
$container->get( 'button.early-wc-checkout-validation-enabled' ),
|
2023-05-16 15:02:27 +02:00
|
|
|
$container->get( 'button.pay-now-contexts' ),
|
2023-06-14 08:59:30 +03:00
|
|
|
$container->get( 'wcgateway.funding-sources-without-redirect' ),
|
2022-04-12 14:59:07 +03:00
|
|
|
$container->get( 'woocommerce.logger.woocommerce' )
|
2020-08-31 11:12:46 +03:00
|
|
|
);
|
|
|
|
},
|
2022-11-09 19:18:16 +04:00
|
|
|
'button.url' => static function ( ContainerInterface $container ): string {
|
2020-08-31 11:12:46 +03:00
|
|
|
return plugins_url(
|
2020-09-01 14:53:03 +03:00
|
|
|
'/modules/ppcp-button/',
|
2022-01-14 16:35:13 +02:00
|
|
|
dirname( realpath( __FILE__ ), 3 ) . '/woocommerce-paypal-payments.php'
|
2020-08-31 11:12:46 +03:00
|
|
|
);
|
|
|
|
},
|
2023-04-24 08:15:22 +03:00
|
|
|
'button.pay-now-contexts' => static function ( ContainerInterface $container ): array {
|
|
|
|
return array( 'checkout', 'pay-now' );
|
|
|
|
},
|
2022-11-09 19:18:16 +04:00
|
|
|
'button.request-data' => static function ( ContainerInterface $container ): RequestData {
|
2020-08-31 11:12:46 +03:00
|
|
|
return new RequestData();
|
|
|
|
},
|
2022-11-09 19:18:16 +04:00
|
|
|
'button.endpoint.change-cart' => static function ( ContainerInterface $container ): ChangeCartEndpoint {
|
2020-08-31 11:12:46 +03:00
|
|
|
if ( ! \WC()->cart ) {
|
|
|
|
throw new RuntimeException( 'cant initialize endpoint at this moment' );
|
|
|
|
}
|
|
|
|
$cart = WC()->cart;
|
|
|
|
$shipping = WC()->shipping();
|
|
|
|
$request_data = $container->get( 'button.request-data' );
|
2022-07-05 14:25:55 +03:00
|
|
|
$purchase_unit_factory = $container->get( 'api.factory.purchase-unit' );
|
2020-08-31 11:12:46 +03:00
|
|
|
$data_store = \WC_Data_Store::load( 'product' );
|
2021-09-24 10:33:21 +02:00
|
|
|
$logger = $container->get( 'woocommerce.logger.woocommerce' );
|
2022-07-05 14:25:55 +03:00
|
|
|
return new ChangeCartEndpoint( $cart, $shipping, $request_data, $purchase_unit_factory, $data_store, $logger );
|
2020-08-31 11:12:46 +03:00
|
|
|
},
|
2022-11-09 19:18:16 +04:00
|
|
|
'button.endpoint.create-order' => static function ( ContainerInterface $container ): CreateOrderEndpoint {
|
2020-09-30 14:24:31 +03:00
|
|
|
$request_data = $container->get( 'button.request-data' );
|
|
|
|
$purchase_unit_factory = $container->get( 'api.factory.purchase-unit' );
|
|
|
|
$order_endpoint = $container->get( 'api.endpoint.order' );
|
|
|
|
$payer_factory = $container->get( 'api.factory.payer' );
|
|
|
|
$session_handler = $container->get( 'session.handler' );
|
|
|
|
$settings = $container->get( 'wcgateway.settings' );
|
|
|
|
$early_order_handler = $container->get( 'button.helper.early-order-handler' );
|
2021-10-20 10:13:27 +03:00
|
|
|
$registration_needed = $container->get( 'button.current-user-must-register' );
|
|
|
|
$logger = $container->get( 'woocommerce.logger.woocommerce' );
|
2020-08-31 11:12:46 +03:00
|
|
|
return new CreateOrderEndpoint(
|
|
|
|
$request_data,
|
2020-09-30 14:24:31 +03:00
|
|
|
$purchase_unit_factory,
|
2022-07-05 14:25:55 +03:00
|
|
|
$container->get( 'api.factory.shipping-preference' ),
|
2020-08-31 11:12:46 +03:00
|
|
|
$order_endpoint,
|
|
|
|
$payer_factory,
|
|
|
|
$session_handler,
|
|
|
|
$settings,
|
2021-09-24 10:33:21 +02:00
|
|
|
$early_order_handler,
|
2021-10-20 10:13:27 +03:00
|
|
|
$registration_needed,
|
2022-07-20 17:28:12 +03:00
|
|
|
$container->get( 'wcgateway.settings.card_billing_data_mode' ),
|
2022-10-27 09:30:40 +03:00
|
|
|
$container->get( 'button.early-wc-checkout-validation-enabled' ),
|
2023-04-24 08:15:22 +03:00
|
|
|
$container->get( 'button.pay-now-contexts' ),
|
2023-04-25 15:06:24 +03:00
|
|
|
$container->get( 'button.handle-shipping-in-paypal' ),
|
2023-06-14 08:59:30 +03:00
|
|
|
$container->get( 'wcgateway.funding-sources-without-redirect' ),
|
2021-09-24 10:33:21 +02:00
|
|
|
$logger
|
2020-08-31 11:12:46 +03:00
|
|
|
);
|
|
|
|
},
|
2022-11-09 19:18:16 +04:00
|
|
|
'button.helper.early-order-handler' => static function ( ContainerInterface $container ) : EarlyOrderHandler {
|
2020-08-25 10:18:53 +03:00
|
|
|
|
2020-08-31 11:12:46 +03:00
|
|
|
$state = $container->get( 'onboarding.state' );
|
|
|
|
$order_processor = $container->get( 'wcgateway.order-processor' );
|
|
|
|
$session_handler = $container->get( 'session.handler' );
|
2023-06-08 16:00:21 +03:00
|
|
|
return new EarlyOrderHandler( $state, $order_processor, $session_handler );
|
2020-08-31 11:12:46 +03:00
|
|
|
},
|
2022-11-09 19:18:16 +04:00
|
|
|
'button.endpoint.approve-order' => static function ( ContainerInterface $container ): ApproveOrderEndpoint {
|
2020-08-31 11:12:46 +03:00
|
|
|
$request_data = $container->get( 'button.request-data' );
|
2020-09-18 11:55:25 +03:00
|
|
|
$order_endpoint = $container->get( 'api.endpoint.order' );
|
2020-08-31 11:12:46 +03:00
|
|
|
$session_handler = $container->get( 'session.handler' );
|
2020-09-18 11:55:25 +03:00
|
|
|
$three_d_secure = $container->get( 'button.helper.three-d-secure' );
|
|
|
|
$settings = $container->get( 'wcgateway.settings' );
|
2020-09-29 09:59:22 +03:00
|
|
|
$dcc_applies = $container->get( 'api.helpers.dccapplies' );
|
2022-06-02 15:11:01 +02:00
|
|
|
$order_helper = $container->get( 'api.order-helper' );
|
2021-05-10 17:12:46 +02:00
|
|
|
$logger = $container->get( 'woocommerce.logger.woocommerce' );
|
2020-09-29 09:59:22 +03:00
|
|
|
return new ApproveOrderEndpoint(
|
|
|
|
$request_data,
|
|
|
|
$order_endpoint,
|
|
|
|
$session_handler,
|
|
|
|
$three_d_secure,
|
|
|
|
$settings,
|
2021-05-10 17:12:46 +02:00
|
|
|
$dcc_applies,
|
2022-06-02 15:11:01 +02:00
|
|
|
$order_helper,
|
2021-05-10 17:12:46 +02:00
|
|
|
$logger
|
2020-09-29 09:59:22 +03:00
|
|
|
);
|
2020-08-31 11:12:46 +03:00
|
|
|
},
|
2023-01-05 14:53:23 +01:00
|
|
|
'button.endpoint.approve-subscription' => static function( ContainerInterface $container ): ApproveSubscriptionEndpoint {
|
|
|
|
return new ApproveSubscriptionEndpoint(
|
|
|
|
$container->get( 'button.request-data' ),
|
|
|
|
$container->get( 'api.endpoint.order' ),
|
|
|
|
$container->get( 'session.handler' )
|
|
|
|
);
|
|
|
|
},
|
2023-01-25 09:42:31 +02:00
|
|
|
'button.checkout-form-saver' => static function ( ContainerInterface $container ): CheckoutFormSaver {
|
|
|
|
return new CheckoutFormSaver();
|
|
|
|
},
|
|
|
|
'button.endpoint.save-checkout-form' => static function ( ContainerInterface $container ): SaveCheckoutFormEndpoint {
|
|
|
|
return new SaveCheckoutFormEndpoint(
|
|
|
|
$container->get( 'button.request-data' ),
|
|
|
|
$container->get( 'button.checkout-form-saver' ),
|
|
|
|
$container->get( 'woocommerce.logger.woocommerce' )
|
|
|
|
);
|
|
|
|
},
|
2022-11-09 19:18:16 +04:00
|
|
|
'button.endpoint.data-client-id' => static function( ContainerInterface $container ) : DataClientIdEndpoint {
|
2020-08-31 11:12:46 +03:00
|
|
|
$request_data = $container->get( 'button.request-data' );
|
|
|
|
$identity_token = $container->get( 'api.endpoint.identity-token' );
|
2021-09-24 10:09:17 +02:00
|
|
|
$logger = $container->get( 'woocommerce.logger.woocommerce' );
|
2020-08-31 11:12:46 +03:00
|
|
|
return new DataClientIdEndpoint(
|
|
|
|
$request_data,
|
2021-09-24 10:09:17 +02:00
|
|
|
$identity_token,
|
|
|
|
$logger
|
2020-08-31 11:12:46 +03:00
|
|
|
);
|
|
|
|
},
|
2022-11-09 19:18:16 +04:00
|
|
|
'button.endpoint.vault-paypal' => static function( ContainerInterface $container ) : StartPayPalVaultingEndpoint {
|
2022-04-12 14:59:07 +03:00
|
|
|
return new StartPayPalVaultingEndpoint(
|
|
|
|
$container->get( 'button.request-data' ),
|
|
|
|
$container->get( 'api.endpoint.payment-token' ),
|
|
|
|
$container->get( 'woocommerce.logger.woocommerce' )
|
|
|
|
);
|
|
|
|
},
|
2023-02-07 15:29:53 +02:00
|
|
|
'button.endpoint.validate-checkout' => static function ( ContainerInterface $container ): ValidateCheckoutEndpoint {
|
|
|
|
return new ValidateCheckoutEndpoint(
|
|
|
|
$container->get( 'button.request-data' ),
|
|
|
|
$container->get( 'button.validation.wc-checkout-validator' ),
|
|
|
|
$container->get( 'woocommerce.logger.woocommerce' )
|
|
|
|
);
|
|
|
|
},
|
2023-02-15 16:50:34 +02:00
|
|
|
'button.endpoint.cart-script-params' => static function ( ContainerInterface $container ): CartScriptParamsEndpoint {
|
|
|
|
return new CartScriptParamsEndpoint(
|
|
|
|
$container->get( 'button.smart-button' ),
|
|
|
|
$container->get( 'woocommerce.logger.woocommerce' )
|
|
|
|
);
|
|
|
|
},
|
2022-11-09 19:18:16 +04:00
|
|
|
'button.helper.three-d-secure' => static function ( ContainerInterface $container ): ThreeDSecure {
|
2021-09-21 11:34:16 +02:00
|
|
|
$logger = $container->get( 'woocommerce.logger.woocommerce' );
|
|
|
|
return new ThreeDSecure( $logger );
|
2020-08-31 11:12:46 +03:00
|
|
|
},
|
2022-11-09 19:18:16 +04:00
|
|
|
'button.helper.messages-apply' => static function ( ContainerInterface $container ): MessagesApply {
|
2021-11-30 10:40:38 +02:00
|
|
|
return new MessagesApply(
|
|
|
|
$container->get( 'api.shop.country' )
|
|
|
|
);
|
2020-08-31 11:12:46 +03:00
|
|
|
},
|
2021-10-20 10:13:27 +03:00
|
|
|
|
2022-11-09 19:18:16 +04:00
|
|
|
'button.is-logged-in' => static function ( ContainerInterface $container ): bool {
|
2021-10-20 10:13:27 +03:00
|
|
|
return is_user_logged_in();
|
|
|
|
},
|
2022-11-09 19:18:16 +04:00
|
|
|
'button.registration-required' => static function ( ContainerInterface $container ): bool {
|
2021-10-20 10:13:27 +03:00
|
|
|
return WC()->checkout()->is_registration_required();
|
|
|
|
},
|
2022-11-09 19:18:16 +04:00
|
|
|
'button.current-user-must-register' => static function ( ContainerInterface $container ): bool {
|
2021-10-20 10:13:27 +03:00
|
|
|
return ! $container->get( 'button.is-logged-in' ) &&
|
|
|
|
$container->get( 'button.registration-required' );
|
|
|
|
},
|
2022-06-28 12:09:18 +03:00
|
|
|
|
2022-11-09 19:18:16 +04:00
|
|
|
'button.basic-checkout-validation-enabled' => static function ( ContainerInterface $container ): bool {
|
2022-06-28 12:09:18 +03:00
|
|
|
/**
|
|
|
|
* The filter allowing to disable the basic client-side validation of the checkout form
|
|
|
|
* when the PayPal button is clicked.
|
|
|
|
*/
|
2022-10-27 09:30:40 +03:00
|
|
|
return (bool) apply_filters( 'woocommerce_paypal_payments_basic_checkout_validation_enabled', false );
|
|
|
|
},
|
|
|
|
'button.early-wc-checkout-validation-enabled' => static function ( ContainerInterface $container ): bool {
|
|
|
|
/**
|
|
|
|
* The filter allowing to disable the WC validation of the checkout form
|
|
|
|
* when the PayPal button is clicked.
|
|
|
|
* The validation is triggered in a non-standard way and may cause issues on some sites.
|
|
|
|
*/
|
|
|
|
return (bool) apply_filters( 'woocommerce_paypal_payments_early_wc_checkout_validation_enabled', true );
|
2022-06-28 12:09:18 +03:00
|
|
|
},
|
2023-02-07 15:29:53 +02:00
|
|
|
'button.validation.wc-checkout-validator' => static function ( ContainerInterface $container ): CheckoutFormValidator {
|
|
|
|
return new CheckoutFormValidator();
|
|
|
|
},
|
2023-04-25 15:06:24 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If true, the shipping methods are sent to PayPal allowing the customer to select it inside the popup.
|
|
|
|
* May result in slower popup performance, additional loading.
|
|
|
|
*/
|
|
|
|
'button.handle-shipping-in-paypal' => static function ( ContainerInterface $container ): bool {
|
|
|
|
return false;
|
|
|
|
},
|
2020-08-31 11:12:46 +03:00
|
|
|
);
|