Created
July 4, 2014 21:07
-
-
Save afuggini/e838d2051149c78ab0be to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@CallbackController = RouteController.extend( | |
fastRender: true | |
onBeforeAction: (pause) -> | |
p = @params | |
run = false | |
switch p.key | |
when "stripe" | |
u = Meteor.user() | |
if u? | |
r = Roles.userIsInRole(u._id, 'stripe-connected') | |
if p.code and p.state and not r and not run | |
Meteor.call('saveStripeToken', p.code, (e, r)-> | |
if e | |
App.debug e | |
else | |
Router.go(p.state) | |
Meteor.setTimeout(()-> | |
App.alert.success 'Your Stripe account has been successfully connected', 7000 | |
App.debug p | |
,500) | |
) | |
run = true | |
pause() | |
return | |
Router.go 'homepage' | |
return | |
action: ()-> | |
@render 'NotFound' | |
return | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment