Magento Multiple Authorize.net Gateways

半城伤御伤魂 提交于 2019-12-10 21:06:25

问题


I've seen this question asked with regard to currency type, but what I am asking is how to configure a second Authorize.net account on the same store for a different credit card type. So, we want some credit cards to use the first main Authorize.net gateway, but the others to use the secondary Authorize.net account so that the payments can be routed into two different bank accounts. This is for purposes of reconciliation and is a constraint; can't be modified.

I'm figuring that all I need to do is figure out once the order has been submitted (but before it has been sent via API to Authorize.net) which card type it is, to know which credentials to pass to the API, but I'm unsure as to where to add this code, or the best way in which to add it.

Any insight or advice would be greatly appreciated.


回答1:


By default, there is no way to accomplish this, so you'll need to use some custom code. Specifically, override the Authnet payment 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 that function, on line 277 for me, the following code is executed to set the Authnet account:

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

Instead, you want something along these lines:

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

To accomplish this, you'll also want to create new options in the backend to hold the credentials in an encrypted form. Hope that helps!

Thanks, Joe



来源:https://stackoverflow.com/questions/5109783/magento-multiple-authorize-net-gateways

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