From 2cbdfdf3bb5f27210c2bae48f3ed3969cc2fa86c Mon Sep 17 00:00:00 2001 From: Narek Zakarian Date: Wed, 24 Aug 2022 16:34:49 +0400 Subject: [PATCH 1/8] Extract connection settings into new file --- .../connection-tab-settings.php | 452 +++++++++++++++ modules/ppcp-wc-gateway/extensions.php | 2 + modules/ppcp-wc-gateway/services.php | 518 +++--------------- 3 files changed, 537 insertions(+), 435 deletions(-) create mode 100644 modules/ppcp-wc-gateway/connection-tab-settings.php diff --git a/modules/ppcp-wc-gateway/connection-tab-settings.php b/modules/ppcp-wc-gateway/connection-tab-settings.php new file mode 100644 index 000000000..0c7cf6aef --- /dev/null +++ b/modules/ppcp-wc-gateway/connection-tab-settings.php @@ -0,0 +1,452 @@ +get( 'onboarding.state' ); + assert( $state instanceof State ); + + $dcc_applies = $container->get( 'api.helpers.dccapplies' ); + assert( $dcc_applies instanceof DccApplies ); + + $is_shop_supports_dcc = $dcc_applies->for_country_currency() || $dcc_applies->for_wc_payments(); + + $onboarding_options_renderer = $container->get( 'onboarding.render-options' ); + assert( $onboarding_options_renderer instanceof OnboardingOptionsRenderer ); + + $module_url = $container->get( 'wcgateway.url' ); + + $dash_icon_yes = ''; + $dash_icon_no = ''; + + $connected_to_paypal_markup = sprintf( + '

%1$s %2$s

', + esc_html__( 'Status: Connected', 'woocommerce-paypal-payments' ), + $dash_icon_yes, + esc_html__( 'Disconnect Account', 'woocommerce-paypal-payments' ) + ); + + $settings = $container->get( 'wcgateway.settings' ); + assert( $settings instanceof Settings ); + + $enabled_status_text = esc_html__( 'Status: Enabled', 'woocommerce-paypal-payments' ); + $disabled_status_text = esc_html__( 'Status: Not yet enabled', 'woocommerce-paypal-payments' ); + + $dcc_enabled = $settings->has( 'dcc_enabled' ) && $settings->get( 'dcc_enabled' ); + + $dcc_button_text = $dcc_enabled + ? esc_html__( 'Disable Advanced Card Payments', 'woocommerce-paypal-payments' ) + : esc_html__( 'Enable Advanced Card Payments', 'woocommerce-paypal-payments' ); + + $dcc_status = sprintf( + '

%1$s %2$s

%4$s

', + $dcc_enabled ? $enabled_status_text : $disabled_status_text, + $dcc_enabled ? $dash_icon_yes : $dash_icon_no, + admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=ppcp-gateway&ppcp-tab=ppcp-credit-card-gateway' ), + esc_html( $dcc_button_text ) + ); + + $pui_enabled = $settings->has( 'products_pui_enabled' ) && $settings->get( 'products_pui_enabled' ); + + $pui_button_text = $pui_enabled + ? esc_html__( 'Disable Pay Upon Invoice', 'woocommerce-paypal-payments' ) + : esc_html__( 'Enable Pay Upon Invoice', 'woocommerce-paypal-payments' ); + + $pui_status = sprintf( + '

%1$s %2$s

%4$s

', + $pui_enabled ? $enabled_status_text : $disabled_status_text, + $pui_enabled ? $dash_icon_yes : $dash_icon_no, + admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=ppcp-pay-upon-invoice-gateway' ), + esc_html( $pui_button_text ) + ); + + $connection_fields = array( + 'ppcp_onboarading_header' => array( + 'type' => 'ppcp-text', + 'classes' => array( 'ppcp-onboarding-element' ), + 'text' => ' +
+
+ PayPal +

The all-in-one checkout solution

+
+
+
+ PayPal + Venmo + Pay Later +
+
+ Visa + Mastercard + American Express + Discover + iDEAL + Sofort +
+
+
', + 'screens' => array( + State::STATE_START, + State::STATE_ONBOARDED, + ), + 'requirements' => array(), + 'gateway' => 'connection', + ), + 'credentials_production_heading' => array( + 'heading' => __( 'API Credentials', 'woocommerce-paypal-payments' ), + 'type' => 'ppcp-heading', + 'screens' => array( + State::STATE_ONBOARDED, + ), + 'state_from' => Environment::PRODUCTION, + 'requirements' => array(), + 'gateway' => 'connection', + ), + 'credentials_sandbox_heading' => array( + 'heading' => __( 'Sandbox API Credentials', 'woocommerce-paypal-payments' ), + 'type' => 'ppcp-heading', + 'screens' => array( + State::STATE_ONBOARDED, + ), + 'state_from' => Environment::SANDBOX, + 'requirements' => array(), + 'gateway' => 'connection', + 'description' => __( 'Your account is connected to sandbox, no real charging takes place. To accept live payments, turn off sandbox mode and connect your live PayPal account.', 'woocommerce-paypal-payments' ), + ), + + 'ppcp_onboarading_options' => array( + 'type' => 'ppcp-text', + 'classes' => array( 'ppcp-onboarding-element' ), + 'text' => $onboarding_options_renderer->render( $is_shop_supports_dcc ), + 'raw' => true, + 'screens' => array( + State::STATE_START, + State::STATE_ONBOARDED, + ), + 'requirements' => array(), + 'gateway' => 'connection', + ), + + // We need to have a button for each option (ppcp, express) + // because currently the only documented way to use the PayPal onboarding JS library + // is to have the buttons before loading the script. + 'ppcp_onboarding_production_ppcp' => array( + 'type' => 'ppcp_onboarding', + 'classes' => array( 'ppcp-onboarding-element' ), + 'screens' => array( + State::STATE_START, + ), + 'state_from' => Environment::PRODUCTION, + 'env' => Environment::PRODUCTION, + 'products' => array( 'PPCP' ), + 'requirements' => array(), + 'gateway' => 'connection', + ), + 'ppcp_onboarding_production_express' => array( + 'type' => 'ppcp_onboarding', + 'classes' => array( 'ppcp-onboarding-element' ), + 'screens' => array( + State::STATE_START, + ), + 'state_from' => Environment::PRODUCTION, + 'env' => Environment::PRODUCTION, + 'products' => array( 'EXPRESS_CHECKOUT' ), + 'requirements' => array(), + 'gateway' => 'connection', + ), + 'ppcp_onboarding_sandbox_ppcp' => array( + 'type' => 'ppcp_onboarding', + 'classes' => array( 'ppcp-onboarding-element' ), + 'screens' => array( + State::STATE_START, + ), + 'state_from' => Environment::SANDBOX, + 'env' => Environment::SANDBOX, + 'products' => array( 'PPCP' ), + 'requirements' => array(), + 'gateway' => 'connection', + 'description' => __( 'Prior to accepting live payments, you can test payments on your WooCommerce platform in a safe PayPal sandbox environment.', 'woocommerce-paypal-payments' ), + ), + 'ppcp_onboarding_sandbox_express' => array( + 'type' => 'ppcp_onboarding', + 'classes' => array( 'ppcp-onboarding-element' ), + 'screens' => array( + State::STATE_START, + ), + 'state_from' => Environment::SANDBOX, + 'env' => Environment::SANDBOX, + 'products' => array( 'EXPRESS_CHECKOUT' ), + 'requirements' => array(), + 'gateway' => 'connection', + 'description' => __( 'Prior to accepting live payments, you can test payments on your WooCommerce platform in a safe PayPal sandbox environment.', 'woocommerce-paypal-payments' ), + ), + + 'ppcp_disconnect_production' => array( + 'title' => __( 'Disconnect from PayPal', 'woocommerce-paypal-payments' ), + 'type' => 'ppcp-text', + 'text' => '', + 'screens' => array( + State::STATE_ONBOARDED, + ), + 'state_from' => Environment::PRODUCTION, + 'env' => Environment::PRODUCTION, + 'requirements' => array(), + 'gateway' => 'connection', + 'description' => __( 'Click to reset current credentials and use another account.', 'woocommerce-paypal-payments' ), + ), + 'ppcp_disconnect_sandbox' => array( + 'title' => __( 'Disconnect from PayPal Sandbox', 'woocommerce-paypal-payments' ), + 'type' => 'ppcp-text', + 'text' => $connected_to_paypal_markup, + 'screens' => array( + State::STATE_ONBOARDED, + ), + 'state_from' => Environment::SANDBOX, + 'env' => Environment::SANDBOX, + 'requirements' => array(), + 'gateway' => 'connection', + 'description' => __( 'Click to reset current credentials and use another account.', 'woocommerce-paypal-payments' ), + ), + 'toggle_manual_input' => array( + 'type' => 'ppcp-text', + 'text' => '', + 'classes' => array( 'ppcp-onboarding-element' ), + 'screens' => array( + State::STATE_START, + State::STATE_ONBOARDED, + ), + 'requirements' => array(), + 'gateway' => 'connection', + ), + 'ppcp_dcc_status' => array( + 'title' => __( 'Advanced Credit & Debit Crad Payments', 'woocommerce-paypal-payments' ), + 'type' => 'ppcp-text', + 'text' => $dcc_status, + 'screens' => array( + State::STATE_ONBOARDED, + ), + 'requirements' => array(), + 'gateway' => 'connection', + ), + 'ppcp_pui_status' => array( + 'title' => __( 'Pay Upon Invoice', 'woocommerce-paypal-payments' ), + 'type' => 'ppcp-text', + 'text' => $pui_status, + 'screens' => array( + State::STATE_ONBOARDED, + ), + 'requirements' => array( 'pui_ready' ), + 'gateway' => 'connection', + ), + 'error_label' => array( + 'type' => 'ppcp-text', + 'text' => '', + 'classes' => array( 'hide', 'ppcp-always-shown-element' ), + 'screens' => array( + State::STATE_START, + State::STATE_ONBOARDED, + ), + 'requirements' => array(), + 'gateway' => 'connection', + ), + 'sandbox_on' => array( + 'title' => __( 'Sandbox', 'woocommerce-paypal-payments' ), + 'classes' => array( 'ppcp-onboarding-element', 'ppcp-always-shown-element' ), + 'type' => 'checkbox', + 'label' => __( 'To test your WooCommerce installation, you can use the sandbox mode.', 'woocommerce-paypal-payments' ), + 'default' => 0, + 'screens' => array( + State::STATE_START, + State::STATE_ONBOARDED, + ), + 'requirements' => array(), + 'gateway' => 'connection', + ), + 'merchant_email_production' => array( + 'title' => __( 'Live Email address', 'woocommerce-paypal-payments' ), + 'classes' => array( State::STATE_ONBOARDED === $state->production_state() ? 'onboarded' : '', 'ppcp-always-shown-element' ), + 'type' => 'text', + 'required' => true, + 'desc_tip' => true, + 'description' => __( 'The email address of your PayPal account.', 'woocommerce-paypal-payments' ), + 'default' => '', + 'screens' => array( + State::STATE_START, + State::STATE_ONBOARDED, + ), + 'requirements' => array(), + 'gateway' => 'connection', + ), + 'merchant_id_production' => array( + 'title' => __( 'Live Merchant Id', 'woocommerce-paypal-payments' ), + 'classes' => array( State::STATE_ONBOARDED === $state->production_state() ? 'onboarded' : '', 'ppcp-always-shown-element' ), + 'type' => 'ppcp-text-input', + 'desc_tip' => true, + 'description' => __( 'The merchant id of your account ', 'woocommerce-paypal-payments' ), + 'default' => false, + 'screens' => array( + State::STATE_START, + State::STATE_ONBOARDED, + ), + 'requirements' => array(), + 'gateway' => 'connection', + ), + 'client_id_production' => array( + 'title' => __( 'Live Client Id', 'woocommerce-paypal-payments' ), + 'classes' => array( State::STATE_ONBOARDED === $state->production_state() ? 'onboarded' : '', 'ppcp-always-shown-element' ), + 'type' => 'ppcp-text-input', + 'desc_tip' => true, + 'description' => __( 'The client id of your api ', 'woocommerce-paypal-payments' ), + 'default' => false, + 'screens' => array( + State::STATE_START, + State::STATE_ONBOARDED, + ), + 'requirements' => array(), + 'gateway' => 'connection', + ), + 'client_secret_production' => array( + 'title' => __( 'Live Secret Key', 'woocommerce-paypal-payments' ), + 'classes' => array( State::STATE_ONBOARDED === $state->production_state() ? 'onboarded' : '', 'ppcp-always-shown-element' ), + 'type' => 'ppcp-password', + 'desc_tip' => true, + 'description' => __( 'The secret key of your api', 'woocommerce-paypal-payments' ), + 'default' => false, + 'screens' => array( + State::STATE_START, + State::STATE_ONBOARDED, + ), + 'requirements' => array(), + 'gateway' => 'connection', + ), + + 'merchant_email_sandbox' => array( + 'title' => __( 'Sandbox Email address', 'woocommerce-paypal-payments' ), + 'classes' => array( State::STATE_ONBOARDED === $state->sandbox_state() ? 'onboarded' : '', 'ppcp-always-shown-element' ), + 'type' => 'text', + 'required' => true, + 'desc_tip' => true, + 'description' => __( 'The email address of your PayPal account.', 'woocommerce-paypal-payments' ), + 'default' => '', + 'screens' => array( + State::STATE_START, + State::STATE_ONBOARDED, + ), + 'requirements' => array(), + 'gateway' => 'connection', + ), + 'merchant_id_sandbox' => array( + 'title' => __( 'Sandbox Merchant Id', 'woocommerce-paypal-payments' ), + 'classes' => array( State::STATE_ONBOARDED === $state->sandbox_state() ? 'onboarded' : '', 'ppcp-always-shown-element' ), + 'type' => 'ppcp-text-input', + 'desc_tip' => true, + 'description' => __( 'The merchant id of your account ', 'woocommerce-paypal-payments' ), + 'default' => false, + 'screens' => array( + State::STATE_START, + State::STATE_ONBOARDED, + ), + 'requirements' => array(), + 'gateway' => 'connection', + ), + 'client_id_sandbox' => array( + 'title' => __( 'Sandbox Client Id', 'woocommerce-paypal-payments' ), + 'classes' => array( State::STATE_ONBOARDED === $state->sandbox_state() ? 'onboarded' : '', 'ppcp-always-shown-element' ), + 'type' => 'ppcp-text-input', + 'desc_tip' => true, + 'description' => __( 'The client id of your api ', 'woocommerce-paypal-payments' ), + 'default' => false, + 'screens' => array( + State::STATE_START, + State::STATE_ONBOARDED, + ), + 'requirements' => array(), + 'gateway' => 'connection', + ), + 'client_secret_sandbox' => array( + 'title' => __( 'Sandbox Secret Key', 'woocommerce-paypal-payments' ), + 'classes' => array( State::STATE_ONBOARDED === $state->sandbox_state() ? 'onboarded' : '', 'ppcp-always-shown-element' ), + 'type' => 'ppcp-password', + 'desc_tip' => true, + 'description' => __( 'The secret key of your api', 'woocommerce-paypal-payments' ), + 'default' => false, + 'screens' => array( + State::STATE_START, + State::STATE_ONBOARDED, + ), + 'requirements' => array(), + 'gateway' => 'connection', + ), + 'logging_enabled' => array( + 'title' => __( 'Logging', 'woocommerce-paypal-payments' ), + 'type' => 'checkbox', + 'desc_tip' => true, + 'label' => __( 'Enable logging. ', 'woocommerce-paypal-payments' ) . + ' ' . __( 'View logs', 'woocommerce-paypal-payments' ) . '', + 'description' => __( 'Enable logging of unexpected behavior. This can also log private data and should only be enabled in a development or stage environment.', 'woocommerce-paypal-payments' ), + 'default' => false, + 'screens' => array( + State::STATE_START, + State::STATE_ONBOARDED, + ), + 'requirements' => array(), + 'gateway' => 'connection', + ), + 'prefix' => array( + 'title' => __( 'Invoice prefix', 'woocommerce-paypal-payments' ), + 'type' => 'text', + 'desc_tip' => true, + 'description' => __( 'If you use your PayPal account with more than one installation, please use a distinct prefix to separate those installations. Please use only English letters and "-", "_" characters.', 'woocommerce-paypal-payments' ), + 'maxlength' => 15, + 'custom_attributes' => array( + 'pattern' => '[a-zA-Z_-]+', + ), + 'default' => ( static function (): string { + $site_url = get_site_url( get_current_blog_id() ); + $hash = md5( $site_url ); + $letters = preg_replace( '~\d~', '', $hash ); + return $letters ? substr( $letters, 0, 6 ) . '-' : ''; + } )(), + 'screens' => array( + State::STATE_START, + State::STATE_ONBOARDED, + ), + 'requirements' => array(), + 'gateway' => 'connection', + ), + 'tracking_enabled' => array( + 'title' => __( 'Tracking', 'woocommerce-paypal-payments' ), + 'type' => 'checkbox', + 'desc_tip' => true, + 'label' => $container->get( 'wcgateway.settings.tracking-label' ), + 'description' => __( 'Allows to send shipment tracking numbers to PayPal for PayPal transactions.', 'woocommerce-paypal-payments' ), + 'default' => false, + 'screens' => array( + State::STATE_ONBOARDED, + ), + 'requirements' => array(), + 'gateway' => 'connection', + 'input_class' => $container->get( 'wcgateway.settings.should-disable-tracking-checkbox' ) ? array( 'ppcp-disabled-checkbox' ) : array(), + ), + ); + + return array_merge( $fields, $connection_fields ); +}; diff --git a/modules/ppcp-wc-gateway/extensions.php b/modules/ppcp-wc-gateway/extensions.php index d49e856ee..1cb43d5ba 100644 --- a/modules/ppcp-wc-gateway/extensions.php +++ b/modules/ppcp-wc-gateway/extensions.php @@ -98,4 +98,6 @@ return array( $source ); }, + + 'wcgateway.settings.fields' => require __DIR__ . '/connection-tab-settings.php', ); diff --git a/modules/ppcp-wc-gateway/services.php b/modules/ppcp-wc-gateway/services.php index 87c4ce2b4..0f55af0ec 100644 --- a/modules/ppcp-wc-gateway/services.php +++ b/modules/ppcp-wc-gateway/services.php @@ -19,7 +19,6 @@ use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException; use WooCommerce\PayPalCommerce\ApiClient\Helper\Cache; use WooCommerce\PayPalCommerce\ApiClient\Helper\DccApplies; use WooCommerce\PayPalCommerce\Button\Helper\MessagesDisclaimers; -use WooCommerce\PayPalCommerce\Onboarding\Environment; use WooCommerce\PayPalCommerce\Onboarding\Render\OnboardingOptionsRenderer; use WooCommerce\PayPalCommerce\Onboarding\State; use WooCommerce\PayPalCommerce\WcGateway\Admin\FeesRenderer; @@ -159,7 +158,7 @@ return array( } $section = isset( $_GET['section'] ) ? sanitize_text_field( wp_unslash( $_GET['section'] ) ) : ''; - return in_array( $section, array( PayPalGateway::ID, CreditCardGateway::ID, WebhooksStatusPage::ID, PayUponInvoiceGateway::ID, CardButtonGateway::ID, OXXOGateway::ID ), true ); + return in_array( $section, array( Settings::CONNECTION_TAB_ID, PayPalGateway::ID, CreditCardGateway::ID, WebhooksStatusPage::ID, PayUponInvoiceGateway::ID, CardButtonGateway::ID, OXXOGateway::ID ), true ); }, 'wcgateway.current-ppcp-settings-page-id' => static function ( ContainerInterface $container ): string { @@ -218,19 +217,20 @@ return array( }, 'wcgateway.settings.sections' => static function ( ContainerInterface $container ): array { $sections = array( - PayPalGateway::ID => __( 'PayPal Checkout', 'woocommerce-paypal-payments' ), - CreditCardGateway::ID => __( 'PayPal Card Processing', 'woocommerce-paypal-payments' ), - CardButtonGateway::ID => __( 'PayPal Card Button', 'woocommerce-paypal-payments' ), - OXXOGateway::ID => __( 'OXXO', 'woocommerce-paypal-payments' ), - PayUponInvoiceGateway::ID => __( 'Pay upon Invoice', 'woocommerce-paypal-payments' ), - WebhooksStatusPage::ID => __( 'Webhooks Status', 'woocommerce-paypal-payments' ), + Settings::CONNECTION_TAB_ID => __( 'Connection', 'woocommerce-paypal-payments' ), + PayPalGateway::ID => __( 'PayPal Checkout', 'woocommerce-paypal-payments' ), + CreditCardGateway::ID => __( 'PayPal Card Processing', 'woocommerce-paypal-payments' ), + CardButtonGateway::ID => __( 'PayPal Card Button', 'woocommerce-paypal-payments' ), + OXXOGateway::ID => __( 'OXXO', 'woocommerce-paypal-payments' ), + PayUponInvoiceGateway::ID => __( 'Pay upon Invoice', 'woocommerce-paypal-payments' ), + WebhooksStatusPage::ID => __( 'Webhooks Status', 'woocommerce-paypal-payments' ), ); // Remove for all not registered in WC gateways that cannot render anything in this case. $gateways = WC()->payment_gateways->payment_gateways(); foreach ( array_diff( array_keys( $sections ), - array( PayPalGateway::ID, CreditCardGateway::ID, WebhooksStatusPage::ID ) + array( Settings::CONNECTION_TAB_ID, PayPalGateway::ID, CreditCardGateway::ID, WebhooksStatusPage::ID ) ) as $id ) { if ( ! isset( $gateways[ $id ] ) ) { unset( $sections[ $id ] ); @@ -252,6 +252,7 @@ return array( $dcc_product_status = $container->get( 'wcgateway.helper.dcc-product-status' ); $settings_status = $container->get( 'wcgateway.settings.status' ); $page_id = $container->get( 'wcgateway.current-ppcp-settings-page-id' ); + $api_shop_country = $container->get( 'api.shop.country' ); return new SettingsRenderer( $settings, $state, @@ -260,7 +261,8 @@ return array( $messages_apply, $dcc_product_status, $settings_status, - $page_id + $page_id, + $api_shop_country ); }, 'wcgateway.settings.listener' => static function ( ContainerInterface $container ): SettingsListener { @@ -358,314 +360,11 @@ return array( $dcc_applies = $container->get( 'api.helpers.dccapplies' ); assert( $dcc_applies instanceof DccApplies ); - $is_shop_supports_dcc = $dcc_applies->for_country_currency() || $dcc_applies->for_wc_payments(); - $onboarding_options_renderer = $container->get( 'onboarding.render-options' ); assert( $onboarding_options_renderer instanceof OnboardingOptionsRenderer ); - $module_url = $container->get( 'wcgateway.url' ); - $fields = array( - 'ppcp_onboarading_header' => array( - 'type' => 'ppcp-text', - 'classes' => array( 'ppcp-onboarding-element' ), - 'text' => ' -
-
- PayPal -

The all-in-one checkout solution

-
-
-
- PayPal - Venmo - Pay Later -
-
- Visa - Mastercard - American Express - Discover - iDEAL - Sofort -
-
-
', - 'screens' => array( - State::STATE_START, - State::STATE_ONBOARDED, - ), - 'requirements' => array(), - 'gateway' => 'paypal', - ), - - 'credentials_production_heading' => array( - 'heading' => __( 'API Credentials', 'woocommerce-paypal-payments' ), - 'type' => 'ppcp-heading', - 'screens' => array( - State::STATE_ONBOARDED, - ), - 'state_from' => Environment::PRODUCTION, - 'requirements' => array(), - 'gateway' => 'paypal', - ), - 'credentials_sandbox_heading' => array( - 'heading' => __( 'Sandbox API Credentials', 'woocommerce-paypal-payments' ), - 'type' => 'ppcp-heading', - 'screens' => array( - State::STATE_ONBOARDED, - ), - 'state_from' => Environment::SANDBOX, - 'requirements' => array(), - 'gateway' => 'paypal', - 'description' => __( 'Your account is connected to sandbox, no real charging takes place. To accept live payments, turn off sandbox mode and connect your live PayPal account.', 'woocommerce-paypal-payments' ), - ), - - 'ppcp_onboarading_options' => array( - 'type' => 'ppcp-text', - 'classes' => array( 'ppcp-onboarding-element' ), - 'text' => $onboarding_options_renderer->render( $is_shop_supports_dcc ), - 'raw' => true, - 'screens' => array( - State::STATE_START, - State::STATE_ONBOARDED, - ), - 'requirements' => array(), - 'gateway' => 'paypal', - ), - - // We need to have a button for each option (ppcp, express) - // because currently the only documented way to use the PayPal onboarding JS library - // is to have the buttons before loading the script. - 'ppcp_onboarding_production_ppcp' => array( - 'type' => 'ppcp_onboarding', - 'classes' => array( 'ppcp-onboarding-element' ), - 'screens' => array( - State::STATE_START, - ), - 'state_from' => Environment::PRODUCTION, - 'env' => Environment::PRODUCTION, - 'products' => array( 'PPCP' ), - 'requirements' => array(), - 'gateway' => 'paypal', - ), - 'ppcp_onboarding_production_express' => array( - 'type' => 'ppcp_onboarding', - 'classes' => array( 'ppcp-onboarding-element' ), - 'screens' => array( - State::STATE_START, - ), - 'state_from' => Environment::PRODUCTION, - 'env' => Environment::PRODUCTION, - 'products' => array( 'EXPRESS_CHECKOUT' ), - 'requirements' => array(), - 'gateway' => 'paypal', - ), - 'ppcp_onboarding_sandbox_ppcp' => array( - 'type' => 'ppcp_onboarding', - 'classes' => array( 'ppcp-onboarding-element' ), - 'screens' => array( - State::STATE_START, - ), - 'state_from' => Environment::SANDBOX, - 'env' => Environment::SANDBOX, - 'products' => array( 'PPCP' ), - 'requirements' => array(), - 'gateway' => 'paypal', - 'description' => __( 'Prior to accepting live payments, you can test payments on your WooCommerce platform in a safe PayPal sandbox environment.', 'woocommerce-paypal-payments' ), - ), - 'ppcp_onboarding_sandbox_express' => array( - 'type' => 'ppcp_onboarding', - 'classes' => array( 'ppcp-onboarding-element' ), - 'screens' => array( - State::STATE_START, - ), - 'state_from' => Environment::SANDBOX, - 'env' => Environment::SANDBOX, - 'products' => array( 'EXPRESS_CHECKOUT' ), - 'requirements' => array(), - 'gateway' => 'paypal', - 'description' => __( 'Prior to accepting live payments, you can test payments on your WooCommerce platform in a safe PayPal sandbox environment.', 'woocommerce-paypal-payments' ), - ), - - 'ppcp_disconnect_production' => array( - 'title' => __( 'Disconnect from PayPal', 'woocommerce-paypal-payments' ), - 'type' => 'ppcp-text', - 'text' => '', - 'screens' => array( - State::STATE_ONBOARDED, - ), - 'state_from' => Environment::PRODUCTION, - 'env' => Environment::PRODUCTION, - 'requirements' => array(), - 'gateway' => 'paypal', - 'description' => __( 'Click to reset current credentials and use another account.', 'woocommerce-paypal-payments' ), - ), - 'ppcp_disconnect_sandbox' => array( - 'title' => __( 'Disconnect from PayPal Sandbox', 'woocommerce-paypal-payments' ), - 'type' => 'ppcp-text', - 'text' => '', - 'screens' => array( - State::STATE_ONBOARDED, - ), - 'state_from' => Environment::SANDBOX, - 'env' => Environment::SANDBOX, - 'requirements' => array(), - 'gateway' => 'paypal', - 'description' => __( 'Click to reset current credentials and use another account.', 'woocommerce-paypal-payments' ), - ), - 'toggle_manual_input' => array( - 'type' => 'ppcp-text', - 'text' => '', - 'classes' => array( 'ppcp-onboarding-element' ), - 'screens' => array( - State::STATE_START, - State::STATE_ONBOARDED, - ), - 'requirements' => array(), - 'gateway' => 'paypal', - ), - 'error_label' => array( - 'type' => 'ppcp-text', - 'text' => '', - 'classes' => array( 'hide', 'ppcp-always-shown-element' ), - 'screens' => array( - State::STATE_START, - State::STATE_ONBOARDED, - ), - 'requirements' => array(), - 'gateway' => 'paypal', - ), - 'sandbox_on' => array( - 'title' => __( 'Sandbox', 'woocommerce-paypal-payments' ), - 'classes' => array( 'ppcp-onboarding-element', 'ppcp-always-shown-element' ), - 'type' => 'checkbox', - 'label' => __( 'To test your WooCommerce installation, you can use the sandbox mode.', 'woocommerce-paypal-payments' ), - 'default' => 0, - 'screens' => array( - State::STATE_START, - State::STATE_ONBOARDED, - ), - 'requirements' => array(), - 'gateway' => 'paypal', - ), - 'merchant_email_production' => array( - 'title' => __( 'Live Email address', 'woocommerce-paypal-payments' ), - 'classes' => array( State::STATE_ONBOARDED === $state->production_state() ? 'onboarded' : '', 'ppcp-always-shown-element' ), - 'type' => 'text', - 'required' => true, - 'desc_tip' => true, - 'description' => __( 'The email address of your PayPal account.', 'woocommerce-paypal-payments' ), - 'default' => '', - 'screens' => array( - State::STATE_START, - State::STATE_ONBOARDED, - ), - 'requirements' => array(), - 'gateway' => 'paypal', - ), - 'merchant_id_production' => array( - 'title' => __( 'Live Merchant Id', 'woocommerce-paypal-payments' ), - 'classes' => array( State::STATE_ONBOARDED === $state->production_state() ? 'onboarded' : '', 'ppcp-always-shown-element' ), - 'type' => 'ppcp-text-input', - 'desc_tip' => true, - 'description' => __( 'The merchant id of your account ', 'woocommerce-paypal-payments' ), - 'default' => false, - 'screens' => array( - State::STATE_START, - State::STATE_ONBOARDED, - ), - 'requirements' => array(), - 'gateway' => 'paypal', - ), - 'client_id_production' => array( - 'title' => __( 'Live Client Id', 'woocommerce-paypal-payments' ), - 'classes' => array( State::STATE_ONBOARDED === $state->production_state() ? 'onboarded' : '', 'ppcp-always-shown-element' ), - 'type' => 'ppcp-text-input', - 'desc_tip' => true, - 'description' => __( 'The client id of your api ', 'woocommerce-paypal-payments' ), - 'default' => false, - 'screens' => array( - State::STATE_START, - State::STATE_ONBOARDED, - ), - 'requirements' => array(), - 'gateway' => 'paypal', - ), - 'client_secret_production' => array( - 'title' => __( 'Live Secret Key', 'woocommerce-paypal-payments' ), - 'classes' => array( State::STATE_ONBOARDED === $state->production_state() ? 'onboarded' : '', 'ppcp-always-shown-element' ), - 'type' => 'ppcp-password', - 'desc_tip' => true, - 'description' => __( 'The secret key of your api', 'woocommerce-paypal-payments' ), - 'default' => false, - 'screens' => array( - State::STATE_START, - State::STATE_ONBOARDED, - ), - 'requirements' => array(), - 'gateway' => 'paypal', - ), - - 'merchant_email_sandbox' => array( - 'title' => __( 'Sandbox Email address', 'woocommerce-paypal-payments' ), - 'classes' => array( State::STATE_ONBOARDED === $state->sandbox_state() ? 'onboarded' : '', 'ppcp-always-shown-element' ), - 'type' => 'text', - 'required' => true, - 'desc_tip' => true, - 'description' => __( 'The email address of your PayPal account.', 'woocommerce-paypal-payments' ), - 'default' => '', - 'screens' => array( - State::STATE_START, - State::STATE_ONBOARDED, - ), - 'requirements' => array(), - 'gateway' => 'paypal', - ), - 'merchant_id_sandbox' => array( - 'title' => __( 'Sandbox Merchant Id', 'woocommerce-paypal-payments' ), - 'classes' => array( State::STATE_ONBOARDED === $state->sandbox_state() ? 'onboarded' : '', 'ppcp-always-shown-element' ), - 'type' => 'ppcp-text-input', - 'desc_tip' => true, - 'description' => __( 'The merchant id of your account ', 'woocommerce-paypal-payments' ), - 'default' => false, - 'screens' => array( - State::STATE_START, - State::STATE_ONBOARDED, - ), - 'requirements' => array(), - 'gateway' => 'paypal', - ), - 'client_id_sandbox' => array( - 'title' => __( 'Sandbox Client Id', 'woocommerce-paypal-payments' ), - 'classes' => array( State::STATE_ONBOARDED === $state->sandbox_state() ? 'onboarded' : '', 'ppcp-always-shown-element' ), - 'type' => 'ppcp-text-input', - 'desc_tip' => true, - 'description' => __( 'The client id of your api ', 'woocommerce-paypal-payments' ), - 'default' => false, - 'screens' => array( - State::STATE_START, - State::STATE_ONBOARDED, - ), - 'requirements' => array(), - 'gateway' => 'paypal', - ), - 'client_secret_sandbox' => array( - 'title' => __( 'Sandbox Secret Key', 'woocommerce-paypal-payments' ), - 'classes' => array( State::STATE_ONBOARDED === $state->sandbox_state() ? 'onboarded' : '', 'ppcp-always-shown-element' ), - 'type' => 'ppcp-password', - 'desc_tip' => true, - 'description' => __( 'The secret key of your api', 'woocommerce-paypal-payments' ), - 'default' => false, - 'screens' => array( - State::STATE_START, - State::STATE_ONBOARDED, - ), - 'requirements' => array(), - 'gateway' => 'paypal', - ), - - 'checkout_settings_heading' => array( + 'checkout_settings_heading' => array( 'heading' => __( 'PayPal Checkout Settings', 'woocommerce-paypal-payments' ), 'type' => 'ppcp-heading', 'screens' => array( @@ -675,7 +374,7 @@ return array( 'requirements' => array(), 'gateway' => 'paypal', ), - 'title' => array( + 'title' => array( 'title' => __( 'Title', 'woocommerce-paypal-payments' ), 'type' => 'text', 'description' => __( @@ -691,7 +390,7 @@ return array( 'requirements' => array(), 'gateway' => 'paypal', ), - 'dcc_enabled' => array( + 'dcc_enabled' => array( 'title' => __( 'Enable/Disable', 'woocommerce-paypal-payments' ), 'desc_tip' => true, 'description' => __( 'Once enabled, the Credit Card option will show up in the checkout.', 'woocommerce-paypal-payments' ), @@ -706,7 +405,7 @@ return array( State::STATE_ONBOARDED, ), ), - 'dcc_gateway_title' => array( + 'dcc_gateway_title' => array( 'title' => __( 'Title', 'woocommerce-paypal-payments' ), 'type' => 'text', 'description' => __( @@ -723,7 +422,7 @@ return array( ), 'gateway' => 'dcc', ), - 'description' => array( + 'description' => array( 'title' => __( 'Description', 'woocommerce-paypal-payments' ), 'type' => 'text', 'desc_tip' => true, @@ -742,7 +441,7 @@ return array( 'requirements' => array(), 'gateway' => 'paypal', ), - 'intent' => array( + 'intent' => array( 'title' => __( 'Intent', 'woocommerce-paypal-payments' ), 'type' => 'select', 'class' => array(), @@ -764,7 +463,7 @@ return array( 'requirements' => array(), 'gateway' => 'paypal', ), - 'capture_for_virtual_only' => array( + 'capture_for_virtual_only' => array( 'title' => __( 'Capture Virtual-Only Orders ', 'woocommerce-paypal-payments' ), 'type' => 'checkbox', 'default' => false, @@ -781,7 +480,7 @@ return array( 'requirements' => array(), 'gateway' => 'paypal', ), - 'payee_preferred' => array( + 'payee_preferred' => array( 'title' => __( 'Instant Payments ', 'woocommerce-paypal-payments' ), 'type' => 'checkbox', 'default' => false, @@ -798,7 +497,7 @@ return array( 'requirements' => array(), 'gateway' => 'paypal', ), - 'brand_name' => array( + 'brand_name' => array( 'title' => __( 'Brand Name', 'woocommerce-paypal-payments' ), 'type' => 'text', 'default' => get_bloginfo( 'name' ), @@ -814,7 +513,7 @@ return array( 'requirements' => array(), 'gateway' => 'paypal', ), - 'landing_page' => array( + 'landing_page' => array( 'title' => __( 'Landing Page', 'woocommerce-paypal-payments' ), 'type' => 'select', 'class' => array(), @@ -836,7 +535,7 @@ return array( 'requirements' => array(), 'gateway' => 'paypal', ), - 'disable_funding' => array( + 'disable_funding' => array( 'title' => __( 'Hide Funding Source(s)', 'woocommerce-paypal-payments' ), 'type' => 'ppcp-multiselect', 'class' => array(), @@ -860,7 +559,7 @@ return array( 'requirements' => array(), 'gateway' => 'paypal', ), - 'vault_enabled' => array( + 'vault_enabled' => array( 'title' => __( 'Vaulting', 'woocommerce-paypal-payments' ), 'type' => 'checkbox', 'desc_tip' => true, @@ -874,44 +573,7 @@ return array( 'gateway' => array( 'paypal', 'dcc' ), 'input_class' => $container->get( 'wcgateway.helper.vaulting-scope' ) ? array() : array( 'ppcp-disabled-checkbox' ), ), - 'logging_enabled' => array( - 'title' => __( 'Logging', 'woocommerce-paypal-payments' ), - 'type' => 'checkbox', - 'desc_tip' => true, - 'label' => __( 'Enable logging. ', 'woocommerce-paypal-payments' ) . - ' ' . __( 'View logs', 'woocommerce-paypal-payments' ) . '', - 'description' => __( 'Enable logging of unexpected behavior. This can also log private data and should only be enabled in a development or stage environment.', 'woocommerce-paypal-payments' ), - 'default' => false, - 'screens' => array( - State::STATE_START, - State::STATE_ONBOARDED, - ), - 'requirements' => array(), - 'gateway' => 'paypal', - ), - 'prefix' => array( - 'title' => __( 'Invoice prefix', 'woocommerce-paypal-payments' ), - 'type' => 'text', - 'desc_tip' => true, - 'description' => __( 'If you use your PayPal account with more than one installation, please use a distinct prefix to separate those installations. Please use only English letters and "-", "_" characters.', 'woocommerce-paypal-payments' ), - 'maxlength' => 15, - 'custom_attributes' => array( - 'pattern' => '[a-zA-Z_-]+', - ), - 'default' => ( static function (): string { - $site_url = get_site_url( get_current_blog_id() ); - $hash = md5( $site_url ); - $letters = preg_replace( '~\d~', '', $hash ); - return substr( $letters, 0, 6 ) . '-'; - } )(), - 'screens' => array( - State::STATE_START, - State::STATE_ONBOARDED, - ), - 'requirements' => array(), - 'gateway' => 'paypal', - ), - 'card_billing_data_mode' => array( + 'card_billing_data_mode' => array( 'title' => __( 'Card billing data handling', 'woocommerce-paypal-payments' ), 'type' => 'select', 'class' => array(), @@ -931,7 +593,7 @@ return array( 'requirements' => array(), 'gateway' => array( 'paypal', CardButtonGateway::ID ), ), - 'allow_card_button_gateway' => array( + 'allow_card_button_gateway' => array( 'title' => __( 'Separate Card Button from PayPal gateway', 'woocommerce-paypal-payments' ), 'type' => 'checkbox', 'desc_tip' => true, @@ -945,23 +607,9 @@ return array( 'requirements' => array(), 'gateway' => 'paypal', ), - 'tracking_enabled' => array( - 'title' => __( 'Tracking', 'woocommerce-paypal-payments' ), - 'type' => 'checkbox', - 'desc_tip' => true, - 'label' => $container->get( 'wcgateway.settings.tracking-label' ), - 'description' => __( 'Allows to send shipment tracking numbers to PayPal for PayPal transactions.', 'woocommerce-paypal-payments' ), - 'default' => false, - 'screens' => array( - State::STATE_ONBOARDED, - ), - 'requirements' => array(), - 'gateway' => array( 'paypal' ), - 'input_class' => $container->get( 'wcgateway.settings.should-disable-tracking-checkbox' ) ? array( 'ppcp-disabled-checkbox' ) : array(), - ), // General button styles. - 'button_style_heading' => array( + 'button_style_heading' => array( 'heading' => __( 'Checkout', 'woocommerce-paypal-payments' ), 'type' => 'ppcp-heading', 'screens' => array( @@ -972,7 +620,7 @@ return array( 'gateway' => 'paypal', 'description' => __( 'Customize the appearance of PayPal Checkout on the checkout page.', 'woocommerce-paypal-payments' ), ), - 'button_enabled' => array( + 'button_enabled' => array( 'title' => __( 'Enable buttons on Checkout', 'woocommerce-paypal-payments' ), 'type' => 'checkbox', 'label' => __( 'Enable on Checkout', 'woocommerce-paypal-payments' ), @@ -984,7 +632,7 @@ return array( 'requirements' => array(), 'gateway' => 'paypal', ), - 'button_layout' => array( + 'button_layout' => array( 'title' => __( 'Button Layout', 'woocommerce-paypal-payments' ), 'type' => 'select', 'class' => array(), @@ -1006,7 +654,7 @@ return array( 'requirements' => array(), 'gateway' => 'paypal', ), - 'button_tagline' => array( + 'button_tagline' => array( 'title' => __( 'Tagline', 'woocommerce-paypal-payments' ), 'type' => 'checkbox', 'default' => true, @@ -1023,7 +671,7 @@ return array( 'requirements' => array(), 'gateway' => 'paypal', ), - 'button_label' => array( + 'button_label' => array( 'title' => __( 'Button Label', 'woocommerce-paypal-payments' ), 'type' => 'select', 'class' => array(), @@ -1050,7 +698,7 @@ return array( 'requirements' => array(), 'gateway' => 'paypal', ), - 'button_color' => array( + 'button_color' => array( 'title' => __( 'Color', 'woocommerce-paypal-payments' ), 'type' => 'select', 'class' => array(), @@ -1074,7 +722,7 @@ return array( 'requirements' => array(), 'gateway' => 'paypal', ), - 'button_shape' => array( + 'button_shape' => array( 'title' => __( 'Shape', 'woocommerce-paypal-payments' ), 'type' => 'select', 'class' => array(), @@ -1096,7 +744,7 @@ return array( 'requirements' => array(), 'gateway' => 'paypal', ), - 'message_heading' => array( + 'message_heading' => array( 'heading' => __( 'Pay Later on Checkout', 'woocommerce-paypal-payments' ), 'type' => 'ppcp-heading', 'screens' => array( @@ -1108,7 +756,7 @@ return array( 'description' => str_replace( '', '', __( 'Displays Pay Later messaging for available offers. Restrictions apply. Click here to learn more. Pay Later button will show for eligible buyers and PayPal determines eligibility.', 'woocommerce-paypal-payments' ) ), 'class' => array( 'ppcp-subheading' ), ), - 'message_enabled' => array( + 'message_enabled' => array( 'title' => __( 'Enable message on Checkout', 'woocommerce-paypal-payments' ), 'type' => 'checkbox', 'label' => sprintf( $container->get( 'wcgateway.settings.fields.pay-later-label' ), __( 'Enable on Checkout', 'woocommerce-paypal-payments' ) ), @@ -1120,7 +768,7 @@ return array( 'requirements' => array( 'messages' ), 'gateway' => 'paypal', ), - 'message_layout' => array( + 'message_layout' => array( 'title' => __( 'Pay Later Messaging layout', 'woocommerce-paypal-payments' ), 'type' => 'select', 'class' => array(), @@ -1142,7 +790,7 @@ return array( 'requirements' => array( 'messages' ), 'gateway' => 'paypal', ), - 'message_logo' => array( + 'message_logo' => array( 'title' => __( 'Pay Later Messaging logo', 'woocommerce-paypal-payments' ), 'type' => 'select', 'class' => array(), @@ -1166,7 +814,7 @@ return array( 'requirements' => array( 'messages' ), 'gateway' => 'paypal', ), - 'message_position' => array( + 'message_position' => array( 'title' => __( 'Pay Later Messaging logo position', 'woocommerce-paypal-payments' ), 'type' => 'select', 'class' => array(), @@ -1189,7 +837,7 @@ return array( 'requirements' => array( 'messages' ), 'gateway' => 'paypal', ), - 'message_color' => array( + 'message_color' => array( 'title' => __( 'Pay Later Messaging text color', 'woocommerce-paypal-payments' ), 'type' => 'select', 'class' => array(), @@ -1213,7 +861,7 @@ return array( 'requirements' => array( 'messages' ), 'gateway' => 'paypal', ), - 'message_flex_color' => array( + 'message_flex_color' => array( 'title' => __( 'Pay Later Messaging color', 'woocommerce-paypal-payments' ), 'type' => 'select', 'class' => array(), @@ -1240,7 +888,7 @@ return array( 'requirements' => array( 'messages' ), 'gateway' => 'paypal', ), - 'message_flex_ratio' => array( + 'message_flex_ratio' => array( 'title' => __( 'Pay Later Messaging ratio', 'woocommerce-paypal-payments' ), 'type' => 'select', 'class' => array(), @@ -1266,7 +914,7 @@ return array( ), // Single product page. - 'button_product_heading' => array( + 'button_product_heading' => array( 'heading' => __( 'Single Product Page', 'woocommerce-paypal-payments' ), 'type' => 'ppcp-heading', 'screens' => array( @@ -1277,7 +925,7 @@ return array( 'gateway' => 'paypal', 'description' => __( 'Customize the appearance of PayPal Checkout on the single product page.', 'woocommerce-paypal-payments' ), ), - 'button_product_enabled' => array( + 'button_product_enabled' => array( 'title' => __( 'Enable buttons on Single Product', 'woocommerce-paypal-payments' ), 'type' => 'checkbox', 'label' => __( 'Enable on Single Product', 'woocommerce-paypal-payments' ), @@ -1289,7 +937,7 @@ return array( 'requirements' => array(), 'gateway' => 'paypal', ), - 'button_product_layout' => array( + 'button_product_layout' => array( 'title' => __( 'Button Layout', 'woocommerce-paypal-payments' ), 'type' => 'select', 'class' => array(), @@ -1311,7 +959,7 @@ return array( 'requirements' => array(), 'gateway' => 'paypal', ), - 'button_product_tagline' => array( + 'button_product_tagline' => array( 'title' => __( 'Tagline', 'woocommerce-paypal-payments' ), 'type' => 'checkbox', 'label' => __( 'Enable tagline', 'woocommerce-paypal-payments' ), @@ -1328,7 +976,7 @@ return array( 'requirements' => array(), 'gateway' => 'paypal', ), - 'button_product_label' => array( + 'button_product_label' => array( 'title' => __( 'Button Label', 'woocommerce-paypal-payments' ), 'type' => 'select', 'class' => array(), @@ -1355,7 +1003,7 @@ return array( 'requirements' => array(), 'gateway' => 'paypal', ), - 'button_product_color' => array( + 'button_product_color' => array( 'title' => __( 'Color', 'woocommerce-paypal-payments' ), 'type' => 'select', 'class' => array(), @@ -1379,7 +1027,7 @@ return array( 'requirements' => array(), 'gateway' => 'paypal', ), - 'button_product_shape' => array( + 'button_product_shape' => array( 'title' => __( 'Shape', 'woocommerce-paypal-payments' ), 'type' => 'select', 'class' => array(), @@ -1402,7 +1050,7 @@ return array( 'gateway' => 'paypal', ), - 'message_product_heading' => array( + 'message_product_heading' => array( 'heading' => __( 'Pay Later on Single Product Page', 'woocommerce-paypal-payments' ), 'type' => 'ppcp-heading', 'screens' => array( @@ -1414,7 +1062,7 @@ return array( 'description' => str_replace( '', '', __( 'Displays Pay Later messaging for available offers. Restrictions apply. Click here to learn more. Pay Later button will show for eligible buyers and PayPal determines eligibility.', 'woocommerce-paypal-payments' ) ), 'class' => array( 'ppcp-subheading' ), ), - 'message_product_enabled' => array( + 'message_product_enabled' => array( 'title' => __( 'Enable message on Single Product', 'woocommerce-paypal-payments' ), 'type' => 'checkbox', 'label' => sprintf( $container->get( 'wcgateway.settings.fields.pay-later-label' ), __( 'Enable on Single Product', 'woocommerce-paypal-payments' ) ), @@ -1426,7 +1074,7 @@ return array( 'requirements' => array( 'messages' ), 'gateway' => 'paypal', ), - 'message_product_layout' => array( + 'message_product_layout' => array( 'title' => __( 'Pay Later Messaging layout', 'woocommerce-paypal-payments' ), 'type' => 'select', 'class' => array(), @@ -1448,7 +1096,7 @@ return array( 'requirements' => array( 'messages' ), 'gateway' => 'paypal', ), - 'message_product_logo' => array( + 'message_product_logo' => array( 'title' => __( 'Pay Later Messaging logo', 'woocommerce-paypal-payments' ), 'type' => 'select', 'class' => array(), @@ -1472,7 +1120,7 @@ return array( 'requirements' => array( 'messages' ), 'gateway' => 'paypal', ), - 'message_product_position' => array( + 'message_product_position' => array( 'title' => __( 'Pay Later Messaging logo position', 'woocommerce-paypal-payments' ), 'type' => 'select', 'class' => array(), @@ -1495,7 +1143,7 @@ return array( 'requirements' => array( 'messages' ), 'gateway' => 'paypal', ), - 'message_product_color' => array( + 'message_product_color' => array( 'title' => __( 'Pay Later Messaging text color', 'woocommerce-paypal-payments' ), 'type' => 'select', 'class' => array(), @@ -1519,7 +1167,7 @@ return array( 'requirements' => array( 'messages' ), 'gateway' => 'paypal', ), - 'message_product_flex_color' => array( + 'message_product_flex_color' => array( 'title' => __( 'Pay Later Messaging color', 'woocommerce-paypal-payments' ), 'type' => 'select', 'class' => array(), @@ -1546,7 +1194,7 @@ return array( 'requirements' => array( 'messages' ), 'gateway' => 'paypal', ), - 'message_product_flex_ratio' => array( + 'message_product_flex_ratio' => array( 'title' => __( 'Pay Later Messaging ratio', 'woocommerce-paypal-payments' ), 'type' => 'select', 'class' => array(), @@ -1572,7 +1220,7 @@ return array( ), // Cart settings. - 'button_cart_heading' => array( + 'button_cart_heading' => array( 'heading' => __( 'Cart', 'woocommerce-paypal-payments' ), 'type' => 'ppcp-heading', 'screens' => array( @@ -1583,7 +1231,7 @@ return array( 'gateway' => 'paypal', 'description' => __( 'Customize the appearance of PayPal Checkout on the cart page.', 'woocommerce-paypal-payments' ), ), - 'button_cart_enabled' => array( + 'button_cart_enabled' => array( 'title' => __( 'Buttons on Cart', 'woocommerce-paypal-payments' ), 'type' => 'checkbox', 'label' => __( 'Enable on Cart', 'woocommerce-paypal-payments' ), @@ -1595,7 +1243,7 @@ return array( 'requirements' => array(), 'gateway' => 'paypal', ), - 'button_cart_layout' => array( + 'button_cart_layout' => array( 'title' => __( 'Button Layout', 'woocommerce-paypal-payments' ), 'type' => 'select', 'class' => array(), @@ -1617,7 +1265,7 @@ return array( 'requirements' => array(), 'gateway' => 'paypal', ), - 'button_cart_tagline' => array( + 'button_cart_tagline' => array( 'title' => __( 'Tagline', 'woocommerce-paypal-payments' ), 'type' => 'checkbox', 'label' => __( 'Enable tagline', 'woocommerce-paypal-payments' ), @@ -1634,7 +1282,7 @@ return array( 'requirements' => array(), 'gateway' => 'paypal', ), - 'button_cart_label' => array( + 'button_cart_label' => array( 'title' => __( 'Button Label', 'woocommerce-paypal-payments' ), 'type' => 'select', 'class' => array(), @@ -1661,7 +1309,7 @@ return array( 'requirements' => array(), 'gateway' => 'paypal', ), - 'button_cart_color' => array( + 'button_cart_color' => array( 'title' => __( 'Color', 'woocommerce-paypal-payments' ), 'type' => 'select', 'class' => array(), @@ -1685,7 +1333,7 @@ return array( 'requirements' => array(), 'gateway' => 'paypal', ), - 'button_cart_shape' => array( + 'button_cart_shape' => array( 'title' => __( 'Shape', 'woocommerce-paypal-payments' ), 'type' => 'select', 'class' => array(), @@ -1708,7 +1356,7 @@ return array( 'gateway' => 'paypal', ), - 'message_cart_heading' => array( + 'message_cart_heading' => array( 'heading' => __( 'Pay Later on Cart', 'woocommerce-paypal-payments' ), 'type' => 'ppcp-heading', 'screens' => array( @@ -1720,7 +1368,7 @@ return array( 'description' => str_replace( '', '', __( 'Displays Pay Later messaging for available offers. Restrictions apply. Click here to learn more. Pay Later button will show for eligible buyers and PayPal determines eligibility.', 'woocommerce-paypal-payments' ) ), 'class' => array( 'ppcp-subheading' ), ), - 'message_cart_enabled' => array( + 'message_cart_enabled' => array( 'title' => __( 'Enable message on Cart', 'woocommerce-paypal-payments' ), 'type' => 'checkbox', 'label' => sprintf( $container->get( 'wcgateway.settings.fields.pay-later-label' ), __( 'Enable on Cart', 'woocommerce-paypal-payments' ) ), @@ -1732,7 +1380,7 @@ return array( 'requirements' => array( 'messages' ), 'gateway' => 'paypal', ), - 'message_cart_layout' => array( + 'message_cart_layout' => array( 'title' => __( 'Pay Later Messaging layout', 'woocommerce-paypal-payments' ), 'type' => 'select', 'class' => array(), @@ -1754,7 +1402,7 @@ return array( 'requirements' => array( 'messages' ), 'gateway' => 'paypal', ), - 'message_cart_logo' => array( + 'message_cart_logo' => array( 'title' => __( 'Pay Later Messaging logo', 'woocommerce-paypal-payments' ), 'type' => 'select', 'class' => array(), @@ -1778,7 +1426,7 @@ return array( 'requirements' => array( 'messages' ), 'gateway' => 'paypal', ), - 'message_cart_position' => array( + 'message_cart_position' => array( 'title' => __( 'Pay Later Messaging logo position', 'woocommerce-paypal-payments' ), 'type' => 'select', 'class' => array(), @@ -1801,7 +1449,7 @@ return array( 'requirements' => array( 'messages' ), 'gateway' => 'paypal', ), - 'message_cart_color' => array( + 'message_cart_color' => array( 'title' => __( 'Pay Later Messaging text color', 'woocommerce-paypal-payments' ), 'type' => 'select', 'class' => array(), @@ -1825,7 +1473,7 @@ return array( 'requirements' => array( 'messages' ), 'gateway' => 'paypal', ), - 'message_cart_flex_color' => array( + 'message_cart_flex_color' => array( 'title' => __( 'Pay Later Messaging color', 'woocommerce-paypal-payments' ), 'type' => 'select', 'class' => array(), @@ -1852,7 +1500,7 @@ return array( 'requirements' => array( 'messages' ), 'gateway' => 'paypal', ), - 'message_cart_flex_ratio' => array( + 'message_cart_flex_ratio' => array( 'title' => __( 'Pay Later Messaging ratio', 'woocommerce-paypal-payments' ), 'type' => 'select', 'class' => array(), @@ -1878,7 +1526,7 @@ return array( ), // Mini cart settings. - 'button_mini-cart_heading' => array( + 'button_mini-cart_heading' => array( 'heading' => __( 'Mini Cart', 'woocommerce-paypal-payments' ), 'type' => 'ppcp-heading', 'screens' => array( @@ -1889,7 +1537,7 @@ return array( 'gateway' => 'paypal', 'description' => __( 'Customize the appearance of PayPal Checkout on the Mini Cart.', 'woocommerce-paypal-payments' ), ), - 'button_mini-cart_enabled' => array( + 'button_mini-cart_enabled' => array( 'title' => __( 'Buttons on Mini Cart', 'woocommerce-paypal-payments' ), 'type' => 'checkbox', 'label' => __( 'Enable on Mini Cart', 'woocommerce-paypal-payments' ), @@ -1901,7 +1549,7 @@ return array( 'requirements' => array(), 'gateway' => 'paypal', ), - 'button_mini-cart_layout' => array( + 'button_mini-cart_layout' => array( 'title' => __( 'Button Layout', 'woocommerce-paypal-payments' ), 'type' => 'select', 'class' => array(), @@ -1923,7 +1571,7 @@ return array( 'requirements' => array(), 'gateway' => 'paypal', ), - 'button_mini-cart_tagline' => array( + 'button_mini-cart_tagline' => array( 'title' => __( 'Tagline', 'woocommerce-paypal-payments' ), 'type' => 'checkbox', 'label' => __( 'Enable tagline', 'woocommerce-paypal-payments' ), @@ -1940,7 +1588,7 @@ return array( 'requirements' => array(), 'gateway' => 'paypal', ), - 'button_mini-cart_label' => array( + 'button_mini-cart_label' => array( 'title' => __( 'Button Label', 'woocommerce-paypal-payments' ), 'type' => 'select', 'class' => array(), @@ -1967,7 +1615,7 @@ return array( 'requirements' => array(), 'gateway' => 'paypal', ), - 'button_mini-cart_color' => array( + 'button_mini-cart_color' => array( 'title' => __( 'Color', 'woocommerce-paypal-payments' ), 'type' => 'select', 'class' => array(), @@ -1991,7 +1639,7 @@ return array( 'requirements' => array(), 'gateway' => 'paypal', ), - 'button_mini-cart_shape' => array( + 'button_mini-cart_shape' => array( 'title' => __( 'Shape', 'woocommerce-paypal-payments' ), 'type' => 'select', 'class' => array(), @@ -2013,7 +1661,7 @@ return array( 'requirements' => array(), 'gateway' => 'paypal', ), - 'button_mini-cart_height' => array( + 'button_mini-cart_height' => array( 'title' => __( 'Button Height', 'woocommerce-paypal-payments' ), 'type' => 'number', 'default' => '35', @@ -2027,7 +1675,7 @@ return array( 'gateway' => 'paypal', ), - 'disable_cards' => array( + 'disable_cards' => array( 'title' => __( 'Disable specific credit cards', 'woocommerce-paypal-payments' ), 'type' => 'ppcp-multiselect', 'class' => array(), @@ -2055,7 +1703,7 @@ return array( ), 'gateway' => 'dcc', ), - 'card_icons' => array( + 'card_icons' => array( 'title' => __( 'Show logo of the following credit cards', 'woocommerce-paypal-payments' ), 'type' => 'ppcp-multiselect', 'class' => array(), @@ -2085,7 +1733,7 @@ return array( ), 'gateway' => 'dcc', ), - '3d_secure_heading' => array( + '3d_secure_heading' => array( 'heading' => __( '3D Secure', 'woocommerce-paypal-payments' ), 'type' => 'ppcp-heading', 'description' => wp_kses_post( @@ -2113,7 +1761,7 @@ return array( ), 'gateway' => 'dcc', ), - '3d_secure_contingency' => array( + '3d_secure_contingency' => array( 'title' => __( 'Contingency for 3D Secure', 'woocommerce-paypal-payments' ), 'type' => 'select', 'description' => sprintf( From 4a8c8eeb8effd9e0ae1967b73ebf320108b16233 Mon Sep 17 00:00:00 2001 From: Narek Zakarian Date: Wed, 24 Aug 2022 16:36:35 +0400 Subject: [PATCH 2/8] prepare code to work with connection tab --- .../src/Gateway/PayPalGateway.php | 18 ++++++++++++++++++ .../src/Settings/PageMatcherTrait.php | 9 +++++---- .../src/Settings/SectionsRenderer.php | 2 +- .../ppcp-wc-gateway/src/Settings/Settings.php | 3 ++- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/modules/ppcp-wc-gateway/src/Gateway/PayPalGateway.php b/modules/ppcp-wc-gateway/src/Gateway/PayPalGateway.php index 1adbbbaf6..0c6ca1f50 100644 --- a/modules/ppcp-wc-gateway/src/Gateway/PayPalGateway.php +++ b/modules/ppcp-wc-gateway/src/Gateway/PayPalGateway.php @@ -26,6 +26,7 @@ use WooCommerce\PayPalCommerce\WcGateway\FundingSource\FundingSourceRenderer; use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayUponInvoice\PayUponInvoiceGateway; use WooCommerce\PayPalCommerce\WcGateway\Processor\OrderProcessor; use WooCommerce\PayPalCommerce\WcGateway\Processor\RefundProcessor; +use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings; use WooCommerce\PayPalCommerce\WcGateway\Settings\SettingsRenderer; use Psr\Container\ContainerInterface; use WooCommerce\PayPalCommerce\Webhooks\Status\WebhooksStatusPage; @@ -290,6 +291,9 @@ class PayPalGateway extends \WC_Payment_Gateway { * @return string */ private function define_method_title(): string { + if ( $this->is_connection_tab() ) { + return __( 'Account Setup', 'woocommerce-paypal-payments' ); + } if ( $this->is_credit_card_tab() ) { return __( 'PayPal Card Processing', 'woocommerce-paypal-payments' ); } @@ -312,6 +316,10 @@ class PayPalGateway extends \WC_Payment_Gateway { * @return string */ private function define_method_description(): string { + if ( $this->is_connection_tab() ) { + return ''; + } + if ( $this->is_credit_card_tab() ) { return __( 'Accept debit and credit cards, and local payment methods.', @@ -374,6 +382,16 @@ class PayPalGateway extends \WC_Payment_Gateway { && WebhooksStatusPage::ID === $this->page_id; } + /** + * Whether we are on the connection tab. + * + * @return bool true if is connection tab, otherwise false + */ + protected function is_connection_tab() : bool { + return is_admin() + && Settings::CONNECTION_TAB_ID === $this->page_id; + } + /** * Whether we are on the PayPal settings tab. * diff --git a/modules/ppcp-wc-gateway/src/Settings/PageMatcherTrait.php b/modules/ppcp-wc-gateway/src/Settings/PageMatcherTrait.php index ea301362b..65f9785f9 100644 --- a/modules/ppcp-wc-gateway/src/Settings/PageMatcherTrait.php +++ b/modules/ppcp-wc-gateway/src/Settings/PageMatcherTrait.php @@ -33,10 +33,11 @@ trait PageMatcherTrait { } $gateway_page_id_map = array( - PayPalGateway::ID => 'paypal', - CreditCardGateway::ID => 'dcc', // TODO: consider using just the gateway ID for PayPal and DCC too. - CardButtonGateway::ID => CardButtonGateway::ID, - WebhooksStatusPage::ID => WebhooksStatusPage::ID, + Settings::CONNECTION_TAB_ID => 'connection', + PayPalGateway::ID => 'paypal', + CreditCardGateway::ID => 'dcc', // TODO: consider using just the gateway ID for PayPal and DCC too. + CardButtonGateway::ID => CardButtonGateway::ID, + WebhooksStatusPage::ID => WebhooksStatusPage::ID, ); return array_key_exists( $current_page_id, $gateway_page_id_map ) && in_array( $gateway_page_id_map[ $current_page_id ], $allowed_gateways, true ); diff --git a/modules/ppcp-wc-gateway/src/Settings/SectionsRenderer.php b/modules/ppcp-wc-gateway/src/Settings/SectionsRenderer.php index abb4d9c0b..0735f671d 100644 --- a/modules/ppcp-wc-gateway/src/Settings/SectionsRenderer.php +++ b/modules/ppcp-wc-gateway/src/Settings/SectionsRenderer.php @@ -77,7 +77,7 @@ class SectionsRenderer { foreach ( $this->sections as $id => $label ) { $url = admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=' . $id ); - if ( in_array( $id, array( CreditCardGateway::ID, WebhooksStatusPage::ID ), true ) ) { + if ( in_array( $id, array( Settings::CONNECTION_TAB_ID, CreditCardGateway::ID, WebhooksStatusPage::ID ), true ) ) { // We need section=ppcp-gateway for the webhooks page because it is not a gateway, // and for DCC because otherwise it will not render the page if gateway is not available (country/currency). // Other gateways render fields differently, and their pages are not expected to work when gateway is not available. diff --git a/modules/ppcp-wc-gateway/src/Settings/Settings.php b/modules/ppcp-wc-gateway/src/Settings/Settings.php index 3701721de..42fd12c48 100644 --- a/modules/ppcp-wc-gateway/src/Settings/Settings.php +++ b/modules/ppcp-wc-gateway/src/Settings/Settings.php @@ -17,7 +17,8 @@ use Psr\Container\ContainerInterface; */ class Settings implements ContainerInterface { - const KEY = 'woocommerce-ppcp-settings'; + const KEY = 'woocommerce-ppcp-settings'; + const CONNECTION_TAB_ID = 'ppcp-connection'; /** * The settings. From f6e2b345c9bb0b28d20d829ac69dee4bd799abc2 Mon Sep 17 00:00:00 2001 From: Narek Zakarian Date: Wed, 24 Aug 2022 16:37:09 +0400 Subject: [PATCH 3/8] Assets should work also on connection tab --- modules/ppcp-onboarding/src/Assets/OnboardingAssets.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/ppcp-onboarding/src/Assets/OnboardingAssets.php b/modules/ppcp-onboarding/src/Assets/OnboardingAssets.php index 8c65cc803..90da04817 100644 --- a/modules/ppcp-onboarding/src/Assets/OnboardingAssets.php +++ b/modules/ppcp-onboarding/src/Assets/OnboardingAssets.php @@ -13,6 +13,7 @@ use WooCommerce\PayPalCommerce\Onboarding\Endpoint\LoginSellerEndpoint; use WooCommerce\PayPalCommerce\Onboarding\Environment; use WooCommerce\PayPalCommerce\Onboarding\State; use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway; +use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings; /** * Class OnboardingAssets @@ -172,6 +173,6 @@ class OnboardingAssets { * @return bool */ private function should_render_onboarding_script(): bool { - return PayPalGateway::ID === $this->page_id; + return PayPalGateway::ID === $this->page_id || Settings::CONNECTION_TAB_ID === $this->page_id; } } From aeb840ff5fab1a6fdc872fdc295a52e6da650f6d Mon Sep 17 00:00:00 2001 From: Narek Zakarian Date: Wed, 24 Aug 2022 16:38:10 +0400 Subject: [PATCH 4/8] add new setting requirement for PUI readiness --- .../src/Settings/SettingsRenderer.php | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/modules/ppcp-wc-gateway/src/Settings/SettingsRenderer.php b/modules/ppcp-wc-gateway/src/Settings/SettingsRenderer.php index cfcce2a15..4a57a83e6 100644 --- a/modules/ppcp-wc-gateway/src/Settings/SettingsRenderer.php +++ b/modules/ppcp-wc-gateway/src/Settings/SettingsRenderer.php @@ -33,6 +33,13 @@ class SettingsRenderer { */ protected $settings_status; + /** + * The api shop country. + * + * @var string + */ + protected $api_shop_country; + /** * The settings. * @@ -93,6 +100,7 @@ class SettingsRenderer { * @param DCCProductStatus $dcc_product_status The product status. * @param SettingsStatus $settings_status The Settings status helper. * @param string $page_id ID of the current PPCP gateway settings page, or empty if it is not such page. + * @param string $api_shop_country The api shop country. */ public function __construct( ContainerInterface $settings, @@ -102,7 +110,8 @@ class SettingsRenderer { MessagesApply $messages_apply, DCCProductStatus $dcc_product_status, SettingsStatus $settings_status, - string $page_id + string $page_id, + string $api_shop_country ) { $this->settings = $settings; @@ -113,6 +122,7 @@ class SettingsRenderer { $this->dcc_product_status = $dcc_product_status; $this->settings_status = $settings_status; $this->page_id = $page_id; + $this->api_shop_country = $api_shop_country; } /** @@ -348,7 +358,7 @@ $data_rows_html /** * Renders the settings. */ - public function render() { + public function render(): void { $is_dcc = CreditCardGateway::ID === $this->page_id; //phpcs:enable WordPress.Security.NonceVerification.Recommended @@ -392,6 +402,12 @@ $data_rows_html ) { continue; } + if ( + in_array( 'pui_ready', $config['requirements'], true ) + && $this->api_shop_country !== 'DE' + ) { + continue; + } $value = $this->settings->has( $field ) ? $this->settings->get( $field ) : ( isset( $config['value'] ) ? $config['value']() : null ); $key = 'ppcp[' . $field . ']'; $id = 'ppcp-' . $field; From 67422293451aa24801303bc534e8042d25d6aed2 Mon Sep 17 00:00:00 2001 From: Narek Zakarian Date: Wed, 24 Aug 2022 16:51:56 +0400 Subject: [PATCH 5/8] Fix Psalm problems --- modules/ppcp-wc-gateway/connection-tab-settings.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/ppcp-wc-gateway/connection-tab-settings.php b/modules/ppcp-wc-gateway/connection-tab-settings.php index 0c7cf6aef..481f3f313 100644 --- a/modules/ppcp-wc-gateway/connection-tab-settings.php +++ b/modules/ppcp-wc-gateway/connection-tab-settings.php @@ -422,8 +422,9 @@ return function ( ContainerInterface $container, array $fields ): array { 'default' => ( static function (): string { $site_url = get_site_url( get_current_blog_id() ); $hash = md5( $site_url ); - $letters = preg_replace( '~\d~', '', $hash ); - return $letters ? substr( $letters, 0, 6 ) . '-' : ''; + $letters = preg_replace( '~\d~', '', $hash ) ?? ''; + $prefix = substr( $letters, 0, 6 ); + return $prefix ? $prefix . '-' : ''; } )(), 'screens' => array( State::STATE_START, From a693829815903976ae96986ed026f33520e865d6 Mon Sep 17 00:00:00 2001 From: Narek Zakarian Date: Thu, 25 Aug 2022 16:21:18 +0400 Subject: [PATCH 6/8] Check for features are available on PayPal, reorder the sections --- .../connection-tab-settings.php | 187 ++++++++---------- modules/ppcp-wc-gateway/services.php | 79 ++++++++ 2 files changed, 164 insertions(+), 102 deletions(-) diff --git a/modules/ppcp-wc-gateway/connection-tab-settings.php b/modules/ppcp-wc-gateway/connection-tab-settings.php index 481f3f313..42e558f8c 100644 --- a/modules/ppcp-wc-gateway/connection-tab-settings.php +++ b/modules/ppcp-wc-gateway/connection-tab-settings.php @@ -16,7 +16,6 @@ use WooCommerce\PayPalCommerce\ApiClient\Helper\DccApplies; use WooCommerce\PayPalCommerce\Onboarding\Environment; use WooCommerce\PayPalCommerce\Onboarding\Render\OnboardingOptionsRenderer; use WooCommerce\PayPalCommerce\Onboarding\State; -use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings; return function ( ContainerInterface $container, array $fields ): array { @@ -33,52 +32,8 @@ return function ( ContainerInterface $container, array $fields ): array { $module_url = $container->get( 'wcgateway.url' ); - $dash_icon_yes = ''; - $dash_icon_no = ''; - - $connected_to_paypal_markup = sprintf( - '

%1$s %2$s

', - esc_html__( 'Status: Connected', 'woocommerce-paypal-payments' ), - $dash_icon_yes, - esc_html__( 'Disconnect Account', 'woocommerce-paypal-payments' ) - ); - - $settings = $container->get( 'wcgateway.settings' ); - assert( $settings instanceof Settings ); - - $enabled_status_text = esc_html__( 'Status: Enabled', 'woocommerce-paypal-payments' ); - $disabled_status_text = esc_html__( 'Status: Not yet enabled', 'woocommerce-paypal-payments' ); - - $dcc_enabled = $settings->has( 'dcc_enabled' ) && $settings->get( 'dcc_enabled' ); - - $dcc_button_text = $dcc_enabled - ? esc_html__( 'Disable Advanced Card Payments', 'woocommerce-paypal-payments' ) - : esc_html__( 'Enable Advanced Card Payments', 'woocommerce-paypal-payments' ); - - $dcc_status = sprintf( - '

%1$s %2$s

%4$s

', - $dcc_enabled ? $enabled_status_text : $disabled_status_text, - $dcc_enabled ? $dash_icon_yes : $dash_icon_no, - admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=ppcp-gateway&ppcp-tab=ppcp-credit-card-gateway' ), - esc_html( $dcc_button_text ) - ); - - $pui_enabled = $settings->has( 'products_pui_enabled' ) && $settings->get( 'products_pui_enabled' ); - - $pui_button_text = $pui_enabled - ? esc_html__( 'Disable Pay Upon Invoice', 'woocommerce-paypal-payments' ) - : esc_html__( 'Enable Pay Upon Invoice', 'woocommerce-paypal-payments' ); - - $pui_status = sprintf( - '

%1$s %2$s

%4$s

', - $pui_enabled ? $enabled_status_text : $disabled_status_text, - $pui_enabled ? $dash_icon_yes : $dash_icon_no, - admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=ppcp-pay-upon-invoice-gateway' ), - esc_html( $pui_button_text ) - ); - $connection_fields = array( - 'ppcp_onboarading_header' => array( + 'ppcp_onboarading_header' => array( 'type' => 'ppcp-text', 'classes' => array( 'ppcp-onboarding-element' ), 'text' => ' @@ -110,7 +65,7 @@ return function ( ContainerInterface $container, array $fields ): array { 'requirements' => array(), 'gateway' => 'connection', ), - 'credentials_production_heading' => array( + 'credentials_production_heading' => array( 'heading' => __( 'API Credentials', 'woocommerce-paypal-payments' ), 'type' => 'ppcp-heading', 'screens' => array( @@ -120,7 +75,7 @@ return function ( ContainerInterface $container, array $fields ): array { 'requirements' => array(), 'gateway' => 'connection', ), - 'credentials_sandbox_heading' => array( + 'credentials_sandbox_heading' => array( 'heading' => __( 'Sandbox API Credentials', 'woocommerce-paypal-payments' ), 'type' => 'ppcp-heading', 'screens' => array( @@ -132,7 +87,7 @@ return function ( ContainerInterface $container, array $fields ): array { 'description' => __( 'Your account is connected to sandbox, no real charging takes place. To accept live payments, turn off sandbox mode and connect your live PayPal account.', 'woocommerce-paypal-payments' ), ), - 'ppcp_onboarading_options' => array( + 'ppcp_onboarading_options' => array( 'type' => 'ppcp-text', 'classes' => array( 'ppcp-onboarding-element' ), 'text' => $onboarding_options_renderer->render( $is_shop_supports_dcc ), @@ -148,7 +103,7 @@ return function ( ContainerInterface $container, array $fields ): array { // We need to have a button for each option (ppcp, express) // because currently the only documented way to use the PayPal onboarding JS library // is to have the buttons before loading the script. - 'ppcp_onboarding_production_ppcp' => array( + 'ppcp_onboarding_production_ppcp' => array( 'type' => 'ppcp_onboarding', 'classes' => array( 'ppcp-onboarding-element' ), 'screens' => array( @@ -160,7 +115,7 @@ return function ( ContainerInterface $container, array $fields ): array { 'requirements' => array(), 'gateway' => 'connection', ), - 'ppcp_onboarding_production_express' => array( + 'ppcp_onboarding_production_express' => array( 'type' => 'ppcp_onboarding', 'classes' => array( 'ppcp-onboarding-element' ), 'screens' => array( @@ -172,7 +127,7 @@ return function ( ContainerInterface $container, array $fields ): array { 'requirements' => array(), 'gateway' => 'connection', ), - 'ppcp_onboarding_sandbox_ppcp' => array( + 'ppcp_onboarding_sandbox_ppcp' => array( 'type' => 'ppcp_onboarding', 'classes' => array( 'ppcp-onboarding-element' ), 'screens' => array( @@ -185,7 +140,7 @@ return function ( ContainerInterface $container, array $fields ): array { 'gateway' => 'connection', 'description' => __( 'Prior to accepting live payments, you can test payments on your WooCommerce platform in a safe PayPal sandbox environment.', 'woocommerce-paypal-payments' ), ), - 'ppcp_onboarding_sandbox_express' => array( + 'ppcp_onboarding_sandbox_express' => array( 'type' => 'ppcp_onboarding', 'classes' => array( 'ppcp-onboarding-element' ), 'screens' => array( @@ -199,7 +154,7 @@ return function ( ContainerInterface $container, array $fields ): array { 'description' => __( 'Prior to accepting live payments, you can test payments on your WooCommerce platform in a safe PayPal sandbox environment.', 'woocommerce-paypal-payments' ), ), - 'ppcp_disconnect_production' => array( + 'ppcp_disconnect_production' => array( 'title' => __( 'Disconnect from PayPal', 'woocommerce-paypal-payments' ), 'type' => 'ppcp-text', 'text' => '', @@ -212,10 +167,14 @@ return function ( ContainerInterface $container, array $fields ): array { 'gateway' => 'connection', 'description' => __( 'Click to reset current credentials and use another account.', 'woocommerce-paypal-payments' ), ), - 'ppcp_disconnect_sandbox' => array( + 'ppcp_disconnect_sandbox' => array( 'title' => __( 'Disconnect from PayPal Sandbox', 'woocommerce-paypal-payments' ), 'type' => 'ppcp-text', - 'text' => $connected_to_paypal_markup, + 'text' => sprintf( + '

%1$s

', + esc_html__( 'Status: Connected', 'woocommerce-paypal-payments' ), + esc_html__( 'Disconnect Account', 'woocommerce-paypal-payments' ) + ), 'screens' => array( State::STATE_ONBOARDED, ), @@ -225,7 +184,7 @@ return function ( ContainerInterface $container, array $fields ): array { 'gateway' => 'connection', 'description' => __( 'Click to reset current credentials and use another account.', 'woocommerce-paypal-payments' ), ), - 'toggle_manual_input' => array( + 'toggle_manual_input' => array( 'type' => 'ppcp-text', 'text' => '', 'classes' => array( 'ppcp-onboarding-element' ), @@ -236,27 +195,7 @@ return function ( ContainerInterface $container, array $fields ): array { 'requirements' => array(), 'gateway' => 'connection', ), - 'ppcp_dcc_status' => array( - 'title' => __( 'Advanced Credit & Debit Crad Payments', 'woocommerce-paypal-payments' ), - 'type' => 'ppcp-text', - 'text' => $dcc_status, - 'screens' => array( - State::STATE_ONBOARDED, - ), - 'requirements' => array(), - 'gateway' => 'connection', - ), - 'ppcp_pui_status' => array( - 'title' => __( 'Pay Upon Invoice', 'woocommerce-paypal-payments' ), - 'type' => 'ppcp-text', - 'text' => $pui_status, - 'screens' => array( - State::STATE_ONBOARDED, - ), - 'requirements' => array( 'pui_ready' ), - 'gateway' => 'connection', - ), - 'error_label' => array( + 'error_label' => array( 'type' => 'ppcp-text', 'text' => '', 'classes' => array( 'hide', 'ppcp-always-shown-element' ), @@ -267,7 +206,7 @@ return function ( ContainerInterface $container, array $fields ): array { 'requirements' => array(), 'gateway' => 'connection', ), - 'sandbox_on' => array( + 'sandbox_on' => array( 'title' => __( 'Sandbox', 'woocommerce-paypal-payments' ), 'classes' => array( 'ppcp-onboarding-element', 'ppcp-always-shown-element' ), 'type' => 'checkbox', @@ -280,7 +219,7 @@ return function ( ContainerInterface $container, array $fields ): array { 'requirements' => array(), 'gateway' => 'connection', ), - 'merchant_email_production' => array( + 'merchant_email_production' => array( 'title' => __( 'Live Email address', 'woocommerce-paypal-payments' ), 'classes' => array( State::STATE_ONBOARDED === $state->production_state() ? 'onboarded' : '', 'ppcp-always-shown-element' ), 'type' => 'text', @@ -295,7 +234,7 @@ return function ( ContainerInterface $container, array $fields ): array { 'requirements' => array(), 'gateway' => 'connection', ), - 'merchant_id_production' => array( + 'merchant_id_production' => array( 'title' => __( 'Live Merchant Id', 'woocommerce-paypal-payments' ), 'classes' => array( State::STATE_ONBOARDED === $state->production_state() ? 'onboarded' : '', 'ppcp-always-shown-element' ), 'type' => 'ppcp-text-input', @@ -309,7 +248,7 @@ return function ( ContainerInterface $container, array $fields ): array { 'requirements' => array(), 'gateway' => 'connection', ), - 'client_id_production' => array( + 'client_id_production' => array( 'title' => __( 'Live Client Id', 'woocommerce-paypal-payments' ), 'classes' => array( State::STATE_ONBOARDED === $state->production_state() ? 'onboarded' : '', 'ppcp-always-shown-element' ), 'type' => 'ppcp-text-input', @@ -323,7 +262,7 @@ return function ( ContainerInterface $container, array $fields ): array { 'requirements' => array(), 'gateway' => 'connection', ), - 'client_secret_production' => array( + 'client_secret_production' => array( 'title' => __( 'Live Secret Key', 'woocommerce-paypal-payments' ), 'classes' => array( State::STATE_ONBOARDED === $state->production_state() ? 'onboarded' : '', 'ppcp-always-shown-element' ), 'type' => 'ppcp-password', @@ -338,7 +277,7 @@ return function ( ContainerInterface $container, array $fields ): array { 'gateway' => 'connection', ), - 'merchant_email_sandbox' => array( + 'merchant_email_sandbox' => array( 'title' => __( 'Sandbox Email address', 'woocommerce-paypal-payments' ), 'classes' => array( State::STATE_ONBOARDED === $state->sandbox_state() ? 'onboarded' : '', 'ppcp-always-shown-element' ), 'type' => 'text', @@ -353,7 +292,7 @@ return function ( ContainerInterface $container, array $fields ): array { 'requirements' => array(), 'gateway' => 'connection', ), - 'merchant_id_sandbox' => array( + 'merchant_id_sandbox' => array( 'title' => __( 'Sandbox Merchant Id', 'woocommerce-paypal-payments' ), 'classes' => array( State::STATE_ONBOARDED === $state->sandbox_state() ? 'onboarded' : '', 'ppcp-always-shown-element' ), 'type' => 'ppcp-text-input', @@ -367,7 +306,7 @@ return function ( ContainerInterface $container, array $fields ): array { 'requirements' => array(), 'gateway' => 'connection', ), - 'client_id_sandbox' => array( + 'client_id_sandbox' => array( 'title' => __( 'Sandbox Client Id', 'woocommerce-paypal-payments' ), 'classes' => array( State::STATE_ONBOARDED === $state->sandbox_state() ? 'onboarded' : '', 'ppcp-always-shown-element' ), 'type' => 'ppcp-text-input', @@ -381,7 +320,7 @@ return function ( ContainerInterface $container, array $fields ): array { 'requirements' => array(), 'gateway' => 'connection', ), - 'client_secret_sandbox' => array( + 'client_secret_sandbox' => array( 'title' => __( 'Sandbox Secret Key', 'woocommerce-paypal-payments' ), 'classes' => array( State::STATE_ONBOARDED === $state->sandbox_state() ? 'onboarded' : '', 'ppcp-always-shown-element' ), 'type' => 'ppcp-password', @@ -395,22 +334,65 @@ return function ( ContainerInterface $container, array $fields ): array { 'requirements' => array(), 'gateway' => 'connection', ), - 'logging_enabled' => array( - 'title' => __( 'Logging', 'woocommerce-paypal-payments' ), - 'type' => 'checkbox', - 'desc_tip' => true, - 'label' => __( 'Enable logging. ', 'woocommerce-paypal-payments' ) . - ' ' . __( 'View logs', 'woocommerce-paypal-payments' ) . '', - 'description' => __( 'Enable logging of unexpected behavior. This can also log private data and should only be enabled in a development or stage environment.', 'woocommerce-paypal-payments' ), - 'default' => false, + + 'credentials_feature_onboarding_heading' => array( + 'heading' => __( 'Feature Onboarding', 'woocommerce-paypal-payments' ), + 'type' => 'ppcp-heading', + 'screens' => array( + State::STATE_ONBOARDED, + ), + 'state_from' => Environment::SANDBOX, + 'requirements' => array(), + 'gateway' => 'connection', + 'description' => __( 'See which features are available.', 'woocommerce-paypal-payments' ), + ), + 'ppcp_dcc_status' => array( + 'title' => __( 'Advanced Credit and Debit Card Payments', 'woocommerce-paypal-payments' ), + 'type' => 'ppcp-text', + 'text' => $container->get( 'wcgateway.settings.connection.dcc-status-text' ), 'screens' => array( - State::STATE_START, State::STATE_ONBOARDED, ), 'requirements' => array(), 'gateway' => 'connection', ), - 'prefix' => array( + 'ppcp_pui_status' => array( + 'title' => __( 'Pay Upon Invoice', 'woocommerce-paypal-payments' ), + 'type' => 'ppcp-text', + 'text' => $container->get( 'wcgateway.settings.connection.pui-status-text' ), + 'screens' => array( + State::STATE_ONBOARDED, + ), + 'requirements' => array( 'pui_ready' ), + 'gateway' => 'connection', + ), + 'tracking_enabled' => array( + 'title' => __( 'Tracking', 'woocommerce-paypal-payments' ), + 'type' => 'checkbox', + 'desc_tip' => true, + 'label' => $container->get( 'wcgateway.settings.tracking-label' ), + 'description' => __( 'Allows to send shipment tracking numbers to PayPal for PayPal transactions.', 'woocommerce-paypal-payments' ), + 'default' => false, + 'screens' => array( + State::STATE_ONBOARDED, + ), + 'requirements' => array(), + 'gateway' => 'connection', + 'input_class' => $container->get( 'wcgateway.settings.should-disable-tracking-checkbox' ) ? array( 'ppcp-disabled-checkbox' ) : array(), + ), + + 'credentials_integration_configuration_heading' => array( + 'heading' => __( 'Integration configuration', 'woocommerce-paypal-payments' ), + 'type' => 'ppcp-heading', + 'screens' => array( + State::STATE_ONBOARDED, + ), + 'state_from' => Environment::SANDBOX, + 'requirements' => array(), + 'gateway' => 'connection', + 'description' => __( 'See which features are available.', 'woocommerce-paypal-payments' ), + ), + 'prefix' => array( 'title' => __( 'Invoice prefix', 'woocommerce-paypal-payments' ), 'type' => 'text', 'desc_tip' => true, @@ -433,19 +415,20 @@ return function ( ContainerInterface $container, array $fields ): array { 'requirements' => array(), 'gateway' => 'connection', ), - 'tracking_enabled' => array( - 'title' => __( 'Tracking', 'woocommerce-paypal-payments' ), + 'logging_enabled' => array( + 'title' => __( 'Logging', 'woocommerce-paypal-payments' ), 'type' => 'checkbox', 'desc_tip' => true, - 'label' => $container->get( 'wcgateway.settings.tracking-label' ), - 'description' => __( 'Allows to send shipment tracking numbers to PayPal for PayPal transactions.', 'woocommerce-paypal-payments' ), + 'label' => __( 'Enable logging. ', 'woocommerce-paypal-payments' ) . + ' ' . __( 'View logs', 'woocommerce-paypal-payments' ) . '', + 'description' => __( 'Enable logging of unexpected behavior. This can also log private data and should only be enabled in a development or stage environment.', 'woocommerce-paypal-payments' ), 'default' => false, 'screens' => array( + State::STATE_START, State::STATE_ONBOARDED, ), 'requirements' => array(), 'gateway' => 'connection', - 'input_class' => $container->get( 'wcgateway.settings.should-disable-tracking-checkbox' ) ? array( 'ppcp-disabled-checkbox' ) : array(), ), ); diff --git a/modules/ppcp-wc-gateway/services.php b/modules/ppcp-wc-gateway/services.php index 0f55af0ec..7f482b814 100644 --- a/modules/ppcp-wc-gateway/services.php +++ b/modules/ppcp-wc-gateway/services.php @@ -19,6 +19,7 @@ use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException; use WooCommerce\PayPalCommerce\ApiClient\Helper\Cache; use WooCommerce\PayPalCommerce\ApiClient\Helper\DccApplies; use WooCommerce\PayPalCommerce\Button\Helper\MessagesDisclaimers; +use WooCommerce\PayPalCommerce\Onboarding\Environment; use WooCommerce\PayPalCommerce\Onboarding\Render\OnboardingOptionsRenderer; use WooCommerce\PayPalCommerce\Onboarding\State; use WooCommerce\PayPalCommerce\WcGateway\Admin\FeesRenderer; @@ -2132,4 +2133,82 @@ return array( return $tracking_label; }, + 'wcgateway.enable-dcc-url-sandbox' => static function ( ContainerInterface $container ): string { + return 'https://www.sandbox.paypal.com/bizsignup/entry/product/ppcp'; + }, + 'wcgateway.enable-dcc-url-live' => static function ( ContainerInterface $container ): string { + return 'https://www.paypal.com/bizsignup/entry/product/ppcp'; + }, + 'wcgateway.enable-pui-url-sandbox' => static function ( ContainerInterface $container ): string { + return 'https://www.sandbox.paypal.com/bizsignup/entry?country.x=DE&product=payment_methods&capabilities=PAY_UPON_INVOICE'; + }, + 'wcgateway.enable-pui-url-live' => static function ( ContainerInterface $container ): string { + return 'https://www.paypal.com/bizsignup/entry?country.x=DE&product=payment_methods&capabilities=PAY_UPON_INVOICE'; + }, + 'wcgateway.settings.connection.dcc-status-text' => static function ( ContainerInterface $container ): string { + $dcc_applies = $container->get( 'api.helpers.dccapplies' ); + assert( $dcc_applies instanceof DccApplies ); + + $environment = $container->get( 'onboarding.environment' ); + assert( $environment instanceof Environment ); + + $dcc_enabled = $dcc_applies->for_country_currency() || $dcc_applies->for_wc_payments(); + + $enabled_status_text = esc_html__( 'Status: Enabled', 'woocommerce-paypal-payments' ); + $disabled_status_text = esc_html__( 'Status: Not yet enabled', 'woocommerce-paypal-payments' ); + + $dcc_button_text = $dcc_enabled + ? esc_html__( 'Settings', 'woocommerce-paypal-payments' ) + : esc_html__( 'Enable Advanced Card Payments', 'woocommerce-paypal-payments' ); + + $enable_dcc_url = $environment->current_environment_is( Environment::PRODUCTION ) + ? $container->get('wcgateway.enable-dcc-url-live') + : $container->get('wcgateway.enable-dcc-url-sandbox'); + + $dcc_button_url = $dcc_enabled + ? admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=ppcp-gateway&ppcp-tab=ppcp-credit-card-gateway' ) + : $enable_dcc_url; + + return sprintf( + '

%1$s %2$s

%4$s

', + $dcc_enabled ? $enabled_status_text : $disabled_status_text, + $dcc_enabled ? '' : '', + esc_url( $dcc_button_url ), + esc_html( $dcc_button_text ) + ); + }, + 'wcgateway.settings.connection.pui-status-text' => static function ( ContainerInterface $container ): string { + $pui_product_status = $container->get( 'wcgateway.pay-upon-invoice-product-status' ); + assert( $pui_product_status instanceof PayUponInvoiceProductStatus ); + + $environment = $container->get( 'onboarding.environment' ); + assert( $environment instanceof Environment ); + + $shop_country = $container->get( 'api.shop.country' ); + + $pui_enabled = 'DE' === $shop_country && $pui_product_status->pui_is_active(); + + $enabled_status_text = esc_html__( 'Status: Enabled', 'woocommerce-paypal-payments' ); + $disabled_status_text = esc_html__( 'Status: Not yet enabled', 'woocommerce-paypal-payments' ); + + $enable_pui_url = $environment->current_environment_is( Environment::PRODUCTION ) + ? $container->get('wcgateway.enable-pui-url-live') + : $container->get('wcgateway.enable-pui-url-sandbox'); + + $pui_button_url = $pui_enabled + ? admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=ppcp-pay-upon-invoice-gateway' ) + : $enable_pui_url; + + $pui_button_text = $pui_enabled + ? esc_html__( 'Settings', 'woocommerce-paypal-payments' ) + : esc_html__( 'Enable Pay Upon Invoice', 'woocommerce-paypal-payments' ); + + return sprintf( + '

%1$s %2$s

%4$s

', + $pui_enabled ? $enabled_status_text : $disabled_status_text, + $pui_enabled ? '' : '', + esc_url( $pui_button_url ), + esc_html( $pui_button_text ) + ); + }, ); From 6496a202a3da4bf0471e9211a37be7aec589593e Mon Sep 17 00:00:00 2001 From: Narek Zakarian Date: Thu, 25 Aug 2022 16:26:36 +0400 Subject: [PATCH 7/8] Fix PHPcs problems --- modules/ppcp-wc-gateway/services.php | 32 ++++++++++++++-------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/modules/ppcp-wc-gateway/services.php b/modules/ppcp-wc-gateway/services.php index 7f482b814..546699cef 100644 --- a/modules/ppcp-wc-gateway/services.php +++ b/modules/ppcp-wc-gateway/services.php @@ -2133,18 +2133,18 @@ return array( return $tracking_label; }, - 'wcgateway.enable-dcc-url-sandbox' => static function ( ContainerInterface $container ): string { - return 'https://www.sandbox.paypal.com/bizsignup/entry/product/ppcp'; - }, - 'wcgateway.enable-dcc-url-live' => static function ( ContainerInterface $container ): string { - return 'https://www.paypal.com/bizsignup/entry/product/ppcp'; - }, - 'wcgateway.enable-pui-url-sandbox' => static function ( ContainerInterface $container ): string { - return 'https://www.sandbox.paypal.com/bizsignup/entry?country.x=DE&product=payment_methods&capabilities=PAY_UPON_INVOICE'; - }, - 'wcgateway.enable-pui-url-live' => static function ( ContainerInterface $container ): string { - return 'https://www.paypal.com/bizsignup/entry?country.x=DE&product=payment_methods&capabilities=PAY_UPON_INVOICE'; - }, + 'wcgateway.enable-dcc-url-sandbox' => static function ( ContainerInterface $container ): string { + return 'https://www.sandbox.paypal.com/bizsignup/entry/product/ppcp'; + }, + 'wcgateway.enable-dcc-url-live' => static function ( ContainerInterface $container ): string { + return 'https://www.paypal.com/bizsignup/entry/product/ppcp'; + }, + 'wcgateway.enable-pui-url-sandbox' => static function ( ContainerInterface $container ): string { + return 'https://www.sandbox.paypal.com/bizsignup/entry?country.x=DE&product=payment_methods&capabilities=PAY_UPON_INVOICE'; + }, + 'wcgateway.enable-pui-url-live' => static function ( ContainerInterface $container ): string { + return 'https://www.paypal.com/bizsignup/entry?country.x=DE&product=payment_methods&capabilities=PAY_UPON_INVOICE'; + }, 'wcgateway.settings.connection.dcc-status-text' => static function ( ContainerInterface $container ): string { $dcc_applies = $container->get( 'api.helpers.dccapplies' ); assert( $dcc_applies instanceof DccApplies ); @@ -2162,8 +2162,8 @@ return array( : esc_html__( 'Enable Advanced Card Payments', 'woocommerce-paypal-payments' ); $enable_dcc_url = $environment->current_environment_is( Environment::PRODUCTION ) - ? $container->get('wcgateway.enable-dcc-url-live') - : $container->get('wcgateway.enable-dcc-url-sandbox'); + ? $container->get( 'wcgateway.enable-dcc-url-live' ) + : $container->get( 'wcgateway.enable-dcc-url-sandbox' ); $dcc_button_url = $dcc_enabled ? admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=ppcp-gateway&ppcp-tab=ppcp-credit-card-gateway' ) @@ -2192,8 +2192,8 @@ return array( $disabled_status_text = esc_html__( 'Status: Not yet enabled', 'woocommerce-paypal-payments' ); $enable_pui_url = $environment->current_environment_is( Environment::PRODUCTION ) - ? $container->get('wcgateway.enable-pui-url-live') - : $container->get('wcgateway.enable-pui-url-sandbox'); + ? $container->get( 'wcgateway.enable-pui-url-live' ) + : $container->get( 'wcgateway.enable-pui-url-sandbox' ); $pui_button_url = $pui_enabled ? admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=ppcp-pay-upon-invoice-gateway' ) From 64a0f0af77bfd05c8321d9c329f1308357453bb1 Mon Sep 17 00:00:00 2001 From: Narek Zakarian Date: Thu, 25 Aug 2022 18:58:54 +0400 Subject: [PATCH 8/8] Fix connection tab settings when using live account --- modules/ppcp-wc-gateway/connection-tab-settings.php | 8 +++++--- modules/ppcp-wc-gateway/services.php | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/modules/ppcp-wc-gateway/connection-tab-settings.php b/modules/ppcp-wc-gateway/connection-tab-settings.php index 42e558f8c..f5da1244d 100644 --- a/modules/ppcp-wc-gateway/connection-tab-settings.php +++ b/modules/ppcp-wc-gateway/connection-tab-settings.php @@ -157,7 +157,11 @@ return function ( ContainerInterface $container, array $fields ): array { 'ppcp_disconnect_production' => array( 'title' => __( 'Disconnect from PayPal', 'woocommerce-paypal-payments' ), 'type' => 'ppcp-text', - 'text' => '', + 'text' => sprintf( + '

%1$s

', + esc_html__( 'Status: Connected', 'woocommerce-paypal-payments' ), + esc_html__( 'Disconnect Account', 'woocommerce-paypal-payments' ) + ), 'screens' => array( State::STATE_ONBOARDED, ), @@ -341,7 +345,6 @@ return function ( ContainerInterface $container, array $fields ): array { 'screens' => array( State::STATE_ONBOARDED, ), - 'state_from' => Environment::SANDBOX, 'requirements' => array(), 'gateway' => 'connection', 'description' => __( 'See which features are available.', 'woocommerce-paypal-payments' ), @@ -387,7 +390,6 @@ return function ( ContainerInterface $container, array $fields ): array { 'screens' => array( State::STATE_ONBOARDED, ), - 'state_from' => Environment::SANDBOX, 'requirements' => array(), 'gateway' => 'connection', 'description' => __( 'See which features are available.', 'woocommerce-paypal-payments' ), diff --git a/modules/ppcp-wc-gateway/services.php b/modules/ppcp-wc-gateway/services.php index 546699cef..0d6024e4c 100644 --- a/modules/ppcp-wc-gateway/services.php +++ b/modules/ppcp-wc-gateway/services.php @@ -2170,9 +2170,10 @@ return array( : $enable_dcc_url; return sprintf( - '

%1$s %2$s

%4$s

', + '

%1$s %2$s

%5$s

', $dcc_enabled ? $enabled_status_text : $disabled_status_text, $dcc_enabled ? '' : '', + $dcc_enabled ? '_self' : '_blank', esc_url( $dcc_button_url ), esc_html( $dcc_button_text ) ); @@ -2204,9 +2205,10 @@ return array( : esc_html__( 'Enable Pay Upon Invoice', 'woocommerce-paypal-payments' ); return sprintf( - '

%1$s %2$s

%4$s

', + '

%1$s %2$s

%5$s

', $pui_enabled ? $enabled_status_text : $disabled_status_text, $pui_enabled ? '' : '', + $pui_enabled ? '_self' : '_blank', esc_url( $pui_button_url ), esc_html( $pui_button_text ) );