assets
7 months ago
src
7 months ago
extensions.php
1 year ago
module.php
1 year ago
services.php
9 months ago
services.php
55 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * The save payment methods module services. |
| 5 | * |
| 6 | * @package WooCommerce\PayPalCommerce\SavePaymentMethods |
| 7 | */ |
| 8 | declare (strict_types=1); |
| 9 | namespace WooCommerce\PayPalCommerce\SavePaymentMethods; |
| 10 | |
| 11 | use WooCommerce\PayPalCommerce\SavePaymentMethods\Endpoint\CreatePaymentToken; |
| 12 | use WooCommerce\PayPalCommerce\SavePaymentMethods\Endpoint\CreateSetupToken; |
| 13 | use WooCommerce\PayPalCommerce\SavePaymentMethods\Endpoint\CreatePaymentTokenForGuest; |
| 14 | use WooCommerce\PayPalCommerce\SavePaymentMethods\Helper\SavePaymentMethodsApplies; |
| 15 | use WooCommerce\PayPalCommerce\SavePaymentMethods\Service\PaymentMethodTokensChecker; |
| 16 | use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface; |
| 17 | return array( |
| 18 | // @deprecated - use `save-payment-methods.eligibility.check` instead. |
| 19 | 'save-payment-methods.eligible' => static function (ContainerInterface $container): bool { |
| 20 | $eligibility_check = $container->get('save-payment-methods.eligibility.check'); |
| 21 | return $eligibility_check(); |
| 22 | }, |
| 23 | 'save-payment-methods.eligibility.check' => static function (ContainerInterface $container): callable { |
| 24 | $save_payment_methods_applies = $container->get('save-payment-methods.helpers.save-payment-methods-applies'); |
| 25 | assert($save_payment_methods_applies instanceof SavePaymentMethodsApplies); |
| 26 | return static function () use ($save_payment_methods_applies): bool { |
| 27 | return $save_payment_methods_applies->for_country() && $save_payment_methods_applies->for_merchant(); |
| 28 | }; |
| 29 | }, |
| 30 | 'save-payment-methods.helpers.save-payment-methods-applies' => static function (ContainerInterface $container): SavePaymentMethodsApplies { |
| 31 | return new SavePaymentMethodsApplies($container->get('save-payment-methods.supported-countries'), $container->get('api.shop.country')); |
| 32 | }, |
| 33 | 'save-payment-methods.supported-countries' => static function (ContainerInterface $container): array { |
| 34 | if (has_filter('woocommerce_paypal_payments_save_payment_methods_supported_country_currency_matrix')) { |
| 35 | _deprecated_hook('woocommerce_paypal_payments_save_payment_methods_supported_country_currency_matrix', '3.0.0', 'woocommerce_paypal_payments_save_payment_methods_supported_countries', esc_attr__('Please use the new Hook to filter countries for saved payments in PayPal Payments.', 'woocommerce-paypal-payments')); |
| 36 | } |
| 37 | return apply_filters('woocommerce_paypal_payments_save_payment_methods_supported_countries', array('AU', 'AT', 'BE', 'BG', 'CA', 'CN', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'HK', 'HU', 'IE', 'IT', 'LV', 'LI', 'LT', 'LU', 'MT', 'NO', 'NL', 'PL', 'PT', 'RO', 'SG', 'SK', 'SI', 'ES', 'SE', 'GB', 'US', 'YT', 'RE', 'GP', 'GF', 'MQ')); |
| 38 | }, |
| 39 | 'save-payment-methods.module.url' => static function (ContainerInterface $container): string { |
| 40 | return plugins_url('/modules/ppcp-save-payment-methods/', $container->get('ppcp.path-to-plugin-main-file')); |
| 41 | }, |
| 42 | 'save-payment-methods.endpoint.create-setup-token' => static function (ContainerInterface $container): CreateSetupToken { |
| 43 | return new CreateSetupToken($container->get('button.request-data'), $container->get('api.endpoint.payment-method-tokens')); |
| 44 | }, |
| 45 | 'save-payment-methods.endpoint.create-payment-token' => static function (ContainerInterface $container): CreatePaymentToken { |
| 46 | return new CreatePaymentToken($container->get('button.request-data'), $container->get('api.endpoint.payment-method-tokens'), $container->get('vaulting.wc-payment-tokens')); |
| 47 | }, |
| 48 | 'save-payment-methods.endpoint.create-payment-token-for-guest' => static function (ContainerInterface $container): CreatePaymentTokenForGuest { |
| 49 | return new CreatePaymentTokenForGuest($container->get('button.request-data'), $container->get('api.endpoint.payment-method-tokens')); |
| 50 | }, |
| 51 | 'save-payment-methods.service.payment-method-tokens-checker' => static function (ContainerInterface $container): PaymentMethodTokensChecker { |
| 52 | return new PaymentMethodTokensChecker($container->get('api.endpoint.payment-tokens')); |
| 53 | }, |
| 54 | ); |
| 55 |