Accepting dummy credit cards on a live site with ActiveMerchant & PayPal

自闭症网瘾萝莉.ら 提交于 2019-12-05 07:21:37

问题


I'm setting up a rails site that will accept credit cards with ActiveMerchant and PayPal Website Payments Pro. I am successfully testing against the PayPal sandbox, but need to be able to test on my live site as well. I'd like to implement a solution whereby registrations on my live site with email addresses from my own domain use the PayPal sandbox, but for everyone else it uses the live PayPal site. That way when I test my live site I'm not paying myself and getting taxed by PayPal in the process :-)

The problem, however, is that to get ActiveMerchant to use the test servers you write this line:

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

That sets a class variable which will apply to other transactions on the site, when I simply wish for one transaction to target the test servers.

Can anyone suggest an elegant solution? Or are there better ways to accomplish this other than the solution I have in mind?


回答1:


It´s always dangerous to leave a backdoor open. I'd recommend against running your production environment against the sandbox under any circumstance. If you need to run an ocassional test do it against the live PayPal environment and process a refund immediately - no fuss and no charge.



来源:https://stackoverflow.com/questions/999521/accepting-dummy-credit-cards-on-a-live-site-with-activemerchant-paypal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!