我有一个包含名字,姓氏,电子邮件和电话的注册表格,然后是一个带卡片条纹结账按钮。用户填写表单后,Stripe Checkout会询问电子邮件地址。如何在表单中获取用户输入的电子邮件地址,以自动填写Stripe Checkout中的电子邮件地址字段。
这是我目前的代码:
.field
= f.label :"Email:"
= f.text_field :email
%br
.actions
%script.stripe-button{ src: "https://checkout.stripe.com/checkout.js",
data: {email: "thisemail@carriesover.com", amount: @level.price*100, description: @level.name, key: Rails.application.secrets.stripe_publishable_key}}
如果我在Stripe Checkout脚本中对电子邮件地址进行硬编码,则可以正常工作。我可以使用jQuery传递它吗?如果是这样,怎么样?
答案 0 :(得分:0)
我是这样做的:
= javascript_include_tag "https://checkout.stripe.com/v2/checkout.js",
:class => "stripe-button",
:"data-key" => "#{Rails.configuration.stripe[:publishable_key]}",
:"data-description" => "charged upon appointment confirmation",
:"data-amount" => total.to_s,
:"data-image" => 'https://s3-us-west-2.amazonaws.com/xx
:"data-label" => "Request Appointment",
:"data-panel-label" => "Pre-Authorize",
:"data-name" => "Pre-Authorize Payment",
:"data-email" => @current_user.email
希望它对你有所帮助。