我正在使用条纹和导轨进行结帐。我有一个shop_controller
,它提供shop#index
中的产品列表。然后导致条形式所在的shop#show
,用户可以购买产品。被阻挡的条纹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(其中形式呈现最佳AY)
<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。任何帮助这个设置将非常感激。谢谢。
我有它在HTTPS开始,这是行不通的,所以我把它改为HTTP。不知何故(也许另一个配置?陈旧的浏览器?等)我改回它,它的工作。谢谢! –