Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion inc/gateways/class-paypal-oauth-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
45 changes: 33 additions & 12 deletions inc/gateways/class-paypal-rest-gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
'<div class="wu-oauth-status-warning wu-p-4 wu-bg-red-50 wu-border wu-border-red-300 wu-rounded wu-mb-3">
<p class="wu-text-sm wu-text-red-800 wu-m-0">%s</p>
</div>',
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(
'<div class="wu-oauth-status-warning wu-p-4 wu-bg-red-50 wu-border wu-border-red-300 wu-rounded wu-mb-3">
<p class="wu-text-sm wu-text-red-800 wu-m-0">%s</p>
</div>',
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(
'<div class="wu-oauth-status wu-connected wu-p-4 wu-bg-green-50 wu-border wu-border-green-200 wu-rounded">
Expand Down Expand Up @@ -1936,22 +1957,22 @@ function () use ($nonce, $sandbox) {
});
});

$(".wu-paypal-disconnect").on("click", function(e) {
e.preventDefault();
if (!confirm(<?php echo wp_json_encode(__('Disconnecting your PayPal account will prevent you from offering PayPal services and products on your website. Do you wish to continue?', 'ultimate-multisite')); ?>)) return;
$(".wu-paypal-disconnect").on("click", function(e) {
e.preventDefault();
if (!confirm(<?php echo wp_json_encode(__('Disconnecting your PayPal account will prevent you from offering PayPal services and products on your website. Do you wish to continue?', 'ultimate-multisite')); ?>)) 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();
});
});
</script>
});
</script>
<?php
}
);
Expand Down
Loading