more
This commit is contained in:
@@ -52,8 +52,7 @@ const PaymentModal = ({
|
|||||||
const totalToday = amountToday + extraAccountsPrice;
|
const totalToday = amountToday + extraAccountsPrice;
|
||||||
|
|
||||||
const handleSignupClick = () => {
|
const handleSignupClick = () => {
|
||||||
console.log("----------------------------_>selectedPlan", selectedPlan);
|
//clear fields
|
||||||
console.log("----------------------------_>selectedPlan", selectedPlan);
|
|
||||||
handleSignup();
|
handleSignup();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,8 @@ const SignupPage = () => {
|
|||||||
const [isAnnual, setIsAnnual] = useState(1);
|
const [isAnnual, setIsAnnual] = useState(1);
|
||||||
const [valX, setValX] = useState(1);
|
const [valX, setValX] = useState(1);
|
||||||
const [valY, setValY] = useState(4);
|
const [valY, setValY] = useState(4);
|
||||||
|
const userAgentSimple = window.navigator.userAgent;
|
||||||
|
console.log("simple userAgent", userAgentSimple);
|
||||||
const handleChangeInput = (e, name) => {
|
const handleChangeInput = (e, name) => {
|
||||||
const newData = handleFormDataChange(e, name, data, signupFields);
|
const newData = handleFormDataChange(e, name, data, signupFields);
|
||||||
if (newData !== null) {
|
if (newData !== null) {
|
||||||
@@ -146,10 +147,6 @@ const SignupPage = () => {
|
|||||||
|
|
||||||
const validatePaymentData = () => {
|
const validatePaymentData = () => {
|
||||||
const newPaymentData = getValidatedFormData(paymentData, paymentfields);
|
const newPaymentData = getValidatedFormData(paymentData, paymentfields);
|
||||||
console.log(
|
|
||||||
"````````````````````````````````````````newPaymentData",
|
|
||||||
newPaymentData
|
|
||||||
);
|
|
||||||
const hasErrors = isFormDataHasErrors(newPaymentData);
|
const hasErrors = isFormDataHasErrors(newPaymentData);
|
||||||
setPaymentData(newPaymentData);
|
setPaymentData(newPaymentData);
|
||||||
return hasErrors ? null : objectMap(({ value }) => value, newPaymentData);
|
return hasErrors ? null : objectMap(({ value }) => value, newPaymentData);
|
||||||
@@ -209,7 +206,6 @@ const SignupPage = () => {
|
|||||||
const fbAuthUid = authId;
|
const fbAuthUid = authId;
|
||||||
let plan = selectedPlan;
|
let plan = selectedPlan;
|
||||||
let docsAllowedPerMonth;
|
let docsAllowedPerMonth;
|
||||||
|
|
||||||
if (isPromotionalMebership === true) {
|
if (isPromotionalMebership === true) {
|
||||||
docsAllowedPerMonth = 1;
|
docsAllowedPerMonth = 1;
|
||||||
subscriptionId = uuidv4();
|
subscriptionId = uuidv4();
|
||||||
@@ -350,9 +346,33 @@ const SignupPage = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const type = selectedPlan[0].value ? selectedPlan[0].value : null;
|
const type = selectedPlan[0].value ? selectedPlan[0].value : null;
|
||||||
const tempAnnual = isAnnual === 1 ? true : false;
|
const tempAnnual =
|
||||||
|
type === "ofCounsel" ? false : isAnnual === 1 ? true : false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`${apiUrl}/create-subscription`, {
|
let response;
|
||||||
|
let data;
|
||||||
|
|
||||||
|
if (type === "ofCounsel") {
|
||||||
|
response = await fetch(`${apiUrl}/new-payment-intent`, {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
planType: type,
|
||||||
|
additionalAccounts: 0,
|
||||||
|
isAnnual: false,
|
||||||
|
customerData: {
|
||||||
|
email: customerDataValues.email,
|
||||||
|
name: `${customerDataValues.firstName} ${customerDataValues.lastName}`,
|
||||||
|
},
|
||||||
|
token,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
data = await response.json();
|
||||||
|
} else {
|
||||||
|
response = await fetch(`${apiUrl}/create-subscription`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
@@ -368,12 +388,8 @@ const SignupPage = () => {
|
|||||||
token,
|
token,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
data = await response.json();
|
||||||
const data = await response.json();
|
}
|
||||||
|
|
||||||
//subscriptionId = response.subscriptionId;
|
|
||||||
//customerId = response.customerId;
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data,
|
data,
|
||||||
};
|
};
|
||||||
@@ -382,8 +398,8 @@ const SignupPage = () => {
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ******************** END STRIPE PAYMENT API CALL ******************** //
|
|
||||||
|
|
||||||
|
// ******************** END STRIPE PAYMENT API CALL ******************** //
|
||||||
const handleSignup = async (e) => {
|
const handleSignup = async (e) => {
|
||||||
const paymentDataValues = validatePaymentData();
|
const paymentDataValues = validatePaymentData();
|
||||||
if (paymentDataValues === null) {
|
if (paymentDataValues === null) {
|
||||||
@@ -401,13 +417,13 @@ const SignupPage = () => {
|
|||||||
setShowPaymentModal(false);
|
setShowPaymentModal(false);
|
||||||
window.scrollTo({ top: 0, behavior: "smooth" });
|
window.scrollTo({ top: 0, behavior: "smooth" });
|
||||||
setIsBusy(true);
|
setIsBusy(true);
|
||||||
console.log("--------------------> dataValues", dataValues);
|
|
||||||
try {
|
try {
|
||||||
const data = await handleStripeAuthorization(
|
const data = await handleStripeAuthorization(
|
||||||
paymentDataValues,
|
paymentDataValues,
|
||||||
dataValues
|
dataValues
|
||||||
);
|
);
|
||||||
|
console.log("9====> ~ ~ ~ ~ data", data);
|
||||||
const customerId = data?.data?.customerId;
|
const customerId = data?.data?.customerId;
|
||||||
const subscriptionCreated = data?.data?.subscriptionCreated;
|
const subscriptionCreated = data?.data?.subscriptionCreated;
|
||||||
const subscriptionPeriodStart = data?.data?.subscriptionPeriodStart;
|
const subscriptionPeriodStart = data?.data?.subscriptionPeriodStart;
|
||||||
|
|||||||
Reference in New Issue
Block a user