Fix postback handling.
This commit is contained in:
@@ -97,16 +97,12 @@ 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.paymentid,
|
transactionid: (values.paymentResponse.paymentid || "").toString(),
|
||||||
payer: t("payments.labels.customer"),
|
payer: t("payments.labels.customer"),
|
||||||
type: values.paymentResponse.cardbrand,
|
type: values.paymentResponse.cardbrand,
|
||||||
jobid: values.jobid,
|
jobid: values.jobid,
|
||||||
|
|||||||
@@ -177,6 +177,7 @@ export function JobPayments({
|
|||||||
bodyshop,
|
bodyshop,
|
||||||
amount: balance.getAmount(),
|
amount: balance.getAmount(),
|
||||||
account: job.ro_number,
|
account: job.ro_number,
|
||||||
|
invoice: job.id,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
setGeneratingtURL(false);
|
setGeneratingtURL(false);
|
||||||
|
|||||||
@@ -987,6 +987,7 @@ exports.GET_JOB_BY_PK = `query GET_JOB_BY_PK($id: uuid!) {
|
|||||||
ins_ph1
|
ins_ph1
|
||||||
est_co_nm
|
est_co_nm
|
||||||
est_ct_fn
|
est_ct_fn
|
||||||
|
shopid
|
||||||
est_ct_ln
|
est_ct_ln
|
||||||
vehicle{
|
vehicle{
|
||||||
id
|
id
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ const queries = require("../graphql-client/queries");
|
|||||||
const Dinero = require("dinero.js");
|
const Dinero = require("dinero.js");
|
||||||
const qs = require("query-string");
|
const qs = require("query-string");
|
||||||
const axios = require("axios");
|
const axios = require("axios");
|
||||||
|
const moment = require("moment");
|
||||||
require("dotenv").config({
|
require("dotenv").config({
|
||||||
path: path.resolve(
|
path: path.resolve(
|
||||||
process.cwd(),
|
process.cwd(),
|
||||||
@@ -111,6 +112,7 @@ exports.generate_payment_url = async (req, res) => {
|
|||||||
data: qs.stringify({
|
data: qs.stringify({
|
||||||
...shopCredentials,
|
...shopCredentials,
|
||||||
...req.body,
|
...req.body,
|
||||||
|
bodyshopid: "1234",
|
||||||
createshorturl: true,
|
createshorturl: true,
|
||||||
//The postback URL is set at the CP teller global terminal settings page.
|
//The postback URL is set at the CP teller global terminal settings page.
|
||||||
}),
|
}),
|
||||||
@@ -131,9 +133,13 @@ exports.postback = async (req, res) => {
|
|||||||
|
|
||||||
const { body: values } = req;
|
const { body: values } = req;
|
||||||
|
|
||||||
|
if (!values.invoice) {
|
||||||
|
res.sendStatus(200);
|
||||||
|
return;
|
||||||
|
}
|
||||||
// TODO query job by account name
|
// TODO query job by account name
|
||||||
const job = await gqlClient.request(queries.GET_JOB_BY_RO_NUMBER, {
|
const job = await gqlClient.request(queries.GET_JOB_BY_PK, {
|
||||||
ro_number: values.account,
|
id: values.invoice,
|
||||||
});
|
});
|
||||||
// TODO add mutation to database
|
// TODO add mutation to database
|
||||||
|
|
||||||
@@ -143,7 +149,7 @@ exports.postback = async (req, res) => {
|
|||||||
transactionid: `C00 ${values.authcode}`,
|
transactionid: `C00 ${values.authcode}`,
|
||||||
payer: "Customer",
|
payer: "Customer",
|
||||||
type: values.cardtype,
|
type: values.cardtype,
|
||||||
jobid: job.jobs[0].id,
|
jobid: values.invoice,
|
||||||
date: moment(Date.now()),
|
date: moment(Date.now()),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -151,9 +157,9 @@ exports.postback = async (req, res) => {
|
|||||||
await gqlClient.request(queries.INSERT_PAYMENT_RESPONSE, {
|
await gqlClient.request(queries.INSERT_PAYMENT_RESPONSE, {
|
||||||
paymentResponse: {
|
paymentResponse: {
|
||||||
amount: values.total,
|
amount: values.total,
|
||||||
bodyshopid: job.jobs[0].bodyshop.id,
|
bodyshopid: job.jobs_by_pk.shopid,
|
||||||
paymentid: paymentResult.id,
|
paymentid: paymentResult.id,
|
||||||
jobid: job.jobs[0].id,
|
jobid: values.invoice,
|
||||||
declinereason: "Approved",
|
declinereason: "Approved",
|
||||||
ext_paymentid: values.paymentid,
|
ext_paymentid: values.paymentid,
|
||||||
successful: true,
|
successful: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user