get( 'wcgateway.current-ppcp-settings-page-id' ); if ( $current_page_id !== Settings::CONNECTION_TAB_ID ) { return $fields; } $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' ); $connection_fields = array( 'ppcp_onboarading_header' => array( 'type' => 'ppcp-text', 'classes' => array( 'ppcp-onboarding-element' ), 'text' => '
%1$s
', esc_html__( 'Status: Connected', 'woocommerce-paypal-payments' ), esc_html__( 'Disconnect Account', 'woocommerce-paypal-payments' ) ), 'screens' => array( State::STATE_ONBOARDED, ), 'state_from' => Environment::PRODUCTION, 'env' => Environment::PRODUCTION, 'requirements' => array(), 'gateway' => Settings::CONNECTION_TAB_ID, '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' => sprintf( '%1$s
', esc_html__( 'Status: Connected', 'woocommerce-paypal-payments' ), esc_html__( 'Disconnect Account', 'woocommerce-paypal-payments' ) ), 'screens' => array( State::STATE_ONBOARDED, ), 'state_from' => Environment::SANDBOX, 'env' => Environment::SANDBOX, 'requirements' => array(), 'gateway' => Settings::CONNECTION_TAB_ID, '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' => Settings::CONNECTION_TAB_ID, ), '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' => Settings::CONNECTION_TAB_ID, ), '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' => Settings::CONNECTION_TAB_ID, ), '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' => Settings::CONNECTION_TAB_ID, ), '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' => Settings::CONNECTION_TAB_ID, ), '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' => Settings::CONNECTION_TAB_ID, ), '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' => Settings::CONNECTION_TAB_ID, ), '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' => Settings::CONNECTION_TAB_ID, ), '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' => Settings::CONNECTION_TAB_ID, ), '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' => Settings::CONNECTION_TAB_ID, ), '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' => Settings::CONNECTION_TAB_ID, ), 'credentials_feature_onboarding_heading' => array( 'heading' => __( 'Advanced feature availability & sign-up', 'woocommerce-paypal-payments' ), 'type' => 'ppcp-heading', 'screens' => array( State::STATE_ONBOARDED, ), 'requirements' => array(), 'gateway' => Settings::CONNECTION_TAB_ID, 'description' => sprintf( // translators: %1$s and %2$s are the opening and closing of HTML 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' ), '', '' ), ), '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, ), 'requirements' => array( 'dcc' ), 'gateway' => Settings::CONNECTION_TAB_ID, ), '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' => Settings::CONNECTION_TAB_ID, ), 'tracking_enabled' => array( 'title' => __( 'Shipment 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' => Settings::CONNECTION_TAB_ID, 'input_class' => $container->get( 'wcgateway.settings.should-disable-tracking-checkbox' ) ? array( 'ppcp-disabled-checkbox' ) : array(), ), 'credentials_integration_configuration_heading' => array( 'heading' => __( 'General integration configuration', 'woocommerce-paypal-payments' ), 'type' => 'ppcp-heading', 'screens' => array( State::STATE_ONBOARDED, ), 'requirements' => array(), 'gateway' => Settings::CONNECTION_TAB_ID, 'description' => sprintf( // translators: %1$s and %2$s are the opening and closing of HTML tag. __( 'Configure integration specific settings such as a unique invoice prefix, or logging for potential %1$stroubleshooting%2$s.', 'woocommerce-paypal-payments' ), '', '' ), ), '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 ) ?? ''; $prefix = substr( $letters, 0, 6 ); return $prefix ? $prefix . '-' : ''; } )(), 'screens' => array( State::STATE_START, State::STATE_ONBOARDED, ), 'requirements' => array(), 'gateway' => Settings::CONNECTION_TAB_ID, ), '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' => Settings::CONNECTION_TAB_ID, ), ); return array_merge( $fields, $connection_fields ); };