mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Add mechanism to refresh feature status.
This commit is contained in:
parent
be28f81758
commit
d2abeb5dbf
8 changed files with 178 additions and 5 deletions
|
@ -353,5 +353,42 @@ document.addEventListener(
|
|||
}, 'card'));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
(() => {
|
||||
const props = PayPalCommerceGatewaySettings.ajax.refresh_feature_status;
|
||||
const $btn = jQuery(props.button);
|
||||
|
||||
$btn.click(async () => {
|
||||
$btn.prop('disabled', true);
|
||||
|
||||
const response = await fetch(
|
||||
props.endpoint,
|
||||
{
|
||||
method: 'POST',
|
||||
credentials: 'same-origin',
|
||||
headers: {
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(
|
||||
{
|
||||
nonce: props.nonce,
|
||||
}
|
||||
)
|
||||
}
|
||||
);
|
||||
|
||||
const responseData = await response.json();
|
||||
|
||||
if (!responseData.success) {
|
||||
alert(responseData.data.message);
|
||||
$btn.prop('disabled', false);
|
||||
} else {
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
|
||||
})();
|
||||
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue