2022-08-24 16:34:49 +04:00
< ? php
/**
* The services of the Gateway module .
*
* @ package WooCommerce\PayPalCommerce\WcGateway
*/
// phpcs:disable WordPress.Security.NonceVerification.Recommended
declare ( strict_types = 1 );
2022-12-05 15:27:58 +04:00
namespace WooCommerce\PayPalCommerce\WcGateway\Settings ;
2022-08-24 16:34:49 +04:00
2023-08-07 16:12:02 +01:00
use WooCommerce\PayPalCommerce\ApiClient\Helper\PurchaseUnitSanitizer ;
2022-11-09 10:11:31 +02:00
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface ;
2022-08-24 16:34:49 +04:00
use WooCommerce\PayPalCommerce\ApiClient\Helper\DccApplies ;
use WooCommerce\PayPalCommerce\Onboarding\Environment ;
use WooCommerce\PayPalCommerce\Onboarding\Render\OnboardingOptionsRenderer ;
use WooCommerce\PayPalCommerce\Onboarding\State ;
2023-09-15 17:32:00 +01:00
use WooCommerce\PayPalCommerce\WcGateway\Helper\DisplayManager ;
2022-08-24 16:34:49 +04:00
return function ( ContainerInterface $container , array $fields ) : array {
2022-09-13 16:07:52 +04:00
$current_page_id = $container -> get ( 'wcgateway.current-ppcp-settings-page-id' );
if ( $current_page_id !== Settings :: CONNECTION_TAB_ID ) {
return $fields ;
}
2022-08-24 16:34:49 +04:00
$state = $container -> 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' );
2023-09-15 17:32:00 +01:00
$display_manager = $container -> get ( 'wcgateway.display-manager' );
assert ( $display_manager instanceof DisplayManager );
2023-09-14 17:48:46 +01:00
2022-08-24 16:34:49 +04:00
$connection_fields = array (
2022-08-25 16:21:18 +04:00
'ppcp_onboarading_header' => array (
2022-08-24 16:34:49 +04:00
'type' => 'ppcp-text' ,
'classes' => array ( 'ppcp-onboarding-element' ),
'text' => '
< div class = " ppcp-onboarding-header " >
< div class = " ppcp-onboarding-header-left " >
< img alt = " PayPal " src = " ' . esc_url( $module_url ) . 'assets/images/paypal.png " />
< h2 > The all - in - one checkout solution </ h2 >
</ div >
< div class = " ppcp-onboarding-header-right " >
< div class = " ppcp-onboarding-header-paypal-logos " >
2023-11-03 10:24:03 +01:00
< a href = " https://woo.com/document/woocommerce-paypal-payments/#standard-paypal-payments " target = " _blank " >< img alt = " PayPal " src = " ' . esc_url( $module_url ) . 'assets/images/paypal-button.svg " /></ a >
< a href = " https://woo.com/document/woocommerce-paypal-payments/#pay-with-venmo " target = " _blank " >< img alt = " Venmo " src = " ' . esc_url( $module_url ) . 'assets/images/venmo.svg " /></ a >
< a href = " https://woo.com/document/woocommerce-paypal-payments/#pay-later " target = " _blank " >< img alt = " Pay Later " src = " ' . esc_url( $module_url ) . 'assets/images/paylater.svg " /></ a >
2022-08-24 16:34:49 +04:00
</ div >
< div class = " ppcp-onboarding-header-cards " >
2023-11-03 10:24:03 +01:00
< a href = " https://woo.com/document/woocommerce-paypal-payments/#paypal-card-processing-acdc " target = " _blank " >< img alt = " Visa " src = " ' . esc_url( $module_url ) . 'assets/images/visa-dark.svg " /></ a >
< a href = " https://woo.com/document/woocommerce-paypal-payments/#paypal-card-processing-acdc " target = " _blank " >< img alt = " Mastercard " src = " ' . esc_url( $module_url ) . 'assets/images/mastercard-dark.svg " /></ a >
< a href = " https://woo.com/document/woocommerce-paypal-payments/#paypal-card-processing-acdc " target = " _blank " >< img alt = " American Express " src = " ' . esc_url( $module_url ) . 'assets/images/amex.svg " /></ a >
< a href = " https://woo.com/document/woocommerce-paypal-payments/#paypal-card-processing-acdc " target = " _blank " >< img alt = " Discover " src = " ' . esc_url( $module_url ) . 'assets/images/discover.svg " /></ a >
< a href = " https://woo.com/document/woocommerce-paypal-payments/#alternative-payment-methods " target = " _blank " >< img alt = " iDEAL " src = " ' . esc_url( $module_url ) . 'assets/images/ideal-dark.svg " /></ a >
< a href = " https://woo.com/document/woocommerce-paypal-payments/#alternative-payment-methods " target = " _blank " >< img alt = " Sofort " src = " ' . esc_url( $module_url ) . 'assets/images/sofort.svg " /></ a >
</ div >
< div class = " ppcp-onboarding-header-apm-logos " >
< a href = " https://woo.com/document/woocommerce-paypal-payments/#apple-pay " target = " _blank " >< img alt = " Apple Pay " src = " ' . esc_url( $module_url ) . 'assets/images/button-Apple-Pay.png " /></ a >
< a href = " https://woo.com/document/woocommerce-paypal-payments/#google-pay " target = " _blank " >< img alt = " Google Pay " src = " ' . esc_url( $module_url ) . 'assets/images/button-Google-Pay.png " /></ a >
2022-08-24 16:34:49 +04:00
</ div >
</ div >
</ div > ' ,
'screens' => array (
State :: STATE_START ,
State :: STATE_ONBOARDED ,
),
'requirements' => array (),
2022-09-02 14:39:41 +04:00
'gateway' => Settings :: CONNECTION_TAB_ID ,
2022-08-24 16:34:49 +04:00
),
2022-08-25 16:21:18 +04:00
'credentials_production_heading' => array (
2022-08-24 16:34:49 +04:00
'heading' => __ ( 'API Credentials' , 'woocommerce-paypal-payments' ),
'type' => 'ppcp-heading' ,
'screens' => array (
State :: STATE_ONBOARDED ,
),
'state_from' => Environment :: PRODUCTION ,
'requirements' => array (),
2022-09-02 14:39:41 +04:00
'gateway' => Settings :: CONNECTION_TAB_ID ,
2022-08-24 16:34:49 +04:00
),
2022-08-25 16:21:18 +04:00
'credentials_sandbox_heading' => array (
2022-08-24 16:34:49 +04:00
'heading' => __ ( 'Sandbox API Credentials' , 'woocommerce-paypal-payments' ),
'type' => 'ppcp-heading' ,
'screens' => array (
State :: STATE_ONBOARDED ,
),
'state_from' => Environment :: SANDBOX ,
'requirements' => array (),
2022-09-02 14:39:41 +04:00
'gateway' => Settings :: CONNECTION_TAB_ID ,
2022-08-24 16:34:49 +04:00
'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' ),
),
2022-08-25 16:21:18 +04:00
'ppcp_onboarading_options' => array (
2022-08-24 16:34:49 +04:00
'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 (),
2022-09-02 14:39:41 +04:00
'gateway' => Settings :: CONNECTION_TAB_ID ,
2022-08-24 16:34:49 +04:00
),
// 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.
2022-08-25 16:21:18 +04:00
'ppcp_onboarding_production_ppcp' => array (
2022-08-24 16:34:49 +04:00
'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 (),
2022-09-02 14:39:41 +04:00
'gateway' => Settings :: CONNECTION_TAB_ID ,
2022-08-24 16:34:49 +04:00
),
2022-08-25 16:21:18 +04:00
'ppcp_onboarding_production_express' => array (
2022-08-24 16:34:49 +04:00
'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 (),
2022-09-02 14:39:41 +04:00
'gateway' => Settings :: CONNECTION_TAB_ID ,
2022-08-24 16:34:49 +04:00
),
2022-08-25 16:21:18 +04:00
'ppcp_onboarding_sandbox_ppcp' => array (
2022-08-24 16:34:49 +04:00
'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 (),
2022-09-02 14:39:41 +04:00
'gateway' => Settings :: CONNECTION_TAB_ID ,
2022-08-24 16:34:49 +04:00
'description' => __ ( 'Prior to accepting live payments, you can test payments on your WooCommerce platform in a safe PayPal sandbox environment.' , 'woocommerce-paypal-payments' ),
),
2022-08-25 16:21:18 +04:00
'ppcp_onboarding_sandbox_express' => array (
2022-08-24 16:34:49 +04:00
'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 (),
2022-09-02 14:39:41 +04:00
'gateway' => Settings :: CONNECTION_TAB_ID ,
2022-08-24 16:34:49 +04:00
'description' => __ ( 'Prior to accepting live payments, you can test payments on your WooCommerce platform in a safe PayPal sandbox environment.' , 'woocommerce-paypal-payments' ),
),
2022-08-25 16:21:18 +04:00
'ppcp_disconnect_production' => array (
2022-08-24 16:34:49 +04:00
'title' => __ ( 'Disconnect from PayPal' , 'woocommerce-paypal-payments' ),
'type' => 'ppcp-text' ,
2022-08-25 18:58:54 +04:00
'text' => sprintf (
'<p>%1$s <span class="dashicons dashicons-yes"></span></p><p><button type="button" class="button ppcp-disconnect production">%2$s</button></p>' ,
esc_html__ ( 'Status: Connected' , 'woocommerce-paypal-payments' ),
esc_html__ ( 'Disconnect Account' , 'woocommerce-paypal-payments' )
),
2022-08-24 16:34:49 +04:00
'screens' => array (
State :: STATE_ONBOARDED ,
),
'state_from' => Environment :: PRODUCTION ,
'env' => Environment :: PRODUCTION ,
'requirements' => array (),
2022-09-02 14:39:41 +04:00
'gateway' => Settings :: CONNECTION_TAB_ID ,
2022-08-24 16:34:49 +04:00
'description' => __ ( 'Click to reset current credentials and use another account.' , 'woocommerce-paypal-payments' ),
),
2022-08-25 16:21:18 +04:00
'ppcp_disconnect_sandbox' => array (
2022-08-24 16:34:49 +04:00
'title' => __ ( 'Disconnect from PayPal Sandbox' , 'woocommerce-paypal-payments' ),
'type' => 'ppcp-text' ,
2022-08-25 16:21:18 +04:00
'text' => sprintf (
'<p>%1$s <span class="dashicons dashicons-yes"></span></p><p><button type="button" class="button ppcp-disconnect sandbox">%2$s</button></p>' ,
esc_html__ ( 'Status: Connected' , 'woocommerce-paypal-payments' ),
esc_html__ ( 'Disconnect Account' , 'woocommerce-paypal-payments' )
),
2022-08-24 16:34:49 +04:00
'screens' => array (
State :: STATE_ONBOARDED ,
),
'state_from' => Environment :: SANDBOX ,
'env' => Environment :: SANDBOX ,
'requirements' => array (),
2022-09-02 14:39:41 +04:00
'gateway' => Settings :: CONNECTION_TAB_ID ,
2022-08-24 16:34:49 +04:00
'description' => __ ( 'Click to reset current credentials and use another account.' , 'woocommerce-paypal-payments' ),
),
2022-08-25 16:21:18 +04:00
'toggle_manual_input' => array (
2022-08-24 16:34:49 +04:00
'type' => 'ppcp-text' ,
'text' => '<button type="button" id="ppcp[toggle_manual_input]">' . __ ( 'Toggle to manual credential input' , 'woocommerce-paypal-payments' ) . '</button>' ,
2023-06-22 09:13:03 +02:00
'description' => sprintf (
'%1$s <a href="https://woocommerce.com/document/woocommerce-paypal-payments/#manual-credential-input" target="_blank">%2$s</a>' ,
esc_html__ ( 'Further information on manual credential input:' , 'woocommerce-paypal-payments' ),
esc_html__ ( 'documentation' , 'woocommerce-paypal-payments' )
),
2022-08-24 16:34:49 +04:00
'classes' => array ( 'ppcp-onboarding-element' ),
'screens' => array (
State :: STATE_START ,
State :: STATE_ONBOARDED ,
),
'requirements' => array (),
2022-09-02 14:39:41 +04:00
'gateway' => Settings :: CONNECTION_TAB_ID ,
2022-08-24 16:34:49 +04:00
),
2022-08-25 16:21:18 +04:00
'error_label' => array (
2022-08-24 16:34:49 +04:00
'type' => 'ppcp-text' ,
'text' => '<label class="error" id="ppcp-form-errors-label"></label>' ,
'classes' => array ( 'hide' , 'ppcp-always-shown-element' ),
'screens' => array (
State :: STATE_START ,
State :: STATE_ONBOARDED ,
),
'requirements' => array (),
2022-09-02 14:39:41 +04:00
'gateway' => Settings :: CONNECTION_TAB_ID ,
2022-08-24 16:34:49 +04:00
),
2022-08-25 16:21:18 +04:00
'sandbox_on' => array (
2022-08-24 16:34:49 +04:00
'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 (),
2022-09-02 14:39:41 +04:00
'gateway' => Settings :: CONNECTION_TAB_ID ,
2022-08-24 16:34:49 +04:00
),
2022-08-25 16:21:18 +04:00
'merchant_email_production' => array (
2022-08-24 16:34:49 +04:00
'title' => __ ( 'Live Email address' , 'woocommerce-paypal-payments' ),
'classes' => array ( State :: STATE_ONBOARDED === $state -> production_state () ? 'onboarded' : '' , 'ppcp-always-shown-element' ),
2023-09-12 17:45:29 +01:00
'type' => 'email' ,
2022-08-24 16:34:49 +04:00
'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 (),
2022-09-02 14:39:41 +04:00
'gateway' => Settings :: CONNECTION_TAB_ID ,
2022-08-24 16:34:49 +04:00
),
2022-08-25 16:21:18 +04:00
'merchant_id_production' => array (
2023-07-11 18:25:37 +01:00
'title' => __ ( 'Live Merchant Id' , 'woocommerce-paypal-payments' ),
'classes' => array ( State :: STATE_ONBOARDED === $state -> production_state () ? 'onboarded' : '' , 'ppcp-always-shown-element' ),
2023-07-12 08:31:55 +01:00
'type' => 'text' ,
2023-07-11 18:25:37 +01:00
'desc_tip' => true ,
'description' => __ ( 'The merchant id of your account. Should be exactly 13 alphanumeric uppercase letters.' , 'woocommerce-paypal-payments' ),
'maxlength' => 13 ,
'custom_attributes' => array (
2023-07-12 08:37:26 +01:00
'pattern' => '[A-Z0-9]{13}' ,
2023-07-12 08:31:55 +01:00
'autocomplete' => 'off' ,
2023-07-11 18:25:37 +01:00
),
'default' => false ,
'screens' => array (
2022-08-24 16:34:49 +04:00
State :: STATE_START ,
State :: STATE_ONBOARDED ,
),
2023-07-11 18:25:37 +01:00
'requirements' => array (),
'gateway' => Settings :: CONNECTION_TAB_ID ,
2022-08-24 16:34:49 +04:00
),
2022-08-25 16:21:18 +04:00
'client_id_production' => array (
2023-07-12 08:37:26 +01:00
'title' => __ ( 'Live Client Id' , 'woocommerce-paypal-payments' ),
'classes' => array ( State :: STATE_ONBOARDED === $state -> production_state () ? 'onboarded' : '' , 'ppcp-always-shown-element' ),
'type' => 'text' ,
'desc_tip' => true ,
'description' => __ ( 'The client id of your api ' , 'woocommerce-paypal-payments' ),
2023-07-12 08:31:55 +01:00
'custom_attributes' => array (
'autocomplete' => 'off' ,
),
2023-07-12 08:37:26 +01:00
'default' => false ,
'screens' => array (
2022-08-24 16:34:49 +04:00
State :: STATE_START ,
State :: STATE_ONBOARDED ,
),
2023-07-12 08:37:26 +01:00
'requirements' => array (),
'gateway' => Settings :: CONNECTION_TAB_ID ,
2022-08-24 16:34:49 +04:00
),
2022-08-25 16:21:18 +04:00
'client_secret_production' => array (
2022-08-24 16:34:49 +04:00
'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 (),
2022-09-02 14:39:41 +04:00
'gateway' => Settings :: CONNECTION_TAB_ID ,
2022-08-24 16:34:49 +04:00
),
2022-08-25 16:21:18 +04:00
'merchant_email_sandbox' => array (
2022-08-24 16:34:49 +04:00
'title' => __ ( 'Sandbox Email address' , 'woocommerce-paypal-payments' ),
'classes' => array ( State :: STATE_ONBOARDED === $state -> sandbox_state () ? 'onboarded' : '' , 'ppcp-always-shown-element' ),
2023-09-12 17:45:29 +01:00
'type' => 'email' ,
2022-08-24 16:34:49 +04:00
'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 (),
2022-09-02 14:39:41 +04:00
'gateway' => Settings :: CONNECTION_TAB_ID ,
2022-08-24 16:34:49 +04:00
),
2022-08-25 16:21:18 +04:00
'merchant_id_sandbox' => array (
2023-07-11 18:25:37 +01:00
'title' => __ ( 'Sandbox Merchant Id' , 'woocommerce-paypal-payments' ),
'classes' => array ( State :: STATE_ONBOARDED === $state -> sandbox_state () ? 'onboarded' : '' , 'ppcp-always-shown-element' ),
2023-07-12 08:31:55 +01:00
'type' => 'text' ,
2023-07-11 18:25:37 +01:00
'desc_tip' => true ,
'description' => __ ( 'The merchant id of your account. Should be exactly 13 alphanumeric uppercase letters.' , 'woocommerce-paypal-payments' ),
'maxlength' => 13 ,
'custom_attributes' => array (
2023-07-12 08:37:26 +01:00
'pattern' => '[A-Z0-9]{13}' ,
'autocomplete' => 'off' ,
2023-07-11 18:25:37 +01:00
),
'default' => false ,
'screens' => array (
2022-08-24 16:34:49 +04:00
State :: STATE_START ,
State :: STATE_ONBOARDED ,
),
2023-07-11 18:25:37 +01:00
'requirements' => array (),
'gateway' => Settings :: CONNECTION_TAB_ID ,
2022-08-24 16:34:49 +04:00
),
2022-08-25 16:21:18 +04:00
'client_id_sandbox' => array (
2023-07-12 08:37:26 +01:00
'title' => __ ( 'Sandbox Client Id' , 'woocommerce-paypal-payments' ),
'classes' => array ( State :: STATE_ONBOARDED === $state -> sandbox_state () ? 'onboarded' : '' , 'ppcp-always-shown-element' ),
'type' => 'text' ,
'desc_tip' => true ,
'description' => __ ( 'The client id of your api ' , 'woocommerce-paypal-payments' ),
2023-07-12 08:31:55 +01:00
'custom_attributes' => array (
'autocomplete' => 'off' ,
),
2023-07-12 08:37:26 +01:00
'default' => false ,
'screens' => array (
2022-08-24 16:34:49 +04:00
State :: STATE_START ,
State :: STATE_ONBOARDED ,
),
2023-07-12 08:37:26 +01:00
'requirements' => array (),
'gateway' => Settings :: CONNECTION_TAB_ID ,
2022-08-24 16:34:49 +04:00
),
2022-08-25 16:21:18 +04:00
'client_secret_sandbox' => array (
2022-08-24 16:34:49 +04:00
'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 (),
2022-09-02 14:39:41 +04:00
'gateway' => Settings :: CONNECTION_TAB_ID ,
2022-08-24 16:34:49 +04:00
),
2022-08-25 16:21:18 +04:00
'credentials_feature_onboarding_heading' => array (
2022-10-28 15:46:40 +02:00
'heading' => __ ( 'Advanced feature availability & sign-up' , 'woocommerce-paypal-payments' ),
2022-08-25 16:21:18 +04:00
'type' => 'ppcp-heading' ,
'screens' => array (
State :: STATE_ONBOARDED ,
),
'requirements' => array (),
2022-09-02 14:39:41 +04:00
'gateway' => Settings :: CONNECTION_TAB_ID ,
2022-10-28 15:46:40 +02:00
'description' => sprintf (
// translators: %1$s and %2$s are the opening and closing of HTML <a> tag.
__ ( 'Displays whether available advanced features are enabled for the connected PayPal account. More information about advanced features is available in the %1$sFeature sign-up documentation%2$s.' , 'woocommerce-paypal-payments' ),
'<a href="https://woocommerce.com/document/woocommerce-paypal-payments/#feature-signup" target="_blank">' ,
'</a>'
),
2022-08-25 16:21:18 +04:00
),
2023-12-12 17:30:55 +00:00
'refresh_feature_status' => array (
'title' => __ ( 'Refresh feature availability status' , 'woocommerce-paypal-payments' ),
'type' => 'ppcp-text' ,
2024-01-04 15:23:01 +00:00
'text' => '<button type="button" class="button ppcp-refresh-feature-status">' . esc_html__ ( 'Check available features' , 'woocommerce-paypal-payments' ) . '</button><div class="ppcp-status-text"></div>' ,
2023-12-12 17:30:55 +00:00
'screens' => array (
State :: STATE_ONBOARDED ,
),
'requirements' => array (),
'gateway' => Settings :: CONNECTION_TAB_ID ,
),
2022-08-25 16:21:18 +04:00
'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_ONBOARDED ,
),
2022-09-02 14:39:41 +04:00
'requirements' => array ( 'dcc' ),
'gateway' => Settings :: CONNECTION_TAB_ID ,
2022-08-25 16:21:18 +04:00
),
2024-01-16 14:24:34 +00:00
'ppcp_reference_transactions_status' => array (
'title' => __ ( 'Advanced PayPal Wallet' , 'woocommerce-paypal-payments' ),
'type' => 'ppcp-text' ,
'text' => $container -> get ( 'wcgateway.settings.connection.reference-transactions-status-text' ),
'screens' => array (
State :: STATE_ONBOARDED ,
),
'requirements' => array ( 'dcc' ),
'gateway' => Settings :: CONNECTION_TAB_ID ,
),
2022-08-25 16:21:18 +04:00
'ppcp_pui_status' => array (
2022-10-28 15:46:40 +02:00
'title' => __ ( 'Pay upon Invoice' , 'woocommerce-paypal-payments' ),
2022-08-25 16:21:18 +04:00
'type' => 'ppcp-text' ,
'text' => $container -> get ( 'wcgateway.settings.connection.pui-status-text' ),
'screens' => array (
State :: STATE_ONBOARDED ,
),
'requirements' => array ( 'pui_ready' ),
2022-09-02 14:39:41 +04:00
'gateway' => Settings :: CONNECTION_TAB_ID ,
2022-08-25 16:21:18 +04:00
),
2022-11-23 17:42:00 +04:00
'fraudnet_enabled' => array (
'title' => __ ( 'FraudNet' , 'woocommerce-paypal-payments' ),
'type' => 'checkbox' ,
'desc_tip' => true ,
2023-02-07 15:53:11 +02:00
'label' => $container -> get ( 'wcgateway.settings.fraudnet-label' ),
2022-11-23 17:42:00 +04:00
'description' => __ ( 'FraudNet is a JavaScript library developed by PayPal and embedded into a merchant’ s web page to collect browser-based data to help reduce fraud.' , 'woocommerce-paypal-payments' ),
'default' => false ,
'screens' => array (
State :: STATE_ONBOARDED ,
),
'requirements' => array (),
'gateway' => Settings :: CONNECTION_TAB_ID ,
2023-01-20 10:58:43 +01:00
'input_class' => $container -> get ( 'wcgateway.settings.should-disable-fraudnet-checkbox' ) ? array ( 'ppcp-disabled-checkbox' ) : array (),
2022-11-23 17:42:00 +04:00
),
2022-08-25 16:21:18 +04:00
'credentials_integration_configuration_heading' => array (
2022-10-28 15:46:40 +02:00
'heading' => __ ( 'General integration configuration' , 'woocommerce-paypal-payments' ),
2022-08-25 16:21:18 +04:00
'type' => 'ppcp-heading' ,
'screens' => array (
State :: STATE_ONBOARDED ,
),
'requirements' => array (),
2022-09-02 14:39:41 +04:00
'gateway' => Settings :: CONNECTION_TAB_ID ,
2022-10-28 15:46:40 +02:00
'description' => sprintf (
// translators: %1$s and %2$s are the opening and closing of HTML <a> tag.
__ ( 'Configure integration specific settings such as a unique invoice prefix, or logging for potential %1$stroubleshooting%2$s.' , 'woocommerce-paypal-payments' ),
'<a href="https://woocommerce.com/document/woocommerce-paypal-payments/#troubleshooting" target="_blank">' ,
'</a>'
),
2022-08-24 16:34:49 +04:00
),
2023-06-12 09:00:08 +02:00
'soft_descriptor' => array (
'title' => __ ( 'Soft Descriptor' , 'woocommerce-paypal-payments' ),
'type' => 'text' ,
'desc_tip' => true ,
2023-06-14 12:19:41 +02:00
'description' => __ ( 'The soft descriptor is the dynamic text used to construct the statement descriptor that appears on a payer\'s card statement. Text field, max value of 22 characters.' , 'woocommerce-paypal-payments' ),
2023-06-12 09:00:08 +02:00
'maxlength' => 22 ,
'default' => '' ,
'screens' => array (
2023-06-02 10:48:47 +02:00
State :: STATE_START ,
State :: STATE_ONBOARDED ,
),
2023-06-12 09:00:08 +02:00
'requirements' => array (),
'gateway' => Settings :: CONNECTION_TAB_ID ,
2023-06-02 10:48:47 +02:00
),
2022-08-25 16:21:18 +04:00
'prefix' => array (
2022-08-24 16:34:49 +04:00
'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 (
2023-10-12 15:27:55 +01:00
'pattern' => '[a-zA-Z_\\-]+' ,
2022-08-24 16:34:49 +04:00
),
'default' => ( static function () : string {
$site_url = get_site_url ( get_current_blog_id () );
$hash = md5 ( $site_url );
2022-08-24 16:51:56 +04:00
$letters = preg_replace ( '~\d~' , '' , $hash ) ? ? '' ;
$prefix = substr ( $letters , 0 , 6 );
return $prefix ? $prefix . '-' : '' ;
2022-08-24 16:34:49 +04:00
} )(),
'screens' => array (
State :: STATE_START ,
State :: STATE_ONBOARDED ,
),
'requirements' => array (),
2022-09-02 14:39:41 +04:00
'gateway' => Settings :: CONNECTION_TAB_ID ,
2022-08-24 16:34:49 +04:00
),
2022-08-25 16:21:18 +04:00
'logging_enabled' => array (
'title' => __ ( 'Logging' , 'woocommerce-paypal-payments' ),
2022-08-24 16:34:49 +04:00
'type' => 'checkbox' ,
'desc_tip' => true ,
2022-08-25 16:21:18 +04:00
'label' => __ ( 'Enable logging. ' , 'woocommerce-paypal-payments' ) .
' <a href="' . admin_url ( 'admin.php?page=wc-status&tab=logs' ) . '">' . __ ( 'View logs' , 'woocommerce-paypal-payments' ) . '</a>' ,
'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' ),
2022-08-24 16:34:49 +04:00
'default' => false ,
'screens' => array (
2022-08-25 16:21:18 +04:00
State :: STATE_START ,
2022-08-24 16:34:49 +04:00
State :: STATE_ONBOARDED ,
),
'requirements' => array (),
2022-09-02 14:39:41 +04:00
'gateway' => Settings :: CONNECTION_TAB_ID ,
2022-08-24 16:34:49 +04:00
),
2023-08-07 16:12:02 +01:00
'subtotal_mismatch_behavior' => array (
2023-08-30 16:57:06 +01:00
'title' => __ ( 'Subtotal mismatch behavior' , 'woocommerce-paypal-payments' ),
'type' => 'select' ,
'input_class' => array ( 'wc-enhanced-select' ),
'default' => 'vertical' ,
'desc_tip' => true ,
'description' => __ (
2023-08-14 12:00:40 +01:00
'Differences between WooCommerce and PayPal roundings may cause mismatch in order items subtotal calculations. If not handled, these mismatches will cause the PayPal transaction to fail.' ,
2023-08-07 16:12:02 +01:00
'woocommerce-paypal-payments'
),
2023-08-30 16:57:06 +01:00
'options' => array (
2023-08-07 16:12:02 +01:00
PurchaseUnitSanitizer :: MODE_DITCH => __ ( 'Do not send line items to PayPal' , 'woocommerce-paypal-payments' ),
PurchaseUnitSanitizer :: MODE_EXTRA_LINE => __ ( 'Add another line item' , 'woocommerce-paypal-payments' ),
),
2023-08-30 16:57:06 +01:00
'screens' => array (
2023-08-07 16:12:02 +01:00
State :: STATE_START ,
State :: STATE_ONBOARDED ,
),
2023-08-30 16:57:06 +01:00
'requirements' => array (),
'gateway' => Settings :: CONNECTION_TAB_ID ,
'custom_attributes' => array (
2023-09-14 17:48:46 +01:00
'data-ppcp-display' => wp_json_encode (
2023-08-30 16:57:06 +01:00
array (
2023-09-15 17:32:00 +01:00
$display_manager
2023-09-14 17:48:46 +01:00
-> rule ()
2023-09-15 17:32:00 +01:00
-> condition_element ( 'subtotal_mismatch_behavior' , PurchaseUnitSanitizer :: MODE_EXTRA_LINE )
-> action_visible ( 'subtotal_mismatch_line_name' )
2023-09-14 17:48:46 +01:00
-> to_array (),
2023-08-30 16:57:06 +01:00
)
),
),
2023-08-07 16:12:02 +01:00
),
'subtotal_mismatch_line_name' => array (
'title' => __ ( 'Subtotal mismatch line name' , 'woocommerce-paypal-payments' ),
'type' => 'text' ,
'desc_tip' => true ,
'description' => __ ( 'The name of the extra line that will be sent to PayPal to correct the subtotal mismatch.' , 'woocommerce-paypal-payments' ),
'maxlength' => 22 ,
'default' => '' ,
'screens' => array (
State :: STATE_START ,
State :: STATE_ONBOARDED ,
),
'requirements' => array (),
'placeholder' => PurchaseUnitSanitizer :: EXTRA_LINE_NAME ,
'gateway' => Settings :: CONNECTION_TAB_ID ,
),
2022-08-24 16:34:49 +04:00
);
return array_merge ( $fields , $connection_fields );
};