Intellipay improvements with Allan
This commit is contained in:
@@ -7,7 +7,7 @@ import {
|
|||||||
InputNumber,
|
InputNumber,
|
||||||
Row,
|
Row,
|
||||||
Spin,
|
Spin,
|
||||||
notification
|
notification,
|
||||||
} from "antd";
|
} from "antd";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
@@ -97,14 +97,18 @@ const CardPaymentModalComponent = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleFinish = async (values) => {
|
const handleFinish = async (values) => {
|
||||||
|
console.log(
|
||||||
|
"🚀 ~ file: card-payment-modal.component..jsx:100 ~ handleFinish ~ values:",
|
||||||
|
values
|
||||||
|
);
|
||||||
try {
|
try {
|
||||||
const paymentResult = await insertPayment({
|
const paymentResult = await insertPayment({
|
||||||
variables: {
|
variables: {
|
||||||
paymentInput: {
|
paymentInput: {
|
||||||
amount: values.amount,
|
amount: values.amount,
|
||||||
transactionid: values.paymentResponse.receiptelements.transid,
|
transactionid: values.paymentResponse.paymentid,
|
||||||
payer: t("payments.labels.customer"),
|
payer: t("payments.labels.customer"),
|
||||||
type: values.paymentResponse.cardType,
|
type: values.paymentResponse.cardbrand,
|
||||||
jobid: values.jobid,
|
jobid: values.jobid,
|
||||||
date: moment(Date.now()),
|
date: moment(Date.now()),
|
||||||
},
|
},
|
||||||
@@ -138,6 +142,7 @@ const CardPaymentModalComponent = ({
|
|||||||
});
|
});
|
||||||
toggleModalVisible();
|
toggleModalVisible();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
@@ -146,16 +151,26 @@ const CardPaymentModalComponent = ({
|
|||||||
const handleIntelliPayCharge = async () => {
|
const handleIntelliPayCharge = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
|
console.warn("*** Window.Intellipay", !!window.intellipay);
|
||||||
|
|
||||||
const response = await axios.post("/intellipay/lightbox_credentials", {
|
const response = await axios.post("/intellipay/lightbox_credentials", {
|
||||||
bodyshop,
|
bodyshop,
|
||||||
|
refresh: !!window.intellipay,
|
||||||
});
|
});
|
||||||
var rg = document.createRange();
|
|
||||||
let node = rg.createContextualFragment(response.data);
|
|
||||||
document.documentElement.appendChild(node);
|
|
||||||
|
|
||||||
SetIntellipayCallbackFunctions();
|
if (window.intellipay) {
|
||||||
window.intellipay.isAutoOpen = true;
|
// eslint-disable-next-line no-eval
|
||||||
window.intellipay.initialize();
|
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) {
|
} catch (error) {
|
||||||
notification.open({
|
notification.open({
|
||||||
type: "error",
|
type: "error",
|
||||||
@@ -167,6 +182,36 @@ const CardPaymentModalComponent = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Card title="Card Payment">
|
<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}>
|
<Spin spinning={loading}>
|
||||||
<Form
|
<Form
|
||||||
onFinish={handleFinish}
|
onFinish={handleFinish}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ require("dotenv").config({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const domain = process.env.NODE_ENV ? "secure" : "test";
|
const domain = process.env.NODE_ENV ? "secure" : "test";
|
||||||
|
|
||||||
const SecretsManager = require("./aws-secrets-manager");
|
const SecretsManager = require("./aws-secrets-manager");
|
||||||
const {
|
const {
|
||||||
SecretsManagerClient,
|
SecretsManagerClient,
|
||||||
@@ -56,12 +57,13 @@ exports.lightbox_credentials = async (req, res) => {
|
|||||||
const options = {
|
const options = {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "content-type": "application/x-www-form-urlencoded" },
|
headers: { "content-type": "application/x-www-form-urlencoded" },
|
||||||
//TODO: Move these to environment variables/database.
|
|
||||||
data: qs.stringify({
|
data: qs.stringify({
|
||||||
...shopCredentials,
|
...shopCredentials,
|
||||||
operatingenv: "businessattended",
|
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);
|
const response = await axios(options);
|
||||||
|
|||||||
Reference in New Issue
Block a user