views:

33

answers:

2

I have a CAD and USD gateway accounts for processing credit card payments, both from a payment provider with support for the Authorize.net API. I've successfully configured one using Magento's built-in Authorize.net support... but how can I configure a second Authorize.net Gateway for use in my store?

A: 

This can be done, but basically requires you to duplicate the Authorize module and change all the namespaces. This will take some fiddling, but start by copying the app/code/core/Mage/Paygate module to somewhere like app/code/local/Yourcompany/Paygatecad and proceed to rename the classes (Mage_Paygate_Model_Authorizenet becomes Yourcompany_Paygatecad_Model_Authorizenet, etc). Be careful of case-sensitive file and class names, I suggest you use all leading capital followed by lowercase.

Create a Yourcompany_Paygatecad.xml module declaration in app/etc/modules, and duplicate the layout and template files in adminhtml and frontend to use your new module name. You'll also need to edit the system.xml and config.xml so that the config values don't conflict in namespace. grep is your friend.

After all that, you should get a new Payment Method in the System>Config>Payment Methods that you can configure with your CAD details, and the blocks should render in the Checkout flow.

As you've probably gathered from what I've said, there's a fair few changes to be made to avoid conflicts, and you'll need to test this really well. But it should work. I'm not aware of any alternative approach to achieve this... I've done this successfully when I've wanted two different set of options for another payment method and it worked, but that was for a community extension, not Magento core, not that it should really matter where you're copying it from.

--------EDIT-----

Ideally, what you should do is copy and modify only the etc and sql files. That way the original Mage_Paygate Models and controllers will still be used (gives you best protection for upgrades/patches) and you just update the config values to point to the CAD instance. I can't confirm whether this will work, but I would try that if at all possible.

HTH, JD

Jonathan Day
Thanks, that's exactly what I was asking for, but I think clockworkgeek's solution probably makes more sense than what I was thinking.
balleyne
A: 

You can reuse the existing authorize.net gateway if you assign separate websites to each currency. They don't need to be actually separate websites with their own domain, just to be designated as websites in the System > Manage Stores menu. Then in Configuration change the Configuration Scope drop down box in the top left to select each website in turn, on the Currency Setup section allow just one currency and in Payment Methods section you can have your specific gateway accounts to match.

This way lets you continue to use the same products for all stores and as long as the base currency is unchanged then it will also continue to convert between currencies automatically.

clockworkgeek
Ah, this seems like a better idea than what I was thinking. I think we'll actually make use of some other domains we have (we have .com and .ca...), but I'll need to get the appropriate SSL certificates for that. Thanks very much for the answer though, that sounds like the right thing to do.
balleyne
Since you already have the .ca domain it makes sense to take advantage of it. Good luck.
clockworkgeek
this is a much better solution than mine - nice one @clockworkgeek
Jonathan Day