Skip to content

Instantly share code, notes, and snippets.

@dylanjhunt
Created August 15, 2016 20:12
Show Gist options
  • Save dylanjhunt/bb6098cbd5ec1224da52b7f9c41cda64 to your computer and use it in GitHub Desktop.
Save dylanjhunt/bb6098cbd5ec1224da52b7f9c41cda64 to your computer and use it in GitHub Desktop.
def new
end
def create
# Amount in cents
@amount = 500
customer = Stripe::Customer.create(
:email => params[:stripeEmail],
:source => 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 new_charge_path
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment