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

Commit

Permalink
Final testing for coinpayments initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanlott committed Nov 20, 2017
1 parent ddf2f37 commit 7fa0295
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions lib/server/routes/coinpayments.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ CoinpaymentsRouter.prototype._currentPrice = function () {
}

CoinpaymentsRouter.prototype.handleIPN = function (req, res) {
log.info('handle ipn request', req.body);
const PaymentProcessor = this.models.PaymentProcessor;
const Credit = this.models.Credit;

Expand Down Expand Up @@ -139,44 +140,43 @@ CoinpaymentsRouter.prototype.handleIPN = function (req, res) {
log.info('credit created', savedCredit);
return res.sendStatus(201);
});
}

credit.data = req.body;
credit.paid_amount = USD;
credit.paid = true;
} else {
credit.data = req.body;
credit.paid_amount = USD;
credit.paid = true;

return credit.save()
.then((savedCredit) => {
log.info('ipn credit found and updated', savedCredit);
return res.sendStatus(204);
});
})
return credit.save()
.then((savedCredit) => {
log.info('ipn credit found and updated', savedCredit);
return res.sendStatus(204);
});
}
})
}
})
.catch((err) => {
log.error('error in ipnHandler: ', err);
return res.status(500).send('error handling ipn request');
})
}

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

CoinpaymentsRouter.prototype._verify = function (req, res, next) {
log.info('coinpayments ipn received', req.body);
return Coinpayments.ipn({
'merchantId': this.config.coinpayments.merchantId,
'merchantSecret': this.config.coinpayments.merchantSecret
});
if (req.body.currency === 'ETH') {
return res.status(501).send(errors.NotImplementedError('bitcoin payments not supported at this time.'));
}
}

CoinpaymentsRouter.prototype._definitions = function () {
return [
['POST', '/coinpayments',
bodyParser.urlencoded({ extended: true }),
bodyParser.json(),
// this._verify,
Coinpayments.ipn({
'merchantId': this.config.coinpayments.merchantId,
'merchantSecret': this.config.coinpayments.merchantSecret
}),
this.handleIPN
]
]
Expand Down

0 comments on commit 7fa0295

Please sign in to comment.