, , Stripe , . . Stripe , Customer Create . . , Charge, :
11/03
, . - , API, , , . , , . , , Heroku. , Stripe . ENV , dev, . , , Heroku CSS jQuery, , , . RAILS_ENV=production bundle exec rake assets:precompile, , .
: https://devcenter.heroku.com/articles/rails-asset-pipeline
token = params[:stripeToken]
begin
customer = Stripe::Customer.create(
:source => token,
:description => "Customer.create"
)
charge = Stripe::Charge.create(
:amount => (@listing.price * 100).floor,
:description => 'charge.create',
:currency => "usd",
:customer => customer.id
)
flash[:notice] = "Thanks for ordering!"
rescue Stripe::CardError => e
flash[:danger] = e.message
end
, Stripe, :
token = params[:stripeToken]
begin
charge = Stripe::Charge.create(
:amount => (@listing.price * 100).floor,
:currency => "usd",
:source => token,
:description => "Example charge"
)
flash[:notice] = "Thanks for ordering!"
rescue Stripe::CardError => e
flash[:danger] = e.message
end
11/07
, , , , , javascript . "Stripe Api" :
https://stripe.com/docs/stripe.js#collecting-card-details
orders.js, , . , . , , .
Stripe.card.createToken({
number: $('.card-number').val(),
cvc: $('.card-cvc').val(),
exp_month: $('.card-expiry-month').val(),
exp_year: $('.card-expiry-year').val()
}, stripeResponseHandler);