mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 13:44:42 +08:00
send form values of checkout to CreateOrderEndpoint
This commit is contained in:
parent
deffc2d0e8
commit
08d8e6824f
1 changed files with 9 additions and 3 deletions
|
@ -9,24 +9,30 @@ class CheckoutActionHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
configuration() {
|
configuration() {
|
||||||
|
|
||||||
const createOrder = (data, actions) => {
|
const createOrder = (data, actions) => {
|
||||||
const payer = payerData();
|
const payer = payerData();
|
||||||
const bnCode = typeof this.config.bn_codes[this.config.context] !== 'undefined' ?
|
const bnCode = typeof this.config.bn_codes[this.config.context] !== 'undefined' ?
|
||||||
this.config.bn_codes[this.config.context] : '';
|
this.config.bn_codes[this.config.context] : '';
|
||||||
|
|
||||||
|
|
||||||
|
const errorHandler = this.errorHandler;
|
||||||
|
const formValues = jQuery('form.checkout').serialize();
|
||||||
|
|
||||||
return fetch(this.config.ajax.create_order.endpoint, {
|
return fetch(this.config.ajax.create_order.endpoint, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
nonce: this.config.ajax.create_order.nonce,
|
nonce: this.config.ajax.create_order.nonce,
|
||||||
payer,
|
payer,
|
||||||
bn_code:bnCode,
|
bn_code:bnCode,
|
||||||
context:this.config.context
|
context:this.config.context,
|
||||||
|
form:formValues
|
||||||
})
|
})
|
||||||
}).then(function (res) {
|
}).then(function (res) {
|
||||||
return res.json();
|
return res.json();
|
||||||
}).then(function (data) {
|
}).then(function (data) {
|
||||||
if (!data.success) {
|
if (!data.success) {
|
||||||
throw Error(data.data);
|
errorHandler.message(data.data, true);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
return data.data.id;
|
return data.data.id;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue