From 1b2b30590ba4afefcf9e0dc66e78348afc289c2d Mon Sep 17 00:00:00 2001 From: Dominik Hebeler <dominik@suma-ev.de> Date: Mon, 14 Nov 2022 16:37:49 +0100 Subject: [PATCH] added capture to paypal checkout --- pass/app/Order.js | 6 ++++-- pass/routes/checkout/paypal.js | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pass/app/Order.js b/pass/app/Order.js index 052720e..d859d78 100644 --- a/pass/app/Order.js +++ b/pass/app/Order.js @@ -105,7 +105,9 @@ class Order { order_data.encrypted_sales_receipts ); if (order_data.payment_method_link) { - loaded_order.setPaymentMethodLink(order_data.payment_method_link); + loaded_order.setPaymentMethodLink( + JSON.parse(order_data.payment_method_link) + ); } loaded_order.set_create_mode(false); resolve(loaded_order); @@ -136,7 +138,7 @@ class Order { price_per_unit: this.#price_per_unit, encrypted_sales_receipts: this.#encrypted_sales_receipts, payment_completed: this.#payment_completed, - payment_method_link: this.#payment_method_link, + payment_method_link: JSON.stringify(this.#payment_method_link), }) .then((result) => { this.#create_mode = false; diff --git a/pass/routes/checkout/paypal.js b/pass/routes/checkout/paypal.js index 41e5fa6..1cde1f4 100644 --- a/pass/routes/checkout/paypal.js +++ b/pass/routes/checkout/paypal.js @@ -39,8 +39,9 @@ router.post("/", async (req, res, next) => { router.post("/capture", async (req, res) => { Order.LOAD_ORDER_FROM_ID(req.body.order_id).then((loaded_order) => { let paypal_order_id = loaded_order.getPaymentMethodLink().id; - console.log(paypal_order_id); - //const captureData = await capturePayment(orderID); + capturePayment(paypal_order_id).then((captureData) => + res.json(captureData) + ); //res.json(captureData); // TODO: store payment information such as the transaction ID }); -- GitLab