2015-01-05 30 views
-1

我目前正在建立一个电子商务网站,用于5个独立的公司使用woocommerce和authorize.net付款。动态改变authorize.net交易密钥?

迄今为止,对于单个供应商而言,授权很有效,问题在于,一旦我按地点选择了供应商,我需要在处理付款之前将api_transaction_keyapi_login_id更改为正确的供应商。

我一直在搜索几个小时的文件,现在无法找到密钥和ID设置。

有人可以帮我找到我可以覆盖的钥匙和id值,我需要什么? 或者为每个供应商创建一个新的支付网关并复制除密钥和ID以外的所有authorize.net网关信息会更好吗?

回答

0

如果有人对我是如何做这项工作感到好奇的,这个答案就在这里。
在Authorize.net woocommerce支付网关,你会发现一个名为

类-WC-授权净CIM-api.php

,它是在这个文件中的contruct功能你的钩子需要放置。

public function __construct($api_user_id, $api_transaction_key, $environment) { 
    // File default code 
    } 

这就需要遵循三行代码放置前的默认文件代码

$custom_auth_info = apply_filters('get_custom_auth', $custom_auth_info); 
$api_user_id = $custom_auth_info['api_user_id']; 
$api_transaction_key = $custom_auth_info['api_transaction_key'];  

的apply_filters是指下列功能被放置在我的插件

add_filter('get_custom_auth', 'select_distributor_by_state'); 

function select_distributor_by_state($custom_auth_info = []) { 
    global $wpdb; 

    //Your Query is here to select the proper distributor from the DB 
    //and retrieve their custom Authorize.net ID and Transaction Key 

    $custom_auth_info['api_user_id'] = $your_query[0]['api_loginid']; 
    $custom_auth_info['api_transaction_key'] = $your_query[0]['api_transactionkey']; 
    $_SESSION['dealer'] = $vendor[0]['id']; 
    return $custom_auth_info; 
} 

这个过滤器允许你挂钩,抓取你需要的数据,然后返回它nd在处理付款之前将其直接应用到代码中。