woocommerce-paypal-payments/modules/ppcp-card-fields/services.php

89 lines
2.2 KiB
PHP
Raw Normal View History

2023-11-08 12:46:01 +01:00
<?php
/**
* The Card Fields module services.
*
* @package WooCommerce\PayPalCommerce\CardFields
*/
declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\CardFields;
use WooCommerce\PayPalCommerce\CardFields\Helper\CardFieldsApplies;
use WooCommerce\PayPalCommerce\CardFields\Service\CardCaptureValidator;
2023-11-08 12:46:01 +01:00
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
return array(
2025-03-25 21:36:44 +01:00
// @deprecated - use `card-fields.eligibility.check` instead.
2023-11-16 17:01:39 +01:00
'card-fields.eligible' => static function ( ContainerInterface $container ): bool {
2025-03-25 21:36:44 +01:00
$eligibility_check = $container->get( 'card-fields.eligibility.check' );
2023-11-08 12:46:01 +01:00
2025-03-25 21:36:44 +01:00
return $eligibility_check();
2023-11-08 12:46:01 +01:00
},
'card-fields.eligibility.check' => static function ( ContainerInterface $container ): callable {
$save_payment_methods_applies = $container->get( 'card-fields.helpers.save-payment-methods-applies' );
assert( $save_payment_methods_applies instanceof CardFieldsApplies );
return static function () use ( $save_payment_methods_applies ) : bool {
return $save_payment_methods_applies->for_country() && $save_payment_methods_applies->for_merchant();
};
},
2023-11-08 12:46:01 +01:00
'card-fields.helpers.save-payment-methods-applies' => static function ( ContainerInterface $container ) : CardFieldsApplies {
return new CardFieldsApplies(
$container->get( 'card-fields.supported-country-matrix' ),
2023-11-08 12:46:01 +01:00
$container->get( 'api.shop.country' )
);
},
'card-fields.supported-country-matrix' => static function ( ContainerInterface $container ) : array {
2023-11-08 12:46:01 +01:00
return apply_filters(
'woocommerce_paypal_payments_card_fields_supported_country_matrix',
2023-11-08 12:46:01 +01:00
array(
'AU',
'AT',
'BE',
'BG',
'CA',
'CN',
'CY',
'CZ',
'DK',
'EE',
'FI',
'FR',
'DE',
'GR',
2025-02-11 12:16:22 +01:00
'HK',
'HU',
'IE',
'IT',
'LV',
'LI',
'LT',
'LU',
'MT',
'MX',
'NL',
'PL',
'PT',
2024-11-04 11:57:12 +01:00
'RO',
'SK',
2025-02-11 12:16:22 +01:00
'SG',
'SI',
'ES',
'SE',
'GB',
'US',
'NO',
'YT',
'RE',
'GP',
'GF',
2025-06-10 09:52:43 +02:00
'MQ',
2023-11-08 12:46:01 +01:00
)
);
},
'card-fields.service.card-capture-validator' => static function ( ContainerInterface $container ) : CardCaptureValidator {
return new CardCaptureValidator();
},
2023-11-08 12:46:01 +01:00
);