-
Notifications
You must be signed in to change notification settings - Fork 3
/
app.rb
44 lines (37 loc) · 945 Bytes
/
app.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
require 'rubygems'
require 'sinatra'
require 'stripe'
require 'mail'
require 'httparty'
STRIPE_KEY=ENV['STRIPE_KEY']
get '/login' do
erb :login
end
get '/' do
erb :main
end
post '/charge' do
Stripe.api_key = STRIPE_KEY
token = params[:stripeToken]
# create a Customer
customer = Stripe::Customer.create(
:card => token,
:email => params[:usremail]
)
# create the charge on Stripe's servers - this will charge the user's card
charge = Stripe::Charge.create(
:amount => params[:Amount].to_i*100, # amount in cents, again
:currency => "usd",
:customer => customer.id,
:description => params[:usremail]
)
p params[:email]
redirect '/'
end
post '/' do
name = params[:name]
userEmail= params[:userEmail]
comment= params[:comment]
HTTParty.post("http://evafong.herokuapp.com/users/", :query => {:'user[name]' => name, :'user[email]'=> userEmail, :'user[comment]' => comment})
redirect '/'
end