mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-03 08:37:53 +08:00
90 lines
3.5 KiB
PHP
90 lines
3.5 KiB
PHP
<?php
|
|
/**
|
|
* The save payment methods module services.
|
|
*
|
|
* @package WooCommerce\PayPalCommerce\SavePaymentMethods
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace WooCommerce\PayPalCommerce\SavePaymentMethods;
|
|
|
|
use WooCommerce\PayPalCommerce\SavePaymentMethods\Endpoint\CaptureCardPayment;
|
|
use WooCommerce\PayPalCommerce\SavePaymentMethods\Endpoint\CreatePaymentToken;
|
|
use WooCommerce\PayPalCommerce\SavePaymentMethods\Endpoint\CreateSetupToken;
|
|
use WooCommerce\PayPalCommerce\SavePaymentMethods\Helper\SavePaymentMethodsApplies;
|
|
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
|
|
|
|
return array(
|
|
'save-payment-methods.eligible' => static function ( ContainerInterface $container ): bool {
|
|
$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',
|
|
),
|
|
)
|
|
);
|
|
},
|
|
'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'
|
|
);
|
|
},
|
|
'save-payment-methods.endpoint.create-setup-token' => static function ( ContainerInterface $container ): CreateSetupToken {
|
|
return new CreateSetupToken(
|
|
$container->get( 'button.request-data' ),
|
|
$container->get( 'api.endpoint.payment-method-tokens' )
|
|
);
|
|
},
|
|
'save-payment-methods.wc-payment-tokens' => static function( ContainerInterface $container ): WooCommercePaymentTokens {
|
|
return new WooCommercePaymentTokens(
|
|
$container->get( 'vaulting.payment-token-helper' ),
|
|
$container->get( 'vaulting.payment-token-factory' ),
|
|
$container->get( 'woocommerce.logger.woocommerce' )
|
|
);
|
|
},
|
|
'save-payment-methods.endpoint.create-payment-token' => static function ( ContainerInterface $container ): CreatePaymentToken {
|
|
return new CreatePaymentToken(
|
|
$container->get( 'button.request-data' ),
|
|
$container->get( 'api.endpoint.payment-method-tokens' ),
|
|
$container->get( 'save-payment-methods.wc-payment-tokens' )
|
|
);
|
|
},
|
|
'save-payment-methods.endpoint.capture-card-payment' => static function( ContainerInterface $container ): CaptureCardPayment {
|
|
return new CaptureCardPayment(
|
|
$container->get( 'button.request-data' ),
|
|
$container->get( 'api.host' ),
|
|
$container->get( 'api.bearer' ),
|
|
$container->get( 'api.factory.order' ),
|
|
$container->get( 'api.factory.purchase-unit' ),
|
|
$container->get( 'api.endpoint.order' ),
|
|
$container->get( 'session.handler' ),
|
|
$container->get( 'woocommerce.logger.woocommerce' )
|
|
);
|
|
},
|
|
);
|