2017-10-12 225 views
-1

我使用与ActiveMarchent条纹支付网关,我已经实现如下的源代码:条纹付款:PARAMS:错误:类型:invalid_request_error

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

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

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. 

谢谢

回答

1

看来你的积分直接发送卡号到API。正如错误消息所述,这是不安全的 - 服务器端代码应该总是处理令牌而不是原始卡号。

在生产中,代币是使用CheckoutElements创建的客户端。如果你想编写自动化测试,这可能很不方便,所以你可以使用测试令牌。点击“Tokens”选项卡查看每个测试卡的测试令牌here

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

+0

谢谢,这意味着我应该把令牌而不是卡号? – Rodrigo

0

实际上,Stripe修复了这个错误。实际的罪魁祸首是活跃商人。它直接发送信用卡号码给条纹API。 但是,您可以通过在高级选项下简单启用https://dashboard.stripe.com/account/integration/settings上的“处理付款不安全”来解决此问题。