This commit is contained in:
Arjun Patel
2019-01-30 22:07:53 -08:00
parent 53c0c95006
commit 258491985d
2 changed files with 4 additions and 3 deletions
+3 -1
View File
@@ -9,6 +9,7 @@ const { Donor, Charge, PaymentPlan } = db;
exports.grantCharge = async (req, res, next) => { exports.grantCharge = async (req, res, next) => {
const { stripeToken, grant_id, amount, monthly } = req.body; const { stripeToken, grant_id, amount, monthly } = req.body;
const user = req.user; const user = req.user;
const product_id = 'prod_ER3jOog6QMX1GP';
try { try {
const donors = await Donor.findAll({ where: { id: user.id } }); 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 } }); await Donor.update({ stripe_id }, { where: { id: user.id } });
} }
// TODO: if there is, then update with the given source
var result; var result;
@@ -50,7 +52,7 @@ exports.grantCharge = async (req, res, next) => {
const plan = await stripe.plans.create({ const plan = await stripe.plans.create({
id: grant_id, id: grant_id,
nickname: `Grant for grant: ${grant_id}`, nickname: `Grant for grant: ${grant_id}`,
product: 'prod_ER3jOog6QMX1GP', product: product_id,
currency: 'usd', currency: 'usd',
interval: 'month', interval: 'month',
amount amount
+1 -2
View File
@@ -7,8 +7,7 @@ module.exports = (sequelize, DataTypes) => {
}, },
name: { name: {
type: DataTypes.STRING, type: DataTypes.STRING,
allowNull: false, allowNull: false
unique: true
}, },
amount: { amount: {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,