Created
November 10, 2015 08:54
-
-
Save chansuke/e81049e158cd047989b0 to your computer and use it in GitHub Desktop.
Sinatraでwebpayを使った課金処理
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
require 'bundler' | |
Bundler.require | |
webpay = WebPay.new('xxxxxx') | |
WEBPAY_PUBLIC_KEY = 'xxxxxx') | |
MAMORIO_PRICE = 3500 | |
set :slim, format: :html5 | |
get '/' do | |
slim :index | |
end | |
post '/purchase' do | |
begin | |
@charge = webpay.charge.create(currency: 'jpy', amount: XXXXX_PRICE, card: params['webpay-token']) | |
slim :purchased | |
rescue => e | |
redirect to('/') | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment