Skip to content

Instantly share code, notes, and snippets.

@zmachuca
Created February 14, 2015 19:28
Show Gist options
  • Save zmachuca/a861465fe4ac1005dd43 to your computer and use it in GitHub Desktop.
Save zmachuca/a861465fe4ac1005dd43 to your computer and use it in GitHub Desktop.
class ChargesController < ApplicationController
before_action :set_charge, only: [:show, :update]
def new
end
def create
# Amount in cents
@amount = 999
customer = Stripe::Customer.create(
:email => 'example@stripe.com',
:card => params[:stripeToken]
)
charge = Stripe::Charge.create(
:customer => customer.id,
:amount => @amount,
:description => 'Rails Stripe Customer',
:currency => 'usd'
)
rescue Stripe::CardError => e
flash[:error] = e.message
redirect_to root_path
end
def index
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment