Ruby on rails 自定义条带表单未在Rails 4中生成令牌
我正在尝试使用Bootstrap3将stripe添加到Rails4内置的web应用程序中。我关注了Stripe网站()上的文档,但在创建令牌时遇到了问题。 我的条带日志显示没有创建令牌,因此我认为这可能是我的JS/表单造成的问题 我的表格: \u new.html.erbRuby on rails 自定义条带表单未在Rails 4中生成令牌,ruby-on-rails,ruby-on-rails-4,stripe-payments,Ruby On Rails,Ruby On Rails 4,Stripe Payments,我正在尝试使用Bootstrap3将stripe添加到Rails4内置的web应用程序中。我关注了Stripe网站()上的文档,但在创建令牌时遇到了问题。 我的条带日志显示没有创建令牌,因此我认为这可能是我的JS/表单造成的问题 我的表格: \u new.html.erb <form action="/charges" method="POST" id="payment-form"> <span class="payment-errors"></span&g
<form action="/charges" method="POST" id="payment-form">
<span class="payment-errors"></span>
<div class="form-group left-inner-addon ">
<i class="glyphicon glyphicon-user"></i>
<input name="sender_name" type="text" class="form-control" placeholder="Sender's Name"/>
</div>
<div class="form-group left-inner-addon">
<i class="glyphicon glyphicon-send"></i>
<input name="recipient_email" type="email" class="form-control" placeholder="Recipient's Email"/>
</div>
<div class="form-group left-inner-addon">
<i class="glyphicon glyphicon-pencil"></i>
<input name="recipient_msg" type="text" class="form-control" placeholder="Message to Recipient"/>
</div>
<div class="form-group left-inner-addon ">
<i class="glyphicon glyphicon-credit-card"></i>
<input type="text" class="form-control" placeholder="Credit Card Number" data-stripe="number"/>
</div>
<div class="form-group">
<div class="row">
<div class="col-xs-4 left-inner-addon ">
<i class="glyphicon glyphicon-calendar"></i>
<input type="text" class="form-control" placeholder="MM " data-stripe="exp-month"/>
</div>
<div class="col-xs-5 left-inner-addon ">
<i class="glyphicon glyphicon-calendar"></i>
<input type="text" class="form-control" placeholder="YYYY" data-stripe="exp-year"/>
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-xs-5 left-inner-addon ">
<i class="glyphicon glyphicon-ok-circle"></i>
<input type="text" class="form-control" placeholder="CVC" data-stripe="cvc"/>
</div>
</div>
</div>
<button type="submit" class="btn btn-primary">Purchase</button>
</form>
条带状态和响应
在我的条带日志中,我看到一个402到v1/费用的帖子和一个200到v1/客户的帖子
响应机构:
error:
message: "Cannot charge a customer that has no active card"
type: "card_error"
param: "card"
code: "missing"
object: "customer"
created: 1387668402
id: cus_3AJmiyuxLK9rTw
livemode: false
description: "payinguser@example.com"
email: null
delinquent: false
metadata:
subscription: null
discount: null
account_balance: 0
cards:
object: "list"
count: 0
url: "/v1/customers/cus_3AJmiyuxLK9rTw/cards"
data:
default_card: null
200响应机构:
error:
message: "Cannot charge a customer that has no active card"
type: "card_error"
param: "card"
code: "missing"
object: "customer"
created: 1387668402
id: cus_3AJmiyuxLK9rTw
livemode: false
description: "payinguser@example.com"
email: null
delinquent: false
metadata:
subscription: null
discount: null
account_balance: 0
cards:
object: "list"
count: 0
url: "/v1/customers/cus_3AJmiyuxLK9rTw/cards"
data:
default_card: null
我试图找出为什么我的代码没有创建令牌。
谢谢,您似乎正在取回一个令牌,但它的密钥不是您所期望的 从Stripe文档中:
{
id : "tok_u5dg20Gra" // String of token identifier
}
stripeResponseHandler
中的status
和response
的值是什么?您确定您的密钥是pk_test\u gGPOa0BlFvxdjnlnvJayZMzQ
(此外,不建议在任何地方发布公钥、私钥或任何与条带相关的密钥,是的,这是一个“测试”)一个,但仍然…例如,我的是pkngv0hji51yaznqbwit4qkpi1cng82
(我更改了几个字母使其无效),我在中没有该测试值it@pdoherty926刚刚发布了402和200响应。正在传递控制器的详细信息,而不是表单中的数据?@nrathaus感谢您的提醒,我已经在键中编辑了一些字符。我的API键中包含了“测试”键的测试,以及“活动”键的活动。@Questifer您有过吗解决这个问题?有同样的问题吗
{
id : "tok_u5dg20Gra" // String of token identifier
}