Intellipay improvements with Allan

This commit is contained in:
Patrick Fic
2023-08-15 14:59:35 -07:00
parent 6b66b76f84
commit c10517a11b
2 changed files with 58 additions and 11 deletions

View File

@@ -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 (
<Card title="Card Payment">
<Button
onClick={() => {
const data = {
operation: "approval",
response: {
messagetype: "paymentresponse",
status: 5,
custid: 39117514,
paymentid: 64430260,
response: "A",
authcode: "169753",
declinereason: "Approved",
avsresult: "Y",
fee: 0,
invoice: "",
account: "QBD272",
paymenttype: "C",
methodhint: "AX ***1002",
cardbrand: "American Express",
cardnumdisplay: "379859..1002",
amount: 0.01,
total: 0.01,
},
};
form.setFieldValue("paymentResponse", data);
form.submit();
}}
>
Test
</Button>
<Spin spinning={loading}>
<Form
onFinish={handleFinish}

View File

@@ -12,6 +12,7 @@ require("dotenv").config({
});
const domain = process.env.NODE_ENV ? "secure" : "test";
const SecretsManager = require("./aws-secrets-manager");
const {
SecretsManagerClient,
@@ -56,12 +57,13 @@ exports.lightbox_credentials = async (req, res) => {
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);