Skip to content
This repository was archived by the owner on Feb 27, 2023. It is now read-only.

Commit fe9526c

Browse files
committed
logs
1 parent 1d316c6 commit fe9526c

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

web.rb

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,21 @@
3333

3434
post '/charge' do
3535
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
4042
# Create the charge on Stripe's servers - this will charge the user's card
4143
begin
4244
charge = Stripe::Charge.create(
43-
:amount => params[:amount], # this number should be in cents
45+
:amount => payload[:amount], # this number should be in cents
4446
:currency => "usd",
4547
:customer => customer,
4648
:source => source,
4749
:description => "Example Charge",
48-
:shipping => params[:shipping],
50+
:shipping => payload[:shipping],
4951
)
5052
rescue Stripe::StripeError => e
5153
status 402
@@ -76,7 +78,7 @@ def authenticate!
7678
@customer
7779
end
7880

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.
8082
post '/create_charge' do
8183
# Create the charge on Stripe's servers
8284
begin

0 commit comments

Comments
 (0)