Magento Multiple Authorize.net Gateways

I saw this question asked regarding the type of currency, but I am asking how to set up a second Authorize.net account in the same store for a different type of credit card. So, we want some credit cards to use the first primary Authorize.net gateway, and the rest to use the secondary Authorize.net account so that payments can be sent to two different bank accounts. This is for reconciliation purposes and is a limitation; cannot be changed.

I believe that all I need to do is find out how the order was sent (but before it was sent via the API to Authorize.net), what type of card it is, to find out what credentials for the API transfer but I'm not sure where to add this code or the best way to add it.

Any information or advice would be helpful.

+3
source share
1 answer

By default, there is no way for this, so you will need to use some kind of custom code. In particular, override the Authnet billing class Mage_Paygate_Model_Authorizenet:

class MyNamespace_MyModule_Model_Authorizenet extends Mage_Paygate_Model_Authorizenet {

  /**
   * Prepare request to gateway
   *
   * @link http://www.authorize.net/support/AIM_guide.pdf
   * @param Mage_Sales_Model_Document $order
   * @return unknown
   */
  protected function _buildRequest(Varien_Object $payment) 
     //see below
  }
}

In this function, for line 277, the following code is executed for me to set up an Authnet account:

    $request->setXLogin($this->getConfigData('login'))
        ->setXTranKey($this->getConfigData('trans_key'))
        ->setXType($payment->getAnetTransType())
        ->setXMethod($payment->getAnetTransMethod());   

Instead, you need something in this direction:

if(whatever cc type) {
     // set alternate gateway
} else {
     // set default gateway
}

For this, you will also want to create new parameters in the backend for storing credentials in encrypted form. Hope this helps!

Thanks Joe

+3
source

Source: https://habr.com/ru/post/1794544/


All Articles