使用Authorize.Net DPM付款后,我得到了不同的哈希值。 它以前曾在工作,但从最近的1-2天开始一直没有工作。 我正在使用以下功能为x_hp_hash生成指纹-
{
"id": 1,
"views": 0,
"modelb": [
{
"id": 46,
"string": "Test1",
"item": 1
},
{
"id": 47,
"string": "Test85",
"item": 1
},
{
"id": 48,
"string": "Test64",
"item": 1
}
]
}
付款后进行哈希比较-
$signature_key = hex2bin($signature_key);
if (function_exists('hash_hmac')) {
return hash_hmac("sha512", $api_login_id . "^" . $fp_sequence . "^" .
$fp_timestamp . "^" . $amount . "^", $signature_key);
}
return bin2hex(mhash(MHASH_SHA512, $api_login_id . "^" . $fp_sequence . "^" . $fp_timestamp . "^" . $amount . "^", $signature_key));
始终给予无效。以前在工作。我确实在2019年1月开始更新了此代码,此后便一直有效。
$ _ POST在测试环境中的值-
$hashFields = [
$_POST['x_trans_id'],
$_POST['x_test_request'],
$_POST['x_response_code'],
$_POST['x_auth_code'],
$_POST['x_cvv2_resp_code'],
$_POST['x_cavv_response'],
$_POST['x_avs_code'],
$_POST['x_method'],
$_POST['x_account_number'],
$_POST['x_amount'],
$_POST['x_company'],
$_POST['x_first_name'],
$_POST['x_last_name'],
$_POST['x_address'],
$_POST['x_city'],
$_POST['x_state'],
$_POST['x_zip'],
$_POST['x_country'],
$_POST['x_phone'],
$_POST['x_fax'],
$_POST['x_email'],
$_POST['x_ship_to_company'],
$_POST['x_ship_to_first_name'],
$_POST['x_ship_to_last_name'],
$_POST['x_ship_to_address'],
$_POST['x_ship_to_city'],
$_POST['x_ship_to_state'],
$_POST['x_ship_to_zip'],
$_POST['x_ship_to_country'],
$_POST['x_invoice_num'],
];
$hashString = '^'.implode('^', $hashFields).'^';
$signature_key = hex2bin($signature_key);
$generatedhash = strtoupper(HASH_HMAC('sha512', $hashString, $signature_key));
if (function_exists('hash_equals')) {
$equals = hash_equals($_POST['x_SHA2_Hash'], $generatedhash);
} else {
$equals = $_POST['x_SHA2_Hash'] === $generatedhash;
}
if($equals) {
//valid
} else{
//not valid
}