【问题标题】:Stripe payment: params: error: type: invalid_request_error条纹支付:参数:错误:类型:invalid_request_error
【发布时间】:2018-03-25 00:20:19
【问题描述】:

我正在使用带有 ActiveMarchent 的 Stripe 支付网关,我已经实现了如下源代码:

ActiveMerchant::Billing::Base.mode = :test
 ActiveMerchant::Billing::StripeGateway.new(:login => 'sk_test_...')

我得到了下面的错误,我花了很多时间寻找解决方案,但是我没有找到它:

params:
 error:
 type: invalid_request_error
 message: Sending credit card numbers directly to the Stripe API is generally unsafe.
 We suggest you use test tokens that map to the test card you are using, see
 https://stripe.com/docs/testing.

谢谢

【问题讨论】:

    标签: ruby-on-rails ruby stripe-payments activemerchant


    【解决方案1】:

    您的集成似乎将卡号直接发送到 API。正如错误消息所说,这是不安全的——服务器端代码应该始终处理令牌而不是原始卡号。

    在生产中,令牌是使用CheckoutElements 在客户端创建的。如果您想编写自动化测试,这可能会很不方便,因此您可以改用测试令牌。点击“Tokens”标签查看每张测试卡here的测试代币。

    我没有使用 ActiveMerchant 绑定的经验,但是通过简要查看源代码,应该可以使用令牌:https://github.com/activemerchant/active_merchant/blob/d27c34e9e0e714afbf03d5eacf2a8cb20dc5b3da/lib/active_merchant/billing/gateways/stripe.rb#L97。您应该传递令牌 ID ("tok_...") 而不是卡哈希。

    【讨论】:

    • 谢谢,意思是我应该放token而不是卡号?
    【解决方案2】:

    实际上,Stripe 已经修复了这个错误。真正的罪魁祸首是活跃商家。它将信用卡号直接发送到条带 API。 不过,您只需在高级选项下的https://dashboard.stripe.com/account/integration/settings 启用“不安全地处理付款”即可解决此问题。

    【讨论】:

    • 如果你这样做,那么我相信你的公司需要符合 PCI 标准
    猜你喜欢
    • 2014-12-06
    • 2017-03-02
    • 2017-04-29
    • 2017-09-14
    • 2021-01-13
    • 2021-08-02
    • 2020-12-30
    • 2021-01-21
    • 2021-07-21
    相关资源
    最近更新 更多