print warning when client_id is not present while trying to store merchant_email

This commit is contained in:
David Remer 2020-10-01 12:07:11 +03:00
parent fa1c2e4246
commit 321a32420f
2 changed files with 21 additions and 0 deletions

View file

@ -108,6 +108,12 @@ class SettingsListener {
$this->settings->set( 'merchant_id', $merchant_id ); $this->settings->set( 'merchant_id', $merchant_id );
$this->settings->set( 'merchant_email', $merchant_email ); $this->settings->set( 'merchant_email', $merchant_email );
if ( ! $this->settings->has( 'client_id' ) || ! $this->settings->get( 'client_id' ) ) {
$redirect_url = admin_url( 'admin.php?page=wc-settings&tab=checkout&section=ppcp-gateway&ppcp-onboarding-error=1' );
wp_safe_redirect( $redirect_url, 302 );
exit;
}
$is_sandbox = $this->settings->has( 'sandbox_on' ) && $this->settings->get( 'sandbox_on' ); $is_sandbox = $this->settings->has( 'sandbox_on' ) && $this->settings->get( 'sandbox_on' );
if ( $is_sandbox ) { if ( $is_sandbox ) {
$this->settings->set( 'merchant_id_sandbox', $merchant_id ); $this->settings->set( 'merchant_id_sandbox', $merchant_id );

View file

@ -224,6 +224,21 @@ class SettingsRenderer {
*/ */
public function render() { public function render() {
//phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( isset( $_GET['ppcp-onboarding-error'] ) ) :
?>
<div class="notice notice-error">
<p><strong>
<?php
esc_html_e(
'We could not properly fetch the necessary credentials. Please try again.',
'paypal-payments-for-woocommerce'
);
?>
</strong></p>
</div>
<?php
endif;
//phpcs:ignore WordPress.Security.NonceVerification.Recommended //phpcs:ignore WordPress.Security.NonceVerification.Recommended
$is_dcc = isset( $_GET[ SectionsRenderer::KEY ] ) && CreditCardGateway::ID === sanitize_text_field( wp_unslash( $_GET[ SectionsRenderer::KEY ] ) ); $is_dcc = isset( $_GET[ SectionsRenderer::KEY ] ) && CreditCardGateway::ID === sanitize_text_field( wp_unslash( $_GET[ SectionsRenderer::KEY ] ) );
$nonce = wp_create_nonce( SettingsListener::NONCE ); $nonce = wp_create_nonce( SettingsListener::NONCE );