如果有人對我是如何做這項工作感到好奇的,這個答案就在這裏。
在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在處理付款之前將其直接應用到代碼中。