如何模拟 ActiveMerchant 和 Authorize.net 信用卡处理的失败情况?

发布于 2024-12-15 14:44:41 字数 661 浏览 2 评论 0原文

我已将 ActiveMerchant 或多或少地按照 RailsCast< 中概述的方式集成到我的 Rails 3 应用程序中/a> 使用 Authorize.net 作为我的网关的主题。我在开发过程中以测试模式 (ActiveMerchant::Billing::Base.mode = :test) 运行网关,一切似乎都按成功案例的预期运行。对于格式不正确的输入,信用卡验证工作正常,但为了充分验证我的工作流程,我还想测试购买失败的情况,例如资金不足或 CCV 代码不匹配。不幸的是,我似乎收到了response.success? == true 对于任何格式正确的信用卡号,至少在针对我的 Authorize.net 测试帐户进行测试模式操作时是如此。

所以,我的问题是:我应该如何在 gateway.purchase() 调用中模拟特定类型的失败?是否有一个测试卡号总是资金不足?我是否只需要虚拟我自己的 response 对象?这里最正确的方法是什么?

警告:我对 Ruby、Rails 和信用卡处理很陌生,所以如果答案非常明显,请原谅我。进行了相当多的谷歌搜索,但找不到练习故障模式的示例。

I've integrated ActiveMerchant into my Rails 3 app more or less along the lines outlined in the RailsCast on the topic using Authorize.net as my gateway. I'm running the gateway in test mode (ActiveMerchant::Billing::Base.mode = :test) in development, and everything seems to be working as expected for the success case. The credit card validation is working fine for incorrectly formatted input, but in order to fully verify my workflows, I'd like to also test purchase failure cases, such as insufficient funds or miss-matched CCV code. Unfortunately, it seems that I'm receiving response.success? == true for any correctly formatted credit card number, at least when operating in test mode against my Authorize.net test account.

So, my question is: How should I simulate particular types of failures on my gateway.purchase() call? Is there a test card number which always has insufficient funds? Do I just need to dummy up my own response object? What's the most correct approach here?

Caveat: I'm new to Ruby, Rails, and credit card processing, so please forgive me if the answer is desperately obvious. Did a fair bit of Googling and couldn't find an example exercising the failure modes.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文