Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 条纹卡未存储,但客户正在存储_Ruby On Rails_Ruby_Haml_Payment Gateway_Stripe Payments - Fatal编程技术网

Ruby on rails 条纹卡未存储,但客户正在存储

Ruby on rails 条纹卡未存储,但客户正在存储,ruby-on-rails,ruby,haml,payment-gateway,stripe-payments,Ruby On Rails,Ruby,Haml,Payment Gateway,Stripe Payments,我可以将一个新客户保存到我的web应用程序中,但我无法为该客户提供信用卡。我相信我正确地遵循了stripe.com的说明,但我似乎无法理解。我正在使用ruby/rails和haml 我的代码在下面 payment.html.haml: = form_tag("", method: "POST", id: "payment-form") do %span.payment-errors .field = label_tag :card_number, "Credit

我可以将一个新客户保存到我的web应用程序中,但我无法为该客户提供信用卡。我相信我正确地遵循了stripe.com的说明,但我似乎无法理解。我正在使用ruby/rails和haml

我的代码在下面

payment.html.haml:

= form_tag("", method: "POST", id: "payment-form") do
    %span.payment-errors
    .field
        = label_tag :card_number, "Credit Card Number", class: "labelTag"
        = text_field_tag :card_number, nil, {:class => "ss-form-control", :name => nil, "data-stripe" => "number"}
    .field
        = label_tag :card_code, "Security Code on Card (CVC)", class: "labelTag"
        = text_field_tag :card_code, nil, {:class => "ss-form-control minilabel", :name => nil, "data-stripe" => "cvc"}
    .field
        = label_tag :card_month, "Card Expiration", class: "labelTag"
        = select_month nil, {add_month_numbers: true}, {name: nil, id: "card_month", class: 'minilabel', "data-stripe" => 'exp-month'}
        = select_year nil, {start_year: Date.today.year, end_year: Date.today.year+15}, {name: nil, id: "card_year", "data-stripe" => 'exp-year'}
    %button.standardButton.btn.btn-sumbit{type: "submit"} Submit Payment
application.js

Stripe.setPublishableKey('mykey');
$('#payment-form').submit(function(event) {
    var $form = $(this);
    alert('first')
    // Disable the submit button to prevent repeated clicks
    $form.find('button').prop('disabled', true);

    Stripe.card.createToken($form, stripeResponseHandler);

    // Prevent the form from submitting with the default action
    return false;
});
var stripeResponseHandler = function(status, response) {
  var $form = $('#payment-form');

  if (response.error) {
    // Show the errors on the form
    $form.find('.payment-errors').text(response.error.message);
    $form.find('button').prop('disabled', false);
  } else {
    alert('second');
    // token contains id, last4, and card type
    var token = response.id;
    // Insert the token into the form so it gets submitted to the server
    $form.append($('<input type="hidden" name="stripeToken" />').val(token));
    // and submit
    $form.get(0).submit();
  }
};  

如果不在post表单上看到Rails日志,很难说这里的错误在哪里,但我想这是因为您没有在form_标记中指定路径。i、 e

= form_tag("", method: "POST", id: "payment-form") 
而不是

= form_tag("/some_path", method: "POST", id: "payment-form")


你能发布正在提交的参数吗?这将有助于查看令牌是否通过表单提交。@MartinLang这是我所有的代码。我是ruby/rails新手,那么如何通过params呢?不用担心-这里有帮助。-提交表单时,终端应显示您根据请求提交的参数。参数是请求的“主体”或更少。在代码中,您正在调用token=params[:stripeToken],这意味着您正在尝试从params获取stripeToken。
= form_tag("/some_path", method: "POST", id: "payment-form")
= form_tag(some_path, method: "POST", id: "payment-form")