/** 例如: appid: wxd930ea5d5a258f4f mch_id: 10000100 device_info: 1000 Body: test nonce_str: ibuaiVcKdpRxkhJA 第一步:对参数按照 key=value 的格式,并按照参数名 ASCII 字典序排序如下: stringA="appid=wxd930ea5d5a258f4f&body=test&device_info=1000&mch_i d=10000100&nonce_str=ibuaiVcKdpRxkhJA"; 第二步:拼接支付密钥: stringSignTemp="stringA&key=192006250b4c09247ec02edce69f6a2d" sign=MD5(stringSignTemp).toUpperCase()="9A0A8659F005D6984697E2CA0A 9CF3B7" */ protected function get_sign() { try { if (null == PARTNERKEY || "" == PARTNERKEY) { // throw new SDKRuntimeException("密钥不能为空!" . "<br>"); throw new SDKRuntimeException("Pkey can't null!" . "<br>"); } if ($this->check_sign_parameters() == false) { //检查生成签名参数 // throw new SDKRuntimeException("生成签名参数缺失!" . "<br>"); throw new SDKRuntimeException("check_sign_parameters!" . "<br>"); } $commonUtil = new CommonUtil(); ksort($this->parameters); // print_r("<pre>"); // print_r($this->parameters); // print_r("</pre>"); $unSignParaString = $commonUtil->formatQueryParaMap($this->parameters, false); $md5SignUtil = new MD5SignUtil(); $returns = $md5SignUtil->sign($unSignParaString, $commonUtil->trimString(PARTNERKEY)); // print_r("++++++++++++++++++++++++".$returns); return $returns; } catch (SDKRuntimeException $e) { die($e->errorMessage()); } }