2017-10-12 221 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上的「處理付款不安全」來解決此問題。