Skip to content

Instantly share code, notes, and snippets.

Started POST "/login/log_in" for ::1 at 2015-08-14 12:57:37 -0700
Processing by LoginController#log_in as */*
Parameters: {"stripeToken"=>"tok_16ZoJ327so3cCAuPzcA7diqG"}
Can't verify CSRF token authenticity
{"stripeToken"=>"tok_16ZoJ327so3cCAuPzcA7diqG", "controller"=>"login", "action"=>"log_in"}
Completed 500 Internal Server Error in 1ms (ActiveRecord: 0.0ms)
Started POST "/login/log_in" for ::1 at 2015-08-14 13:05:08 -0700
Processing by LoginController#log_in as */*
Parameters: {"stripeToken"=>"tok_16ZoQK27so3cCAuPJ5K06P7y"}
{"stripeToken"=>"tok_16ZoQK27so3cCAuPJ5K06P7y", "controller"=>"login", "action"=>"log_in"}
Completed 500 Internal Server Error in 1ms (ActiveRecord: 0.0ms)
NoMethodError (undefined method `[]' for nil:NilClass):
app/controllers/login_controller.rb:11:in `log_in'
Started POST "/login/log_in" for ::1 at 2015-08-14 16:13:04 -0700
Processing by LoginController#log_in as */*
Parameters: {"stripeToken"=>"tok_16ZrMC27so3cCAuP1WR2C9zF"}
tok_16ZrMC27so3cCAuP1WR2C9zF
Rendered login/log_in.html.erb within layouts/application (1.3ms)
Completed 200 OK in 885ms (Views: 49.0ms | ActiveRecord: 0.0ms)
Started POST "/login/log_in" for ::1 at 2015-08-14 16:13:04 -0700
Processing by LoginController#log_in as */*
Parameters: {"stripeToken"=>"tok_16ZrMC27so3cCAuP1WR2C9zF"}
tok_16ZrMC27so3cCAuP1WR2C9zF
Rendered login/log_in.html.erb within layouts/application (1.3ms)
Completed 200 OK in 885ms (Views: 49.0ms | ActiveRecord: 0.0ms)
at=info method=POST path="/charge/index" host=stripeconnect.herokuapp.com request_id=13d6b366-ad40-4f11-abc7-c0ac20fdd8b0 fwd="172.1.34.105" dyno=web.1 connect=0ms service=6991ms status=200 bytes=1482
2015-09-14T00:47:31.356798+00:00 app[web.1]: Completed 200 OK in 1029ms (Views: 6.4ms | ActiveRecord: 0.0ms)
2015-09-14T00:47:31.355291+00:00 app[web.1]: Rendered charge/index.html.erb within layouts/application (0.6ms)
2015-09-14T03:51:25.101424+00:00 app[web.1]: app/controllers/charge_controller.rb:12:in `index'
2015-09-14T03:51:25.101425+00:00 app[web.1]:
2015-09-14T03:51:25.101427+00:00 app[web.1]:
2015-09-14T03:51:25.325976+00:00 heroku[router]: at=info method=GET path="/charge/index" host=stripeconnect.herokuapp.com request_id=b9e6e031-c789-4d3b-b176-7353f9cef381 fwd="172.1.34.105" dyno=web.1 connect=0ms service=784ms status=500 bytes=1754
2015-09-14T03:54:15.804691+00:00 app[web.1]: Started POST "/charge/index" for 172.1.34.105 at 2015-09-14 03:54:15 +0000
2015-09-14T03:54:15.814697+00:00 app[web.1]: 14180
2015-09-14T03:54:15.814058+00:00 app[web.1]: Parameters: {"stripeToken"=>"tok_16ko2l27so3cCAuPfdVZvnyC", "stipeConnectedAccount"=>"acct_16gXNXBG9NLnd6fU", "price"=>"141.80"}
2015-09-14T03:54:15.814043+00:00 app[web.1]: Processing by ChargeController#index as */*
2015-09-14T03:54:16.681167+00:00 heroku[router]: at=info method=POST path="/charge/index" host=stripeconnect.herokuapp.com request_id=0738edf7-dc89-4c
class ChargeController < ApplicationController
def index
decimal = params["price"]
cents = decimal.to_s.sub('.','').to_i
puts cents
Stripe.api_key = "sk_test_XXXXXXXXXXXXXXXXX"
charge = Stripe::Charge.create(
:amount => cents,
:currency => "usd",
:source => params["stripeToken"],
:description => "Example charge",
:destination => params["stipeConnectedAccount"]
)
stripe.charges.create({
amount: req.params.price,
currency: "usd",
customer: req.params.stripe_customer_cccount,
description: 'Charge for ' + req.params.charge_description,
application_fee: application_fee
}, {stripe_account: {req.params.seller_stripe_account}});
stripe.tokens.create(
{ customer: req.params.stripe_customer_cccount },
{ stripe_account: req.params.seller_stripe_account },
{ amount:req.params.price },
{ currency: "usd" },
{ description: 'Charge for ' + req.params.charge_description },
{ application_fee: application_fee}
function(err, token) {
// callback