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
32
33
|
# File 'app/controllers/stripe_helper/stripe_controller.rb', line 5
def handle
amount = do_call(:charge_amount, self, params[:token])
if amount == nil || !amount.is_a?(Integer)
redirect_to do_call(:charge_failure, self, params[:token],
'Invalid charge; potential security error.')
return
end
token = params[:stripeToken]
opts = {
amount: amount,
currency: "cad",
description: params[:desc]
}
ret = StripeHelper.charge_from_token(token, opts)
if ret
redirect_to do_call(:charge_success, self, params[:token], token)
else
redirect_to do_call(:charge_failure, self, params[:token],
'Card declined.')
end
end
|