diff --git a/client/src/components/payment-form/payment-form.totalpayments.component.jsx b/client/src/components/payment-form/payment-form.totalpayments.component.jsx
index ff362ae39..06da88105 100644
--- a/client/src/components/payment-form/payment-form.totalpayments.component.jsx
+++ b/client/src/components/payment-form/payment-form.totalpayments.component.jsx
@@ -20,7 +20,9 @@ export default function PaymentFormTotalPayments({ jobid }) {
if (!data) return <>>;
const totalPayments = data.jobs_by_pk.payments.reduce((acc, val) => {
- return acc.add(Dinero({ amount: (val.amount || 0) * 100 }));
+ return acc.add(
+ Dinero({ amount: Math.round(((val && val.amount) || 0) * 100) })
+ );
}, Dinero());
const balance =
@@ -39,7 +41,7 @@ export default function PaymentFormTotalPayments({ jobid }) {
)}
{!balance &&
{t("jobs.errors.nofinancial")}
}
diff --git a/client/src/components/payment-modal/payment-modal.container.jsx b/client/src/components/payment-modal/payment-modal.container.jsx
index 675af2664..45fd312ba 100644
--- a/client/src/components/payment-modal/payment-modal.container.jsx
+++ b/client/src/components/payment-modal/payment-modal.container.jsx
@@ -1,4 +1,4 @@
-import { useMutation } from "@apollo/client";
+import { useApolloClient, useMutation } from "@apollo/client";
import { CardElement, useElements, useStripe } from "@stripe/react-stripe-js";
import { Button, Form, Modal, notification } from "antd";
import axios from "axios";
@@ -7,6 +7,7 @@ import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { logImEXEvent } from "../../firebase/firebase.utils";
+import { GET_JOB_INFO_FOR_STRIPE } from "../../graphql/jobs.queries";
import {
INSERT_NEW_PAYMENT,
UPDATE_PAYMENT,
@@ -44,6 +45,7 @@ function PaymentModalContainer({
const [enterAgain, setEnterAgain] = useState(false);
const [insertPayment] = useMutation(INSERT_NEW_PAYMENT);
const [updatePayment] = useMutation(UPDATE_PAYMENT);
+ const client = useApolloClient();
const stripe = useStripe();
const elements = useElements();
const { t } = useTranslation();
@@ -80,13 +82,22 @@ function PaymentModalContainer({
stripe_acct_id: bodyshop.stripe_acct_id,
});
+ const { data } = await client.query({
+ query: GET_JOB_INFO_FOR_STRIPE,
+ variables: { jobid: values.jobid },
+ });
+
stripePayment = await stripe.confirmCardPayment(
secretKey.data.clientSecret,
{
payment_method: {
card: elements.getElement(CardElement),
billing_details: {
- name: "Jenny Rosen",
+ name: `${data.jobs_by_pk.ownr_fn || ""} ${
+ data.jobs_by_pk.ownr_ln || ""
+ } ${data.jobs_by_pk.ownr_co_nm || ""}`,
+ email: data.jobs_by_pk.ownr_ea,
+ phone: data.jobs_by_pk.ownr_ph1,
},
},
}
diff --git a/client/src/graphql/jobs.queries.js b/client/src/graphql/jobs.queries.js
index 8bb3f5faa..a608f1e48 100644
--- a/client/src/graphql/jobs.queries.js
+++ b/client/src/graphql/jobs.queries.js
@@ -973,6 +973,20 @@ export const INSERT_NEW_JOB = gql`
}
`;
+export const GET_JOB_INFO_FOR_STRIPE = gql`
+ query GET_JOB_INFO_FOR_STRIPE($jobid: uuid!) {
+ jobs_by_pk(id: $jobid) {
+ id
+ ro_number
+ ownr_fn
+ ownr_ln
+ ownr_co_nm
+ ownr_ph1
+ ownr_ea
+ }
+ }
+`;
+
export const UPDATE_JOB_STATUS = gql`
mutation UPDATE_JOB_STATUS($jobId: uuid!, $status: String!) {
update_jobs(where: { id: { _eq: $jobId } }, _set: { status: $status }) {
diff --git a/package.json b/package.json
index fc839ce19..9dbe66bb1 100644
--- a/package.json
+++ b/package.json
@@ -7,13 +7,13 @@
"npm": "6.11.3"
},
"scripts": {
- "setup": "npm i && cd client && npm i",
- "admin": "cd admin && npm start",
- "client": "cd client && npm start",
+ "setup": "yarn && cd client && yarn",
+ "admin": "cd admin && yarn start",
+ "client": "cd client && yarn start",
"server": "nodemon server.js",
- "build": "cd client && npm run build",
- "dev": "concurrently --kill-others-on-fail \"npm run server\" \"npm run client\"",
- "deva": "concurrently --kill-others-on-fail \"npm run server\" \"npm run client\" \"npm run admin\"",
+ "build": "cd client && yarn run build",
+ "dev": "concurrently --kill-others-on-fail \"yarn run server\" \"yarn run client\"",
+ "deva": "concurrently --kill-others-on-fail \"yarn run server\" \"yarn run client\" \"yarn run admin\"",
"start": "node server.js"
},
"dependencies": {