Minor stripe updates.
This commit is contained in:
@@ -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 { CardElement, useElements, useStripe } from "@stripe/react-stripe-js";
|
||||||
import { Button, Form, Modal, notification } from "antd";
|
import { Button, Form, Modal, notification } from "antd";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
@@ -7,6 +7,7 @@ import { useTranslation } from "react-i18next";
|
|||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
import { logImEXEvent } from "../../firebase/firebase.utils";
|
import { logImEXEvent } from "../../firebase/firebase.utils";
|
||||||
|
import { GET_JOB_INFO_FOR_STRIPE } from "../../graphql/jobs.queries";
|
||||||
import {
|
import {
|
||||||
INSERT_NEW_PAYMENT,
|
INSERT_NEW_PAYMENT,
|
||||||
UPDATE_PAYMENT,
|
UPDATE_PAYMENT,
|
||||||
@@ -44,6 +45,7 @@ function PaymentModalContainer({
|
|||||||
const [enterAgain, setEnterAgain] = useState(false);
|
const [enterAgain, setEnterAgain] = useState(false);
|
||||||
const [insertPayment] = useMutation(INSERT_NEW_PAYMENT);
|
const [insertPayment] = useMutation(INSERT_NEW_PAYMENT);
|
||||||
const [updatePayment] = useMutation(UPDATE_PAYMENT);
|
const [updatePayment] = useMutation(UPDATE_PAYMENT);
|
||||||
|
const client = useApolloClient();
|
||||||
const stripe = useStripe();
|
const stripe = useStripe();
|
||||||
const elements = useElements();
|
const elements = useElements();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -80,13 +82,22 @@ function PaymentModalContainer({
|
|||||||
stripe_acct_id: bodyshop.stripe_acct_id,
|
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(
|
stripePayment = await stripe.confirmCardPayment(
|
||||||
secretKey.data.clientSecret,
|
secretKey.data.clientSecret,
|
||||||
{
|
{
|
||||||
payment_method: {
|
payment_method: {
|
||||||
card: elements.getElement(CardElement),
|
card: elements.getElement(CardElement),
|
||||||
billing_details: {
|
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,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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`
|
export const UPDATE_JOB_STATUS = gql`
|
||||||
mutation UPDATE_JOB_STATUS($jobId: uuid!, $status: String!) {
|
mutation UPDATE_JOB_STATUS($jobId: uuid!, $status: String!) {
|
||||||
update_jobs(where: { id: { _eq: $jobId } }, _set: { status: $status }) {
|
update_jobs(where: { id: { _eq: $jobId } }, _set: { status: $status }) {
|
||||||
|
|||||||
12
package.json
12
package.json
@@ -7,13 +7,13 @@
|
|||||||
"npm": "6.11.3"
|
"npm": "6.11.3"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"setup": "npm i && cd client && npm i",
|
"setup": "yarn && cd client && yarn",
|
||||||
"admin": "cd admin && npm start",
|
"admin": "cd admin && yarn start",
|
||||||
"client": "cd client && npm start",
|
"client": "cd client && yarn start",
|
||||||
"server": "nodemon server.js",
|
"server": "nodemon server.js",
|
||||||
"build": "cd client && npm run build",
|
"build": "cd client && yarn run build",
|
||||||
"dev": "concurrently --kill-others-on-fail \"npm run server\" \"npm run client\"",
|
"dev": "concurrently --kill-others-on-fail \"yarn run server\" \"yarn run client\"",
|
||||||
"deva": "concurrently --kill-others-on-fail \"npm run server\" \"npm run client\" \"npm run admin\"",
|
"deva": "concurrently --kill-others-on-fail \"yarn run server\" \"yarn run client\" \"yarn run admin\"",
|
||||||
"start": "node server.js"
|
"start": "node server.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
Reference in New Issue
Block a user