Skip to content

Instantly share code, notes, and snippets.

@chansuke
Created November 10, 2015 08:54
Show Gist options
  • Save chansuke/e81049e158cd047989b0 to your computer and use it in GitHub Desktop.
Save chansuke/e81049e158cd047989b0 to your computer and use it in GitHub Desktop.
Sinatraでwebpayを使った課金処理
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