PluginProbe ʕ •ᴥ•ʔ
WooCommerce PayPal Payments / 3.3.2
WooCommerce PayPal Payments v3.3.2
4.0.4 4.0.3 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.1.0 1.2.0 1.2.1 1.3.0 1.3.1 1.3.2 1.4.0 1.5.0 1.5.1 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.7.0 1.7.1 1.8.0 1.8.1 1.9.0 1.9.1 1.9.2 1.9.3 1.9.4 1.9.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.1.0 2.2.0 2.2.1 2.2.2 2.3.0 2.3.1 2.4.0 2.4.1 2.4.2 2.4.3 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.6.0 2.6.1 2.7.0 2.7.1 2.8.0 2.8.1 2.8.2 2.8.3 2.9.0 2.9.1 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.2.0 3.2.1 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 4.0.0 4.0.1 4.0.2
woocommerce-paypal-payments / modules / ppcp-onboarding / services.php
woocommerce-paypal-payments / modules / ppcp-onboarding Last commit date
assets 1 year ago src 9 months ago extensions.php 1 year ago module.php 1 year ago services.php 9 months ago
services.php
147 lines
1 <?php
2
3 /**
4 * The onboarding module services.
5 *
6 * @package WooCommerce\PayPalCommerce\Onboarding
7 */
8 declare (strict_types=1);
9 namespace WooCommerce\PayPalCommerce\Onboarding;
10
11 use WooCommerce\PayPalCommerce\Onboarding\Render\OnboardingOptionsRenderer;
12 use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
13 use WooCommerce\PayPalCommerce\ApiClient\Helper\Cache;
14 use WooCommerce\PayPalCommerce\Onboarding\Assets\OnboardingAssets;
15 use WooCommerce\PayPalCommerce\Onboarding\Endpoint\LoginSellerEndpoint;
16 use WooCommerce\PayPalCommerce\Onboarding\Endpoint\UpdateSignupLinksEndpoint;
17 use WooCommerce\PayPalCommerce\Onboarding\Render\OnboardingSendOnlyNoticeRenderer;
18 use WooCommerce\PayPalCommerce\Onboarding\Render\OnboardingRenderer;
19 use WooCommerce\PayPalCommerce\WcGateway\Helper\Environment;
20 use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
21 use WooCommerce\PayPalCommerce\WcGateway\Helper\ConnectionState;
22 use WooCommerce\PayPalCommerce\Settings\Data\GeneralSettings;
23 use WooCommerce\PayPalCommerce\WcGateway\Helper\MerchantDetails;
24 return array(
25 'api.paypal-host' => function (ContainerInterface $container): string {
26 $environment = $container->get('settings.environment');
27 /**
28 * The current environment.
29 *
30 * @var Environment $environment
31 */
32 if ($environment->current_environment_is(Environment::SANDBOX)) {
33 return $container->get('api.paypal-host-sandbox');
34 }
35 return $container->get('api.paypal-host-production');
36 },
37 'api.paypal-website-url' => function (ContainerInterface $container): string {
38 $environment = $container->get('settings.environment');
39 assert($environment instanceof Environment);
40 if ($environment->current_environment_is(Environment::SANDBOX)) {
41 return $container->get('api.paypal-website-url-sandbox');
42 }
43 return $container->get('api.paypal-website-url-production');
44 },
45 'onboarding.state' => function (ContainerInterface $container): \WooCommerce\PayPalCommerce\Onboarding\State {
46 $settings = $container->get('wcgateway.settings');
47 return new \WooCommerce\PayPalCommerce\Onboarding\State($settings);
48 },
49 /**
50 * Merchant connection details, which includes the connection status
51 * (onboarding/connected) and connection-aware environment checks.
52 * This is the preferred solution to check environment and connection state.
53 */
54 'settings.connection-state' => static function (ContainerInterface $container): ConnectionState {
55 $state = $container->get('onboarding.state');
56 assert($state instanceof \WooCommerce\PayPalCommerce\Onboarding\State);
57 $settings = $container->get('wcgateway.settings');
58 assert($settings instanceof Settings);
59 $is_sandbox = $settings->has('sandbox_on') && $settings->get('sandbox_on');
60 $is_connected = $state->current_state() >= \WooCommerce\PayPalCommerce\Onboarding\State::STATE_ONBOARDED;
61 $environment = new Environment($is_sandbox);
62 return new ConnectionState($is_connected, $environment);
63 },
64 /**
65 * Checks if the onboarding process is completed and the merchant API can be used.
66 * This service only resolves the connection status once per request.
67 *
68 * @deprecated Use 'settings.connection-state' instead.
69 */
70 'settings.flag.is-connected' => static function (ContainerInterface $container): bool {
71 $state = $container->get('settings.connection-state');
72 assert($state instanceof ConnectionState);
73 return $state->is_connected();
74 },
75 /**
76 * Determines whether the merchant is connected to a sandbox account.
77 * This service only resolves the sandbox flag once per request.
78 *
79 * @deprecated Use 'settings.connection-state' instead.
80 */
81 'settings.flag.is-sandbox' => static function (ContainerInterface $container): bool {
82 $state = $container->get('settings.connection-state');
83 assert($state instanceof ConnectionState);
84 return $state->is_sandbox();
85 },
86 /**
87 * Returns details about the connected environment (production/sandbox).
88 *
89 * @deprecated Directly use 'settings.connection-state' instead of this.
90 */
91 'settings.environment' => function (ContainerInterface $container): Environment {
92 $state = $container->get('settings.connection-state');
93 assert($state instanceof ConnectionState);
94 return $state->get_environment();
95 },
96 'settings.merchant-details' => static function (ContainerInterface $container): MerchantDetails {
97 $woo_country = $container->get('api.shop.country');
98 $eligibility_checks = $container->get('wcgateway.feature-eligibility.list');
99 return new MerchantDetails($woo_country, $woo_country, $eligibility_checks);
100 },
101 'onboarding.assets' => function (ContainerInterface $container): OnboardingAssets {
102 $state = $container->get('onboarding.state');
103 $login_seller_endpoint = $container->get('onboarding.endpoint.login-seller');
104 return new OnboardingAssets($container->get('onboarding.url'), $container->get('ppcp.asset-version'), $state, $container->get('settings.environment'), $login_seller_endpoint, $container->get('wcgateway.current-ppcp-settings-page-id'));
105 },
106 'onboarding.url' => static function (ContainerInterface $container): string {
107 return plugins_url('/modules/ppcp-onboarding/', $container->get('ppcp.path-to-plugin-main-file'));
108 },
109 'onboarding.endpoint.login-seller' => static function (ContainerInterface $container): LoginSellerEndpoint {
110 $request_data = $container->get('button.request-data');
111 $login_seller_production = $container->get('api.endpoint.login-seller-production');
112 $login_seller_sandbox = $container->get('api.endpoint.login-seller-sandbox');
113 $partner_referrals_data = $container->get('api.repository.partner-referrals-data');
114 $settings = $container->get('wcgateway.settings');
115 $cache = $container->get('api.paypal-bearer-cache');
116 $logger = $container->get('woocommerce.logger.woocommerce');
117 return new LoginSellerEndpoint($request_data, $login_seller_production, $login_seller_sandbox, $partner_referrals_data, $settings, $cache, $logger, new Cache('ppcp-client-credentials-cache'));
118 },
119 'onboarding.endpoint.pui' => static function (ContainerInterface $container): UpdateSignupLinksEndpoint {
120 return new UpdateSignupLinksEndpoint($container->get('wcgateway.settings'), $container->get('button.request-data'), $container->get('onboarding.signup-link-cache'), $container->get('onboarding.render'), $container->get('onboarding.signup-link-ids'), $container->get('woocommerce.logger.woocommerce'));
121 },
122 'onboarding.signup-link-cache' => static function (ContainerInterface $container): Cache {
123 return new Cache('ppcp-paypal-signup-link');
124 },
125 'onboarding.signup-link-ids' => static function (ContainerInterface $container): array {
126 return array('production-ppcp', 'production-express_checkout', 'sandbox-ppcp', 'sandbox-express_checkout');
127 },
128 'onboarding.render-send-only-notice' => static function (ContainerInterface $container) {
129 return new OnboardingSendOnlyNoticeRenderer($container->get('wcgateway.send-only-message'));
130 },
131 'onboarding.render' => static function (ContainerInterface $container): OnboardingRenderer {
132 $partner_referrals = $container->get('api.endpoint.partner-referrals-production');
133 $partner_referrals_sandbox = $container->get('api.endpoint.partner-referrals-sandbox');
134 $partner_referrals_data = $container->get('api.repository.partner-referrals-data');
135 $settings = $container->get('wcgateway.settings');
136 $signup_link_cache = $container->get('onboarding.signup-link-cache');
137 $logger = $container->get('woocommerce.logger.woocommerce');
138 return new OnboardingRenderer($settings, $partner_referrals, $partner_referrals_sandbox, $partner_referrals_data, $signup_link_cache, $logger);
139 },
140 'onboarding.render-options' => static function (ContainerInterface $container): OnboardingOptionsRenderer {
141 return new OnboardingOptionsRenderer($container->get('onboarding.url'), $container->get('api.shop.country'), $container->get('wcgateway.settings'));
142 },
143 'onboarding.rest' => static function ($container): \WooCommerce\PayPalCommerce\Onboarding\OnboardingRESTController {
144 return new \WooCommerce\PayPalCommerce\Onboarding\OnboardingRESTController($container);
145 },
146 );
147