Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'stripe'
- Stripe.api_key = "sk_test_xxxxxxxxxxxxxxxxxx"
- # カスタマーを作成
- customer = Stripe::Customer.create({
- email: 'example@example.com', # カスタマーのメアド
- })
- # カードトークン生成
- p token = Stripe::Token.create(
- card: {
- number: '4242424242424242',
- exp_month: 12,
- exp_year: 2020,
- cvc: '314'
- }
- )
- # カードトークンをカスタマーに紐付け
- p Stripe::Customer.update( customer.id, {
- source: token.id,
- })
- # 決済する
- p charge = Stripe::Charge.create({
- amount: 6000, # カスタマーが支払う金額
- currency: 'jpy',
- customer: customer.id,
- source: token.card.id,
- destination: {
- amount: 400, # 店舗振込金額
- account: 'acct_xxxxxxxxxx' # 店舗トークン
- }
- })
Add Comment
Please, Sign In to add comment