Stripe测试交易(Rails)没有收到钱

时间:2016-05-15 13:01:11

标签: ruby-on-rails stripe-payments

所以我使用Stripe的测试API密钥在我的Rails应用程序中创建了订阅。 我用虚拟卡创建的费用在我这边成功完成,但是当我在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 %>   

2 个答案:

答案 0 :(得分:2)

确保您使用的是Stripe测试API密钥,而不是您的实时密钥。这些可以在条带信息中心的帐户设置的“API密钥”部分找到:

enter image description here

因此,您使用的API密钥应包含_test_

为了进行测试,您还应该考虑使用StripeMock,它运行虚拟Stripe服务器来模拟Stripe:https://github.com/rebelidealist/stripe-ruby-mock

修改

如果您仍然遇到错误,请检查条带日志并在此处提供编辑副本:

enter image description here

答案 1 :(得分:0)

我花了将近一年的时间才能找到答案。

我仅在本机应用程序上使用 tipsi-stripe

我不知道我需要将令牌发送到我自己的后端。而且我的后端需要与条带REST API通信,以便使用该令牌并从中进行付款。

https://stripe.com/docs/payments/accept-a-payment-charges