我是authorize.net的新手,我从他们那里收到一封电子邮件,说他们正在逐步淘汰md5哈希,我必须通过签名密钥转移到sha-512哈希,但是我不知道该怎么办那个。
我已经从他们的网站https://developer.authorize.net/hello_world/开始执行了hello world(PHP)步骤,并且运行正常。
我的代码中没有任何md5,并且我认为我当前正在使用的sdk包含该代码。
这是我从客户的信用卡收取费用时的代码
function chargeCreditCard($arrayPost, $creditCardNum, $creditCardExp, $creditCardCode)
{
$totalAmountDue = str_replace(',', '', $arrayPost['total-due']);
// Common setup for API credentials
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
$merchantAuthentication->setName(X_API_LOGIN);
$merchantAuthentication->setTransactionKey(X_TRAN_KEY);
$refId = 'ref' . time();
// Create the payment data for a credit card
$creditCard = new AnetAPI\CreditCardType();
$creditCard->setCardNumber($creditCardNum);
$creditCard->setExpirationDate($creditCardExp);
$creditCard->setCardCode($creditCardCode);
$paymentOne = new AnetAPI\PaymentType();
$paymentOne->setCreditCard($creditCard);
$order = new AnetAPI\OrderType();
$order->setInvoiceNumber($arrayPost['invoice']);
$order->setDescription(PRODUCT_DESCRIPTION);
// Set the customer's Bill To address
$customerAddress = new AnetAPI\CustomerAddressType();
$customerAddress->setFirstName($arrayPost['fname']);
$customerAddress->setLastName($arrayPost['lname']);
$customerAddress->setCompany($arrayPost['company']);
$customerAddress->setAddress($arrayPost['address']);
$customerAddress->setCity($arrayPost['city']);
$customerAddress->setState($arrayPost['state']);
$customerAddress->setZip($arrayPost['zip']);
$customerAddress->setCountry($arrayPost['country']);
// Create a TransactionRequestType object
$transactionRequestType = new AnetAPI\TransactionRequestType();
$transactionRequestType->setTransactionType("authCaptureTransaction");
$transactionRequestType->setAmount($totalAmountDue);
$transactionRequestType->setOrder($order);
$transactionRequestType->setPayment($paymentOne);
$transactionRequestType->setBillTo($customerAddress);
$request = new AnetAPI\CreateTransactionRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setRefId($refId);
$request->setTransactionRequest($transactionRequestType);
$controller = new AnetController\CreateTransactionController($request);
$response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::PRODUCTION);
if ($response != null) {
$tresponse = $response->getTransactionResponse();
if ($response->getMessages()->getResultCode() == "Ok") {
if ($tresponse != null && $tresponse->getMessages() != null) {
$messages = "";
$errors = "";
$responseCode = $tresponse->getResponseCode();
$rawResponseCode = $tresponse->getRawResponseCode();
$authCode = $tresponse->getAuthCode();
$avsResultCode = $tresponse->getAvsResultCode();
$cvvResultCode = $tresponse->getCvvResultCode();
$cavvResultCode = $tresponse->getCavvResultCode();
$transId = $tresponse->getTransId();
$refTransID = $tresponse->getRefTransID();
$transHash = $tresponse->getTransHash();
$testRequest = $tresponse->getTestRequest();
$accountNumber = $tresponse->getAccountNumber();
$entryMode = $tresponse->getEntryMode();
$accountType = $tresponse->getAccountType();
$splitTenderId = $tresponse->getSplitTenderId();
$prePaidCard = $tresponse->getPrePaidCard();
if($tresponse->getMessages() != null){
$messages .= " Code : " . $tresponse->getMessages()[0]->getCode() . "\n";
$messages .= " Description : " . $tresponse->getMessages()[0]->getDescription() . "\n";
}
if($tresponse->getErrors() != null){
$errors .= " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n";
$errors .= " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n";
}
$splitTenderPayments = serialize($tresponse->getSplitTenderPayments());
$userFields = serialize($tresponse->getUserFields());
$shipTo = $tresponse->getShipTo();
$secureAcceptance = $tresponse->getSecureAcceptance();
$emvResponse = $tresponse->getEmvResponse();
$transHashSha2 = $tresponse->getTransHashSha2();
//$profile = $tresponse->getProfile();
$profile = "";
//SAVE PERSONAL DETAILS
$personal_detail_id = $this->objEcommerceModel->savePersonalDetails($arrayPost['fname'], $arrayPost['lname'], $arrayPost['company'], $arrayPost['address'], $arrayPost['city'], $arrayPost['state'], $arrayPost['zip'], $arrayPost['country']);
//SAVE MERCHANT LOGS
$this->objEcommerceModel->saveMerchantTransactionLogs($personal_detail_id, $responseCode, $rawResponseCode, $authCode, $avsResultCode, $cvvResultCode, $cavvResultCode, $transId, $refTransID, $transHash, $testRequest, $accountNumber, $entryMode, $accountType, $splitTenderId, $prePaidCard, $messages, $errors, $splitTenderPayments, $userFields, $shipTo, $secureAcceptance, $emvResponse, $transHashSha2, $profile);
return 'Success';
} else {
$msg = "Transaction Failed \n";
if ($tresponse->getErrors() != null) {
$msg .= " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n";
$msg .= " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n";
}
}
} else {
$msg = "Transaction Failed \n";
$tresponse = $response->getTransactionResponse();
if ($tresponse != null && $tresponse->getErrors() != null) {
$msg .= " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n";
$msg .= " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n";
} else {
$msg .= " Error code : " . $response->getMessages()->getMessage()[0]->getCode() . "\n";
$msg .= " Error message : " . $response->getMessages()->getMessage()[0]->getText() . "\n";
}
}
} else {
$msg .= "No response returned \n";
}
}
答案 0 :(得分:1)
MD5哈希仅用于验证事务响应实际上是否来自Authorize.Net。此代码使用AIM API处理事务,由于直接调用Authorize.Net即可获得响应,因此通常不需要验证响应。没有直接连接到Authorize.Net的SIM和DPM API用户通常使用MD5哈希,因此需要一种方法来验证响应的真实性。