/** * 生成支付跳转链接 * * @return Wap支付中心URL * @throws Exception Wap支付中心连接异常, Wap支付中心初始化返回异常 */ function getURL() { $paraString = parent::genParaStr(); $domain = parent::getDomain(); $url = $domain . parent::$this->WAP_PAY_OPPOSITE_ADDRESS . '?' . $paraString; try { $http = new HttpClientUtil(); $util = new XmlParseUtil(); $str = $http->httpClientCall($url, "utf-8"); $wapPayInitResponse = new WapPayInitResponse($util->openapiXmlToMap($str, "utf-8"), parent::getSecretKey()); } catch (SDKRuntimeException $e) { die($e->errorMessage()); throw new SDKRuntimeException('Wap支付中心连接异常.' . $e->getMessage(), e); } if ($wapPayInitResponse && $wapPayInitResponse->isRetCodeOK()) { return $wapPayInitResponse->getURL(); } else { throw new SDKRuntimeException('Wap支付中心初始化返回异常.' . $wapPayInitResponse->getMessage()); } }