mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 10:55:00 +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() {
|
||||
|
||||
const createOrder = (data, actions) => {
|
||||
const payer = payerData();
|
||||
const bnCode = typeof this.config.bn_codes[this.config.context] !== 'undefined' ?
|
||||
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, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
nonce: this.config.ajax.create_order.nonce,
|
||||
payer,
|
||||
bn_code:bnCode,
|
||||
context:this.config.context
|
||||
context:this.config.context,
|
||||
form:formValues
|
||||
})
|
||||
}).then(function (res) {
|
||||
return res.json();
|
||||
}).then(function (data) {
|
||||
if (!data.success) {
|
||||
throw Error(data.data);
|
||||
errorHandler.message(data.data, true);
|
||||
return;
|
||||
}
|
||||
return data.data.id;
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue