From 08d8e6824f218befa13a0c42938e86b37f3c4037 Mon Sep 17 00:00:00 2001 From: David Remer Date: Mon, 24 Aug 2020 12:05:02 +0300 Subject: [PATCH] send form values of checkout to CreateOrderEndpoint --- .../modules/ActionHandler/CheckoutActionHandler.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/modules.local/ppcp-button/resources/js/modules/ActionHandler/CheckoutActionHandler.js b/modules.local/ppcp-button/resources/js/modules/ActionHandler/CheckoutActionHandler.js index 475c5ff0d..d06e57918 100644 --- a/modules.local/ppcp-button/resources/js/modules/ActionHandler/CheckoutActionHandler.js +++ b/modules.local/ppcp-button/resources/js/modules/ActionHandler/CheckoutActionHandler.js @@ -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; });