如果有人对我是如何做这项工作感到好奇的,这个答案就在这里。
在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在处理付款之前将其直接应用到代码中。