v3 payments: working IAP and Stripe, move paypalBillingSetup to its own file, closeChal is now a challenge instance method

This commit is contained in:
Matteo Pagliazzi
2016-05-09 22:58:15 +02:00
parent e980b3ce0a
commit 0114e310eb
18 changed files with 414 additions and 381 deletions
+2 -4
View File
@@ -289,8 +289,6 @@ api.update = function(req, res, next){
});
}
import { _closeChal } from '../api-v3/challenges';
/**
* Delete & close
*/
@@ -304,7 +302,7 @@ api.delete = async function(req, res, next){
if (!challenge.canModify(user)) return next(shared.i18n.t('noPermissionCloseChallenge'));
// Close channel in background, some ops are run in the background without `await`ing
await _closeChal(challenge, {broken: 'CHALLENGE_DELETED'});
await challenge.closeChal({broken: 'CHALLENGE_DELETED'});
res.sendStatus(200);
} catch (err) {
next(err);
@@ -326,7 +324,7 @@ api.selectWinner = async function(req, res, next) {
if (!winner || winner.challenges.indexOf(challenge._id) === -1) return next('Winner ' + req.query.uid + ' not found.');
// Close channel in background, some ops are run in the background without `await`ing
await _closeChal(challenge, {broken: 'CHALLENGE_CLOSED', winner});
await challenge.closeChal({broken: 'CHALLENGE_CLOSED', winner});
res.respond(200, {});
} catch (err) {
next(err);