Stripe Payment Gateway在rails上发出ruby(TypeError:window.multimedia(...)为null)

时间:2017-07-24 05:43:18

标签: javascript jquery ruby-on-rails ruby-on-rails-4 stripe-payments

在firebug console =>上出现此错误(TypeError:window.matchMedia(...)为null)

当我在firebug控制台上点击paywithcard按钮时,我会得到(TypeError:window.multimedia(...)为null)。

button.html.erb

<%= form_tag front_charges_path do %>
  <article>
    <% if flash[:error].present? %>
      <div id="error_explanation">
        <p><%= flash[:error] %></p>
      </div>
    <% end %>
    <label class="amount">
      <span>Amount: <%=@cart_totals%></span>
    </label>
  </article>
<script src="https://js.stripe.com/v3/"></script>

  <script src="https://checkout.stripe.com/checkout.js" class="stripe-button"
          data-key="<%= Stripe.api_key = "pk_test_******************" %>"
          data-description="A month's subscription"
          data-amount="<%=@cart_totals%>"
          data-locale="auto"></script>

<% end %>
<script type="text/javascript">

  var widthQuery = window.matchMedia("(min-width: 600px)");

</script>

Stripe.rb

Rails.configuration.stripe = {
  :publishable_key => ENV['pk_test_****************'],
  :secret_key      => ENV['sk_test_************']
}


Stripe.api_key = "sk_test_****************"

Charges_controller.rb

class Front::ChargesController < ApplicationController
layout 'product'
def new
end

def create  
  # Amount in cents
  @amount = 500

  customer = Stripe::Customer.create(
    :email => params[:ronakabhattrz],
    :source  => params[:stripeToken]
  )

  charge = Stripe::Charge.create(
    :customer    => customer.id,
    :amount      => @amount,
    :description => 'Rails Stripe customer',
    :currency    => 'INR'
  )

rescue Stripe::CardError => e
  flash[:error] = e.message
  redirect_to new_charge_path
end



end

1 个答案:

答案 0 :(得分:0)

这似乎是FF中的一个顽固的错误。

检查matchMedia returns null when the FireBug is enabled是否有解决方法