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?