static async registration(req, res) {
const {
firstName,
lastName,
email,
password
} = req.body;
var hash = bcrypt.hashSync(password, salt);
try {
const userAcc = await User.findOne({ email });
if (userAcc) {
const message1 = {
message: "A user with that email address or username already exists",
status: 404,
};
return res.json({
error: 'error',
message: message1
});
} else {
const user = new User({
email,
firstName,
lastName,
password: hash,
})
const customer = await stripe.customer.create(
{
email: req.body.email,
}
)
console.log(customer);
const result = await user.save()
const userToken = GenerateToken(result);
res.json({
access_token: userToken,
user: result,
response: "TRUE",
message: "Your account has been created, please check your email for a password",
customerId: customer.id,
customerEmail: customer.email,
});
}
} catch (error) {
console.error(error)
}
}
when i run this on Postman it generates an empty array, i think i am not using the Stripe variable well
i get this from the log
TypeError: Cannot read property 'create' of undefined