allowing charities to add ribbons for

This commit is contained in:
Arjun Patel
2019-04-12 14:11:33 -07:00
parent 3756f88cc7
commit 66df6bb576
3 changed files with 106 additions and 106 deletions
+4 -1
View File
@@ -12,7 +12,9 @@ exports.getStatusUpdatesByOrg = async (req, res, next) => {
const posts = await sequelize.query(
`
SELECT * FROM posts
WHERE organization_id = :organization_id`,
WHERE organization_id = :organization_id
ORDER BY created_at DESC
LIMIT 6`,
{
type: db.Sequelize.QueryTypes.SELECT,
replacements: { organization_id }
@@ -70,6 +72,7 @@ exports.addRibbon = async (req, res, next) => {
message: 'Successfully added ribbon to post!'
});
} catch (error) {
console.log(error);
next(error);
}
};
+15 -15
View File
@@ -1,8 +1,8 @@
const db = require("../../models"),
errorMaker = require("../helpers/error.maker"),
requestPromise = require("request-promise");
const db = require('../../models'),
errorMaker = require('../helpers/error.maker'),
requestPromise = require('request-promise');
const stripe = require("stripe")(process.env.STRIPE_KEY);
const stripe = require('stripe')(process.env.STRIPE_KEY);
const { Donor, Organization, Charge, PaymentPlan } = db;
@@ -25,11 +25,11 @@ exports.grantCharge = async ({
// charge if yes or no monthly
let charge = await stripe.charges.create({
amount: stripeAmount,
currency: "usd",
source: "tok_visa",
currency: 'usd',
source: 'tok_visa',
description: `Charity Bundle Payment`,
statement_descriptor: `charity bundle ${grant.id}`,
receipt_email: "[email protected]"
receipt_email: '[email protected]'
});
let transfers = await organizations.map(async org => {
@@ -38,9 +38,9 @@ exports.grantCharge = async ({
let t = await stripe.transfers.create({
amount: stripeOrgAmount - applicationStripeFee,
currency: "usd",
currency: 'usd',
source_transaction: charge.id,
destination: "acct_1EAxzUIVW1uo07uH"
destination: 'acct_1EAxzUIVW1uo07uH'
});
return t;
});
@@ -61,7 +61,7 @@ exports.deleteGrant = async (req, res, next) => {
// check if there are plans for that grant
if (!paymentPlans.length) {
return res.status(400).json({
message: "Not a valid grant"
message: 'Not a valid grant'
});
} else {
const plan = paymentPlans[0];
@@ -115,12 +115,12 @@ exports.activateStripeAccount = async (req, res, next) => {
}&code=${code}&grant_type=authorization_code`;
var options = {
uri: "https://connect.stripe.com/oauth/token",
method: "POST",
uri: 'https://connect.stripe.com/oauth/token',
method: 'POST',
body: {
client_secret: process.env.STRIPE_KEY,
code,
grant_type: "authorization_code"
grant_type: 'authorization_code'
},
json: true
};
@@ -130,11 +130,11 @@ exports.activateStripeAccount = async (req, res, next) => {
const { stripe_user_id } = stripeAccRes;
const updateRes = await db.sequelize.query(
"UPDATE organizations SET stripe_account_id = :stripe_user_id WHERE id = :org_id",
'UPDATE organizations SET stripe_account_id = :stripe_user_id WHERE id = :org_id',
{ replacements: { stripe_user_id, org_id } }
);
return res.status(302).redirect("http://localhost:8081/org/main/banking");
return res.status(302).redirect('http://localhost:8081/org/main/');
} catch (error) {
next(error);
}
+2 -5
View File
@@ -55,11 +55,8 @@ router.get('/dashboard', checkAuth(roles.DONOR), donor.getDashboardData);
router.get('/charges', checkAuth(roles.DONOR), charge.getAllChargesbyDonor);
router.put(
'/statusupdate/ribbon/:update_id',
checkAuth(roles.DONOR),
post.addRibbon
);
//TODO: checkAuth so only donors can add ribbons
router.put('/statusupdate/ribbon/:update_id', post.addRibbon);
// // Retrieve a single Donor by Id
// router.get('/:donor_id', donor.findById);