working on stripe controller
This commit is contained in:
@@ -9,7 +9,15 @@ const { Donor, Organization } = db;
|
||||
exports.grantCharge = async (req, res, next) => {
|
||||
const { stripeToken, amount, monthly } = req.body;
|
||||
console.log(req.body);
|
||||
const user = req.user;
|
||||
|
||||
findStripeId(user.id)
|
||||
.then(stripeId => {
|
||||
if (!stripeId) {
|
||||
stripe.customers.create({});
|
||||
}
|
||||
})
|
||||
.catch(error => next(error));
|
||||
// if (!monthly) {
|
||||
// const charge = stripe.charges.create({
|
||||
// amount,
|
||||
@@ -20,3 +28,17 @@ exports.grantCharge = async (req, res, next) => {
|
||||
// });
|
||||
// }
|
||||
};
|
||||
|
||||
const findStripeId = userId => {
|
||||
return new Promise((resolve, reject) => {
|
||||
Donor.findAll({ where: { id: userId } })
|
||||
.then(donors => {
|
||||
// add stripe id for
|
||||
// if (donors[0]) {
|
||||
// return next(errorMaker(409, `Email Exists: ${req.body.email}`));
|
||||
// }
|
||||
resolve(donors[0].stripe_id);
|
||||
})
|
||||
.catch(error => reject(error));
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user