mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Add delete payment functionality
This commit is contained in:
parent
964936ee17
commit
28b12af089
7 changed files with 243 additions and 56 deletions
|
@ -3,7 +3,39 @@ document.addEventListener(
|
|||
() => {
|
||||
jQuery('.ppcp-delete-payment-button').click(async (event) => {
|
||||
event.preventDefault();
|
||||
jQuery(this).prop('disabled', true);
|
||||
const token = event.target.id;
|
||||
|
||||
console.log(event.target.id)
|
||||
const response = await fetch(
|
||||
PayPalCommerceGatewayVaulting.delete.endpoint,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(
|
||||
{
|
||||
nonce: PayPalCommerceGatewayVaulting.delete.nonce,
|
||||
token,
|
||||
}
|
||||
)
|
||||
}
|
||||
);
|
||||
|
||||
const reportError = error => {
|
||||
alert(error);
|
||||
}
|
||||
|
||||
if (!response.ok) {
|
||||
try {
|
||||
const result = await response.json();
|
||||
reportError(result.data);
|
||||
} catch (exc) {
|
||||
console.error(exc);
|
||||
reportError(response.status);
|
||||
}
|
||||
}
|
||||
|
||||
window.location.reload();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue