我试图让用户填写表格,然后付费提交。一旦用户付款,我需要使用 Rails 将布尔值从单独的模型更改为 true。
这是我的收费控制器,完全来自文档。
class ChargesController < ApplicationController
def new
end
def create
# Amount in cents
@amount = 2900
customer = Stripe::Customer.create(
:email => current_user.email,
:card => params[:stripeToken]
)
charge = Stripe::Charge.create(
:customer => current_user.email,
:amount => @amount,
:description => 'OneApp',
:currency => 'usd'
)
rescue Stripe::CardError => e
flash[:error] = e.message
redirect_to charges_path
end
end