This repository was archived by the owner on Feb 27, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change 33
33
34
34
post '/charge' do
35
35
authenticate!
36
- # Get the credit card details submitted by the form
37
- source = params [ :source ]
38
- customer = params [ :customer_id ] || @customer . id
39
-
36
+ # Get the credit card details submitted
37
+ payload = params . empty? ? indifferent_params ( JSON . parse ( request . body . read ) ) : params
38
+
39
+ source = payload [ :source ]
40
+ payload [ :amount ]
41
+ customer = payload [ :customer_id ] || @customer . id
40
42
# Create the charge on Stripe's servers - this will charge the user's card
41
43
begin
42
44
charge = Stripe ::Charge . create (
43
- :amount => params [ :amount ] , # this number should be in cents
45
+ :amount => payload [ :amount ] , # this number should be in cents
44
46
:currency => "usd" ,
45
47
:customer => customer ,
46
48
:source => source ,
47
49
:description => "Example Charge" ,
48
- :shipping => params [ :shipping ] ,
50
+ :shipping => payload [ :shipping ] ,
49
51
)
50
52
rescue Stripe ::StripeError => e
51
53
status 402
@@ -76,7 +78,7 @@ def authenticate!
76
78
@customer
77
79
end
78
80
79
- # This endpoint is used by the Obj-C example app to create a charge.
81
+ # This endpoint is used by the Obj-C and Android example apps to create a charge.
80
82
post '/create_charge' do
81
83
# Create the charge on Stripe's servers
82
84
begin
You can’t perform that action at this time.
0 commit comments