需要帮助从 md5 更新到 sha-512 Authorize.net

Need help updating from md5 to sha-512 Authorize.net

我是 authorize.net 的新手,我收到他们的一封电子邮件,说他们正在逐步淘汰 md5 哈希,我必须通过签名密钥转移到 sha-512 哈希,但我没有任何知道怎么做。

我已经按照他们网站上的 hello world (PHP) 步骤进行操作:https://developer.authorize.net/hello_world/ 并且工作正常。

我的代码中没有任何 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";
        }

    }

MD5 哈希仅用于验证交易响应是否确实来自 Authorize.Net。此代码使用 AIM API 处理交易,这通常不需要验证响应,因为您是直接调用 Authorize.Net 获得的。 MD5 哈希通常由 SIM 和 DPM API 用户使用,他们与 Authorize.Net 没有直接连接,因此需要一种方法来验证响应的真实性。