Ruby on rails 如何使用Rails和HAML将数据传递到条带签出?

Ruby on rails 如何使用Rails和HAML将数据传递到条带签出?,ruby-on-rails,haml,stripe-payments,Ruby On Rails,Haml,Stripe Payments,我有一张登记表,上面有名字、姓氏、电子邮件和电话,然后是“带卡付款”的结账按钮。用户填写表单后,Stripe Checkout会询问电子邮件地址。如何在表单中获取用户输入的电子邮件地址,以自动填写条带签出中的电子邮件地址字段 以下是我当前的代码: .field = f.label :"Email:" = f.text_field :email %br .actions %script.

我有一张登记表,上面有名字、姓氏、电子邮件和电话,然后是“带卡付款”的结账按钮。用户填写表单后,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}}
如果我在条带签出脚本中硬编码电子邮件地址,它就可以工作。我可以使用jQuery传递它吗?如果是,怎么做?

我是这样做的:

    = 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

希望它对您有所帮助。

如果您在同一页面的JS中获得它,那么您就不能这样做。您需要使用自定义签出()并在
handler.open()
@koopajah的
email
参数中传递电子邮件,谢谢!但它似乎打破了这条线:
@registration=registration.new registration_params.merge(电子邮件:stripe_params[“stripeEmail”])
不确定stripe_params[]来自何处。如果使用自定义签出,您将在
令牌()中获得令牌
回调,此时您必须将令牌id和用户电子邮件发送到服务器