�PNG  IHDR22?�� pHYs  �� OiCCPPhotoshop ICC profilexڝSgTS�=���BK���KoR RB���&*! J�!��Q�EEȠ�����Q, � ��!���������{�kּ������>���� �H3Q5� �B�������.@� $p�d!s�#�~<<+"��x� �M��0���B�\���t�8K�@z�B�@F���&S�`�cb�P-`'������{[�!�� e�Dh;��V�EX0fK�9�-0IWfH���� � 0Q��){`�##x��F�W<�+��*x��<�$9E�[-qWW.(�I+6aa�@.�y�2�4���������x����6��_-��"bb���ϫp@�t~��,/��;�m��%�h^ �u��f�@����W�p�~<�5�j>{�-�]c�K'Xt����o��(�h���w��?�G�%�fI�q^D$.Tʳ?�D��*�A��,���� �`6�B$��BB d�r`)��B(�Ͱ*`/�@4�Qh��p.�U�=p�a��(�� A�a!ڈb�X#����!�H�$ ɈQ"K�5H1R�T UH�=r9�\F��;�2����G1���Q=� �C��7�F� �dt1�����r�=�6��Ыhڏ>C�0��3�l0.��B�8, �c˱"� ���V����cϱw�E� 6wB aAHXLXN�H� $4� 7 �Q�'"��K�&���b21�XH,#��/{�C�7$�C2'��I��T��F�nR#�,��4H#���dk�9�, +ȅ����3��!�[ �b@q��S�(R�jJ��4�e�2AU��Rݨ�T5�ZB���R�Q��4u�9̓IK�����hh�i��t�ݕN��W���G���w ��Ljg(�gw��L�Ӌ�T071���oUX*�*|�� �J�&�*/T����ު U�U�T��^S}�FU3S� Ԗ�U��P�SSg�;���g�oT?�~Y��Y�L�OC�Q��_�� c�x,!k ��u�5�&���|v*�����=���9C3J3W�R�f?�q��tN �(���~���)�)�4L�1e\k����X�H�Q�G�6������E�Y��A�J'\'Gg����S�Sݧ �M=:��.�k���Dw�n��^��Lo��y���}/�T�m���G X� $� �<�5qo</���QC]�@C�a�a�ᄑ��<��F�F�i�\�$�m�mƣ&&!&KM�M�RM��)�;L;L���͢�֙5�=1�2��כ߷`ZxZ,����eI��Z�Yn�Z9Y�XUZ]�F���%ֻ�����N�N���gð�ɶ�����ۮ�m�}agbg�Ů��}�}��= ���Z~s�r:V:ޚΜ�?}����/gX���3��)�i�S��Ggg�s�󈋉K��.�>.���Ƚ�Jt�q]�z���������ۯ�6�i�ܟ�4�)�Y3s���C�Q��? ��0k߬~OCO�g��#/c/�W�װ��w��a�>�>r��>�<7�2�Y_�7��ȷ�O�o�_��C#�d�z����%g��A�[��z|!��?:�e����A���AA�������!h�쐭!��Α�i�P~���a�a��~ '���W�?�p�X�1�5w��Cs�D�D�Dޛg1O9�-J5*>�.j<�7�4�?�.fY��X�XIlK9.*�6nl������� �{�/�]py�����.,:�@L�N8��A*��%�w%� y��g"/�6ш�C\*N�H*Mz�쑼5y$�3�,幄'���L Lݛ:��v m2=:�1����qB�!M��g�g�fvˬe����n��/��k���Y- �B��TZ(�*�geWf�͉�9���+��̳�ې7�����ᒶ��KW-X潬j9�������(�x��oʿ�ܔ���Ĺd�f�f���-�[����n �ڴ �V����E�/��(ۻ��C���<��e����;?T�T�T�T6��ݵa��n��{��4���[���>ɾ�UUM�f�e�I���?�������m]�Nmq����#�׹���=TR��+�G�����w- 6 U����#pDy��� �� :�v�{���vg/jB��F�S��[b[�O�>����z�G��499�?r����C�d�&����ˮ/~�����јѡ�򗓿m|������������x31^�V���w�w��O�| (�h���SЧ��������c3-� cHRMz%������u0�`:�o�_�F5IDATx��ytUս�?�;���fN$$��@B�!�k��� -*�gE���j�O�kQ�ʠ`U�B_ �AÐ0%�Ȕ�@r3ޛ;߳��$�@��v����^�s����������$��ߢ !�W��5�̱'-٘������4�>�Rƫ$�G��0U�H}�_ _� #��k�MJ/=�9Du *ڲ�k�PQ;0��j|�*�$�^컂脛y���>�z×� B��� ��(�:$�ʔ_�6��C!B����MVx��a��ζyY����j��ƋY2�9�F�{r��r�딟F��Q��hY6��� x��[l��RC��������nt@��;P��3��� F�w��7��:�P���ɋ'���mj���Bƪ�$�Q�L��y��߷g��\���z����v5�p�v$�v櫻�`6~K �Y�X����,�:��"�o�e0II"(��,������l_�C���/4�+f�E�!q��:����u����c��樼.UE�@� �]K�W���$-�h]�JG���Dz)�`��.�A/ ���mᏣc�3jK� �!�>���$�Q�!�_�? \�C2(E �M$Z I{�U���s�ǣ���=��@Բe ޻��W�����@ �w����}�9v,)��.}*|"�s��di���,���G�]W�AC�������|<����[��ߕ������K�*�G nߴ!��‹��J�!��6(L�a)��Am��������;adf��:�xm��nh�;֦I��(���o�C~ډa?�=��s����h��E������xp����)���_���t��W�����´;8���`dz=(��@@�+,�;�`�fhl��XȌ�3,uI�~z(J����� �ZX�A����H'�À�㜦�82|��a�n�z2��I���� ���EY�h�ε<�0�q�{��C��v�˅��?"@��χ�x�WS+��N�~�KQ�J�8ل�� _.W��� !TU{�����,��"�� �;�������HI S� ��))�o�1�H�D� ���� (� ;����"Ҕ��,���� �F=���O��&�Ph>�`���y��߲ &S��P�<��'��1s�1cĂ�N����2)����@�u��tv��<�+�-&�����h��[!FSG���' � z z0��<����8d&�����E0�,��<��"!P�b4��� �{S�����X����.�囤���T��hEF��X�q0"-<����h���]�Py*����F⩍��@v�˂�Y08�� .q��a��s����(!<̫1�3�L�H��7sYW�`��qtu�\7��?�@�Y�� %Ka�x�GZ�*W�P��y�����N0r9��Z�c�%���q,��k�����!!,��>���IB��� �x1�Xu�Y���v-���ֺ��N������JP��a�2`�e5��w��u;�6�i���̃��(K���ťa��(l51��JL��O'%���]���ٖ뿉!��{*�p+f ���i8��D�ȑ���ܩ�M��V��ӟz��x�7Z�1i}�^͜���6e����x��)u�d�ˏ�V�eG�\�X1�����=n�U'�~Y����L�\,�(d!x ,�:�TW8� M`r���@��r+v�Q0��>^;˴�VbF��('����� �*O��i��j�Ӆ����^�S3&� ���{������.ی�� N;��NU%d0�Ce\r"�C�b��&t7N�7��� �ȪD�[%l�۪�$��'m?�A9tI�9>��NVL ��� 6v~M�����ъ�B���0����9$&=ώm��W�0���L���&��E���f�f��'+�9��hv��7,���M��6�D�&�^� �����8 D֮�����o��k^z��O��hP�8q�5d*��YVq3�{��������#LX4�?��jP=3�~�؅c�ݰ�̱�ұ��8̲��2�G�����j��έ�9��w7���U�X�w�85C��?!I&���o&����L���I#�^�eV�,�^t5�k� �xs˛\��U�8��."���{���ǵ�l4��ݼ�;��r"���G�/~���gJV�N糦��ZZ^k+NN�D��I$�=OE�z����|*�*{��%k���G��>�`9��b;�s���8,�qs��c��.b��q�%�>r��n�R�Ƨ�%�,�A��le#�8���}; 21�0�b�&�QX�f���q�00����$>�h�N�'�a3��A���/�r ��L5�8�GԲ'�����w;��c#�q1���h$*��V^�k��QĽ�b:i������� ����H F#�_���,��]g����Ը����`RUU���� ��"�qD���>-��ϤI�~��3�̴�����NZ[[555�eeek7�m����YF#[��Đ��R��i��L�H�r ��@��J-�Pŝ��_|�-��6y��ks�V�U~��6���w.����(��0A� 4��f��� /���C�xŊ�ٳ����z=6�����rg���mKo��o�/����a�g���?'9%9��P��斓��~���L{�� �H��{AW��B��$����v�1b�&Mb�ر��ر#�0`�`xMBp! )Z�Nmo�mZ�g�}�eذaWTVV ���'99��C5��&�&+5�bT>|8��PUUETT����&���t��~TE%��'������b�tEGG;RSS�S�N�v��ѯ��t����u1@�ޚ"f��͈���r'L�Ph��m��ƌ�74o��`�x�q�P���NRSS�X,�����l&&&��MFFA!-��`��ҷ�n��Yuu�����x<I�LB%����KԒ50�!�3�bz�����ʸKL���;---�l6[��`��������Ȏ;�����egg4��!D�T��jWujyZ��������K����%����p�^���X,6��sV=�ܖ����6�3�X ���4ҿ��A2�&����_k�;d�� �VfOIEND�B`�
Warning: session_start(): Session cannot be started after headers have already been sent in /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php on line 124

Warning: Cannot modify header information - headers already sent by (output started at /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php:1) in /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php on line 130

Warning: Cannot modify header information - headers already sent by (output started at /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php:1) in /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php on line 131

Warning: Cannot modify header information - headers already sent by (output started at /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php:1) in /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php on line 132

Warning: Cannot modify header information - headers already sent by (output started at /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php:1) in /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php on line 133

Warning: Cannot modify header information - headers already sent by (output started at /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php:1) in /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php on line 134

Warning: Cannot modify header information - headers already sent by (output started at /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php:1) in /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php on line 135

Warning: Cannot modify header information - headers already sent by (output started at /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php:1) in /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php on line 547

Warning: Cannot modify header information - headers already sent by (output started at /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php:1) in /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php on line 548

Warning: Cannot modify header information - headers already sent by (output started at /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php:1) in /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php on line 549

Warning: Cannot modify header information - headers already sent by (output started at /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php:1) in /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php on line 550

Warning: Cannot modify header information - headers already sent by (output started at /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php:1) in /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php on line 551
has_test_account(); $has_sandbox_account = $this->has_sandbox_account(); // Switch the onboarding type to native. $details['onboarding']['type'] = self::ONBOARDING_TYPE_NATIVE; // Add the test [drive] account details to the onboarding state. $details['onboarding']['state']['test_drive_account'] = $has_test_account; // Add WPCOM/Jetpack connection details to the onboarding state. $details['onboarding']['state'] = array_merge( $details['onboarding']['state'], $this->get_wpcom_connection_state() ); // If the WooPayments installed version is less than minimum required version, // we can't use the in-context onboarding flows. if ( Constants::is_defined( 'WCPAY_VERSION_NUMBER' ) && version_compare( Constants::get_constant( 'WCPAY_VERSION_NUMBER' ), WooPaymentsService::EXTENSION_MINIMUM_VERSION, '<' ) ) { return $details; } // Switch the onboarding type to native in-context. $details['onboarding']['type'] = self::ONBOARDING_TYPE_NATIVE_IN_CONTEXT; // Provide the native, in-context onboarding URL instead of the external one. // This is a catch-all URL that should start or continue the onboarding process. $details['onboarding']['_links']['onboard'] = array( 'href' => Utils::wc_payments_settings_url( '/woopayments/onboarding', array( 'from' => Payments::FROM_PAYMENTS_SETTINGS ) ), ); try { /** * The WooPayments REST controller instance. * * @var WooPaymentsRestController $rest_controller */ $rest_controller = wc_get_container()->get( WooPaymentsRestController::class ); // Add disable test account URL to onboarding links, if the current account is a test or sandbox account. if ( $has_test_account || $has_sandbox_account ) { $details['onboarding']['_links']['disable_test_account'] = array( 'href' => rest_url( $rest_controller->get_rest_url_path( 'onboarding/test_account/disable' ) ), ); } // Add reset account/onboarding URL to onboarding links. $details['onboarding']['_links']['reset'] = array( 'href' => rest_url( $rest_controller->get_rest_url_path( 'onboarding/reset' ) ), ); } catch ( \Throwable $e ) { // If the REST controller is not available, we can't generate the REST API endpoint URLs. // This is not a critical error, so we just ignore it. // Log so we can investigate. SafeGlobalFunctionProxy::wc_get_logger()->error( 'Failed to get the WooPayments REST controller instance: ' . $e->getMessage(), array( 'source' => 'settings-payments', ) ); } // Override the onboarding state with the entries provided by the WooPayments service. if ( ! empty( $country_code ) ) { try { /** * The WooPayments service instance. * * @var WooPaymentsService $service */ $service = wc_get_container()->get( WooPaymentsService::class ); // Ensure we have a valid rest_controller from the earlier try block. if ( ! isset( $rest_controller ) ) { throw new \RuntimeException( 'WooPayments REST controller not available' ); } $onboarding_details = $service->get_onboarding_details( $country_code, $rest_controller->get_rest_url_path( 'onboarding' ) ); // Merge the onboarding state with the one provided by the service. if ( ! empty( $onboarding_details['state'] ) && is_array( $onboarding_details['state'] ) ) { $details['onboarding']['state'] = array_merge( $details['onboarding']['state'], $onboarding_details['state'] ); } // Merge any messages provided by the service. if ( ! empty( $onboarding_details['messages'] ) && is_array( $onboarding_details['messages'] ) ) { if ( ! isset( $details['onboarding']['messages'] ) || ! is_array( $details['onboarding']['messages'] ) ) { $details['onboarding']['messages'] = array(); } $details['onboarding']['messages'] = array_merge( $details['onboarding']['messages'], $onboarding_details['messages'] ); } // The steps provided by the service override any existing steps. if ( ! empty( $onboarding_details['steps'] ) && is_array( $onboarding_details['steps'] ) ) { $details['onboarding']['steps'] = $onboarding_details['steps']; } // Merge any context provided by the service. if ( ! empty( $onboarding_details['context'] ) && is_array( $onboarding_details['context'] ) ) { if ( ! isset( $details['onboarding']['context'] ) || ! is_array( $details['onboarding']['context'] ) ) { $details['onboarding']['context'] = array(); } $details['onboarding']['context'] = array_merge( $details['onboarding']['context'], $onboarding_details['context'] ); } } catch ( \Throwable $e ) { // If the service is not available, we can't impose the more specific logic. // This is not a critical error, so we just ignore it. // Log so we can investigate. SafeGlobalFunctionProxy::wc_get_logger()->error( 'Failed to get the WooPayments service instance: ' . $e->getMessage(), array( 'source' => 'settings-payments', ) ); } } return $details; } /** * Enhance this provider's payment extension suggestion with additional information. * * The details added do not require the payment extension to be active or a gateway instance. * * @param array $extension_suggestion The extension suggestion details. * * @return array The enhanced payment extension suggestion details. */ public function enhance_extension_suggestion( array $extension_suggestion ): array { $extension_suggestion = parent::enhance_extension_suggestion( $extension_suggestion ); // If the extension is installed, we can get the plugin data and act upon it. if ( ! empty( $extension_suggestion['plugin']['file'] ) && isset( $extension_suggestion['plugin']['status'] ) && in_array( $extension_suggestion['plugin']['status'], array( PaymentsProviders::EXTENSION_INSTALLED, PaymentsProviders::EXTENSION_ACTIVE ), true ) ) { // Switch to the native in-context onboarding type if the WooPayments extension its version is compatible. // We need to put back the '.php' extension to construct the plugin filename. $plugin_data = $this->proxy->call_static( PluginsHelper::class, 'get_plugin_data', $extension_suggestion['plugin']['file'] . '.php' ); if ( $plugin_data && ! empty( $plugin_data['Version'] ) && version_compare( $plugin_data['Version'], PaymentsProviders\WooPayments\WooPaymentsService::EXTENSION_MINIMUM_VERSION, '>=' ) ) { $extension_suggestion['onboarding']['type'] = self::ONBOARDING_TYPE_NATIVE_IN_CONTEXT; } } else { // We assume the latest version of the WooPayments extension will be installed. $extension_suggestion['onboarding']['type'] = self::ONBOARDING_TYPE_NATIVE_IN_CONTEXT; } // Add onboarding state. if ( ! isset( $extension_suggestion['onboarding']['state'] ) || ! is_array( $extension_suggestion['onboarding']['state'] ) ) { $extension_suggestion['onboarding']['state'] = array(); } // Add the store's WPCOM/Jetpack connection state to the onboarding state. $extension_suggestion['onboarding']['state'] = array_merge( $extension_suggestion['onboarding']['state'], $this->get_wpcom_connection_state() ); // Add onboarding links. if ( empty( $extension_suggestion['onboarding']['_links'] ) || ! is_array( $extension_suggestion['onboarding']['_links'] ) ) { $extension_suggestion['onboarding']['_links'] = array(); } // We only add the preload link if we don't have a working WPCOM connection. // This is because WooPayments onboarding preloading focuses on hydrating the WPCOM connection. if ( ! $extension_suggestion['onboarding']['state']['wpcom_has_working_connection'] ) { try { /** * The WooPayments REST controller instance. * * @var WooPaymentsRestController $rest_controller */ $rest_controller = wc_get_container()->get( WooPaymentsRestController::class ); // Add the onboarding preload URL. $extension_suggestion['onboarding']['_links']['preload'] = array( 'href' => rest_url( $rest_controller->get_rest_url_path( 'onboarding/preload' ) ), ); } catch ( Throwable $e ) { // If the REST controller is not available, we can't preload the onboarding data. // This is not a critical error, so we just ignore it. // Log so we can investigate. SafeGlobalFunctionProxy::wc_get_logger()->error( 'Failed to get the WooPayments REST controller instance: ' . $e->getMessage(), array( 'source' => 'settings-payments', ) ); } } return $extension_suggestion; } /** * Check if the payment gateway needs setup. * * @param WC_Payment_Gateway $payment_gateway The payment gateway object. * * @return bool True if the payment gateway needs setup, false otherwise. */ public function needs_setup( WC_Payment_Gateway $payment_gateway ): bool { // No account means we need setup. if ( ! $this->is_account_connected( $payment_gateway ) ) { return true; } // Test-drive accounts don't need setup. if ( $this->has_test_account() ) { return false; } return parent::needs_setup( $payment_gateway ); } /** * Try to determine if the payment gateway is in test mode. * * This is a best-effort attempt, as there is no standard way to determine this. * Trust the true value, but don't consider a false value as definitive. * * @param WC_Payment_Gateway $payment_gateway The payment gateway object. * * @return bool True if the payment gateway is in test mode, false otherwise. */ public function is_in_test_mode( WC_Payment_Gateway $payment_gateway ): bool { if ( $this->proxy->call_function( 'class_exists', 'WC_Payments' ) && $this->proxy->call_function( 'is_callable', 'WC_Payments::mode' ) ) { $woopayments_mode = $this->proxy->call_static( 'WC_Payments', 'mode' ); if ( $this->proxy->call_function( 'method_exists', $woopayments_mode, 'is_test' ) && $this->proxy->call_function( 'is_callable', array( $woopayments_mode, 'is_test' ) ) ) { return $woopayments_mode->is_test(); } } return parent::is_in_test_mode( $payment_gateway ); } /** * Try to determine if the payment gateway is in dev mode. * * This is a best-effort attempt, as there is no standard way to determine this. * Trust the true value, but don't consider a false value as definitive. * * @param WC_Payment_Gateway $payment_gateway The payment gateway object. * * @return bool True if the payment gateway is in dev mode, false otherwise. */ public function is_in_dev_mode( WC_Payment_Gateway $payment_gateway ): bool { if ( $this->proxy->call_function( 'class_exists', 'WC_Payments' ) && $this->proxy->call_function( 'is_callable', 'WC_Payments::mode' ) ) { $woopayments_mode = $this->proxy->call_static( 'WC_Payments', 'mode' ); if ( $this->proxy->call_function( 'method_exists', $woopayments_mode, 'is_dev' ) && $this->proxy->call_function( 'is_callable', array( $woopayments_mode, 'is_dev' ) ) ) { return $woopayments_mode->is_dev(); } } return parent::is_in_dev_mode( $payment_gateway ); } /** * Check if the payment gateway supports the current store state for onboarding. * * Most of the time the current business location should be the main factor, but could also * consider other store settings like currency. * * @param WC_Payment_Gateway $payment_gateway The payment gateway object. * @param string $country_code Optional. The country code for which to check. * This should be an ISO 3166-1 alpha-2 country code. * * @return bool|null True if the payment gateway supports onboarding, false otherwise. * If the payment gateway does not provide the information, * we will return null to indicate that we don't know. */ public function is_onboarding_supported( WC_Payment_Gateway $payment_gateway, string $country_code = '' ): ?bool { $is_onboarding_supported = parent::is_onboarding_supported( $payment_gateway, $country_code ); if ( ! is_null( $is_onboarding_supported ) ) { return $is_onboarding_supported; } // Without a country code to check against, we assume onboarding is supported to avoid blocking the user. if ( empty( $country_code ) ) { return true; } // Normalize the country code. $country_code = strtoupper( $country_code ); // The payment gateway didn't provide the information. We will do it the hard way. $supported_country_codes = $this->get_supported_country_codes(); // If we can't get the supported countries, we assume onboarding supported to avoid blocking the user. if ( is_null( $supported_country_codes ) ) { return true; } return in_array( $country_code, $supported_country_codes, true ); } /** * Get the message to show when the payment gateway does not support onboarding. * * @see self::is_onboarding_supported() * * @param WC_Payment_Gateway $payment_gateway The payment gateway object. * @param string $country_code Optional. The country code for which to check. * This should be an ISO 3166-1 alpha-2 country code. * * @return string|null The message to show when the payment gateway does not support onboarding, * or null if no specific message should be provided. */ public function get_onboarding_not_supported_message( WC_Payment_Gateway $payment_gateway, string $country_code = '' ): ?string { $message = parent::get_onboarding_not_supported_message( $payment_gateway, $country_code ); if ( ! is_null( $message ) ) { return $message; } return sprintf( /* translators: %s: WooPayments. */ esc_html__( '%s is not supported in the selected business location.', 'woocommerce' ), 'WooPayments' ); } /** * Try to determine if the payment gateway is in test mode onboarding (aka sandbox or test-drive). * * This is a best-effort attempt, as there is no standard way to determine this. * Trust the true value, but don't consider a false value as definitive. * * @param WC_Payment_Gateway $payment_gateway The payment gateway object. * * @return bool True if the payment gateway is in test mode onboarding, false otherwise. */ public function is_in_test_mode_onboarding( WC_Payment_Gateway $payment_gateway ): bool { if ( $this->proxy->call_function( 'class_exists', 'WC_Payments' ) && $this->proxy->call_function( 'is_callable', 'WC_Payments::mode' ) ) { $woopayments_mode = $this->proxy->call_static( 'WC_Payments', 'mode' ); if ( $this->proxy->call_function( 'method_exists', $woopayments_mode, 'is_test_mode_onboarding' ) && $this->proxy->call_function( 'is_callable', array( $woopayments_mode, 'is_test_mode_onboarding' ) ) ) { return $woopayments_mode->is_test_mode_onboarding(); } } return parent::is_in_test_mode_onboarding( $payment_gateway ); } /** * Get the onboarding URL for the payment gateway. * * This URL should start or continue the onboarding process. * * @param WC_Payment_Gateway $payment_gateway The payment gateway object. * @param string $return_url Optional. The URL to return to after onboarding. * This will likely get attached to the onboarding URL. * * @return string The onboarding URL for the payment gateway. */ public function get_onboarding_url( WC_Payment_Gateway $payment_gateway, string $return_url = '' ): string { if ( $this->proxy->call_function( 'class_exists', 'WC_Payments_Account' ) && $this->proxy->call_function( 'is_callable', 'WC_Payments_Account::get_connect_url' ) ) { $connect_url = $this->proxy->call_static( 'WC_Payments_Account', 'get_connect_url' ); } else { $connect_url = parent::get_onboarding_url( $payment_gateway, $return_url ); } // Default URL params to set, regardless if they exist. $params = array( 'from' => Constants::is_defined( 'WC_Payments_Onboarding_Service::FROM_WCADMIN_PAYMENTS_SETTINGS' ) ? (string) Constants::get_constant( 'WC_Payments_Onboarding_Service::FROM_WCADMIN_PAYMENTS_SETTINGS' ) : 'WCADMIN_PAYMENT_SETTINGS', 'source' => Constants::is_defined( 'WC_Payments_Onboarding_Service::SOURCE_WCADMIN_SETTINGS_PAGE' ) ? (string) Constants::get_constant( 'WC_Payments_Onboarding_Service::SOURCE_WCADMIN_SETTINGS_PAGE' ) : 'wcadmin-settings-page', 'redirect_to_settings_page' => 'true', ); // First, sanity check to handle existing accounts. // Such accounts should keep their current onboarding mode. // Do not force things either way. if ( $this->is_account_connected( $payment_gateway ) ) { return add_query_arg( $params, $connect_url ); } // We don't have an account yet, so the onboarding link is used to kickstart the process. // Default to test-account-first onboarding. $live_onboarding = false; /* * Apply our routing logic to determine if we should do a live onboarding/account. * * For new stores (not yet launched aka in Coming Soon mode), * based on the answers provided in the onboarding profile, we will do live onboarding if: * - Merchant selected “I’m already selling” AND answered either: * - Yes, I’m selling online. * - I’m selling both online and offline. * * For launched stores, we will only consider live onboarding if all are true: * - Store is at least 90 days old. * - Store has an active payments gateway (other than WooPayments). * - Store has processed a live electronic payment in the past 90 days (any gateway). * * @see plugins/woocommerce/client/admin/client/core-profiler/pages/UserProfile.tsx for the values. */ if ( filter_var( get_option( 'woocommerce_coming_soon' ), FILTER_VALIDATE_BOOLEAN ) ) { $onboarding_profile = get_option( OnboardingProfile::DATA_OPTION, array() ); if ( isset( $onboarding_profile['business_choice'] ) && 'im_already_selling' === $onboarding_profile['business_choice'] && isset( $onboarding_profile['selling_online_answer'] ) && ( 'yes_im_selling_online' === $onboarding_profile['selling_online_answer'] || 'im_selling_both_online_and_offline' === $onboarding_profile['selling_online_answer'] ) ) { $live_onboarding = true; } } elseif ( WCAdminHelper::is_wc_admin_active_for( 90 * DAY_IN_SECONDS ) && $this->has_enabled_other_ecommerce_gateways() && $this->has_orders() ) { $live_onboarding = true; } // If we are doing live onboarding, we don't need to add more to the URL. // But for test-drive/sandbox mode, we have work to do. if ( ! $live_onboarding ) { $params['test_drive'] = 'true'; $params['auto_start_test_drive_onboarding'] = 'true'; } return add_query_arg( $params, $connect_url ); } /** * Check if the store has any paid orders. * * Currently, we look at the past 90 days and only consider orders * with status `wc-completed`, `wc-processing`, or `wc-refunded`. * * @return boolean Whether the store has any paid orders. */ private function has_orders(): bool { $store_has_orders_transient_name = self::PREFIX . 'store_has_orders'; // First, get the stored value, if it exists. // This way we avoid costly DB queries and API calls. $has_orders = get_transient( $store_has_orders_transient_name ); if ( false !== $has_orders ) { return wc_string_to_bool( $has_orders ); } // We need to determine the value. // Start with the assumption that the store doesn't have orders in the timeframe we look at. $has_orders = false; // By default, we will check for new orders every 6 hours. $expiration = 6 * HOUR_IN_SECONDS; // Get the latest completed, processing, or refunded order. $latest_order = wc_get_orders( array( 'status' => array( OrderInternalStatus::COMPLETED, OrderInternalStatus::PROCESSING, OrderInternalStatus::REFUNDED ), 'limit' => 1, 'orderby' => 'date', 'order' => 'DESC', ) ); if ( ! empty( $latest_order ) ) { $latest_order = reset( $latest_order ); // If the latest order is within the timeframe we look at, we consider the store to have orders. // Otherwise, it clearly doesn't have orders. if ( $latest_order instanceof WC_Abstract_Order && strtotime( (string) $latest_order->get_date_created() ) >= strtotime( '-90 days' ) ) { $has_orders = true; // For ultimate efficiency, we will check again after 90 days from the latest order // because in all that time we will consider the store to have orders regardless of new orders. $expiration = strtotime( (string) $latest_order->get_date_created() ) + 90 * DAY_IN_SECONDS - time(); } } // Store the value for future use. set_transient( $store_has_orders_transient_name, $has_orders ? 'yes' : 'no', $expiration ); return $has_orders; } /** * Check if the store has any other enabled ecommerce gateways. * * We exclude offline payment methods from this check. * * @return bool True if the store has any enabled ecommerce gateways, false otherwise. */ private function has_enabled_other_ecommerce_gateways(): bool { $gateways = WC()->payment_gateways()->payment_gateways; $other_ecommerce_gateways = array_filter( $gateways, function ( $gateway ) { // Filter out offline gateways and WooPayments. return 'yes' === $gateway->enabled && ! in_array( $gateway->id, array( 'woocommerce_payments', ...PaymentsProviders::OFFLINE_METHODS ), true ); } ); return ! empty( $other_ecommerce_gateways ); } /** * Determines if the current account is a test account. * * Test accounts are test-drive accounts. * They are different from sandbox accounts (i.e. accounts onboarded in test mode). * * @return bool True if the account is a test account, false otherwise. */ private function has_test_account(): bool { if ( $this->proxy->call_function( 'function_exists', 'wcpay_get_container' ) && $this->proxy->call_function( 'class_exists', 'WC_Payments_Account' ) ) { $woopayments_container = $this->proxy->call_function( 'wcpay_get_container' ); $account_service = $woopayments_container->get( 'WC_Payments_Account' ); if ( ! empty( $account_service ) && $this->proxy->call_function( 'method_exists', $account_service, 'get_account_status_data' ) && $this->proxy->call_function( 'is_callable', array( $account_service, 'get_account_status_data' ) ) ) { $account_status = $account_service->get_account_status_data(); return ! empty( $account_status['testDrive'] ); } } return false; } /** * Determines if the current account is a sandbox account. * * Sandbox accounts are accounts that were onboarded in test mode. * They are different from test accounts (i.e. test-drive accounts). * * Sandbox accounts are generally created in development or staging environments when simulating live onboarding. * * @return bool True if the account is a sandbox account, false otherwise. */ private function has_sandbox_account(): bool { if ( $this->proxy->call_function( 'function_exists', 'wcpay_get_container' ) && $this->proxy->call_function( 'class_exists', 'WC_Payments_Account' ) ) { $woopayments_container = $this->proxy->call_function( 'wcpay_get_container' ); $account_service = $woopayments_container->get( 'WC_Payments_Account' ); if ( ! empty( $account_service ) && $this->proxy->call_function( 'method_exists', $account_service, 'get_account_status_data' ) && $this->proxy->call_function( 'is_callable', array( $account_service, 'get_account_status_data' ) ) ) { $account_status = $account_service->get_account_status_data(); return empty( $account_status['isLive'] ) && empty( $account_status['testDrive'] ); } } return false; } /** * Get the list of supported country codes for WooPayments. * * @return array|null The list of supported countries as ISO 3166-1 alpha-2 country codes. * The country codes are normalized in uppercase. * If the list cannot be retrieved, null is returned. */ private function get_supported_country_codes(): ?array { try { if ( $this->proxy->call_function( 'class_exists', 'WC_Payments_Utils' ) && $this->proxy->call_function( 'is_callable', 'WC_Payments_Utils::supported_countries' ) ) { $supported_country_codes = $this->proxy->call_static( 'WC_Payments_Utils', 'supported_countries' ); if ( is_array( $supported_country_codes ) ) { return array_unique( array_map( 'strtoupper', array_keys( $supported_country_codes ) ) ); } } } catch ( Throwable $e ) { // This is not a critical error, so we just ignore it. // Log so we can investigate. SafeGlobalFunctionProxy::wc_get_logger()->error( 'Failed to get the WooPayments supported country codes list: ' . $e->getMessage(), array( 'source' => 'settings-payments', ) ); } return null; } /** * Get the current state of the store's WPCOM/Jetpack connection. * * @return array The store's WPCOM/Jetpack connection state. */ private function get_wpcom_connection_state(): array { try { $wpcom_connection_manager = $this->proxy->get_instance_of( WPCOM_Connection_Manager::class, 'woocommerce' ); } catch ( \Throwable $e ) { // Log so we can investigate. SafeGlobalFunctionProxy::wc_get_logger()->error( 'Failed to get the WPCOM/Jetpack Connection Manager instance: ' . $e->getMessage(), array( 'source' => 'settings-payments', ) ); // Assume no connection. return array( 'wpcom_has_working_connection' => false, 'wpcom_is_store_connected' => false, 'wpcom_has_connected_owner' => false, 'wpcom_is_connection_owner' => false, ); } $is_connected = $wpcom_connection_manager->is_connected(); $has_connected_owner = $wpcom_connection_manager->has_connected_owner(); return array( 'wpcom_has_working_connection' => $is_connected && $has_connected_owner, 'wpcom_is_store_connected' => $is_connected, 'wpcom_has_connected_owner' => $has_connected_owner, 'wpcom_is_connection_owner' => $has_connected_owner && $wpcom_connection_manager->is_connection_owner(), ); } }