Created
May 15, 2016 17:21
-
-
Save thorwebdev/7930c0528d2e961d5759a4b3287744e7 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
post '/charge' do | |
# Output the params hash with the values from Checkout in the bash | |
puts params.inspect | |
# Store Stripe Token and Customer Email Address in local variables | |
token = params[:stripeToken] | |
email = params[:stripeEmail] | |
# Create a new Customer | |
# Store the Response in a local variable | |
customer = Stripe::Customer.create( | |
:source => token, | |
:email => email, | |
:description => "Ruby customer" | |
) | |
# Charge the Customer instead of the card | |
Stripe::Charge.create( | |
:amount => 2000, # in cents | |
:currency => "eur", | |
:customer => customer.id | |
) | |
# Output the Customer ID to the user | |
"Successfully created customer with ID: #{customer.id}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment