mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-14 07:00:01 -04:00
Set up an endpoint for fetching Stripe info.
This commit is contained in:
parent
640b841306
commit
f4e3416918
4 changed files with 12 additions and 3 deletions
|
@ -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 = {
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -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 =
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue