From c10517a11b6edcd8faa37011a4847212f1fc5d4f Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Tue, 15 Aug 2023 14:59:35 -0700 Subject: [PATCH] Intellipay improvements with Allan --- .../card-payment-modal.component..jsx | 63 ++++++++++++++++--- server/intellipay/intellipay.js | 6 +- 2 files changed, 58 insertions(+), 11 deletions(-) diff --git a/client/src/components/card-payment-modal/card-payment-modal.component..jsx b/client/src/components/card-payment-modal/card-payment-modal.component..jsx index 755282bb2..13b5e6c68 100644 --- a/client/src/components/card-payment-modal/card-payment-modal.component..jsx +++ b/client/src/components/card-payment-modal/card-payment-modal.component..jsx @@ -7,7 +7,7 @@ import { InputNumber, Row, Spin, - notification + notification, } from "antd"; import axios from "axios"; import moment from "moment"; @@ -97,14 +97,18 @@ const CardPaymentModalComponent = ({ }; const handleFinish = async (values) => { + console.log( + "🚀 ~ file: card-payment-modal.component..jsx:100 ~ handleFinish ~ values:", + values + ); try { const paymentResult = await insertPayment({ variables: { paymentInput: { amount: values.amount, - transactionid: values.paymentResponse.receiptelements.transid, + transactionid: values.paymentResponse.paymentid, payer: t("payments.labels.customer"), - type: values.paymentResponse.cardType, + type: values.paymentResponse.cardbrand, jobid: values.jobid, date: moment(Date.now()), }, @@ -138,6 +142,7 @@ const CardPaymentModalComponent = ({ }); toggleModalVisible(); } catch (error) { + console.error(error); } finally { setLoading(false); } @@ -146,16 +151,26 @@ const CardPaymentModalComponent = ({ const handleIntelliPayCharge = async () => { setLoading(true); try { + console.warn("*** Window.Intellipay", !!window.intellipay); + const response = await axios.post("/intellipay/lightbox_credentials", { bodyshop, + refresh: !!window.intellipay, }); - var rg = document.createRange(); - let node = rg.createContextualFragment(response.data); - document.documentElement.appendChild(node); - SetIntellipayCallbackFunctions(); - window.intellipay.isAutoOpen = true; - window.intellipay.initialize(); + if (window.intellipay) { + // eslint-disable-next-line no-eval + eval(response.data); + SetIntellipayCallbackFunctions(); + window.intellipay.autoOpen(); + } else { + var rg = document.createRange(); + let node = rg.createContextualFragment(response.data); + document.documentElement.appendChild(node); + SetIntellipayCallbackFunctions(); + window.intellipay.isAutoOpen = true; + window.intellipay.initialize(); + } } catch (error) { notification.open({ type: "error", @@ -167,6 +182,36 @@ const CardPaymentModalComponent = ({ return ( +
{ const options = { method: "POST", headers: { "content-type": "application/x-www-form-urlencoded" }, - //TODO: Move these to environment variables/database. data: qs.stringify({ ...shopCredentials, operatingenv: "businessattended", }), - url: `https://${domain}.cpteller.com/api/custapi.cfc?method=autoterminal`, + url: `https://${domain}.cpteller.com/api/custapi.cfc?method=autoterminal${ + req.body.refresh ? "_refresh" : "" + }`, //autoterminal_refresh }; const response = await axios(options);