Set up an endpoint for fetching Stripe info.

This commit is contained in:
Scott Erickson 2014-12-05 16:47:44 -08:00
parent 640b841306
commit f4e3416918
4 changed files with 12 additions and 3 deletions

View file

@ -8,7 +8,6 @@ sendwithus = require '../sendwithus'
hipchat = require '../hipchat'
config = require '../../server_config'
request = require 'request'
stripe = require('stripe')(config.stripe.secretKey)
async = require 'async'
products = {

View file

@ -2,8 +2,6 @@
# the stripe property in the user with what's being stored in Stripe.
Handler = require '../commons/Handler'
config = require '../../server_config'
stripe = require('stripe')(config.stripe.secretKey)
discountHandler = require './discount_handler'
subscriptions = {

View file

@ -230,9 +230,19 @@ UserHandler = class UserHandler extends Handler
return @trackActivity(req, res, args[0], args[2], args[3]) if args[1] is 'track' and args[2]
return @getRemark(req, res, args[0]) if args[1] is 'remark'
return @searchForUser(req, res) if args[1] is 'admin_search'
return @getStripeInfo(req, res, args[0]) if args[1] is 'stripe'
return @sendNotFoundError(res)
super(arguments...)
getStripeInfo: (req, res, handle) ->
@getDocumentForIdOrSlug handle, (err, user) =>
return @notFoundError(res) if not user
return @sendForbiddenError(res) unless req.user and (req.user.isAdmin() or req.user.get('_id').equals(user.get('_id')))
return @notFoundError(res) if not customerID = user.get('stripe')?.customerID
stripe.customers.retrieve customerID, (err, customer) =>
return @sendDatabaseError(res, err) if err
@sendSuccess(res, JSON.stringify(customer, null, '\t'))
agreeToCLA: (req, res) ->
return @sendForbiddenError(res) unless req.user
doc =

View file

@ -16,6 +16,8 @@ UserHandler = require './server/users/user_handler'
hipchat = require './server/hipchat'
global.tv4 = require 'tv4' # required for TreemaUtils to work
global.jsondiffpatch = require 'jsondiffpatch'
global.stripe = require('stripe')(config.stripe.secretKey)
productionLogging = (tokens, req, res) ->
status = res.statusCode