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-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-23 16:50:43 +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 );
|
|
|
|
|
|
|
|
return $save_payment_methods_applies->for_country_currency();
|
|
|
|
},
|
|
|
|
'save-payment-methods.helpers.save-payment-methods-applies' => static function ( ContainerInterface $container ) : SavePaymentMethodsApplies {
|
|
|
|
return new SavePaymentMethodsApplies(
|
|
|
|
$container->get( 'save-payment-methods.supported-country-currency-matrix' ),
|
|
|
|
$container->get( 'api.shop.currency' ),
|
|
|
|
$container->get( 'api.shop.country' )
|
|
|
|
);
|
|
|
|
},
|
|
|
|
'save-payment-methods.supported-country-currency-matrix' => static function ( ContainerInterface $container ) : array {
|
|
|
|
return apply_filters(
|
|
|
|
'woocommerce_paypal_payments_save_payment_methods_supported_country_currency_matrix',
|
|
|
|
array(
|
|
|
|
'US' => array(
|
|
|
|
'AUD',
|
|
|
|
'CAD',
|
|
|
|
'EUR',
|
|
|
|
'GBP',
|
|
|
|
'JPY',
|
|
|
|
'USD',
|
|
|
|
),
|
|
|
|
)
|
|
|
|
);
|
|
|
|
},
|
2023-10-23 16:50:43 +02:00
|
|
|
'save-payment-methods.module.url' => static function ( ContainerInterface $container ): string {
|
|
|
|
/**
|
|
|
|
* 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-19 11:18:01 +02:00
|
|
|
);
|