mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-03 08:37:53 +08:00
39 lines
935 B
JavaScript
39 lines
935 B
JavaScript
|
|
||
|
class UpdatePaymentData {
|
||
|
|
||
|
constructor(config) {
|
||
|
this.config = config;
|
||
|
}
|
||
|
|
||
|
update(paymentData) {
|
||
|
return new Promise((resolve, reject) => {
|
||
|
fetch(
|
||
|
this.config.endpoint,
|
||
|
{
|
||
|
method: 'POST',
|
||
|
headers: {
|
||
|
'Content-Type': 'application/json'
|
||
|
},
|
||
|
credentials: 'same-origin',
|
||
|
body: JSON.stringify({
|
||
|
nonce: this.config.nonce,
|
||
|
paymentData: paymentData,
|
||
|
})
|
||
|
|
||
|
}
|
||
|
)
|
||
|
.then(result => result.json())
|
||
|
.then(result => {
|
||
|
if (!result.success) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
resolve(result.data);
|
||
|
});
|
||
|
});
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
export default UpdatePaymentData;
|