diff options
| author | Adam Soltys <[email protected]> | 2018-12-25 21:13:37 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2019-02-05 20:53:45 -0800 |
| commit | 3bb1a1600a9788d6571d3fa736331d8b104a16b9 (patch) | |
| tree | c352cea4cf55b4f3c3f2ae05d60cf66437c68827 /index.js | |
| parent | ae79b2a52f4527de0e24a6fe2e9b161c804de02a (diff) | |
| download | coinos-server-3bb1a1600a9788d6571d3fa736331d8b104a16b9.tar.gz coinos-server-3bb1a1600a9788d6571d3fa736331d8b104a16b9.zip | |
stripe integration
Diffstat (limited to 'index.js')
| -rw-r--r-- | index.js | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -476,6 +476,23 @@ const l = console.log } }) + app.post('/buy', auth, async (req, res) => { + const stripe = require('stripe')(config.stripe); + const { token, amount, sats } = req.body + + const charge = stripe.charges.create({ + amount, + currency: 'cad', + description: 'Bitcoin', + source: token, + }) + + req.user.balance += parseInt(sats) + await req.user.save() + + res.send(`Bought ${amount}`) + }) + app.use(function (err, req, res, next) { res.status(500) res.send('An error occurred') |
