【发布时间】:2016-05-15 13:01:10
【问题描述】:
所以我在我的 Rails 应用程序中使用 Stripe 的测试 API 密钥创建了订阅。 我使用虚拟卡创建的费用在我这边成功通过,但是当我在 Stripe 仪表板中时,测试余额保持不变,也没有添加客户详细信息。我不确定我做错了什么。你知道为什么我不能以及如何将这些测试客户数据添加到 Stripe 吗?在日志中,我得到了 200 OK 响应,但我担心在实时模式下某些东西不会起作用,因为没有更新测试余额。
class SubscribersController < ApplicationController
before_filter :authenticate_user!
def new
end
def update
token = params[:stripeToken]
customer = Stripe::Customer.create(
card: token,
plan: 1020,
email: current_user.email
)
current_user.subscribed = true
current_user.stripeid = customer.id
current_user.save
redirect_to profiles_user_path
end
end
和_form.html.erb
<%= form_tag profiles_user_path, method: :get do %>
<script src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="<%= Rails.configuration.stripe[:publishable_key] %>"
data-description="A month's subscription"
data-amount="8999"></script><span> $89 per month </span>
<% end %>
【问题讨论】:
-
当您调用更新操作时,您是否在 Rails 日志或浏览器控制台中收到任何警告或错误?
-
不,我这边一切都很顺利,我没有收到任何错误,我正在使用测试 api 密钥..
-
Stripe 仪表板中的日志怎么样?
-
我的状态为 200,这是响应正文的一部分:tok_18BPCiAwJUZIqFavuf8fN27f 对象:"token" 卡:id:card_18BPCiAwJUZIqFavCQ2TFbIr 对象:"card" 品牌:"Visa" 国家:"US" cvc_check: "pass" dynamic_last4: null exp_month: 11 exp_year: 2018 资金: "credit" last4: "4242" metadata: name: "test@gmail.com" tokenization_method: null email: "test@gmail.com" livemode: false type:使用“卡”:假
-
好的会联系他们看看发生了什么!将及时向大家发布。谢谢
标签: ruby-on-rails stripe-payments