我有一个rails应用程序,我试图实现条带化。我需要订阅,我想使用非常简单的JS表单条带提供,但我不知道如何使用订阅。
使用JS表单(如下所示),我似乎无法指定计划或方法来了解选择了哪个计划。以下是我的观点:
= form_tag subscriptions_path do
%article
%label.amount
%span Plan: Basic, Amount: $5.00
%script.stripe-button{"data-amount" => "500", "data-description" => "A month's subscription", "data-key" => Rails.configuration.stripe[:publishable_key], src: "https://checkout.stripe.com/checkout.js"}
这是我在订阅控制器中的创建方法:
def create
# Amount in cents
@amount = 500
customer = Stripe::Customer.create(
email: current_user.company.admin.email,
plan: '???'
card: params[:stripeToken]
)
rescue Stripe::CardError => e
flash[:error] = e.message
redirect_to subscriptions_path
end
我如何知道从条形码checkout.js
中选择了哪个计划