Merge branch 'pcp-370-onboarding' of github.com:woocommerce/woocommerce-paypal-payments into pcp-370-onboarding

This commit is contained in:
dinamiko 2022-02-07 10:21:29 +01:00
commit ab4acaa3f3
15 changed files with 355 additions and 318 deletions

View file

@ -13,6 +13,7 @@ namespace WooCommerce\PayPalCommerce\ApiClient\Repository;
* Class CustomerRepository
*/
class CustomerRepository {
const CLIENT_ID_MAX_LENGTH = 22;
/**
* The prefix.
@ -43,7 +44,7 @@ class CustomerRepository {
return $guest_customer_id;
}
$unique_id = $this->prefix . uniqid();
$unique_id = substr( $this->prefix . strrev( uniqid() ), 0, self::CLIENT_ID_MAX_LENGTH );
WC()->session->set( 'ppcp_guest_customer_id', $unique_id );
return $unique_id;

View file

@ -52,7 +52,7 @@ return array(
*
* @var State $state
*/
if ( $state->current_state() <= State::STATE_PROGRESSIVE ) {
if ( $state->current_state() !== State::STATE_ONBOARDED ) {
return new DisabledSmartButton();
}
$settings = $container->get( 'wcgateway.settings' );

View file

@ -647,7 +647,7 @@ class SmartButton implements SmartButtonInterface {
$localize = array(
'script_attributes' => $this->attributes(),
'data_client_id' => array(
'set_attribute' => $this->can_save_vault_token(),
'set_attribute' => ( is_checkout() && $this->dcc_is_enabled() ) || $this->can_save_vault_token(),
'endpoint' => home_url( \WC_AJAX::get_endpoint( DataClientIdEndpoint::ENDPOINT ) ),
'nonce' => wp_create_nonce( DataClientIdEndpoint::nonce() ),
'user' => get_current_user_id(),

View file

@ -2,28 +2,27 @@
display: none;
}
#field-merchant_email_production,
#field-merchant_id_production,
#field-client_id_production,
#field-client_secret_production,
#field-merchant_email_sandbox,
#field-merchant_id_sandbox,
#field-client_id_sandbox,
#field-client_secret_sandbox{
.ppcp-onboarded .ppcp-onboarding-element:not(.ppcp-always-shown-element) {
display: none;
}
#field-merchant_email_production.show,
#field-merchant_id_production.show,
#field-client_id_production.show,
#field-client_secret_production.show,
#field-merchant_email_sandbox.show,
#field-merchant_id_sandbox.show,
#field-client_id_sandbox.show,
#field-client_secret_sandbox.show {
.ppcp-onboarding .ppcp-settings-field:not(.ppcp-onboarding-element):not(.ppcp-always-shown-element) {
display: none;
}
.ppcp-settings-field.hide {
display: none;
}
.ppcp-settings-field.show {
display: table-row;
}
label.error {
color: red;
font-weight: bold;
}
#field-toggle_manual_input button {
color: #0073aa;
transition-property: border, background, color;
@ -37,32 +36,6 @@
padding: 0;
}
#field-sandbox_on.onboarded {
display: none;
}
#field-merchant_email_sandbox.onboarded,
#field-merchant_id_sandbox.onboarded,
#field-client_id_sandbox.onboarded,
#field-client_secret_sandbox.onboarded,
#field-merchant_email_production.onboarded,
#field-merchant_id_production.onboarded,
#field-client_id_production.onboarded,
#field-client_secret_production.onboarded {
display:table-row;
}
#field-merchant_email_sandbox.onboarded.hide,
#field-merchant_id_sandbox.onboarded.hide,
#field-client_id_sandbox.onboarded.hide,
#field-client_secret_sandbox.onboarded.hide,
#field-merchant_email_production.onboarded.hide,
#field-merchant_id_production.onboarded.hide,
#field-client_id_production.onboarded.hide,
#field-client_secret_production.onboarded.hide {
display:none;
}
/* Probably not the best location for this but will do until there's a general purpose settings CSS file. */
.ppcp-settings-field-heading td, .ppcp-settings-field-heading th, .ppcp-settings-no-title-col td {
padding-left: 0;

View file

@ -1,9 +1,11 @@
// Onboarding.
const ppcp_onboarding = {
BUTTON_SELECTOR: '[data-paypal-onboard-button]',
PAYPAL_JS_ID: 'ppcp-onboarding-paypal-js',
_timeout: false,
STATE_START: 'start',
STATE_ONBOARDED: 'onboarded',
init: function() {
document.addEventListener('DOMContentLoaded', this.reload);
},
@ -89,8 +91,6 @@ const ppcp_onboarding = {
}
);
},
};
function ppcp_onboarding_sandboxCallback(...args) {
@ -101,108 +101,143 @@ function ppcp_onboarding_productionCallback(...args) {
return ppcp_onboarding.loginSeller('production', ...args);
}
const updateOptionsState = () => {
const cardsChk = document.querySelector('#ppcp-onboarding-accept-cards');
if (!cardsChk) {
return;
}
document.querySelectorAll('#ppcp-onboarding-dcc-options input').forEach(input => {
input.disabled = !cardsChk.checked;
});
const basicRb = document.querySelector('#ppcp-onboarding-dcc-basic');
const isExpress = !cardsChk.checked || basicRb.checked;
const expressButtonSelectors = [
'#field-ppcp_onboarding_production_express',
'#field-ppcp_onboarding_sandbox_express',
];
const ppcpButtonSelectors = [
'#field-ppcp_onboarding_production_ppcp',
'#field-ppcp_onboarding_sandbox_ppcp',
];
document.querySelectorAll(expressButtonSelectors.join()).forEach(
element => element.style.display = isExpress ? '' : 'none'
);
document.querySelectorAll(ppcpButtonSelectors.join()).forEach(
element => element.style.display = !isExpress ? '' : 'none'
);
};
const updateManualInputControls = (shown, isSandbox) => {
const productionElementsSelectors = [
(() => {
const productionCredentialElementsSelectors = [
'#field-merchant_email_production',
'#field-merchant_id_production',
'#field-client_id_production',
'#field-client_secret_production',
];
const sandboxElementsSelectors = [
const sandboxCredentialElementsSelectors = [
'#field-merchant_email_sandbox',
'#field-merchant_id_sandbox',
'#field-client_id_sandbox',
'#field-client_secret_sandbox',
];
const otherElementsSelectors = [
'#field-sandbox_on',
'.woocommerce-save-button',
];
document.querySelectorAll(productionElementsSelectors.join()).forEach(
element => {
element.classList.remove('hide', 'show');
element.classList.add((shown && !isSandbox) ? 'show' : 'hide');
const updateOptionsState = () => {
const cardsChk = document.querySelector('#ppcp-onboarding-accept-cards');
if (!cardsChk) {
return;
}
);
document.querySelectorAll(sandboxElementsSelectors.join()).forEach(
element => {
element.classList.remove('hide', 'show');
element.classList.add((shown && isSandbox) ? 'show' : 'hide');
document.querySelectorAll('#ppcp-onboarding-dcc-options input').forEach(input => {
input.disabled = !cardsChk.checked;
});
const basicRb = document.querySelector('#ppcp-onboarding-dcc-basic');
const isExpress = !cardsChk.checked || basicRb.checked;
const expressButtonSelectors = [
'#field-ppcp_onboarding_production_express',
'#field-ppcp_onboarding_sandbox_express',
];
const ppcpButtonSelectors = [
'#field-ppcp_onboarding_production_ppcp',
'#field-ppcp_onboarding_sandbox_ppcp',
];
document.querySelectorAll(expressButtonSelectors.join()).forEach(
element => element.style.display = isExpress ? '' : 'none'
);
document.querySelectorAll(ppcpButtonSelectors.join()).forEach(
element => element.style.display = !isExpress ? '' : 'none'
);
};
const updateManualInputControls = (shown, isSandbox, isAnyEnvOnboarded) => {
const productionElementsSelectors = productionCredentialElementsSelectors;
const sandboxElementsSelectors = sandboxCredentialElementsSelectors;
const otherElementsSelectors = [
'.woocommerce-save-button',
];
if (!isAnyEnvOnboarded) {
otherElementsSelectors.push('#field-sandbox_on');
}
);
document.querySelectorAll(otherElementsSelectors.join()).forEach(
element => element.style.display = shown ? '' : 'none'
);
};
const disconnect = (event) => {
event.preventDefault();
const fields = event.target.classList.contains('production') ? [
'#field-merchant_email_production input',
'#field-merchant_id_production input',
'#field-client_id_production input',
'#field-client_secret_production input',
] : [
'#field-merchant_email_sandbox input',
'#field-merchant_id_sandbox input',
'#field-client_id_sandbox input',
'#field-client_secret_sandbox input',
];
document.querySelectorAll(productionElementsSelectors.join()).forEach(
element => {
element.classList.remove('hide', 'show');
element.classList.add((shown && !isSandbox) ? 'show' : 'hide');
}
);
document.querySelectorAll(sandboxElementsSelectors.join()).forEach(
element => {
element.classList.remove('hide', 'show');
element.classList.add((shown && isSandbox) ? 'show' : 'hide');
}
);
document.querySelectorAll(otherElementsSelectors.join()).forEach(
element => element.style.display = shown ? '' : 'none'
);
};
document.querySelectorAll(fields.join()).forEach(
(element) => {
element.value = '';
}
);
document.querySelector('.woocommerce-save-button').click();
};
const updateEnvironmentControls = (isSandbox) => {
const productionElementsSelectors = [
'#field-ppcp_disconnect_production',
'#field-credentials_production_heading',
];
const sandboxElementsSelectors = [
'#field-ppcp_disconnect_sandbox',
'#field-credentials_sandbox_heading',
];
// Prevent the message about unsaved checkbox/radiobutton when reloading the page.
// (WC listens for changes on all inputs and sets dirty flag until form submission)
const preventDirtyCheckboxPropagation = event => {
event.preventDefault();
event.stopPropagation();
document.querySelectorAll(productionElementsSelectors.join()).forEach(
element => element.style.display = !isSandbox ? '' : 'none'
);
document.querySelectorAll(sandboxElementsSelectors.join()).forEach(
element => element.style.display = isSandbox ? '' : 'none'
);
};
const value = event.target.checked;
setTimeout( () => {
event.target.checked = value;
}, 1
);
};
let isDisconnecting = false;
const disconnect = (event) => {
event.preventDefault();
const fields = event.target.classList.contains('production') ? productionCredentialElementsSelectors : sandboxCredentialElementsSelectors;
document.querySelectorAll(fields.map(f => f + ' input').join()).forEach(
(element) => {
element.value = '';
}
);
isDisconnecting = true;
document.querySelector('.woocommerce-save-button').click();
};
// Prevent the message about unsaved checkbox/radiobutton when reloading the page.
// (WC listens for changes on all inputs and sets dirty flag until form submission)
const preventDirtyCheckboxPropagation = event => {
event.preventDefault();
event.stopPropagation();
const value = event.target.checked;
setTimeout( () => {
event.target.checked = value;
}, 1
);
};
const sandboxSwitchElement = document.querySelector('#ppcp-sandbox_on');
const validate = () => {
const selectors = sandboxSwitchElement.checked ? sandboxCredentialElementsSelectors : productionCredentialElementsSelectors;
const values = selectors.map(s => document.querySelector(s + ' input')).map(el => el.value);
const errors = [];
if (values.some(v => !v)) {
errors.push(PayPalCommerceGatewayOnboarding.error_messages.no_credentials);
}
return errors;
};
const isAnyEnvOnboarded = PayPalCommerceGatewayOnboarding.sandbox_state === ppcp_onboarding.STATE_ONBOARDED ||
PayPalCommerceGatewayOnboarding.production_state === ppcp_onboarding.STATE_ONBOARDED;
(() => {
document.querySelectorAll('.ppcp-disconnect').forEach(
(button) => {
button.addEventListener(
@ -224,32 +259,72 @@ const preventDirtyCheckboxPropagation = event => {
updateOptionsState();
const sandboxSwitchElement = document.querySelector('#ppcp-sandbox_on');
const settingsContainer = document.querySelector('#mainform .form-table');
const markCurrentOnboardingState = (isOnboarded) => {
settingsContainer.classList.remove('ppcp-onboarded', 'ppcp-onboarding');
settingsContainer.classList.add(isOnboarded ? 'ppcp-onboarded' : 'ppcp-onboarding');
}
markCurrentOnboardingState(PayPalCommerceGatewayOnboarding.current_state === ppcp_onboarding.STATE_ONBOARDED);
const manualInputToggleButton = document.querySelector('#field-toggle_manual_input button');
let isManualInputShown = manualInputToggleButton === null; // toggle is removed after onboarding and the fields are always shown
let isManualInputShown = PayPalCommerceGatewayOnboarding.current_state === ppcp_onboarding.STATE_ONBOARDED;
manualInputToggleButton?.addEventListener(
manualInputToggleButton.addEventListener(
'click',
(event) => {
event.preventDefault();
isManualInputShown = !isManualInputShown;
updateManualInputControls(isManualInputShown, sandboxSwitchElement.checked);
updateManualInputControls(isManualInputShown, sandboxSwitchElement.checked, isAnyEnvOnboarded);
}
);
sandboxSwitchElement.addEventListener(
'click',
(event) => {
updateManualInputControls(isManualInputShown, sandboxSwitchElement.checked);
const isSandbox = sandboxSwitchElement.checked;
if (isAnyEnvOnboarded) {
const onboardingState = isSandbox ? PayPalCommerceGatewayOnboarding.sandbox_state : PayPalCommerceGatewayOnboarding.production_state;
const isOnboarded = onboardingState === ppcp_onboarding.STATE_ONBOARDED;
markCurrentOnboardingState(isOnboarded);
isManualInputShown = isOnboarded;
}
updateManualInputControls(isManualInputShown, isSandbox, isAnyEnvOnboarded);
updateEnvironmentControls(isSandbox);
preventDirtyCheckboxPropagation(event);
}
);
updateManualInputControls(isManualInputShown, sandboxSwitchElement.checked);
updateManualInputControls(isManualInputShown, sandboxSwitchElement.checked, isAnyEnvOnboarded);
updateEnvironmentControls(sandboxSwitchElement.checked);
document.querySelector('#mainform').addEventListener('submit', e => {
if (isDisconnecting) {
return;
}
const errors = validate();
if (errors.length) {
e.preventDefault();
const errorLabel = document.querySelector('#ppcp-form-errors-label');
errorLabel.parentElement.parentElement.classList.remove('hide');
errorLabel.innerHTML = errors.join('<br/>');
errorLabel.scrollIntoView();
window.scrollBy(0, -120); // WP + WC floating header
}
});
// Onboarding buttons.
ppcp_onboarding.init();

View file

@ -23,7 +23,7 @@ document.addEventListener(
}
group.forEach( (elementToShow) => {
document.querySelector(elementToShow).style.display = 'table-row';
document.querySelector(elementToShow).style.display = '';
})
if('ppcp-message_enabled' === event.target.getAttribute('id')){
@ -56,7 +56,7 @@ document.addEventListener(
return;
}
if (value === elementToToggle.value && domElement.style.display !== 'none') {
domElement.style.display = 'table-row';
domElement.style.display = '';
return;
}
domElement.style.display = 'none';
@ -69,7 +69,7 @@ document.addEventListener(
const value = event.target.value;
group.forEach( (elementToToggle) => {
if (value === elementToToggle.value) {
document.querySelector(elementToToggle.selector).style.display = 'table-row';
document.querySelector(elementToToggle.selector).style.display = '';
return;
}
document.querySelector(elementToToggle.selector).style.display = 'none';

View file

@ -103,9 +103,15 @@ class OnboardingAssets {
*/
public function get_script_data() {
return array(
'endpoint' => home_url( \WC_AJAX::get_endpoint( LoginSellerEndpoint::ENDPOINT ) ),
'nonce' => wp_create_nonce( $this->login_seller_endpoint::nonce() ),
'paypal_js_url' => 'https://www.paypal.com/webapps/merchantboarding/js/lib/lightbox/partner.js',
'endpoint' => home_url( \WC_AJAX::get_endpoint( LoginSellerEndpoint::ENDPOINT ) ),
'nonce' => wp_create_nonce( $this->login_seller_endpoint::nonce() ),
'paypal_js_url' => 'https://www.paypal.com/webapps/merchantboarding/js/lib/lightbox/partner.js',
'sandbox_state' => State::get_state_name( $this->state->sandbox_state() ),
'production_state' => State::get_state_name( $this->state->production_state() ),
'current_state' => State::get_state_name( $this->state->current_state() ),
'error_messages' => array(
'no_credentials' => __( 'Enter the credentials.', 'woocommerce-paypal-payments' ),
),
);
}

View file

@ -10,7 +10,6 @@ declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\Onboarding;
use Psr\Container\ContainerInterface;
use WooCommerce\PayPalCommerce\Onboarding\State;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
/**
@ -138,13 +137,13 @@ class OnboardingRESTController {
return array(
'environment' => $environment->current_environment(),
'onboarded' => ( $state->current_state() >= State::STATE_ONBOARDED ),
'state' => $this->get_onboarding_state_name( $state->current_state() ),
'state' => State::get_state_name( $state->current_state() ),
'sandbox' => array(
'state' => $this->get_onboarding_state_name( $state->sandbox_state() ),
'state' => State::get_state_name( $state->sandbox_state() ),
'onboarded' => ( $state->sandbox_state() >= State::STATE_ONBOARDED ),
),
'production' => array(
'state' => $this->get_onboarding_state_name( $state->production_state() ),
'state' => State::get_state_name( $state->production_state() ),
'onboarded' => ( $state->production_state() >= State::STATE_ONBOARDED ),
),
);
@ -265,34 +264,6 @@ class OnboardingRESTController {
return add_query_arg( $this->return_url_args, $url );
}
/**
* Translates an onboarding state to a string.
*
* @param int $state An onboarding state to translate as returned by {@link State} methods.
* @return string A string representing the state: "start", "progressive" or "onboarded".
* @see State::current_state(), State::sandbox_state(), State::production_state().
*/
public function get_onboarding_state_name( $state ) {
$name = 'unknown';
switch ( absint( $state ) ) {
case State::STATE_START:
$name = 'start';
break;
case State::STATE_PROGRESSIVE:
$name = 'progressive';
break;
case State::STATE_ONBOARDED:
$name = 'onboarded';
break;
default:
break;
}
return $name;
}
/**
* Generates a signup link for onboarding for a given environment and optionally adding certain URL arguments
* to the URL users are redirected after completing the onboarding flow.

View file

@ -102,7 +102,7 @@ class OnboardingRenderer {
$this->render_button(
$this->get_signup_link( $is_production, $products ),
$id,
$is_production ? __( 'Connect PayPal', 'woocommerce-paypal-payments' ) : __( 'Test Payments', 'woocommerce-paypal-payments' ),
$is_production ? __( 'Connect with PayPal', 'woocommerce-paypal-payments' ) : __( 'Test payments with PayPal sandbox', 'woocommerce-paypal-payments' ),
$is_production ? 'primary' : 'secondary',
$is_production ? 'production' : 'sandbox'
);

View file

@ -16,9 +16,8 @@ use Psr\Container\ContainerInterface;
*/
class State {
const STATE_START = 0;
const STATE_PROGRESSIVE = 4;
const STATE_ONBOARDED = 8;
const STATE_START = 0;
const STATE_ONBOARDED = 8;
/**
* The Environment.
@ -49,6 +48,22 @@ class State {
$this->settings = $settings;
}
/**
* Returns the state of the specified environment (or the active environment if null).
*
* @param string|null $environment 'sandbox', 'production'.
* @return int
*/
public function environment_state( ?string $environment = null ): int {
switch ( $environment ) {
case Environment::PRODUCTION:
return $this->production_state();
case Environment::SANDBOX:
return $this->sandbox_state();
}
return $this->current_state();
}
/**
* Returns the current active onboarding state.
*
@ -57,9 +72,6 @@ class State {
public function current_state(): int {
return $this->state_by_keys(
array(
'merchant_email',
),
array(
'merchant_email',
'merchant_id',
@ -77,9 +89,6 @@ class State {
public function sandbox_state() : int {
return $this->state_by_keys(
array(
'merchant_email_sandbox',
),
array(
'merchant_email_sandbox',
'merchant_id_sandbox',
@ -97,9 +106,6 @@ class State {
public function production_state() : int {
return $this->state_by_keys(
array(
'merchant_email_production',
),
array(
'merchant_email_production',
'merchant_id_production',
@ -109,37 +115,37 @@ class State {
);
}
/**
* Translates an onboarding state to a string.
*
* @param int $state An onboarding state to translate.
* @return string A string representing the state: "start" or "onboarded".
*/
public static function get_state_name( int $state ) : string {
switch ( $state ) {
case self::STATE_START:
return 'start';
case self::STATE_ONBOARDED:
return 'onboarded';
default:
return 'unknown';
}
}
/**
* Returns the state based on progressive and onboarded values being looked up in the settings.
*
* @param array $progressive_keys The keys which need to be present to be at least in progressive state.
* @param array $onboarded_keys The keys which need to be present to be in onboarded state.
*
* @return int
*/
private function state_by_keys( array $progressive_keys, array $onboarded_keys ) : int {
$state = self::STATE_START;
$is_progressive = true;
foreach ( $progressive_keys as $key ) {
if ( ! $this->settings->has( $key ) || ! $this->settings->get( $key ) ) {
$is_progressive = false;
}
}
if ( $is_progressive ) {
$state = self::STATE_PROGRESSIVE;
}
$is_onboarded = true;
private function state_by_keys( array $onboarded_keys ) : int {
foreach ( $onboarded_keys as $key ) {
if ( ! $this->settings->has( $key ) || ! $this->settings->get( $key ) ) {
$is_onboarded = false;
return self::STATE_START;
}
}
if ( $is_onboarded ) {
$state = self::STATE_ONBOARDED;
}
return $state;
return self::STATE_ONBOARDED;
}
}

View file

@ -255,6 +255,8 @@ return array(
'wcgateway.settings.fields' => static function ( ContainerInterface $container ): array {
$state = $container->get( 'onboarding.state' );
assert( $state instanceof State );
$messages_disclaimers = $container->get( 'button.helper.messages-disclaimers' );
$dcc_applies = $container->get( 'api.helpers.dccapplies' );
@ -270,6 +272,7 @@ return array(
$fields = array(
'ppcp_onboarading_header' => array(
'type' => 'ppcp-text',
'classes' => array( 'ppcp-onboarding-element' ),
'text' => '
<div class="ppcp-onboarding-header">
<div class="ppcp-onboarding-header-left">
@ -294,7 +297,7 @@ return array(
</div>',
'screens' => array(
State::STATE_START,
State::STATE_PROGRESSIVE,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
@ -304,9 +307,9 @@ return array(
'heading' => __( 'API Credentials', 'woocommerce-paypal-payments' ),
'type' => 'ppcp-heading',
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_ONBOARDED,
),
'state_from' => Environment::PRODUCTION,
'requirements' => array(),
'gateway' => 'paypal',
),
@ -314,9 +317,9 @@ return array(
'heading' => __( 'Sandbox API Credentials', 'woocommerce-paypal-payments' ),
'type' => 'ppcp-heading',
'screens' => array(
State::STATE_PROGRESSIVE,
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, disconnect and connect your live PayPal account.', 'woocommerce-paypal-payments' ),
@ -324,11 +327,12 @@ return array(
'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_PROGRESSIVE,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
@ -339,33 +343,36 @@ return array(
// 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::STATE_PROGRESSIVE,
),
'env' => 'production',
'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::STATE_PROGRESSIVE,
),
'env' => 'production',
'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::STATE_PROGRESSIVE,
),
'env' => 'sandbox',
'state_from' => Environment::SANDBOX,
'env' => Environment::SANDBOX,
'products' => array( 'PPCP' ),
'requirements' => array(),
'gateway' => 'paypal',
@ -373,11 +380,12 @@ return array(
),
'ppcp_onboarding_sandbox_express' => array(
'type' => 'ppcp_onboarding',
'classes' => array( 'ppcp-onboarding-element' ),
'screens' => array(
State::STATE_START,
State::STATE_PROGRESSIVE,
),
'env' => 'sandbox',
'state_from' => Environment::SANDBOX,
'env' => Environment::SANDBOX,
'products' => array( 'EXPRESS_CHECKOUT' ),
'requirements' => array(),
'gateway' => 'paypal',
@ -391,7 +399,8 @@ return array(
'screens' => array(
State::STATE_ONBOARDED,
),
'env' => 'production',
'state_from' => Environment::PRODUCTION,
'env' => Environment::PRODUCTION,
'requirements' => array(),
'gateway' => 'paypal',
'description' => __( 'Click to reset current credentials and use another account.', 'woocommerce-paypal-payments' ),
@ -403,7 +412,8 @@ return array(
'screens' => array(
State::STATE_ONBOARDED,
),
'env' => 'production',
'state_from' => Environment::SANDBOX,
'env' => Environment::SANDBOX,
'requirements' => array(),
'gateway' => 'paypal',
'description' => __( 'Click to reset current credentials and use another account.', 'woocommerce-paypal-payments' ),
@ -411,22 +421,33 @@ return array(
'toggle_manual_input' => array(
'type' => 'ppcp-text',
'text' => '<button type="button" id="ppcp[toggle_manual_input]">' . __( 'Toggle to manual credential input', 'woocommerce-paypal-payments' ) . '</button>',
'classes' => array( 'ppcp-onboarding-element' ),
'screens' => array(
State::STATE_START,
State::STATE_PROGRESSIVE,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'error_label' => array(
'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(),
'gateway' => 'paypal',
),
'sandbox_on' => array(
'title' => __( 'Sandbox', 'woocommerce-paypal-payments' ),
'classes' => array( State::STATE_ONBOARDED === $state->production_state() || State::STATE_ONBOARDED === $state->sandbox_state() ? 'onboarded' : '' ),
'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_PROGRESSIVE,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -434,7 +455,7 @@ return array(
),
'merchant_email_production' => array(
'title' => __( 'Live Email address', 'woocommerce-paypal-payments' ),
'classes' => array( State::STATE_ONBOARDED === $state->production_state() ? 'onboarded' : '' ),
'classes' => array( State::STATE_ONBOARDED === $state->production_state() ? 'onboarded' : '', 'ppcp-always-shown-element' ),
'type' => 'text',
'required' => true,
'desc_tip' => true,
@ -442,7 +463,6 @@ return array(
'default' => '',
'screens' => array(
State::STATE_START,
State::STATE_PROGRESSIVE,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -450,14 +470,13 @@ return array(
),
'merchant_id_production' => array(
'title' => __( 'Live Merchant Id', 'woocommerce-paypal-payments' ),
'classes' => array( State::STATE_ONBOARDED === $state->production_state() ? 'onboarded' : '' ),
'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_PROGRESSIVE,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -465,14 +484,13 @@ return array(
),
'client_id_production' => array(
'title' => __( 'Live Client Id', 'woocommerce-paypal-payments' ),
'classes' => array( State::STATE_ONBOARDED === $state->production_state() ? 'onboarded' : '' ),
'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_PROGRESSIVE,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -480,14 +498,13 @@ return array(
),
'client_secret_production' => array(
'title' => __( 'Live Secret Key', 'woocommerce-paypal-payments' ),
'classes' => array( State::STATE_ONBOARDED === $state->production_state() ? 'onboarded' : '' ),
'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_PROGRESSIVE,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -496,7 +513,7 @@ return array(
'merchant_email_sandbox' => array(
'title' => __( 'Sandbox Email address', 'woocommerce-paypal-payments' ),
'classes' => array( State::STATE_ONBOARDED === $state->sandbox_state() ? 'onboarded' : '' ),
'classes' => array( State::STATE_ONBOARDED === $state->sandbox_state() ? 'onboarded' : '', 'ppcp-always-shown-element' ),
'type' => 'text',
'required' => true,
'desc_tip' => true,
@ -504,7 +521,6 @@ return array(
'default' => '',
'screens' => array(
State::STATE_START,
State::STATE_PROGRESSIVE,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -512,14 +528,13 @@ return array(
),
'merchant_id_sandbox' => array(
'title' => __( 'Sandbox Merchant Id', 'woocommerce-paypal-payments' ),
'classes' => array( State::STATE_ONBOARDED === $state->sandbox_state() ? 'onboarded' : '' ),
'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_PROGRESSIVE,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -527,14 +542,13 @@ return array(
),
'client_id_sandbox' => array(
'title' => __( 'Sandbox Client Id', 'woocommerce-paypal-payments' ),
'classes' => array( State::STATE_ONBOARDED === $state->sandbox_state() ? 'onboarded' : '' ),
'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_PROGRESSIVE,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -542,14 +556,13 @@ return array(
),
'client_secret_sandbox' => array(
'title' => __( 'Sandbox Secret Key', 'woocommerce-paypal-payments' ),
'classes' => array( State::STATE_ONBOARDED === $state->sandbox_state() ? 'onboarded' : '' ),
'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_PROGRESSIVE,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -560,7 +573,7 @@ return array(
'heading' => __( 'PayPal Checkout Settings', 'woocommerce-paypal-payments' ),
'type' => 'ppcp-heading',
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -576,7 +589,7 @@ return array(
'default' => __( 'PayPal', 'woocommerce-paypal-payments' ),
'desc_tip' => true,
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -627,7 +640,7 @@ return array(
'woocommerce-paypal-payments'
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -649,6 +662,7 @@ return array(
'authorize' => __( 'Authorize', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -665,6 +679,7 @@ return array(
),
'label' => __( 'Capture Virtual-Only Orders', 'woocommerce-paypal-payments' ),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -681,7 +696,7 @@ return array(
),
'label' => __( 'Require Instant Payment', 'woocommerce-paypal-payments' ),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -697,7 +712,7 @@ return array(
'woocommerce-paypal-payments'
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -719,7 +734,7 @@ return array(
ApplicationContext::LANDING_PAGE_BILLING => __( 'Billing (Non-PayPal account)', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -752,7 +767,7 @@ return array(
'venmo' => _x( 'Venmo', 'Name of payment method', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -788,7 +803,7 @@ return array(
'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_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -810,7 +825,7 @@ return array(
return substr( $letters, 0, 6 ) . '-';
} )(),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -822,7 +837,7 @@ return array(
'heading' => __( 'Checkout', 'woocommerce-paypal-payments' ),
'type' => 'ppcp-heading',
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -835,7 +850,7 @@ return array(
'label' => __( 'Enable on Checkout', 'woocommerce-paypal-payments' ),
'default' => true,
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -857,7 +872,7 @@ return array(
'horizontal' => __( 'Horizontal', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -874,7 +889,7 @@ return array(
'woocommerce-paypal-payments'
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -898,7 +913,7 @@ return array(
'pay' => __( 'Pay with PayPal', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -922,7 +937,7 @@ return array(
'black' => __( 'Black', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -944,7 +959,7 @@ return array(
'rect' => __( 'Rectangle', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -954,7 +969,7 @@ return array(
'heading' => __( 'Pay Later on Checkout', 'woocommerce-paypal-payments' ),
'type' => 'ppcp-heading',
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array( 'messages' ),
@ -968,7 +983,7 @@ return array(
'label' => __( 'Enable on Checkout', 'woocommerce-paypal-payments' ),
'default' => true,
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array( 'messages' ),
@ -990,7 +1005,7 @@ return array(
'flex' => __( 'Flex', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array( 'messages' ),
@ -1014,7 +1029,7 @@ return array(
'none' => __( 'None', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array( 'messages' ),
@ -1037,7 +1052,7 @@ return array(
'top' => __( 'Top', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array( 'messages' ),
@ -1061,7 +1076,7 @@ return array(
'grayscale' => __( 'Grayscale', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array( 'messages' ),
@ -1088,7 +1103,7 @@ return array(
'grayscale' => __( 'Grayscale', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array( 'messages' ),
@ -1112,7 +1127,7 @@ return array(
'20x1' => __( '20x1', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array( 'messages' ),
@ -1124,7 +1139,7 @@ return array(
'heading' => __( 'Single Product Page', 'woocommerce-paypal-payments' ),
'type' => 'ppcp-heading',
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -1137,7 +1152,7 @@ return array(
'label' => __( 'Enable on Single Product', 'woocommerce-paypal-payments' ),
'default' => true,
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -1159,7 +1174,7 @@ return array(
'horizontal' => __( 'Horizontal', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -1176,7 +1191,7 @@ return array(
'woocommerce-paypal-payments'
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -1200,7 +1215,7 @@ return array(
'pay' => __( 'Pay with PayPal', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -1224,7 +1239,7 @@ return array(
'black' => __( 'Black', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -1246,7 +1261,7 @@ return array(
'rect' => __( 'Rectangle', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -1257,7 +1272,7 @@ return array(
'heading' => __( 'Pay Later on Single Product Page', 'woocommerce-paypal-payments' ),
'type' => 'ppcp-heading',
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array( 'messages' ),
@ -1271,7 +1286,7 @@ return array(
'label' => __( 'Enable on Single Product', 'woocommerce-paypal-payments' ),
'default' => true,
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array( 'messages' ),
@ -1293,7 +1308,7 @@ return array(
'flex' => __( 'Flex', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array( 'messages' ),
@ -1317,7 +1332,7 @@ return array(
'none' => __( 'None', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array( 'messages' ),
@ -1340,7 +1355,7 @@ return array(
'top' => __( 'Top', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array( 'messages' ),
@ -1364,7 +1379,7 @@ return array(
'grayscale' => __( 'Grayscale', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array( 'messages' ),
@ -1391,7 +1406,7 @@ return array(
'grayscale' => __( 'Grayscale', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array( 'messages' ),
@ -1415,7 +1430,7 @@ return array(
'20x1' => __( '20x1', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array( 'messages' ),
@ -1427,7 +1442,7 @@ return array(
'heading' => __( 'Cart', 'woocommerce-paypal-payments' ),
'type' => 'ppcp-heading',
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -1440,7 +1455,7 @@ return array(
'label' => __( 'Enable on Cart', 'woocommerce-paypal-payments' ),
'default' => true,
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -1462,7 +1477,7 @@ return array(
'horizontal' => __( 'Horizontal', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -1479,7 +1494,7 @@ return array(
'woocommerce-paypal-payments'
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -1503,7 +1518,7 @@ return array(
'pay' => __( 'Pay with PayPal', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -1527,7 +1542,7 @@ return array(
'black' => __( 'Black', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -1549,7 +1564,7 @@ return array(
'rect' => __( 'Rectangle', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -1560,7 +1575,7 @@ return array(
'heading' => __( 'Pay Later on Cart', 'woocommerce-paypal-payments' ),
'type' => 'ppcp-heading',
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array( 'messages' ),
@ -1574,7 +1589,7 @@ return array(
'label' => __( 'Enable on Cart', 'woocommerce-paypal-payments' ),
'default' => true,
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array( 'messages' ),
@ -1596,7 +1611,7 @@ return array(
'flex' => __( 'Flex', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array( 'messages' ),
@ -1620,7 +1635,7 @@ return array(
'none' => __( 'None', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array( 'messages' ),
@ -1643,7 +1658,7 @@ return array(
'top' => __( 'Top', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array( 'messages' ),
@ -1667,7 +1682,7 @@ return array(
'grayscale' => __( 'Grayscale', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array( 'messages' ),
@ -1694,7 +1709,7 @@ return array(
'grayscale' => __( 'Grayscale', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array( 'messages' ),
@ -1718,7 +1733,7 @@ return array(
'20x1' => __( '20x1', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array( 'messages' ),
@ -1730,7 +1745,7 @@ return array(
'heading' => __( 'Mini Cart', 'woocommerce-paypal-payments' ),
'type' => 'ppcp-heading',
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -1743,7 +1758,7 @@ return array(
'label' => __( 'Enable on Mini Cart', 'woocommerce-paypal-payments' ),
'default' => true,
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -1765,7 +1780,7 @@ return array(
'horizontal' => __( 'Horizontal', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -1782,7 +1797,7 @@ return array(
'woocommerce-paypal-payments'
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -1806,7 +1821,7 @@ return array(
'pay' => __( 'Pay with PayPal', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -1830,7 +1845,7 @@ return array(
'black' => __( 'Black', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -1852,7 +1867,7 @@ return array(
'rect' => __( 'Rectangle', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -1865,7 +1880,7 @@ return array(
'desc_tip' => true,
'description' => __( 'Add a value from 25 to 55.', 'woocommerce-paypal-payments' ),
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -1989,14 +2004,6 @@ return array(
unset( $fields['vault_enabled'] );
}
if ( State::STATE_ONBOARDED === $state->production_state() ) {
unset( $fields['ppcp_disconnect_sandbox'] );
unset( $fields['credentials_sandbox_heading'] );
} elseif ( State::STATE_ONBOARDED === $state->sandbox_state() ) {
unset( $fields['ppcp_disconnect_production'] );
unset( $fields['credentials_production_heading'] );
}
/**
* Depending on your store location, some credit cards can't be used.
* Here, we filter them out.

View file

@ -71,6 +71,6 @@ class ConnectAdminNotice {
* @return bool
*/
protected function should_display(): bool {
return $this->state->current_state() < State::STATE_PROGRESSIVE;
return $this->state->current_state() !== State::STATE_ONBOARDED;
}
}

View file

@ -12,6 +12,7 @@ namespace WooCommerce\PayPalCommerce\WcGateway\Settings;
use WooCommerce\PayPalCommerce\AdminNotices\Entity\Message;
use WooCommerce\PayPalCommerce\ApiClient\Helper\DccApplies;
use WooCommerce\PayPalCommerce\Button\Helper\MessagesApply;
use WooCommerce\PayPalCommerce\Onboarding\Environment;
use WooCommerce\PayPalCommerce\Onboarding\State;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\CreditCardGateway;
use Psr\Container\ContainerInterface;
@ -388,7 +389,7 @@ $data_rows_html
<?php
foreach ( $this->fields as $field => $config ) :
if ( ! in_array( $this->state->current_state(), $config['screens'], true ) ) {
if ( ! in_array( $this->state->environment_state( $config['state_from'] ?? null ), $config['screens'], true ) ) {
continue;
}
if ( ! $this->field_matches_page( $config, $this->page_id ) ) {
@ -418,6 +419,7 @@ $data_rows_html
$config['id'] = $id;
$colspan = ( 'ppcp-heading' !== $config['type'] && isset( $config['title'] ) ) ? 1 : 2;
$classes = isset( $config['classes'] ) ? $config['classes'] : array();
$classes[] = 'ppcp-settings-field';
$classes[] = sprintf( 'ppcp-settings-field-%s', str_replace( 'ppcp-', '', $config['type'] ) );
if ( 1 !== $colspan ) {
$classes[] = 'ppcp-settings-no-title-col';

View file

@ -19,7 +19,6 @@ return array(
'title' => __( 'Subscribed webhooks', 'woocommerce-paypal-payments' ),
'type' => 'ppcp-table',
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -34,7 +33,6 @@ return array(
'type' => 'ppcp-text',
'text' => '<button type="button" class="button ppcp-webhooks-resubscribe">' . esc_html__( 'Resubscribe', 'woocommerce-paypal-payments' ) . '</button>',
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_ONBOARDED,
),
'requirements' => array(),
@ -53,7 +51,6 @@ return array(
'type' => 'ppcp-text',
'text' => '<button type="button" class="button ppcp-webhooks-simulate">' . esc_html__( 'Simulate', 'woocommerce-paypal-payments' ) . '</button>',
'screens' => array(
State::STATE_PROGRESSIVE,
State::STATE_ONBOARDED,
),
'requirements' => array(),

View file

@ -269,7 +269,6 @@ class WcGatewayTest extends TestCase
{
return [
[State::STATE_START, true],
[State::STATE_PROGRESSIVE, true],
[State::STATE_ONBOARDED, false]
];
}