more
This commit is contained in:
@@ -241,7 +241,6 @@ const SignupPage = () => {
|
||||
|
||||
// ******************** STRIPE PAY API CALL ******************** //
|
||||
async function handleStripeAuthorization(
|
||||
user,
|
||||
paymentDataValues,
|
||||
customerDataValues
|
||||
) {
|
||||
@@ -326,16 +325,7 @@ const SignupPage = () => {
|
||||
setIsBusy(true);
|
||||
if (paymentDataValues && dataValues) {
|
||||
try {
|
||||
const userCredential = await createUserWithEmailAndPassword(
|
||||
auth,
|
||||
dataValues.email,
|
||||
dataValues.password
|
||||
);
|
||||
|
||||
const user = userCredential.user;
|
||||
|
||||
const paymentResponse = await handleStripeAuthorization(
|
||||
user,
|
||||
paymentDataValues,
|
||||
dataValues
|
||||
);
|
||||
@@ -343,14 +333,30 @@ const SignupPage = () => {
|
||||
"----------------------------->>>>>>>>>>>>>>>>>paymentResponse",
|
||||
paymentResponse
|
||||
);
|
||||
const customerId = data.customerId;
|
||||
const subscriptionId = data.subscriptionId;
|
||||
|
||||
if (paymentResponse === false) {
|
||||
setIsBusy(false);
|
||||
setNotice("Sorry, something went wrong. Please try again.");
|
||||
return;
|
||||
} else {
|
||||
const userCredential = await createUserWithEmailAndPassword(
|
||||
auth,
|
||||
dataValues.email,
|
||||
dataValues.password
|
||||
);
|
||||
|
||||
const user = userCredential.user;
|
||||
dataValues = { ...dataValues, ...paymentResponse };
|
||||
if (subscriptionId) {
|
||||
dataValues.subscriptionId = subscriptionId;
|
||||
}
|
||||
if (customerId) {
|
||||
dataValues.customerId = customerId;
|
||||
}
|
||||
await saveUserData(user.uid, dataValues);
|
||||
navigate("/");
|
||||
navigate("/dashboard");
|
||||
}
|
||||
} catch (error) {
|
||||
setIsBusy(false);
|
||||
|
||||
Reference in New Issue
Block a user