2016-10-07 4 views
0

Я делаю форму выписки с полосой и рельсами. У меня есть shop_controller, который обслуживает список продуктов в shop#index. Затем это приводит к shop#show, где расположена форма полосы, и пользователи могут приобретать продукт.Stripe iFrame заблокирован - рельсы и полоса

Сейчас при нажатии на кнопку, чтобы сделать покупку (с помощью поддельной карты полоса дает вам), все, что происходит, кнопка бесконечно вращается, и я получаю следующие ошибки в консоли:

GET https://checkout.stripe.com/api/account/lookup?email=MYEMAILADDRESS&key=&locale=en-US 400 (Bad Request)

и

Uncaught SecurityError: Failed to read the 'contentDocument' property from 'HTMLIFrameElement': Blocked a frame with origin "http://localhost:3000" from accessing a frame with origin "https://checkout.stripe.com". The frame requesting access has a protocol of "http", the frame being accessed has a protocol of "https". Protocols must match.

Когда я добавляю свою электронную почту в форму, я также получаю эту ошибку:

The specified value "MYEMAILADDRESS" is not a valid email address.

Вот мой набор до

routes.rb

resources :shop 

shop_controller

class ShopController < ApplicationController 

     def index 
     @products = Product.all 
     end 

     def show 
     @product = Product.find(params[:id]) 
     end 

     def new 
     end 

     # the create happens in the show action 
     def create 
     @product = Product.find(params[:id]) 
     customer = Stripe::Customer.create(
      :email => params[:stripeEmail], 
      :source => params[:stripeToken] 
     ) 

     charge = Stripe::Charge.create(
      :customer => customer.id, 
      :amount  => @product.price * 100, 
      :description => @product.description, 
      :currency => 'usd' 
     ) 

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

    end 

show.html.erb (где визуализируется форма Вверх ау)

<div class='shop-show'> 
    <div class="container"> 
    <div class="row text-center"> 
     <div class="col-lg-12 col-xs-12"> 
     <h2><%= @product.name %></h2> 
     <hr class="generic"> 
     </div> 
    </div> 

    <div class="row"> 
     <div class="col-md-6 col-md-offset-3"> 
     <div class="white_panel"> 
      <%= form_for @product, url: url_for(controller: 'shop', action: 'create') do %> 
      <% if flash[:error].present? %> 
       <div id="error_explanation"> 
       <p><%= flash[:error] %></p> 
       </div> 
      <% end %> 
      <script src="http://checkout.stripe.com/checkout.js" class="stripe-button" 
       data-key="<%= Rails.configuration.stripe[:publishable_key] %>" 
       data-description="<%= @product.description %>" 
       data-amount="<%= @product.price * 100 %>" 
       data-locale="auto" 
       data-shipping-address=true> 
      </script> 
      <% end %> 
      <img class="img-responsive" width='400' height='250' src="<%= @product.pictures.first.image.url %>"> 
      <h2><%= @product.description %></h2> 
     </div> 
     </div> 
    </div> 
    </div> 
</div> 

Кто-нибудь создать такую ​​функциональность раньше? Это было тщательно соблюдено, используя ссылку, предоставленную полосой: https://stripe.com/docs/checkout/rails. Любая помощь с этой настройкой была бы очень оценена. Благодарю.

ответ

0

URL-адрес тега Checkout ctript должен быть получен через HTTPS. Попробуйте поменять это:

<script src="http://checkout.stripe.com/checkout.js" 

для этого:

<script src="https://checkout.stripe.com/checkout.js" 
+0

у меня было на HTTPS, чтобы начать, и он не работает, поэтому я изменил его на HTTP. Каким-то образом (возможно, другой конфигурационный браузер? И т. Д.) Я изменил его, и он сработал. Благодаря! –

Смежные вопросы