gpt4 book ai didi

ruby-on-rails - 使用 ActiveMerchant 测试 Paypal 错误消息

转载 作者:太空宇宙 更新时间:2023-11-03 15:51:45 24 4
gpt4 key购买 nike

有没有办法测试您的应用程序处理和处理 Paypal 生成的信用卡错误的能力?我想验证我的应用程序是否可以处理被拒绝的信用卡或类似的东西。

那么有没有办法让Paypal发送错误信息呢?或者生成一个 stub 并在测试环境中使用它会更好吗?如果这是更好的方法,如何生成 stub ?

谢谢!

最佳答案

是的!您可以通过设置进行测试:

ActiveMerchant::Billing::Base.mode = :test

但是 PayPal 会要求您输入完整的账单信息,否则 API 甚至不会接受并返回:

Error: There's an error with this transaction. Please enter a complete billing address.

在这种情况下,您可以为其提供一些通用信息:

:billing_address => {
:name => "Test Guy",
:address1 => "123 W 423 E",
:city => "Somewhere",
:state => "CA",
:country => "US",
:zip => "88888"
}

关于ruby-on-rails - 使用 ActiveMerchant 测试 Paypal 错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2472867/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com