【问题标题】:Not receiving money in Stripe test transactions (Rails)在 Stripe 测试交易中没有收到钱(Rails)
【发布时间】: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


【解决方案1】:

确保您使用的是 Stripe 测试 API 密钥,而不是您的实时密钥。这些可以在 Stripe 控制面板的帐户设置的“API 密钥”部分找到:

所以您使用的 API 密钥应该包括 _test_

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

编辑

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

【讨论】:

    【解决方案2】:

    我花了将近一年的时间才发现这一点。

    我只在我的 react-native 应用上使用了 tipsi-stripe

    我不知道我需要将 令牌 发送到我自己的后端。我的后端需要与 Stripe REST API 通信,才能使用该令牌并以此创建付款。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-02-12
      • 2021-04-22
      • 1970-01-01
      • 2021-08-31
      • 2016-05-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多