/** * Gets the redirect target url. */ public function getRedirectUrl() { $data = $this->getData(); $params = array_except($data, 'merchantKey'); $merchantKey = $data['merchantKey']; $sTotalString = Utils::POSTDATA($this->endpoint, $params); $recv = $sTotalString["MSG"]; $recv = iconv('gb2312', 'utf-8', $recv); $recvArray = Utils::parseRecv($recv); $code = $recvArray["returnCode"]; $payUrl = false; if ($code != "000000") { // echo "code:" . $code . "</br>msg:" . decodeUtf8($recvArray["message"]); return $code . ':' . $recvArray["message"]; } else { $vfsign = $recvArray["merchantId"] . $recvArray["requestId"] . $recvArray["signType"] . $recvArray["type"] . $recvArray["version"] . $recvArray["returnCode"] . $recvArray["message"] . $recvArray["payUrl"]; $hmac = Utils::MD5sign($merchantKey, $vfsign); $vhmac = $recvArray["hmac"]; if ($hmac != $vhmac) { echo "验证签名失败!"; exit; } else { $payUrl = $recvArray["payUrl"]; //返回url处理 $rpayUrl = Utils::parseUrl($payUrl); $payUrl = $rpayUrl['url']; $this->redirectMethod = $rpayUrl['method']; } } return $payUrl; }