diff --git a/inc/gateways/class-paypal-oauth-handler.php b/inc/gateways/class-paypal-oauth-handler.php index f41cca792..82c83941c 100644 --- a/inc/gateways/class-paypal-oauth-handler.php +++ b/inc/gateways/class-paypal-oauth-handler.php @@ -269,7 +269,16 @@ public function handle_oauth_return(): void { // Clean up the tracking transient delete_site_transient('wu_paypal_onboarding_' . $tracking_id); - wu_log_add('paypal', sprintf('PayPal OAuth completed. Merchant ID: %s, Mode: %s, payments_receivable: %s, email_confirmed: %s', $merchant_id, $mode_prefix, $payments_receivable ? 'true' : 'false', $email_confirmed ? 'true' : 'false')); + wu_log_add( + 'paypal', + sprintf( + 'PayPal OAuth completed. Merchant ID: %s, Mode: %s, payments_receivable: %s, email_confirmed: %s', + $merchant_id, + $mode_prefix, + $payments_receivable ? 'true' : 'false', + $email_confirmed ? 'true' : 'false' + ) + ); // Automatically install webhooks for the connected account $this->install_webhook_after_oauth($mode_prefix); diff --git a/inc/gateways/class-paypal-rest-gateway.php b/inc/gateways/class-paypal-rest-gateway.php index 3b81ac7d3..415548b7d 100644 --- a/inc/gateways/class-paypal-rest-gateway.php +++ b/inc/gateways/class-paypal-rest-gateway.php @@ -1787,6 +1787,27 @@ public function render_oauth_connection(): void { $identifier = $status['details']['merchant_id'] ?? ($status['details']['email'] ?? ($status['details']['client_id'] ?? '')); + $mode_prefix = $this->test_mode ? 'sandbox' : 'live'; + $payments_receivable = (bool) wu_get_setting("paypal_rest_{$mode_prefix}_payments_receivable", true); + $email_confirmed = (bool) wu_get_setting("paypal_rest_{$mode_prefix}_email_confirmed", true); + + // Show required PayPal error banners when merchant status is incomplete + if (! $payments_receivable) { + printf( + '
+

%s

+
', + esc_html__('Attention: You currently cannot receive payments due to restriction on your PayPal account. Please reach out to PayPal Customer Support or connect to https://www.paypal.com for more information.', 'ultimate-multisite') + ); + } elseif (! $email_confirmed) { + printf( + '
+

%s

+
', + esc_html__('Attention: Please confirm your email address on https://www.paypal.com/businessprofile/settings in order to receive payments! You currently cannot receive payments.', 'ultimate-multisite') + ); + } + // Connected state printf( '
@@ -1936,22 +1957,22 @@ function () use ($nonce, $sandbox) { }); }); - $(".wu-paypal-disconnect").on("click", function(e) { - e.preventDefault(); - if (!confirm()) return; + $(".wu-paypal-disconnect").on("click", function(e) { + e.preventDefault(); + if (!confirm()) return; - var $btn = $(this); - $btn.prop("disabled", true); + var $btn = $(this); + $btn.prop("disabled", true); - $.post(ajaxurl, { - action: "wu_paypal_disconnect", - nonce: wuPayPalNonce - }, function(response) { - window.location.reload(); - }); + $.post(ajaxurl, { + action: "wu_paypal_disconnect", + nonce: wuPayPalNonce + }, function(response) { + window.location.reload(); }); }); - + }); +