如何模拟 ActiveMerchant 和 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须使用正确的邮政编码来通过您想要的失败:
http://community.developer.authorize.net/t5/Integration-and-Testing/Triggering-Specific-Transaction-Responses-Using-Test-Account/mp/4361
You have to pass the failure you want by using the proper zip code:
http://community.developer.authorize.net/t5/Integration-and-Testing/Triggering-Specific-Transaction-Responses-Using-Test-Account/m-p/4361