diff --git a/app/controllers/stripe.controller.js b/app/controllers/stripe.controller.js index 1c91d5f..3197066 100644 --- a/app/controllers/stripe.controller.js +++ b/app/controllers/stripe.controller.js @@ -9,6 +9,7 @@ const { Donor, Charge, PaymentPlan } = db; exports.grantCharge = async (req, res, next) => { const { stripeToken, grant_id, amount, monthly } = req.body; const user = req.user; + const product_id = 'prod_ER3jOog6QMX1GP'; try { const donors = await Donor.findAll({ where: { id: user.id } }); @@ -26,6 +27,7 @@ exports.grantCharge = async (req, res, next) => { await Donor.update({ stripe_id }, { where: { id: user.id } }); } + // TODO: if there is, then update with the given source var result; @@ -50,7 +52,7 @@ exports.grantCharge = async (req, res, next) => { const plan = await stripe.plans.create({ id: grant_id, nickname: `Grant for grant: ${grant_id}`, - product: 'prod_ER3jOog6QMX1GP', + product: product_id, currency: 'usd', interval: 'month', amount diff --git a/app/models/grant.model.js b/app/models/grant.model.js index 47d1595..3acb15b 100644 --- a/app/models/grant.model.js +++ b/app/models/grant.model.js @@ -7,8 +7,7 @@ module.exports = (sequelize, DataTypes) => { }, name: { type: DataTypes.STRING, - allowNull: false, - unique: true + allowNull: false }, amount: { type: DataTypes.INTEGER,