2023-10-17 15:11:48 +02:00
< ? php
/**
* The save payment methods module services .
*
* @ package WooCommerce\PayPalCommerce\SavePaymentMethods
*/
declare ( strict_types = 1 );
namespace WooCommerce\PayPalCommerce\SavePaymentMethods ;
2023-10-26 16:36:38 +02:00
use WooCommerce\PayPalCommerce\SavePaymentMethods\Endpoint\CreatePaymentToken ;
use WooCommerce\PayPalCommerce\SavePaymentMethods\Endpoint\CreateSetupToken ;
2024-04-09 17:34:51 +02:00
use WooCommerce\PayPalCommerce\SavePaymentMethods\Endpoint\CreatePaymentTokenForGuest ;
2023-10-19 11:18:01 +02:00
use WooCommerce\PayPalCommerce\SavePaymentMethods\Helper\SavePaymentMethodsApplies ;
2023-10-17 15:11:48 +02:00
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface ;
2023-10-19 11:18:01 +02:00
return array (
2023-10-27 12:25:42 +02:00
'save-payment-methods.eligible' => static function ( ContainerInterface $container ) : bool {
2023-10-19 11:18:01 +02:00
$save_payment_methods_applies = $container -> get ( 'save-payment-methods.helpers.save-payment-methods-applies' );
assert ( $save_payment_methods_applies instanceof SavePaymentMethodsApplies );
2024-12-16 08:42:20 +01:00
return $save_payment_methods_applies -> for_country ();
2023-10-19 11:18:01 +02:00
},
'save-payment-methods.helpers.save-payment-methods-applies' => static function ( ContainerInterface $container ) : SavePaymentMethodsApplies {
return new SavePaymentMethodsApplies (
2024-12-16 08:42:20 +01:00
$container -> get ( 'save-payment-methods.supported-countries' ),
2023-10-19 11:18:01 +02:00
$container -> get ( 'api.shop.country' )
);
},
2024-12-16 08:42:20 +01:00
'save-payment-methods.supported-countries' => static function ( ContainerInterface $container ) : array {
if ( has_filter ( 'woocommerce_paypal_payments_save_payment_methods_supported_country_currency_matrix' ) ) {
2024-12-18 09:20:08 +01:00
_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' ) );
2024-12-16 08:42:20 +01:00
}
2024-08-21 15:03:34 +02:00
2023-10-19 11:18:01 +02:00
return apply_filters (
2024-12-16 08:42:20 +01:00
'woocommerce_paypal_payments_save_payment_methods_supported_countries' ,
2023-10-19 11:18:01 +02:00
array (
2024-12-16 08:42:20 +01:00
'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' ,
2023-10-19 11:18:01 +02:00
)
);
},
2023-10-27 12:25:42 +02:00
'save-payment-methods.module.url' => static function ( ContainerInterface $container ) : string {
2023-10-23 16:50:43 +02:00
/**
* The path cannot be false .
*
* @ psalm - suppress PossiblyFalseArgument
*/
return plugins_url (
'/modules/ppcp-save-payment-methods/' ,
dirname ( realpath ( __FILE__ ), 3 ) . '/woocommerce-paypal-payments.php'
);
},
2023-10-27 12:25:42 +02:00
'save-payment-methods.endpoint.create-setup-token' => static function ( ContainerInterface $container ) : CreateSetupToken {
2023-10-26 16:36:38 +02:00
return new CreateSetupToken (
$container -> get ( 'button.request-data' ),
2023-10-27 12:25:42 +02:00
$container -> get ( 'api.endpoint.payment-method-tokens' )
2023-10-26 16:36:38 +02:00
);
},
2023-10-27 12:25:42 +02:00
'save-payment-methods.endpoint.create-payment-token' => static function ( ContainerInterface $container ) : CreatePaymentToken {
2023-10-26 16:36:38 +02:00
return new CreatePaymentToken (
2023-10-27 12:25:42 +02:00
$container -> get ( 'button.request-data' ),
$container -> get ( 'api.endpoint.payment-method-tokens' ),
2024-03-22 11:55:44 +01:00
$container -> get ( 'vaulting.wc-payment-tokens' )
2023-10-26 16:36:38 +02:00
);
2023-10-27 12:25:42 +02:00
},
2024-04-09 17:34:51 +02:00
'save-payment-methods.endpoint.create-payment-token-for-guest' => static function ( ContainerInterface $container ) : CreatePaymentTokenForGuest {
return new CreatePaymentTokenForGuest (
$container -> get ( 'button.request-data' ),
$container -> get ( 'api.endpoint.payment-method-tokens' )
);
},
2023-10-19 11:18:01 +02:00
);