mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Merge branch 'master' of github.com:woocommerce/paypal-for-woocommerce
This commit is contained in:
commit
7fbd288fa4
19 changed files with 912 additions and 328 deletions
|
@ -47,10 +47,10 @@ use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
|||
|
||||
return array(
|
||||
'api.host' => function( $container ) : string {
|
||||
return 'https://api.paypal.com';
|
||||
return PAYPAL_API_URL;
|
||||
},
|
||||
'api.paypal-host' => function( $container ) : string {
|
||||
return 'https://api.paypal.com';
|
||||
return PAYPAL_API_URL;
|
||||
},
|
||||
'api.partner_merchant_id' => static function () : string {
|
||||
return '';
|
||||
|
|
|
@ -72,7 +72,6 @@ class PartnerReferralsData {
|
|||
private function default_data(): array {
|
||||
|
||||
return array(
|
||||
'email' => $this->merchant_email,
|
||||
'partner_config_override' => array(
|
||||
'partner_logo_url' => 'https://connect.woocommerce.com/images/woocommerce_logo.png',
|
||||
'return_url' => admin_url(
|
||||
|
|
|
@ -860,18 +860,23 @@ class SmartButton implements SmartButtonInterface {
|
|||
* @throws \WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException If a setting has not been found.
|
||||
*/
|
||||
private function dcc_is_enabled(): bool {
|
||||
if ( ! is_checkout() ) {
|
||||
return false;
|
||||
}
|
||||
if ( ! $this->dcc_applies->for_country_currency() ) {
|
||||
return false;
|
||||
}
|
||||
$keys = array(
|
||||
'dcc_enabled' => 'is_checkout',
|
||||
'client_id',
|
||||
'client_secret',
|
||||
'dcc_enabled',
|
||||
);
|
||||
foreach ( $keys as $key => $callback ) {
|
||||
if ( $this->settings->has( $key ) && $this->settings->get( $key ) && $callback() ) {
|
||||
return true;
|
||||
foreach ( $keys as $key ) {
|
||||
if ( ! $this->settings->has( $key ) || ! $this->settings->get( $key ) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,14 +2,28 @@
|
|||
display: none;
|
||||
}
|
||||
|
||||
#field-client_secret,
|
||||
#field-client_id,
|
||||
#field-merchant_id{
|
||||
#field-merchant_email_production,
|
||||
#field-ppcp_disconnect_sandbox,
|
||||
#field-ppcp_disconnect_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{
|
||||
display: none;
|
||||
}
|
||||
#field-client_secret.show,
|
||||
#field-client_id.show,
|
||||
#field-merchant_id.show {
|
||||
#field-merchant_email_production.show,
|
||||
#field-ppcp_disconnect_sandbox.show,
|
||||
#field-ppcp_disconnect_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 {
|
||||
display: table-row;
|
||||
}
|
||||
|
||||
|
@ -21,7 +35,8 @@
|
|||
display: unset;
|
||||
}
|
||||
|
||||
#field-toggle_manual_input button {
|
||||
#field-production_toggle_manual_input button,
|
||||
#field-sandbox_toggle_manual_input button {
|
||||
color: #0073aa;
|
||||
transition-property: border, background, color;
|
||||
transition-duration: .05s;
|
||||
|
@ -33,3 +48,34 @@
|
|||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#field-sandbox_toggle_manual_input.onboarded,
|
||||
#field-production_toggle_manual_input.onboarded {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
#field-ppcp_disconnect_sandbox.onboarded,
|
||||
#field-ppcp_disconnect_production.onboarded,
|
||||
#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-ppcp_disconnect_sandbox.onboarded.hide,
|
||||
#field-ppcp_disconnect_production.onboarded.hide,
|
||||
#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;
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
function onboardingCallback(authCode, sharedId) {
|
||||
const sandboxSwitchElement = document.querySelector('#ppcp-sandbox_on');
|
||||
fetch(
|
||||
PayPalCommerceGatewayOnboarding.endpoint,
|
||||
{
|
||||
|
@ -10,18 +11,186 @@ function onboardingCallback(authCode, sharedId) {
|
|||
{
|
||||
authCode: authCode,
|
||||
sharedId: sharedId,
|
||||
nonce: PayPalCommerceGatewayOnboarding.nonce
|
||||
nonce: PayPalCommerceGatewayOnboarding.nonce,
|
||||
env: sandboxSwitchElement && sandboxSwitchElement.checked ? 'sandbox' : 'production'
|
||||
}
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Since the PayPal modal will redirect the user a dirty form
|
||||
* provokes an alert if the user wants to leave the page. Since the user
|
||||
* needs to toggle the sandbox switch, we disable this dirty state with the
|
||||
* following workaround for checkboxes.
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
const checkBoxOnClick = (event) => {
|
||||
const value = event.target.checked;
|
||||
if (event.target.getAttribute('id') === 'ppcp-sandbox_on') {
|
||||
toggleSandboxProduction(! value);
|
||||
}
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
setTimeout( () => {
|
||||
event.target.checked = value;
|
||||
},1
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Toggles the credential input fields.
|
||||
*
|
||||
* @param forProduction
|
||||
*/
|
||||
const credentialToggle = (forProduction) => {
|
||||
|
||||
const sandboxClassSelectors = [
|
||||
'#field-ppcp_disconnect_sandbox',
|
||||
'#field-merchant_email_sandbox',
|
||||
'#field-merchant_id_sandbox',
|
||||
'#field-client_id_sandbox',
|
||||
'#field-client_secret_sandbox',
|
||||
];
|
||||
const productionClassSelectors = [
|
||||
'#field-ppcp_disconnect_production',
|
||||
'#field-merchant_email_production',
|
||||
'#field-merchant_id_production',
|
||||
'#field-client_id_production',
|
||||
'#field-client_secret_production',
|
||||
];
|
||||
|
||||
const selectors = forProduction ? productionClassSelectors : sandboxClassSelectors;
|
||||
document.querySelectorAll(selectors.join()).forEach(
|
||||
(element) => {element.classList.toggle('show')}
|
||||
)
|
||||
};
|
||||
|
||||
/**
|
||||
* Toggles the visibility of the sandbox/production input fields.
|
||||
*
|
||||
* @param showProduction
|
||||
*/
|
||||
const toggleSandboxProduction = (showProduction) => {
|
||||
const productionDisplaySelectors = [
|
||||
'#field-credentials_production_heading',
|
||||
'#field-production_toggle_manual_input',
|
||||
'#field-ppcp_onboarding_production',
|
||||
];
|
||||
const productionClassSelectors = [
|
||||
|
||||
'#field-ppcp_disconnect_production',
|
||||
'#field-merchant_email_production',
|
||||
'#field-merchant_id_production',
|
||||
'#field-client_id_production',
|
||||
'#field-client_secret_production',
|
||||
];
|
||||
const sandboxDisplaySelectors = [
|
||||
'#field-credentials_sandbox_heading',
|
||||
'#field-sandbox_toggle_manual_input',
|
||||
'#field-ppcp_onboarding_sandbox',
|
||||
];
|
||||
const sandboxClassSelectors = [
|
||||
'#field-ppcp_disconnect_sandbox',
|
||||
'#field-merchant_email_sandbox',
|
||||
'#field-merchant_id_sandbox',
|
||||
'#field-client_id_sandbox',
|
||||
'#field-client_secret_sandbox',
|
||||
];
|
||||
|
||||
if (showProduction) {
|
||||
document.querySelectorAll(productionDisplaySelectors.join()).forEach(
|
||||
(element) => {element.style.display = ''}
|
||||
);
|
||||
document.querySelectorAll(sandboxDisplaySelectors.join()).forEach(
|
||||
(element) => {element.style.display = 'none'}
|
||||
);
|
||||
document.querySelectorAll(productionClassSelectors.join()).forEach(
|
||||
(element) => {element.classList.remove('hide')}
|
||||
);
|
||||
document.querySelectorAll(sandboxClassSelectors.join()).forEach(
|
||||
(element) => {
|
||||
element.classList.remove('show');
|
||||
element.classList.add('hide');
|
||||
}
|
||||
);
|
||||
return;
|
||||
}
|
||||
document.querySelectorAll(productionDisplaySelectors.join()).forEach(
|
||||
(element) => {element.style.display = 'none'}
|
||||
);
|
||||
document.querySelectorAll(sandboxDisplaySelectors.join()).forEach(
|
||||
(element) => {element.style.display = ''}
|
||||
);
|
||||
|
||||
document.querySelectorAll(sandboxClassSelectors.join()).forEach(
|
||||
(element) => {element.classList.remove('hide')}
|
||||
);
|
||||
document.querySelectorAll(productionClassSelectors.join()).forEach(
|
||||
(element) => {
|
||||
element.classList.remove('show');
|
||||
element.classList.add('hide');
|
||||
}
|
||||
)
|
||||
};
|
||||
|
||||
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(fields.join()).forEach(
|
||||
(element) => {
|
||||
element.value = '';
|
||||
}
|
||||
);
|
||||
|
||||
document.querySelector('.woocommerce-save-button').click();
|
||||
};
|
||||
|
||||
(() => {
|
||||
const sandboxSwitchElement = document.querySelector('#ppcp-sandbox_on');
|
||||
if (sandboxSwitchElement) {
|
||||
toggleSandboxProduction(! sandboxSwitchElement.checked);
|
||||
}
|
||||
|
||||
document.querySelectorAll('.ppcp-disconnect').forEach(
|
||||
(button) => {
|
||||
button.addEventListener(
|
||||
'click',
|
||||
disconnect
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
document.querySelectorAll('#mainform input[type="checkbox"]').forEach(
|
||||
(checkbox) => {
|
||||
checkbox.addEventListener('click', checkBoxOnClick);
|
||||
}
|
||||
);
|
||||
|
||||
document.querySelectorAll('#field-sandbox_toggle_manual_input button, #field-production_toggle_manual_input button').forEach(
|
||||
(button) => {
|
||||
button.addEventListener(
|
||||
'click',
|
||||
(event) => {
|
||||
event.preventDefault();
|
||||
const isProduction = event.target.classList.contains('production-toggle');
|
||||
credentialToggle(isProduction);
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
.then( response => response.json() )
|
||||
.then(
|
||||
(data) => {
|
||||
if (data.success) {
|
||||
return;
|
||||
}
|
||||
alert( PayPalCommerceGatewayOnboarding.error )
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
})();
|
|
@ -15,7 +15,7 @@ const groupToggle = (selector, group) => {
|
|||
if (! event.target.checked) {
|
||||
group.forEach( (elementToHide) => {
|
||||
document.querySelector(elementToHide).style.display = 'none';
|
||||
})
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -24,8 +24,7 @@ const groupToggle = (selector, group) => {
|
|||
})
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
const groupToggleSelect = (selector, group) => {
|
||||
const toggleElement = document.querySelector(selector);
|
||||
|
@ -43,7 +42,7 @@ const groupToggleSelect = (selector, group) => {
|
|||
return;
|
||||
}
|
||||
domElement.style.display = 'none';
|
||||
})
|
||||
});
|
||||
toggleElement.addEventListener(
|
||||
'change',
|
||||
(event) => {
|
||||
|
@ -57,7 +56,7 @@ const groupToggleSelect = (selector, group) => {
|
|||
})
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const disableOptions = (sourceSelector, targetSelector) => {
|
||||
|
||||
|
@ -87,28 +86,14 @@ const disableOptions = (sourceSelector, targetSelector) => {
|
|||
target.append(option);
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
source.on('change',replace);
|
||||
replace();
|
||||
}
|
||||
};
|
||||
|
||||
(() => {
|
||||
const manualInputToggle = document.querySelector('#field-toggle_manual_input');
|
||||
if (manualInputToggle) {
|
||||
manualInputToggle.addEventListener(
|
||||
'click',
|
||||
(event) => {
|
||||
event.preventDefault();
|
||||
document.querySelector('#field-toggle_manual_input').classList.toggle('show');
|
||||
document.querySelector('#field-merchant_id').classList.toggle('show');
|
||||
document.querySelector('#field-client_id').classList.toggle('show');
|
||||
document.querySelector('#field-client_secret').classList.toggle('show');
|
||||
}
|
||||
)
|
||||
}
|
||||
disableOptions('select[name="ppcp[disable_cards][]"]', 'select[name="ppcp[card_icons][]"]');
|
||||
|
||||
groupToggle(
|
||||
'#ppcp-button_enabled',
|
||||
[
|
||||
|
@ -272,4 +257,4 @@ const disableOptions = (sourceSelector, targetSelector) => {
|
|||
}
|
||||
]
|
||||
);
|
||||
})()
|
||||
})();
|
|
@ -9,23 +9,36 @@ declare(strict_types=1);
|
|||
|
||||
namespace WooCommerce\PayPalCommerce\Onboarding;
|
||||
|
||||
use Dhii\Data\Container\ContainerInterface;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Authentication\Bearer;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Authentication\ConnectBearer;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Authentication\PayPalBearer;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\LoginSeller;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\PartnerReferrals;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Helper\Cache;
|
||||
use WooCommerce\PayPalCommerce\Onboarding\Assets\OnboardingAssets;
|
||||
use WooCommerce\PayPalCommerce\Onboarding\Endpoint\LoginSellerEndpoint;
|
||||
use WooCommerce\PayPalCommerce\Onboarding\Render\OnboardingRenderer;
|
||||
use WpOop\TransientCache\CachePoolFactory;
|
||||
|
||||
return array(
|
||||
'api.sandbox-host' => static function ( $container ): string {
|
||||
|
||||
$state = $container->get( 'onboarding.state' );
|
||||
|
||||
/**
|
||||
* The State object.
|
||||
*
|
||||
* @var State $state
|
||||
*/
|
||||
if ( $state->current_state() >= State::STATE_ONBOARDED ) {
|
||||
return PAYPAL_SANDBOX_API_URL;
|
||||
}
|
||||
// ToDo: Real connect.woocommerce.com sandbox link.
|
||||
return CONNECT_WOO_SANDBOX_URL;
|
||||
},
|
||||
'api.production-host' => static function ( $container ): string {
|
||||
|
||||
'api.host' => static function ( $container ): string {
|
||||
$state = $container->get( 'onboarding.state' );
|
||||
$environment = $container->get( 'onboarding.environment' );
|
||||
|
||||
// ToDo: Correct the URLs.
|
||||
/**
|
||||
* The Environment and State variables.
|
||||
*
|
||||
|
@ -33,20 +46,29 @@ return array(
|
|||
* @var State $state
|
||||
*/
|
||||
if ( $state->current_state() >= State::STATE_ONBOARDED ) {
|
||||
if ( $environment->current_environment_is( Environment::SANDBOX ) ) {
|
||||
return 'https://api.sandbox.paypal.com';
|
||||
}
|
||||
return 'https://api.sandbox.paypal.com';
|
||||
return PAYPAL_API_URL;
|
||||
}
|
||||
return CONNECT_WOO_URL;
|
||||
},
|
||||
'api.host' => static function ( $container ): string {
|
||||
$environment = $container->get( 'onboarding.environment' );
|
||||
|
||||
// ToDo: Real connect.woocommerce.com.
|
||||
if ( $environment->current_environment_is( Environment::SANDBOX ) ) {
|
||||
return 'http://connect-woo.wpcust.com/ppcsandbox';
|
||||
}
|
||||
return 'http://connect-woo.wpcust.com/ppc';
|
||||
/**
|
||||
* The Environment and State variables.
|
||||
*
|
||||
* @var Environment $environment
|
||||
*/
|
||||
return $environment->current_environment_is( Environment::SANDBOX )
|
||||
? (string) $container->get( 'api.sandbox-host' ) : (string) $container->get( 'api.production-host' );
|
||||
|
||||
},
|
||||
'api.paypal-host' => function( $container ) : string {
|
||||
'api.paypal-host-production' => static function( $container ) : string {
|
||||
return PAYPAL_API_URL;
|
||||
},
|
||||
'api.paypal-host-sandbox' => static function( $container ) : string {
|
||||
return PAYPAL_SANDBOX_API_URL;
|
||||
},
|
||||
'api.paypal-host' => function( $container ) : string {
|
||||
$environment = $container->get( 'onboarding.environment' );
|
||||
/**
|
||||
* The current environment.
|
||||
|
@ -54,12 +76,13 @@ return array(
|
|||
* @var Environment $environment
|
||||
*/
|
||||
if ( $environment->current_environment_is( Environment::SANDBOX ) ) {
|
||||
return 'https://api.sandbox.paypal.com';
|
||||
return $container->get( 'api.paypal-host-sandbox' );
|
||||
}
|
||||
return 'https://api.paypal.com';
|
||||
return $container->get( 'api.paypal-host-production' );
|
||||
|
||||
},
|
||||
|
||||
'api.bearer' => static function ( $container ): Bearer {
|
||||
'api.bearer' => static function ( $container ): Bearer {
|
||||
|
||||
$state = $container->get( 'onboarding.state' );
|
||||
|
||||
|
@ -85,17 +108,17 @@ return array(
|
|||
$logger
|
||||
);
|
||||
},
|
||||
'onboarding.state' => function( $container ) : State {
|
||||
'onboarding.state' => function( $container ) : State {
|
||||
$environment = $container->get( 'onboarding.environment' );
|
||||
$settings = $container->get( 'wcgateway.settings' );
|
||||
return new State( $environment, $settings );
|
||||
},
|
||||
'onboarding.environment' => function( $container ) : Environment {
|
||||
'onboarding.environment' => function( $container ) : Environment {
|
||||
$settings = $container->get( 'wcgateway.settings' );
|
||||
return new Environment( $settings );
|
||||
},
|
||||
|
||||
'onboarding.assets' => function( $container ) : OnboardingAssets {
|
||||
'onboarding.assets' => function( $container ) : OnboardingAssets {
|
||||
$state = $container->get( 'onboarding.state' );
|
||||
$login_seller_endpoint = $container->get( 'onboarding.endpoint.login-seller' );
|
||||
return new OnboardingAssets(
|
||||
|
@ -105,34 +128,78 @@ return array(
|
|||
);
|
||||
},
|
||||
|
||||
'onboarding.url' => static function ( $container ): string {
|
||||
'onboarding.url' => static function ( $container ): string {
|
||||
return plugins_url(
|
||||
'/modules/ppcp-onboarding/',
|
||||
dirname( __FILE__, 3 ) . '/woocommerce-paypal-commerce-gateway.php'
|
||||
);
|
||||
},
|
||||
|
||||
'onboarding.endpoint.login-seller' => static function ( $container ) : LoginSellerEndpoint {
|
||||
'api.endpoint.login-seller-production' => static function ( $container ) : LoginSeller {
|
||||
|
||||
$request_data = $container->get( 'button.request-data' );
|
||||
$login_seller = $container->get( 'api.endpoint.login-seller' );
|
||||
$partner_referrals_data = $container->get( 'api.repository.partner-referrals-data' );
|
||||
$settings = $container->get( 'wcgateway.settings' );
|
||||
$logger = $container->get( 'woocommerce.logger.woocommerce' );
|
||||
return new LoginSeller(
|
||||
$container->get( 'api.paypal-host-production' ),
|
||||
$container->get( 'api.partner_merchant_id' ),
|
||||
$logger
|
||||
);
|
||||
},
|
||||
|
||||
'api.endpoint.login-seller-sandbox' => static function ( $container ) : LoginSeller {
|
||||
|
||||
$logger = $container->get( 'woocommerce.logger.woocommerce' );
|
||||
return new LoginSeller(
|
||||
$container->get( 'api.paypal-host-sandbox' ),
|
||||
$container->get( 'api.partner_merchant_id' ),
|
||||
$logger
|
||||
);
|
||||
},
|
||||
|
||||
'onboarding.endpoint.login-seller' => static function ( $container ) : LoginSellerEndpoint {
|
||||
|
||||
$request_data = $container->get( 'button.request-data' );
|
||||
$login_seller_production = $container->get( 'api.endpoint.login-seller-production' );
|
||||
$login_seller_sandbox = $container->get( 'api.endpoint.login-seller-sandbox' );
|
||||
$partner_referrals_data = $container->get( 'api.repository.partner-referrals-data' );
|
||||
$settings = $container->get( 'wcgateway.settings' );
|
||||
|
||||
$cache = new Cache( 'ppcp-paypal-bearer' );
|
||||
return new LoginSellerEndpoint(
|
||||
$request_data,
|
||||
$login_seller,
|
||||
$login_seller_production,
|
||||
$login_seller_sandbox,
|
||||
$partner_referrals_data,
|
||||
$settings,
|
||||
$cache
|
||||
);
|
||||
},
|
||||
'onboarding.render' => static function ( $container ) : OnboardingRenderer {
|
||||
'api.endpoint.partner-referrals-sandbox' => static function ( $container ) : PartnerReferrals {
|
||||
|
||||
$partner_referrals = $container->get( 'api.endpoint.partner-referrals' );
|
||||
return new PartnerReferrals(
|
||||
CONNECT_WOO_SANDBOX_URL,
|
||||
new ConnectBearer(),
|
||||
$container->get( 'api.repository.partner-referrals-data' ),
|
||||
$container->get( 'woocommerce.logger.woocommerce' )
|
||||
);
|
||||
},
|
||||
'api.endpoint.partner-referrals-production' => static function ( $container ) : PartnerReferrals {
|
||||
|
||||
return new PartnerReferrals(
|
||||
CONNECT_WOO_SANDBOX_URL,
|
||||
new ConnectBearer(),
|
||||
$container->get( 'api.repository.partner-referrals-data' ),
|
||||
$container->get( 'woocommerce.logger.woocommerce' )
|
||||
);
|
||||
},
|
||||
'onboarding.render' => static function ( $container ) : OnboardingRenderer {
|
||||
|
||||
$partner_referrals = $container->get( 'api.endpoint.partner-referrals-production' );
|
||||
$partner_referrals_sandbox = $container->get( 'api.endpoint.partner-referrals-sandbox' );
|
||||
$settings = $container->get( 'wcgateway.settings' );
|
||||
return new OnboardingRenderer(
|
||||
$partner_referrals
|
||||
$settings,
|
||||
$partner_referrals,
|
||||
$partner_referrals_sandbox
|
||||
);
|
||||
},
|
||||
);
|
||||
|
|
|
@ -96,10 +96,6 @@ class OnboardingAssets {
|
|||
array(
|
||||
'endpoint' => home_url( \WC_AJAX::get_endpoint( LoginSellerEndpoint::ENDPOINT ) ),
|
||||
'nonce' => wp_create_nonce( $this->login_seller_endpoint::nonce() ),
|
||||
'error' => __(
|
||||
'We could not properly onboard you. Please reload and try again.',
|
||||
'paypal-payments-for-woocommerce'
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -129,11 +125,6 @@ class OnboardingAssets {
|
|||
*/
|
||||
private function should_render_onboarding_script(): bool {
|
||||
global $current_section;
|
||||
if ( 'ppcp-gateway' !== $current_section ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$should_render = $this->state->current_state() === State::STATE_PROGRESSIVE;
|
||||
return $should_render;
|
||||
return 'ppcp-gateway' === $current_section;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,11 +33,18 @@ class LoginSellerEndpoint implements EndpointInterface {
|
|||
private $request_data;
|
||||
|
||||
/**
|
||||
* The Login Seller Endpoint.
|
||||
* The Login Seller Endpoint for the production environment
|
||||
*
|
||||
* @var LoginSeller
|
||||
*/
|
||||
private $login_seller_endpoint;
|
||||
private $login_seller_production;
|
||||
|
||||
/**
|
||||
* The Login Seller Endpoint for the sandbox environment
|
||||
*
|
||||
* @var LoginSeller
|
||||
*/
|
||||
private $login_seller_sandbox;
|
||||
|
||||
/**
|
||||
* The Partner Referrals Data.
|
||||
|
@ -64,24 +71,27 @@ class LoginSellerEndpoint implements EndpointInterface {
|
|||
* LoginSellerEndpoint constructor.
|
||||
*
|
||||
* @param RequestData $request_data The Request Data.
|
||||
* @param LoginSeller $login_seller The Login Seller.
|
||||
* @param LoginSeller $login_seller_production The Login Seller for the production environment.
|
||||
* @param LoginSeller $login_seller_sandbox The Login Seller for the sandbox environment.
|
||||
* @param PartnerReferralsData $partner_referrals_data The Partner Referrals Data.
|
||||
* @param Settings $settings The Settings.
|
||||
* @param Cache $cache The Cache.
|
||||
*/
|
||||
public function __construct(
|
||||
RequestData $request_data,
|
||||
LoginSeller $login_seller,
|
||||
LoginSeller $login_seller_production,
|
||||
LoginSeller $login_seller_sandbox,
|
||||
PartnerReferralsData $partner_referrals_data,
|
||||
Settings $settings,
|
||||
Cache $cache
|
||||
) {
|
||||
|
||||
$this->request_data = $request_data;
|
||||
$this->login_seller_endpoint = $login_seller;
|
||||
$this->partner_referrals_data = $partner_referrals_data;
|
||||
$this->settings = $settings;
|
||||
$this->cache = $cache;
|
||||
$this->request_data = $request_data;
|
||||
$this->login_seller_production = $login_seller_production;
|
||||
$this->login_seller_sandbox = $login_seller_sandbox;
|
||||
$this->partner_referrals_data = $partner_referrals_data;
|
||||
$this->settings = $settings;
|
||||
$this->cache = $cache;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -101,12 +111,23 @@ class LoginSellerEndpoint implements EndpointInterface {
|
|||
public function handle_request(): bool {
|
||||
|
||||
try {
|
||||
$data = $this->request_data->read_request( $this->nonce() );
|
||||
$credentials = $this->login_seller_endpoint->credentials_for(
|
||||
$data = $this->request_data->read_request( $this->nonce() );
|
||||
$is_sandbox = isset( $data['env'] ) && 'sandbox' === $data['env'];
|
||||
$this->settings->set( 'sandbox_on', $is_sandbox );
|
||||
$this->settings->persist();
|
||||
$endpoint = $is_sandbox ? $this->login_seller_sandbox : $this->login_seller_production;
|
||||
$credentials = $endpoint->credentials_for(
|
||||
$data['sharedId'],
|
||||
$data['authCode'],
|
||||
$this->partner_referrals_data->nonce()
|
||||
);
|
||||
if ( $is_sandbox ) {
|
||||
$this->settings->set( 'client_secret_sandbox', $credentials->client_secret );
|
||||
$this->settings->set( 'client_id_sandbox', $credentials->client_id );
|
||||
} else {
|
||||
$this->settings->set( 'client_secret_production', $credentials->client_secret );
|
||||
$this->settings->set( 'client_id_production', $credentials->client_id );
|
||||
}
|
||||
$this->settings->set( 'client_secret', $credentials->client_secret );
|
||||
$this->settings->set( 'client_id', $credentials->client_id );
|
||||
$this->settings->persist();
|
||||
|
|
|
@ -11,6 +11,7 @@ namespace WooCommerce\PayPalCommerce\Onboarding\Render;
|
|||
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\PartnerReferrals;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
||||
|
||||
/**
|
||||
* Class OnboardingRenderer
|
||||
|
@ -18,52 +19,66 @@ use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
|||
class OnboardingRenderer {
|
||||
|
||||
/**
|
||||
* The partner referrals object.
|
||||
* The settings.
|
||||
*
|
||||
* @var Settings
|
||||
*/
|
||||
private $settings;
|
||||
|
||||
/**
|
||||
* The partner referrals object for the production environment.
|
||||
*
|
||||
* @var PartnerReferrals
|
||||
*/
|
||||
private $partner_referrals;
|
||||
private $production_partner_referrals;
|
||||
|
||||
/**
|
||||
* The partner referrals object for the sandbox environment.
|
||||
*
|
||||
* @var PartnerReferrals
|
||||
*/
|
||||
private $sandbox_partner_referrals;
|
||||
|
||||
/**
|
||||
* OnboardingRenderer constructor.
|
||||
*
|
||||
* @param PartnerReferrals $partner_referrals The PartnerReferrals.
|
||||
* @param Settings $settings The settings.
|
||||
* @param PartnerReferrals $production_partner_referrals The PartnerReferrals for production.
|
||||
* @param PartnerReferrals $sandbox_partner_referrals The PartnerReferrals for sandbox.
|
||||
*/
|
||||
public function __construct( PartnerReferrals $partner_referrals ) {
|
||||
$this->partner_referrals = $partner_referrals;
|
||||
public function __construct( Settings $settings, PartnerReferrals $production_partner_referrals, PartnerReferrals $sandbox_partner_referrals ) {
|
||||
$this->settings = $settings;
|
||||
$this->production_partner_referrals = $production_partner_referrals;
|
||||
$this->sandbox_partner_referrals = $sandbox_partner_referrals;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the "Connect to PayPal" button.
|
||||
*
|
||||
* @param bool $is_production Whether the production or sandbox button should be rendered.
|
||||
*/
|
||||
public function render() {
|
||||
public function render( bool $is_production ) {
|
||||
try {
|
||||
$url = add_query_arg(
|
||||
array(
|
||||
'displayMode' => 'minibrowser',
|
||||
),
|
||||
$this->partner_referrals->signup_link()
|
||||
$args = array(
|
||||
'displayMode' => 'minibrowser',
|
||||
);
|
||||
?>
|
||||
<a
|
||||
target="_blank"
|
||||
class="button-primary"
|
||||
data-paypal-onboard-complete="onboardingCallback"
|
||||
href="<?php echo esc_url( $url ); ?>"
|
||||
data-paypal-button="true"
|
||||
>
|
||||
<?php
|
||||
esc_html_e(
|
||||
'Connect to PayPal',
|
||||
'paypal-payments-for-woocommerce'
|
||||
);
|
||||
?>
|
||||
</a>
|
||||
<script>document.querySelector('[data-paypal-onboard-complete=onboardingCallback]').addEventListener('click', (e) => {if ('undefined' === typeof PAYPAL ) e.preventDefault(); });</script>
|
||||
<script
|
||||
id="paypal-js"
|
||||
src="https://www.sandbox.paypal.com/webapps/merchantboarding/js/lib/lightbox/partner.js"
|
||||
></script>
|
||||
|
||||
$url = $is_production ? $this->production_partner_referrals->signup_link() : $this->sandbox_partner_referrals->signup_link();
|
||||
$url = add_query_arg( $args, $url );
|
||||
$id = $is_production ? 'connect-to-production' : 'connect-to-sandbox';
|
||||
$label = $is_production ? __( 'Connect to PayPal', 'paypal-payments-for-woocommerce' ) : __( 'Connect to PayPal Sandbox', 'paypal-payments-for-woocommerce' );
|
||||
$this->render_button(
|
||||
$url,
|
||||
$id,
|
||||
$label
|
||||
);
|
||||
|
||||
$script_url = 'https://www.paypal.com/webapps/merchantboarding/js/lib/lightbox/partner.js'; ?>
|
||||
<script>document.querySelectorAll('[data-paypal-onboard-complete=onboardingCallback]').forEach( (element) => { element.addEventListener('click', (e) => {if ('undefined' === typeof PAYPAL ) e.preventDefault(); }) });</script>
|
||||
<script
|
||||
id="paypal-js"
|
||||
src="<?php echo esc_url( $script_url ); ?>"
|
||||
></script>
|
||||
<?php
|
||||
} catch ( RuntimeException $exception ) {
|
||||
esc_html_e(
|
||||
|
@ -72,4 +87,26 @@ class OnboardingRenderer {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the button.
|
||||
*
|
||||
* @param string $url The url of the button.
|
||||
* @param string $id The ID of the button.
|
||||
* @param string $label The button text.
|
||||
*/
|
||||
private function render_button( string $url, string $id, string $label ) {
|
||||
?>
|
||||
<a
|
||||
target="_blank"
|
||||
class="button-primary"
|
||||
id="<?php echo esc_attr( $id ); ?>"
|
||||
data-paypal-onboard-complete="onboardingCallback"
|
||||
href="<?php echo esc_url( $url ); ?>"
|
||||
data-paypal-button="true"
|
||||
>
|
||||
<?php echo esc_html( $label ); ?>
|
||||
</a>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,7 +69,8 @@ class OnboardingModule implements ModuleInterface {
|
|||
if ( 'ppcp_onboarding' !== $config['type'] ) {
|
||||
return $field;
|
||||
}
|
||||
$renderer = $container->get( 'onboarding.render' );
|
||||
$renderer = $container->get( 'onboarding.render' );
|
||||
$is_production = 'production' === $config['env'];
|
||||
|
||||
/**
|
||||
* The OnboardingRenderer.
|
||||
|
@ -77,7 +78,7 @@ class OnboardingModule implements ModuleInterface {
|
|||
* @var OnboardingRenderer $renderer
|
||||
*/
|
||||
ob_start();
|
||||
$renderer->render();
|
||||
$renderer->render( $is_production );
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
return $content;
|
||||
|
|
|
@ -50,29 +50,96 @@ class State {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the current onboarding state.
|
||||
* Returns the current active onboarding state.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function current_state(): int {
|
||||
$value = self::STATE_START;
|
||||
/**
|
||||
* Having provided the merchant email means, we are at least
|
||||
* in the progressive phase of our onboarding.
|
||||
*/
|
||||
if (
|
||||
$this->settings->has( 'merchant_email' )
|
||||
&& is_email( $this->settings->get( 'merchant_email' ) )
|
||||
) {
|
||||
$value = self::STATE_PROGRESSIVE;
|
||||
|
||||
return $this->state_by_keys(
|
||||
array(
|
||||
'merchant_email',
|
||||
),
|
||||
array(
|
||||
'merchant_email',
|
||||
'merchant_id',
|
||||
'client_id',
|
||||
'client_secret',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the onboarding state of the sandbox.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function sandbox_state() : int {
|
||||
|
||||
return $this->state_by_keys(
|
||||
array(
|
||||
'merchant_email_sandbox',
|
||||
),
|
||||
array(
|
||||
'merchant_email_sandbox',
|
||||
'merchant_id_sandbox',
|
||||
'client_id_sandbox',
|
||||
'client_secret_sandbox',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the onboarding state of the production mode.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function production_state() : int {
|
||||
|
||||
return $this->state_by_keys(
|
||||
array(
|
||||
'merchant_email_production',
|
||||
),
|
||||
array(
|
||||
'merchant_email_production',
|
||||
'merchant_id_production',
|
||||
'client_id_production',
|
||||
'client_secret_production',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Once we can fetch credentials we are completely onboarded.
|
||||
*/
|
||||
if ( $this->settings->has( 'client_id' ) && $this->settings->get( 'client_id' ) ) {
|
||||
$value = self::STATE_ONBOARDED;
|
||||
$is_onboarded = true;
|
||||
foreach ( $onboarded_keys as $key ) {
|
||||
if ( ! $this->settings->has( $key ) || ! $this->settings->get( $key ) ) {
|
||||
$is_onboarded = false;
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
|
||||
if ( $is_onboarded ) {
|
||||
$state = self::STATE_ONBOARDED;
|
||||
}
|
||||
|
||||
return $state;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -166,97 +166,89 @@ return array(
|
|||
},
|
||||
|
||||
'wcgateway.settings.fields' => static function ( $container ): array {
|
||||
$settings = $container->get( 'wcgateway.settings' );
|
||||
$sandbox_text = $settings->has( 'sandbox_on' ) && $settings->get( 'sandbox_on' ) ?
|
||||
// translators: %1$s and %2$s are button tags.
|
||||
__(
|
||||
'You are currently in the sandbox mode to test your installation. You can switch this, by clicking %1$sReset%2$s',
|
||||
'paypal-payments-for-woocommerce'
|
||||
) :
|
||||
// translators: %1$s and %2$s are button tags.
|
||||
__(
|
||||
'You are in live mode. This means, you can receive money into your account. You can switch this, by clicking %1$sReset%2$s',
|
||||
'paypal-payments-for-woocommerce'
|
||||
);
|
||||
$sandbox_text = sprintf(
|
||||
$sandbox_text,
|
||||
'<button name="save" value="reset">',
|
||||
'</button>'
|
||||
);
|
||||
|
||||
$merchant_email_text = sprintf(
|
||||
// translators: %1$s is the email address %2$s and %3$s are button tags.
|
||||
__(
|
||||
'You are connected with your email address %1$s.
|
||||
If you want to change this settings, please click %2$sReset%3$s',
|
||||
'paypal-payments-for-woocommerce'
|
||||
),
|
||||
$settings->has( 'merchant_email' ) ? '<mark>' . $settings->get( 'merchant_email' ) . '</mark>' : '',
|
||||
'<button name="save" value="reset">',
|
||||
'</button>'
|
||||
);
|
||||
$state = $container->get( 'onboarding.state' );
|
||||
/**
|
||||
* The state.
|
||||
*
|
||||
* @var State $state
|
||||
*/
|
||||
|
||||
$settings = $container->get( 'wcgateway.settings' );
|
||||
|
||||
$fields = array(
|
||||
'ppcp_onboarding' => array(
|
||||
'title' => __( 'Connect to PayPal', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'ppcp_onboarding',
|
||||
'screens' => array(
|
||||
State::STATE_PROGRESSIVE,
|
||||
),
|
||||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'sandbox_on' => array(
|
||||
'sandbox_on' => array(
|
||||
'title' => __( 'Sandbox', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'To test your WooCommerce installation, you can use the sandbox mode.', 'paypal-payments-for-woocommerce' ),
|
||||
'default' => 0,
|
||||
'screens' => array(
|
||||
State::STATE_START,
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
),
|
||||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'sandbox_on_info' => array(
|
||||
'title' => __( 'Sandbox', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'ppcp-text',
|
||||
'text' => $sandbox_text,
|
||||
|
||||
// Production credentials.
|
||||
'credentials_production_heading' => array(
|
||||
'heading' => __( 'API', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'ppcp-heading',
|
||||
'screens' => array(
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
),
|
||||
'hidden' => 'sandbox_on',
|
||||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'merchant_email' => array(
|
||||
'title' => __( 'Email address', 'paypal-payments-for-woocommerce' ),
|
||||
'ppcp_onboarding_production' => array(
|
||||
'title' => __( 'Connect to PayPal', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'ppcp_onboarding',
|
||||
'screens' => array(
|
||||
State::STATE_START,
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
),
|
||||
'env' => 'production',
|
||||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'ppcp_disconnect_production' => array(
|
||||
'title' => __( 'Disconnect from PayPal', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'ppcp-text',
|
||||
'classes' => array( State::STATE_ONBOARDED === $state->production_state() ? 'onboarded' : '' ),
|
||||
'text' => '<button type="button" class="button ppcp-disconnect production">' . esc_html__( 'Disconnect', 'paypal-payments-for-woocommerce' ) . '</button>',
|
||||
'screens' => array(
|
||||
State::STATE_START,
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
),
|
||||
'env' => 'production',
|
||||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'production_toggle_manual_input' => array(
|
||||
'type' => 'ppcp-text',
|
||||
'title' => __( 'Manual mode', 'paypal-payments-for-woocommerce' ),
|
||||
'classes' => array( State::STATE_ONBOARDED === $state->production_state() ? 'onboarded' : '' ),
|
||||
'text' => '<button type="button" id="ppcp[production_toggle_manual_input]" class="production-toggle">' . __( 'Toggle to manual credential input', 'paypal-payments-for-woocommerce' ) . '</button>',
|
||||
'screens' => array(
|
||||
State::STATE_START,
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
),
|
||||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'merchant_email_production' => array(
|
||||
'title' => __( 'Live Email address', 'paypal-payments-for-woocommerce' ),
|
||||
'classes' => array( State::STATE_ONBOARDED === $state->production_state() ? 'onboarded' : '' ),
|
||||
'type' => 'text',
|
||||
'required' => true,
|
||||
'desc_tip' => true,
|
||||
'description' => __( 'The email address of your PayPal account.', 'paypal-payments-for-woocommerce' ),
|
||||
'default' => '',
|
||||
'screens' => array(
|
||||
State::STATE_START,
|
||||
),
|
||||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'merchant_email_info' => array(
|
||||
'title' => __( 'Email address', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'ppcp-text',
|
||||
'text' => $merchant_email_text,
|
||||
'screens' => array(
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
),
|
||||
'hidden' => 'merchant_email',
|
||||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'toggle_manual_input' => array(
|
||||
'type' => 'ppcp-text',
|
||||
'title' => __( 'Manual mode', 'paypal-payments-for-woocommerce' ),
|
||||
'text' => '<button id="ppcp[toggle_manual_input]"><span class="show">' . __( 'Show manual credential input', 'paypal-payments-for-woocommerce' ) . '</span><span class="hide">' . __( 'Hide manual credential input', 'paypal-payments-for-woocommerce' ) . '</span></button>',
|
||||
'screens' => array(
|
||||
State::STATE_START,
|
||||
State::STATE_PROGRESSIVE,
|
||||
|
@ -265,8 +257,9 @@ return array(
|
|||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'merchant_id' => array(
|
||||
'title' => __( 'Merchant Id', 'paypal-payments-for-woocommerce' ),
|
||||
'merchant_id_production' => array(
|
||||
'title' => __( 'Live Merchant Id', 'paypal-payments-for-woocommerce' ),
|
||||
'classes' => array( State::STATE_ONBOARDED === $state->production_state() ? 'onboarded' : '' ),
|
||||
'type' => 'ppcp-text-input',
|
||||
'desc_tip' => true,
|
||||
'description' => __( 'The merchant id of your account ', 'paypal-payments-for-woocommerce' ),
|
||||
|
@ -279,8 +272,9 @@ return array(
|
|||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'client_id' => array(
|
||||
'title' => __( 'Client Id', 'paypal-payments-for-woocommerce' ),
|
||||
'client_id_production' => array(
|
||||
'title' => __( 'Live Client Id', 'paypal-payments-for-woocommerce' ),
|
||||
'classes' => array( State::STATE_ONBOARDED === $state->production_state() ? 'onboarded' : '' ),
|
||||
'type' => 'ppcp-text-input',
|
||||
'desc_tip' => true,
|
||||
'description' => __( 'The client id of your api ', 'paypal-payments-for-woocommerce' ),
|
||||
|
@ -293,8 +287,9 @@ return array(
|
|||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'client_secret' => array(
|
||||
'title' => __( 'Secret Key', 'paypal-payments-for-woocommerce' ),
|
||||
'client_secret_production' => array(
|
||||
'title' => __( 'Live Secret Key', 'paypal-payments-for-woocommerce' ),
|
||||
'classes' => array( State::STATE_ONBOARDED === $state->production_state() ? 'onboarded' : '' ),
|
||||
'type' => 'ppcp-password',
|
||||
'desc_tip' => true,
|
||||
'description' => __( 'The secret key of your api', 'paypal-payments-for-woocommerce' ),
|
||||
|
@ -308,7 +303,119 @@ return array(
|
|||
'gateway' => 'paypal',
|
||||
),
|
||||
|
||||
'checkout_settings_heading' => array(
|
||||
// Sandbox credentials.
|
||||
'credentials_sandbox_heading' => array(
|
||||
'heading' => __( 'Sandbox API', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'ppcp-heading',
|
||||
'screens' => array(
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
),
|
||||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'ppcp_onboarding_sandbox' => array(
|
||||
'title' => __( 'Connect to PayPal', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'ppcp_onboarding',
|
||||
'screens' => array(
|
||||
State::STATE_START,
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
),
|
||||
'env' => 'sandbox',
|
||||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'ppcp_disconnect_sandbox' => array(
|
||||
'title' => __( 'Disconnect from PayPal Sandbox', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'ppcp-text',
|
||||
'classes' => array( State::STATE_ONBOARDED === $state->sandbox_state() ? 'onboarded' : '' ),
|
||||
'text' => '<button type="button" class="button ppcp-disconnect sandbox">' . esc_html__( 'Disconnect', 'paypal-payments-for-woocommerce' ) . '</button>',
|
||||
'screens' => array(
|
||||
State::STATE_START,
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
),
|
||||
'env' => 'production',
|
||||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'sandbox_toggle_manual_input' => array(
|
||||
'type' => 'ppcp-text',
|
||||
'title' => __( 'Manual mode', 'paypal-payments-for-woocommerce' ),
|
||||
'classes' => array( State::STATE_ONBOARDED === $state->sandbox_state() ? 'onboarded' : '' ),
|
||||
'text' => '<button type="button" id="ppcp[sandbox_toggle_manual_input]" class="sandbox-toggle">' . __( 'Toggle to manual credential input', 'paypal-payments-for-woocommerce' ) . '</button>',
|
||||
'screens' => array(
|
||||
State::STATE_START,
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
),
|
||||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'merchant_email_sandbox' => array(
|
||||
'title' => __( 'Sandbox Email address', 'paypal-payments-for-woocommerce' ),
|
||||
'classes' => array( State::STATE_ONBOARDED === $state->sandbox_state() ? 'onboarded' : '' ),
|
||||
'type' => 'text',
|
||||
'required' => true,
|
||||
'desc_tip' => true,
|
||||
'description' => __( 'The email address of your PayPal account.', 'paypal-payments-for-woocommerce' ),
|
||||
'default' => '',
|
||||
'screens' => array(
|
||||
State::STATE_START,
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
),
|
||||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'merchant_id_sandbox' => array(
|
||||
'title' => __( 'Sandbox Merchant Id', 'paypal-payments-for-woocommerce' ),
|
||||
'classes' => array( State::STATE_ONBOARDED === $state->sandbox_state() ? 'onboarded' : '' ),
|
||||
'type' => 'ppcp-text-input',
|
||||
'desc_tip' => true,
|
||||
'description' => __( 'The merchant id of your account ', 'paypal-payments-for-woocommerce' ),
|
||||
'default' => false,
|
||||
'screens' => array(
|
||||
State::STATE_START,
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
),
|
||||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'client_id_sandbox' => array(
|
||||
'title' => __( 'Sandbox Client Id', 'paypal-payments-for-woocommerce' ),
|
||||
'classes' => array( State::STATE_ONBOARDED === $state->sandbox_state() ? 'onboarded' : '' ),
|
||||
'type' => 'ppcp-text-input',
|
||||
'desc_tip' => true,
|
||||
'description' => __( 'The client id of your api ', 'paypal-payments-for-woocommerce' ),
|
||||
'default' => false,
|
||||
'screens' => array(
|
||||
State::STATE_START,
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
),
|
||||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'client_secret_sandbox' => array(
|
||||
'title' => __( 'Sandbox Secret Key', 'paypal-payments-for-woocommerce' ),
|
||||
'classes' => array( State::STATE_ONBOARDED === $state->sandbox_state() ? 'onboarded' : '' ),
|
||||
'type' => 'ppcp-password',
|
||||
'desc_tip' => true,
|
||||
'description' => __( 'The secret key of your api', 'paypal-payments-for-woocommerce' ),
|
||||
'default' => false,
|
||||
'screens' => array(
|
||||
State::STATE_START,
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
),
|
||||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
|
||||
'checkout_settings_heading' => array(
|
||||
'heading' => __( 'PayPal Checkout Plugin Settings', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'ppcp-heading',
|
||||
'screens' => array(
|
||||
|
@ -318,7 +425,7 @@ return array(
|
|||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'title' => array(
|
||||
'title' => array(
|
||||
'title' => __( 'Title', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'text',
|
||||
'description' => __(
|
||||
|
@ -334,7 +441,7 @@ return array(
|
|||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'dcc_enabled' => array(
|
||||
'dcc_enabled' => array(
|
||||
'title' => __( 'Enable/Disable', 'paypal-payments-for-woocommerce' ),
|
||||
'desc_tip' => true,
|
||||
'description' => __( 'Once enabled, the Credit Card option will show up in the checkout.', 'paypal-payments-for-woocommerce' ),
|
||||
|
@ -349,7 +456,7 @@ return array(
|
|||
State::STATE_ONBOARDED,
|
||||
),
|
||||
),
|
||||
'dcc_gateway_title' => array(
|
||||
'dcc_gateway_title' => array(
|
||||
'title' => __( 'Title', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'text',
|
||||
'description' => __(
|
||||
|
@ -366,7 +473,7 @@ return array(
|
|||
),
|
||||
'gateway' => 'dcc',
|
||||
),
|
||||
'description' => array(
|
||||
'description' => array(
|
||||
'title' => __( 'Description', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'text',
|
||||
'desc_tip' => true,
|
||||
|
@ -385,7 +492,7 @@ return array(
|
|||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'intent' => array(
|
||||
'intent' => array(
|
||||
'title' => __( 'Intent', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'select',
|
||||
'class' => array( 'wc-enhanced-select' ),
|
||||
|
@ -405,7 +512,7 @@ return array(
|
|||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'capture_for_virtual_only' => array(
|
||||
'capture_for_virtual_only' => array(
|
||||
'title' => __( 'Capture Virtual-Only Orders ', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'checkbox',
|
||||
'default' => false,
|
||||
|
@ -421,7 +528,7 @@ return array(
|
|||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'payee_preferred' => array(
|
||||
'payee_preferred' => array(
|
||||
'title' => __( 'Instant Payments ', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'checkbox',
|
||||
'default' => false,
|
||||
|
@ -438,7 +545,7 @@ return array(
|
|||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'brand_name' => array(
|
||||
'brand_name' => array(
|
||||
'title' => __( 'Brand Name', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'text',
|
||||
'default' => get_bloginfo( 'name' ),
|
||||
|
@ -454,7 +561,7 @@ return array(
|
|||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'landing_page' => array(
|
||||
'landing_page' => array(
|
||||
'title' => __( 'Landing Page', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'select',
|
||||
'class' => array( 'wc-enhanced-select' ),
|
||||
|
@ -475,7 +582,7 @@ return array(
|
|||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'disable_funding' => array(
|
||||
'disable_funding' => array(
|
||||
'title' => __( 'Disable funding sources', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'ppcp-multiselect',
|
||||
'class' => array( 'wc-enhanced-select' ),
|
||||
|
@ -504,7 +611,7 @@ return array(
|
|||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'vault_enabled' => array(
|
||||
'vault_enabled' => array(
|
||||
'title' => __( 'Vaulting', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'checkbox',
|
||||
'desc_tip' => true,
|
||||
|
@ -518,7 +625,7 @@ return array(
|
|||
'gateway' => 'paypal',
|
||||
),
|
||||
|
||||
'logging_enabled' => array(
|
||||
'logging_enabled' => array(
|
||||
'title' => __( 'Logging', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'checkbox',
|
||||
'desc_tip' => true,
|
||||
|
@ -526,21 +633,19 @@ 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.', 'paypal-payments-for-woocommerce' ),
|
||||
'default' => false,
|
||||
'screens' => array(
|
||||
State::STATE_START,
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
),
|
||||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'prefix' => array(
|
||||
'prefix' => array(
|
||||
'title' => __( 'Invoice prefix', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'text',
|
||||
'desc_tip' => true,
|
||||
'description' => __( 'If you use your PayPal account with more than one installation, please use a distinct prefix to seperate those installations. Please do not use numbers in your prefix.', 'paypal-payments-for-woocommerce' ),
|
||||
'default' => 'WC-',
|
||||
'screens' => array(
|
||||
State::STATE_START,
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
),
|
||||
|
@ -549,7 +654,7 @@ return array(
|
|||
),
|
||||
|
||||
// General button styles.
|
||||
'button_style_heading' => array(
|
||||
'button_style_heading' => array(
|
||||
'heading' => __( 'Checkout', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'ppcp-heading',
|
||||
'screens' => array(
|
||||
|
@ -559,7 +664,7 @@ return array(
|
|||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'button_enabled' => array(
|
||||
'button_enabled' => array(
|
||||
'title' => __( 'Enable buttons on Checkout', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Enable on Checkout', 'paypal-payments-for-woocommerce' ),
|
||||
|
@ -571,7 +676,7 @@ return array(
|
|||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'button_layout' => array(
|
||||
'button_layout' => array(
|
||||
'title' => __( 'Button Layout', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'select',
|
||||
'class' => array( 'wc-enhanced-select' ),
|
||||
|
@ -592,7 +697,7 @@ return array(
|
|||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'button_tagline' => array(
|
||||
'button_tagline' => array(
|
||||
'title' => __( 'Tagline', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'checkbox',
|
||||
'default' => true,
|
||||
|
@ -609,7 +714,7 @@ return array(
|
|||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'button_label' => array(
|
||||
'button_label' => array(
|
||||
'title' => __( 'Button Label', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'select',
|
||||
'class' => array( 'wc-enhanced-select' ),
|
||||
|
@ -632,7 +737,7 @@ return array(
|
|||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'button_color' => array(
|
||||
'button_color' => array(
|
||||
'title' => __( 'Color', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'select',
|
||||
'class' => array( 'wc-enhanced-select' ),
|
||||
|
@ -655,7 +760,7 @@ return array(
|
|||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'button_shape' => array(
|
||||
'button_shape' => array(
|
||||
'title' => __( 'Shape', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'select',
|
||||
'class' => array( 'wc-enhanced-select' ),
|
||||
|
@ -676,7 +781,7 @@ return array(
|
|||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'message_heading' => array(
|
||||
'message_heading' => array(
|
||||
'heading' => __( 'Credit Messaging on Checkout', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'ppcp-heading',
|
||||
'screens' => array(
|
||||
|
@ -686,7 +791,7 @@ return array(
|
|||
'requirements' => array( 'messages' ),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'message_enabled' => array(
|
||||
'message_enabled' => array(
|
||||
'title' => __( 'Enable message on Checkout', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Enable on Checkout', 'paypal-payments-for-woocommerce' ),
|
||||
|
@ -698,7 +803,7 @@ return array(
|
|||
'requirements' => array( 'messages' ),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'message_layout' => array(
|
||||
'message_layout' => array(
|
||||
'title' => __( 'Credit Messaging layout', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'select',
|
||||
'class' => array( 'wc-enhanced-select' ),
|
||||
|
@ -719,7 +824,7 @@ return array(
|
|||
'requirements' => array( 'messages' ),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'message_logo' => array(
|
||||
'message_logo' => array(
|
||||
'title' => __( 'Credit Messaging logo', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'select',
|
||||
'class' => array( 'wc-enhanced-select' ),
|
||||
|
@ -742,7 +847,7 @@ return array(
|
|||
'requirements' => array( 'messages' ),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'message_position' => array(
|
||||
'message_position' => array(
|
||||
'title' => __( 'Credit Messaging logo position', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'select',
|
||||
'class' => array( 'wc-enhanced-select' ),
|
||||
|
@ -764,7 +869,7 @@ return array(
|
|||
'requirements' => array( 'messages' ),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'message_color' => array(
|
||||
'message_color' => array(
|
||||
'title' => __( 'Credit Messaging text color', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'select',
|
||||
'class' => array( 'wc-enhanced-select' ),
|
||||
|
@ -787,7 +892,7 @@ return array(
|
|||
'requirements' => array( 'messages' ),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'message_flex_color' => array(
|
||||
'message_flex_color' => array(
|
||||
'title' => __( 'Credit Messaging color', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'select',
|
||||
'class' => array( 'wc-enhanced-select' ),
|
||||
|
@ -813,7 +918,7 @@ return array(
|
|||
'requirements' => array( 'messages' ),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'message_flex_ratio' => array(
|
||||
'message_flex_ratio' => array(
|
||||
'title' => __( 'Credit Messaging ratio', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'select',
|
||||
'class' => array( 'wc-enhanced-select' ),
|
||||
|
@ -838,7 +943,7 @@ return array(
|
|||
),
|
||||
|
||||
// Single product page.
|
||||
'button_product_heading' => array(
|
||||
'button_product_heading' => array(
|
||||
'heading' => __( 'Button on Single product', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'ppcp-heading',
|
||||
'screens' => array(
|
||||
|
@ -848,7 +953,7 @@ return array(
|
|||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'button_product_enabled' => array(
|
||||
'button_product_enabled' => array(
|
||||
'title' => __( 'Enable buttons on Single Product', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Enable on Single Product', 'paypal-payments-for-woocommerce' ),
|
||||
|
@ -860,7 +965,7 @@ return array(
|
|||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'button_product_layout' => array(
|
||||
'button_product_layout' => array(
|
||||
'title' => __( 'Button Layout', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'select',
|
||||
'class' => array( 'wc-enhanced-select' ),
|
||||
|
@ -881,7 +986,7 @@ return array(
|
|||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'button_product_tagline' => array(
|
||||
'button_product_tagline' => array(
|
||||
'title' => __( 'Tagline', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Enable tagline', 'paypal-payments-for-woocommerce' ),
|
||||
|
@ -898,7 +1003,7 @@ return array(
|
|||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'button_product_label' => array(
|
||||
'button_product_label' => array(
|
||||
'title' => __( 'Button Label', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'select',
|
||||
'class' => array( 'wc-enhanced-select' ),
|
||||
|
@ -921,7 +1026,7 @@ return array(
|
|||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'button_product_color' => array(
|
||||
'button_product_color' => array(
|
||||
'title' => __( 'Color', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'select',
|
||||
'class' => array( 'wc-enhanced-select' ),
|
||||
|
@ -944,7 +1049,7 @@ return array(
|
|||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'button_product_shape' => array(
|
||||
'button_product_shape' => array(
|
||||
'title' => __( 'Shape', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'select',
|
||||
'class' => array( 'wc-enhanced-select' ),
|
||||
|
@ -966,7 +1071,7 @@ return array(
|
|||
'gateway' => 'paypal',
|
||||
),
|
||||
|
||||
'message_product_heading' => array(
|
||||
'message_product_heading' => array(
|
||||
'heading' => __( 'Credit Messaging on Single product', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'ppcp-heading',
|
||||
'screens' => array(
|
||||
|
@ -976,7 +1081,7 @@ return array(
|
|||
'requirements' => array( 'messages' ),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'message_product_enabled' => array(
|
||||
'message_product_enabled' => array(
|
||||
'title' => __( 'Enable message on Single Product', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Enable on Single Product', 'paypal-payments-for-woocommerce' ),
|
||||
|
@ -988,7 +1093,7 @@ return array(
|
|||
'requirements' => array( 'messages' ),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'message_product_layout' => array(
|
||||
'message_product_layout' => array(
|
||||
'title' => __( 'Credit Messaging layout', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'select',
|
||||
'class' => array( 'wc-enhanced-select' ),
|
||||
|
@ -1009,7 +1114,7 @@ return array(
|
|||
'requirements' => array( 'messages' ),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'message_product_logo' => array(
|
||||
'message_product_logo' => array(
|
||||
'title' => __( 'Credit Messaging logo', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'select',
|
||||
'class' => array( 'wc-enhanced-select' ),
|
||||
|
@ -1032,7 +1137,7 @@ return array(
|
|||
'requirements' => array( 'messages' ),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'message_product_position' => array(
|
||||
'message_product_position' => array(
|
||||
'title' => __( 'Credit Messaging logo position', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'select',
|
||||
'class' => array( 'wc-enhanced-select' ),
|
||||
|
@ -1054,7 +1159,7 @@ return array(
|
|||
'requirements' => array( 'messages' ),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'message_product_color' => array(
|
||||
'message_product_color' => array(
|
||||
'title' => __( 'Credit Messaging text color', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'select',
|
||||
'class' => array( 'wc-enhanced-select' ),
|
||||
|
@ -1077,7 +1182,7 @@ return array(
|
|||
'requirements' => array( 'messages' ),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'message_product_flex_color' => array(
|
||||
'message_product_flex_color' => array(
|
||||
'title' => __( 'Credit Messaging color', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'select',
|
||||
'class' => array( 'wc-enhanced-select' ),
|
||||
|
@ -1103,7 +1208,7 @@ return array(
|
|||
'requirements' => array( 'messages' ),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'message_product_flex_ratio' => array(
|
||||
'message_product_flex_ratio' => array(
|
||||
'title' => __( 'Credit Messaging ratio', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'select',
|
||||
'class' => array( 'wc-enhanced-select' ),
|
||||
|
@ -1128,7 +1233,7 @@ return array(
|
|||
),
|
||||
|
||||
// Mini cart settings.
|
||||
'button_mini-cart_heading' => array(
|
||||
'button_mini-cart_heading' => array(
|
||||
'heading' => __( 'Mini Cart', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'ppcp-heading',
|
||||
'screens' => array(
|
||||
|
@ -1138,7 +1243,7 @@ return array(
|
|||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'button_mini-cart_enabled' => array(
|
||||
'button_mini-cart_enabled' => array(
|
||||
'title' => __( 'Buttons on Mini Cart', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Enable on Mini Cart', 'paypal-payments-for-woocommerce' ),
|
||||
|
@ -1150,7 +1255,7 @@ return array(
|
|||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'button_mini-cart_layout' => array(
|
||||
'button_mini-cart_layout' => array(
|
||||
'title' => __( 'Button Layout', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'select',
|
||||
'class' => array( 'wc-enhanced-select' ),
|
||||
|
@ -1171,7 +1276,7 @@ return array(
|
|||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'button_mini-cart_tagline' => array(
|
||||
'button_mini-cart_tagline' => array(
|
||||
'title' => __( 'Tagline', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Enable tagline', 'paypal-payments-for-woocommerce' ),
|
||||
|
@ -1188,7 +1293,7 @@ return array(
|
|||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'button_mini-cart_label' => array(
|
||||
'button_mini-cart_label' => array(
|
||||
'title' => __( 'Button Label', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'select',
|
||||
'class' => array( 'wc-enhanced-select' ),
|
||||
|
@ -1211,7 +1316,7 @@ return array(
|
|||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'button_mini-cart_color' => array(
|
||||
'button_mini-cart_color' => array(
|
||||
'title' => __( 'Color', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'select',
|
||||
'class' => array( 'wc-enhanced-select' ),
|
||||
|
@ -1234,7 +1339,7 @@ return array(
|
|||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'button_mini-cart_shape' => array(
|
||||
'button_mini-cart_shape' => array(
|
||||
'title' => __( 'Shape', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'select',
|
||||
'class' => array( 'wc-enhanced-select' ),
|
||||
|
@ -1257,7 +1362,7 @@ return array(
|
|||
),
|
||||
|
||||
// Cart settings.
|
||||
'button_cart_heading' => array(
|
||||
'button_cart_heading' => array(
|
||||
'heading' => __( 'Cart', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'ppcp-heading',
|
||||
'screens' => array(
|
||||
|
@ -1267,7 +1372,7 @@ return array(
|
|||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'button_cart_enabled' => array(
|
||||
'button_cart_enabled' => array(
|
||||
'title' => __( 'Buttons on Cart', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Enable on Cart', 'paypal-payments-for-woocommerce' ),
|
||||
|
@ -1279,7 +1384,7 @@ return array(
|
|||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'button_cart_layout' => array(
|
||||
'button_cart_layout' => array(
|
||||
'title' => __( 'Button Layout', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'select',
|
||||
'class' => array( 'wc-enhanced-select' ),
|
||||
|
@ -1300,7 +1405,7 @@ return array(
|
|||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'button_cart_tagline' => array(
|
||||
'button_cart_tagline' => array(
|
||||
'title' => __( 'Tagline', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Enable tagline', 'paypal-payments-for-woocommerce' ),
|
||||
|
@ -1317,7 +1422,7 @@ return array(
|
|||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'button_cart_label' => array(
|
||||
'button_cart_label' => array(
|
||||
'title' => __( 'Button Label', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'select',
|
||||
'class' => array( 'wc-enhanced-select' ),
|
||||
|
@ -1340,7 +1445,7 @@ return array(
|
|||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'button_cart_color' => array(
|
||||
'button_cart_color' => array(
|
||||
'title' => __( 'Color', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'select',
|
||||
'class' => array( 'wc-enhanced-select' ),
|
||||
|
@ -1363,7 +1468,7 @@ return array(
|
|||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'button_cart_shape' => array(
|
||||
'button_cart_shape' => array(
|
||||
'title' => __( 'Shape', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'select',
|
||||
'class' => array( 'wc-enhanced-select' ),
|
||||
|
@ -1385,7 +1490,7 @@ return array(
|
|||
'gateway' => 'paypal',
|
||||
),
|
||||
|
||||
'message_cart_heading' => array(
|
||||
'message_cart_heading' => array(
|
||||
'heading' => __( 'Credit Messaging on Cart', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'ppcp-heading',
|
||||
'screens' => array(
|
||||
|
@ -1395,7 +1500,7 @@ return array(
|
|||
'requirements' => array( 'messages' ),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'message_cart_enabled' => array(
|
||||
'message_cart_enabled' => array(
|
||||
'title' => __( 'Enable message on Cart', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Enable on Cart', 'paypal-payments-for-woocommerce' ),
|
||||
|
@ -1407,7 +1512,7 @@ return array(
|
|||
'requirements' => array( 'messages' ),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'message_cart_layout' => array(
|
||||
'message_cart_layout' => array(
|
||||
'title' => __( 'Credit Messaging layout', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'select',
|
||||
'class' => array( 'wc-enhanced-select' ),
|
||||
|
@ -1428,7 +1533,7 @@ return array(
|
|||
'requirements' => array( 'messages' ),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'message_cart_logo' => array(
|
||||
'message_cart_logo' => array(
|
||||
'title' => __( 'Credit Messaging logo', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'select',
|
||||
'class' => array( 'wc-enhanced-select' ),
|
||||
|
@ -1451,7 +1556,7 @@ return array(
|
|||
'requirements' => array( 'messages' ),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'message_cart_position' => array(
|
||||
'message_cart_position' => array(
|
||||
'title' => __( 'Credit Messaging logo position', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'select',
|
||||
'class' => array( 'wc-enhanced-select' ),
|
||||
|
@ -1473,7 +1578,7 @@ return array(
|
|||
'requirements' => array( 'messages' ),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'message_cart_color' => array(
|
||||
'message_cart_color' => array(
|
||||
'title' => __( 'Credit Messaging text color', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'select',
|
||||
'class' => array( 'wc-enhanced-select' ),
|
||||
|
@ -1496,7 +1601,7 @@ return array(
|
|||
'requirements' => array( 'messages' ),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'message_cart_flex_color' => array(
|
||||
'message_cart_flex_color' => array(
|
||||
'title' => __( 'Credit Messaging color', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'select',
|
||||
'class' => array( 'wc-enhanced-select' ),
|
||||
|
@ -1522,7 +1627,7 @@ return array(
|
|||
'requirements' => array( 'messages' ),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'message_cart_flex_ratio' => array(
|
||||
'message_cart_flex_ratio' => array(
|
||||
'title' => __( 'Credit Messaging ratio', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'select',
|
||||
'class' => array( 'wc-enhanced-select' ),
|
||||
|
@ -1546,7 +1651,7 @@ return array(
|
|||
'gateway' => 'paypal',
|
||||
),
|
||||
|
||||
'disable_cards' => array(
|
||||
'disable_cards' => array(
|
||||
'title' => __( 'Disable specific credit cards', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'ppcp-multiselect',
|
||||
'class' => array( 'wc-enhanced-select' ),
|
||||
|
@ -1573,7 +1678,7 @@ return array(
|
|||
),
|
||||
'gateway' => 'dcc',
|
||||
),
|
||||
'card_icons' => array(
|
||||
'card_icons' => array(
|
||||
'title' => __( 'Show logo of the following credit cards', 'paypal-payments-for-woocommerce' ),
|
||||
'type' => 'ppcp-multiselect',
|
||||
'class' => array( 'wc-enhanced-select' ),
|
||||
|
@ -1604,6 +1709,18 @@ return array(
|
|||
if ( ! defined( 'PPCP_FLAG_SUBSCRIPTION' ) || ! PPCP_FLAG_SUBSCRIPTION ) {
|
||||
unset( $fields['vault_enabled'] );
|
||||
}
|
||||
|
||||
if ( State::STATE_ONBOARDED === $state->production_state() ) {
|
||||
unset( $fields['ppcp_onboarding_production'] );
|
||||
} else {
|
||||
unset( $fields['ppcp_disconnect_production'] );
|
||||
}
|
||||
if ( State::STATE_ONBOARDED === $state->sandbox_state() ) {
|
||||
unset( $fields['ppcp_onboarding_sandbox'] );
|
||||
} else {
|
||||
unset( $fields['ppcp_disconnect_sandbox'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable card for UK.
|
||||
*/
|
||||
|
|
|
@ -184,7 +184,9 @@ class PayPalGateway extends \WC_Payment_Gateway {
|
|||
'type' => 'ppcp',
|
||||
),
|
||||
);
|
||||
if ( $this->is_credit_card_tab() ) {
|
||||
|
||||
$should_show_enabled_checkbox = ! $this->is_credit_card_tab() && ( $this->config->has( 'merchant_email' ) && $this->config->get( 'merchant_email' ) );
|
||||
if ( ! $should_show_enabled_checkbox ) {
|
||||
unset( $this->form_fields['enabled'] );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,17 +72,6 @@ class Settings implements ContainerInterface {
|
|||
update_option( self::KEY, $this->settings );
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the onboarding.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function reset(): bool {
|
||||
$this->load();
|
||||
$this->settings = array();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the settings.
|
||||
|
|
|
@ -97,13 +97,32 @@ class SettingsListener {
|
|||
* phpcs:disable WordPress.Security.NonceVerification.Missing
|
||||
* phpcs:disable WordPress.Security.NonceVerification.Recommended
|
||||
*/
|
||||
if ( isset( $_GET['merchantIdInPayPal'] ) ) {
|
||||
$this->settings->set( 'merchant_id', sanitize_text_field( wp_unslash( $_GET['merchantIdInPayPal'] ) ) );
|
||||
$this->settings->persist();
|
||||
if ( ! isset( $_GET['merchantIdInPayPal'] ) || ! isset( $_GET['merchantId'] ) ) {
|
||||
return;
|
||||
}
|
||||
$merchant_id = sanitize_text_field( wp_unslash( $_GET['merchantIdInPayPal'] ) );
|
||||
$merchant_email = sanitize_text_field( wp_unslash( $_GET['merchantId'] ) );
|
||||
// phpcs:enable WordPress.Security.NonceVerification.Missing
|
||||
// phpcs:enable WordPress.Security.NonceVerification.Recommended
|
||||
|
||||
$this->settings->set( 'merchant_id', $merchant_id );
|
||||
$this->settings->set( 'merchant_email', $merchant_email );
|
||||
|
||||
$is_sandbox = $this->settings->has( 'sandbox_on' ) && $this->settings->get( 'sandbox_on' );
|
||||
if ( $is_sandbox ) {
|
||||
$this->settings->set( 'merchant_id_sandbox', $merchant_id );
|
||||
$this->settings->set( 'merchant_email_sandbox', $merchant_email );
|
||||
} else {
|
||||
$this->settings->set( 'merchant_id_production', $merchant_id );
|
||||
$this->settings->set( 'merchant_email_production', $merchant_email );
|
||||
}
|
||||
$this->settings->persist();
|
||||
$redirect_url = admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=ppcp-gateway' );
|
||||
if ( ! $this->settings->has( 'client_id' ) || ! $this->settings->get( 'client_id' ) ) {
|
||||
$redirect_url = admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=ppcp-gateway&ppcp-onboarding-error=1' );
|
||||
}
|
||||
wp_safe_redirect( $redirect_url, 302 );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -118,34 +137,28 @@ class SettingsListener {
|
|||
}
|
||||
|
||||
/**
|
||||
* Nonce verification has been done in is_valid_update_request().
|
||||
* Sanitization is done in retrieve_settings_from_raw_data().
|
||||
*
|
||||
* phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
|
||||
*
|
||||
* Nonce verification is done in is_valid_update_request().
|
||||
*
|
||||
* phpcs:disable WordPress.Security.NonceVerification.Missing
|
||||
* phpcs:disable WordPress.Security.NonceVerification.Recommended
|
||||
*/
|
||||
if ( isset( $_POST['save'] ) && sanitize_text_field( wp_unslash( $_POST['save'] ) ) === 'reset' ) {
|
||||
$this->settings->reset();
|
||||
$this->settings->persist();
|
||||
$this->webhook_registrar->unregister();
|
||||
if ( $this->cache->has( PayPalBearer::CACHE_KEY ) ) {
|
||||
$this->cache->delete( PayPalBearer::CACHE_KEY );
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitization is done in retrieve_settings_from_raw_data().
|
||||
*
|
||||
* phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
|
||||
*/
|
||||
$raw_data = ( isset( $_POST['ppcp'] ) ) ? (array) wp_unslash( $_POST['ppcp'] ) : array();
|
||||
// phpcs:enable phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
|
||||
$settings = $this->retrieve_settings_from_raw_data( $raw_data );
|
||||
|
||||
$settings = $this->read_active_credentials_from_settings( $settings );
|
||||
|
||||
if ( ! isset( $_GET[ SectionsRenderer::KEY ] ) || PayPalGateway::ID === $_GET[ SectionsRenderer::KEY ] ) {
|
||||
$settings['enabled'] = isset( $_POST['woocommerce_ppcp-gateway_enabled'] )
|
||||
&& 1 === absint( $_POST['woocommerce_ppcp-gateway_enabled'] );
|
||||
$this->maybe_register_webhooks( $settings );
|
||||
}
|
||||
// phpcs:enable phpcs:disable WordPress.Security.NonceVerification.Missing
|
||||
// phpcs:enable phpcs:disable WordPress.Security.NonceVerification.Missing
|
||||
|
||||
foreach ( $settings as $id => $value ) {
|
||||
$this->settings->set( $id, $value );
|
||||
|
@ -155,10 +168,36 @@ class SettingsListener {
|
|||
$this->cache->delete( PayPalBearer::CACHE_KEY );
|
||||
}
|
||||
|
||||
if ( isset( $_GET['ppcp-onboarding-error'] ) ) {
|
||||
$url = remove_query_arg( 'ppcp-onboarding-error' );
|
||||
wp_safe_redirect( $url, 302 );
|
||||
exit;
|
||||
}
|
||||
|
||||
// phpcs:enable WordPress.Security.NonceVerification.Missing
|
||||
// phpcs:enable WordPress.Security.NonceVerification.Recommended
|
||||
}
|
||||
|
||||
/**
|
||||
* The actual used client credentials are stored in 'client_secret', 'client_id', 'merchant_id' and 'merchant_email'.
|
||||
* This method populates those fields depending on the sandbox status.
|
||||
*
|
||||
* @param array $settings The settings array.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function read_active_credentials_from_settings( array $settings ) : array {
|
||||
if ( ! isset( $settings['client_id_sandbox'] ) && ! isset( $settings['client_id_production'] ) ) {
|
||||
return $settings;
|
||||
}
|
||||
$is_sandbox = isset( $settings['sandbox_on'] ) && $settings['sandbox_on'];
|
||||
$settings['client_id'] = $is_sandbox ? $settings['client_id_sandbox'] : $settings['client_id_production'];
|
||||
$settings['client_secret'] = $is_sandbox ? $settings['client_secret_sandbox'] : $settings['client_secret_production'];
|
||||
$settings['merchant_id'] = $is_sandbox ? $settings['merchant_id_sandbox'] : $settings['merchant_id_production'];
|
||||
$settings['merchant_email'] = $is_sandbox ? $settings['merchant_email_sandbox'] : $settings['merchant_email_production'];
|
||||
return $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Depending on the settings change, we might need to register or unregister the Webhooks at PayPal.
|
||||
*
|
||||
|
|
|
@ -9,6 +9,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace WooCommerce\PayPalCommerce\WcGateway\Settings;
|
||||
|
||||
use WooCommerce\PayPalCommerce\AdminNotices\Entity\Message;
|
||||
use WooCommerce\PayPalCommerce\AdminNotices\Repository\Repository;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Helper\DccApplies;
|
||||
use WooCommerce\PayPalCommerce\Button\Helper\MessagesApply;
|
||||
use WooCommerce\PayPalCommerce\Onboarding\State;
|
||||
|
@ -90,6 +92,34 @@ class SettingsRenderer {
|
|||
$this->dcc_product_status = $dcc_product_status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the notice, when onboarding failed.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function messages() : array {
|
||||
|
||||
//phpcs:disable WordPress.Security.NonceVerification.Recommended
|
||||
//phpcs:disable WordPress.Security.NonceVerification.Missing
|
||||
if ( ! isset( $_GET['ppcp-onboarding-error'] ) || ! empty( $_POST ) ) {
|
||||
return array();
|
||||
}
|
||||
//phpcs:enable WordPress.Security.NonceVerification.Recommended
|
||||
//phpcs:enable WordPress.Security.NonceVerification.Missing
|
||||
|
||||
$messages = array(
|
||||
new Message(
|
||||
__(
|
||||
'We could not complete the onboarding process. Some features, such as card processing, will not be available. To fix this, please try again.',
|
||||
'paypal-payments-for-woocommerce'
|
||||
),
|
||||
'error',
|
||||
false
|
||||
),
|
||||
);
|
||||
return $messages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the multiselect field.
|
||||
*
|
||||
|
@ -224,9 +254,12 @@ class SettingsRenderer {
|
|||
*/
|
||||
public function render() {
|
||||
|
||||
//phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
//phpcs:disable WordPress.Security.NonceVerification.Recommended
|
||||
//phpcs:disable WordPress.Security.NonceVerification.Missing
|
||||
$is_dcc = isset( $_GET[ SectionsRenderer::KEY ] ) && CreditCardGateway::ID === sanitize_text_field( wp_unslash( $_GET[ SectionsRenderer::KEY ] ) );
|
||||
$nonce = wp_create_nonce( SettingsListener::NONCE );
|
||||
//phpcs:enable WordPress.Security.NonceVerification.Recommended
|
||||
//phpcs:enable WordPress.Security.NonceVerification.Missing
|
||||
$nonce = wp_create_nonce( SettingsListener::NONCE );
|
||||
?>
|
||||
<input type="hidden" name="ppcp-nonce" value="<?php echo esc_attr( $nonce ); ?>">
|
||||
<?php
|
||||
|
@ -264,9 +297,9 @@ class SettingsRenderer {
|
|||
$config['id'] = $id;
|
||||
$th_td = 'ppcp-heading' !== $config['type'] ? 'td' : 'th';
|
||||
$colspan = 'ppcp-heading' !== $config['type'] ? 1 : 2;
|
||||
|
||||
$classes = isset( $config['classes'] ) ? $config['classes'] : array();
|
||||
?>
|
||||
<tr valign="top" id="<?php echo esc_attr( 'field-' . $field ); ?>">
|
||||
<tr valign="top" id="<?php echo esc_attr( 'field-' . $field ); ?>" class="<?php echo esc_attr( implode( ' ', $classes ) ); ?>">
|
||||
<?php if ( 'ppcp-heading' !== $config['type'] ) : ?>
|
||||
<th>
|
||||
<label
|
||||
|
|
|
@ -91,6 +91,15 @@ class WcGatewayModule implements ModuleInterface {
|
|||
$notices[] = $authorized_message;
|
||||
}
|
||||
|
||||
$settings_renderer = $container->get( 'wcgateway.settings.render' );
|
||||
/**
|
||||
* The settings renderer.
|
||||
*
|
||||
* @var SettingsRenderer $settings_renderer
|
||||
*/
|
||||
$messages = $settings_renderer->messages();
|
||||
$notices = array_merge( $notices, $messages );
|
||||
|
||||
return $notices;
|
||||
}
|
||||
);
|
||||
|
|
|
@ -22,6 +22,13 @@ use Dhii\Container\DelegatingContainer;
|
|||
use Dhii\Container\ProxyContainer;
|
||||
use Dhii\Modular\Module\ModuleInterface;
|
||||
|
||||
define( 'PAYPAL_API_URL', 'https://api.paypal.com' );
|
||||
define( 'PAYPAL_SANDBOX_API_URL', 'https://api.sandbox.paypal.com' );
|
||||
|
||||
// @ToDo: Real connect.woocommerce.com production link.
|
||||
define( 'CONNECT_WOO_URL', 'http://connect-woo.wpcust.com/ppc' );
|
||||
define( 'CONNECT_WOO_SANDBOX_URL', 'http://connect-woo.wpcust.com/ppcsandbox' );
|
||||
|
||||
( function () {
|
||||
include __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue