我正在使用条纹为我正在制作的网站收款。
这是我的看法:
%script.stripe-button{"data-amount" => "10000", "data-description" => "A Generous Donation", "data-key" => Rails.configuration.stripe[:publishable_key], src: "https://checkout.stripe.com/v2/checkout.js"}
%br
%b Amount:
%br
%input
%script.stripe-button{"data-amount" => "", "data-description" => "A Generous Donation", "data-key" => Rails.configuration.stripe[:publishable_key], src: "https://checkout.stripe.com/v2/checkout.js", style:"padding-left: 30px;"}
这是我的控制器:
def create
# Amount in cents
@amount = 500
customer = Stripe::Customer.create(
:email => 'example@stripe.com',
:card => params[:stripeToken]
)
charge = Stripe::Charge.create(
:customer => customer.id,
:amount => @amount,
:description => 'Rails Stripe customer',
:currency => 'usd'
)
rescue Stripe::CardError => e
flash[:error] = e.message
redirect_to charges_path
end
对于我的第一个按钮,我正在尝试将数据数量发送到数量变量。第二,我试图从输入框中收集一个值,并在条纹按钮中设置@amount 变量和数据量标签来收集付款。我该怎么做呢?