send form values of checkout to CreateOrderEndpoint

This commit is contained in:
David Remer 2020-08-24 12:05:02 +03:00
parent deffc2d0e8
commit 08d8e6824f

View file

@ -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;
}); });