2015-01-05 59 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在處理付款之前將其直接應用到代碼中。