Created
February 14, 2015 19:28
-
-
Save zmachuca/a861465fe4ac1005dd43 to your computer and use it in GitHub Desktop.
This file contains 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
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