Fri Sep 29 2017
Copied to clipboard! Copy reply
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
var charge = Checkout._processCreditCard(email, serverTotal, 'usd', stripeToken)
console.log('charge: ', charge) // outputs: Promise { { result: 'error', payload: 'Unexpected error' } }

if (charge.result == 'error')
{
  console.log('Charge failed: ', charge.payload)
  ctx.body = charge     
}


try {
      stripe.charges.create({
        amount: 2000,
        currency: "usd",
        source: token.id, // throws an error because token is not defined. trying to catch this.
        description: `Charge for ${email}`
      }, function(err, charge) {
   
        if (err)
        {
          return {result: 'error', payload: err}
        }     
        return {result: 'success', payload: err}
      });
    }
    catch (e)
    {
      // This gets output in the console.
      console.log('error thrown')
      return {result: 'error', payload: "Unexpected error"}
    }