Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
Merge 3f33306 into 927c69a
Browse files Browse the repository at this point in the history
  • Loading branch information
Dylan Lott committed Jan 22, 2018
2 parents 927c69a + 3f33306 commit 2f55d48
Show file tree
Hide file tree
Showing 7 changed files with 960 additions and 752 deletions.
14 changes: 8 additions & 6 deletions lib/server/routes/coinpayments.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,17 @@ inherits(CoinpaymentsRouter, Router);
CoinpaymentsRouter.prototype._currentPrice = function () {
return axios.get('https://min-api.cryptocompare.com/data/price?fsym=STORJ&tsyms=USD')
.then((res) => {
const current_price = res.data.USD;
if (!current_price) {
return constants.STORJ_FALLBACK_PRICE
let currentPrice;
currentPrice = res.data.USD;

if (!currentPrice) {
currentPrice = constants.STORJ_FALLBACK_PRICE
}
return current_price;
return currentPrice;
})
.catch((err) => {
log.error('error getting STORJ price', err)
return current_price;
return constants.STORJ_FALLBACK_PRICE;
});
}

Expand Down Expand Up @@ -163,7 +165,7 @@ CoinpaymentsRouter.prototype.handleIPN = function (req, res) {
}

if (req.body.currency === 'ETH') {
return res.status(501).send(errors.NotImplementedError('bitcoin payments not supported at this time.'));
return res.status(501).send(errors.NotImplementedError('ethereum payments not supported at this time.'));
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/server/routes/credits.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ CreditsRouter.prototype.handleSignups = function (req, res) {
console.log('Error creating signup marketing: ', err);
return res.status(500).send(err);
}
console.log('CREATED MARKETING DOC: ', marketing);

if (req.body.referralLink) {
return self.handleReferralSignup(req, res);
}
Expand Down
16 changes: 5 additions & 11 deletions lib/server/routes/debits.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ const middleware = require('storj-service-middleware');
const errors = require('storj-service-error-types');
const logger = require('../../logger');

// TODO: duplicated from service-storge-models `PaymentProcessor`

function DebitsRouter(options) {
if (!(this instanceof DebitsRouter)) {
return new DebitsRouter(options);
Expand Down Expand Up @@ -102,23 +100,19 @@ DebitsRouter.prototype.getDebits = function(req, res, next) {
return Debit.find({ user: req.user.id })
.then((debits) => {
const debitObjects = debits.map((debit) => debit.toObject());
res.status(200).send(debitObjects);
return res.status(200).send(debitObjects);
})
.catch((err) => next(new errors.InternalError(err.message)));
}

Debit.find({
return Debit.find({
user: req.user.id,
created: {
$gte: req.query.startDate,
$lt: req.query.endDate
}
}, function(err, debits) {
if (err) {
return next(new errors.InternalError(err.message));
}
res.status(200).send(debits.map(debit => debit.toObject()));
})
}})
.then((debits) => res.status(200).send(debits.map(debit => debit.toObject())))
.catch((err) => next(new errors.InternalError(err.message)));
};

DebitsRouter.prototype._getBillingPeriodFor = function(referenceMoment = moment.utc(),
Expand Down
Loading

0 comments on commit 2f55d48

Please sign in to comment.