{"size": 601, "ext": "js", "max_stars_repo_path": "server/api/checkout.js", "max_stars_repo_name": "BAM-Shopper/BAM-Shopper", "max_stars_repo_stars_event_min_datetime": "2018-10-31T15:30:32.000Z", "max_stars_repo_stars_event_max_datetime": "2018-10-31T15:30:32.000Z", "max_issues_repo_path": "server/api/checkout.js", "max_issues_repo_name": "BAM-Shopper/BAM-Shopper", "max_issues_repo_issues_event_min_datetime": "2018-10-29T21:16:57.000Z", "max_issues_repo_issues_event_max_datetime": "2018-11-07T00:02:14.000Z", "max_forks_repo_path": "server/api/checkout.js", "max_forks_repo_name": "BAM-Shopper/BAM-Shopper", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 34, "max_forks_count": null, "avg_line_length": 25.0416666667, "max_line_length": 63, "alphanum_fraction": 0.6139767055}
//const passport = require('passport')
const router = require('express').Router()
module.exports = router

if (!process.env.STRIPE_SECRET_KEY) {
  console.log('Stripe secret key not found. Cannot checkout.')
} else {
  var stripe = require('stripe')(process.env.STRIPE_SECRET_KEY)

  router.post('/', async (req, res, next) => {
    try {
      const charge = await stripe.charges.create({
        amount: req.body.price,
        currency: 'usd',
        description: 'Test $1 Charge',
        source: req.body.token.id
      })
      res.json(charge)
    } catch (err) {
      next(err)
    }
  })
}
