Created
August 15, 2016 20:12
-
-
Save dylanjhunt/bb6098cbd5ec1224da52b7f9c41cda64 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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