From 926b21dcf4e6927938a85d2806a25afd1ff0b371 Mon Sep 17 00:00:00 2001 From: sugar1569 Date: Thu, 27 Dec 2018 12:37:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E5=9B=9E=E8=B0=83=E6=96=87=E4=BB=B6=E4=B8=A2=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/service/RoutineNotify.php | 58 ++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 extend/service/RoutineNotify.php diff --git a/extend/service/RoutineNotify.php b/extend/service/RoutineNotify.php new file mode 100644 index 00000000..f7b49872 --- /dev/null +++ b/extend/service/RoutineNotify.php @@ -0,0 +1,58 @@ +return_code != 'SUCCESS') die($postObj->return_msg); + if ($postObj->result_code != 'SUCCESS') die($postObj->err_code); + $arr = (array)$postObj; + unset($arr['sign']); + if (self::getSign($arr, $config['pay_routine_key']) == $postObj->sign) { + echo ''; + return $arr; + } + } + /** + * 获取签名 + */ + public static function getSign($params, $key) + { + ksort($params, SORT_STRING); + $unSignParaString = self::formatQueryParaMap($params, false); + $signStr = strtoupper(md5($unSignParaString . "&key=" . $key)); + return $signStr; + } + protected static function formatQueryParaMap($paraMap, $urlEncode = false) + { + $buff = ""; + ksort($paraMap); + foreach ($paraMap as $k => $v) { + if (null != $v && "null" != $v) { + if ($urlEncode) { + $v = urlencode($v); + } + $buff .= $k . "=" . $v . "&"; + } + } + $reqPar = ''; + if (strlen($buff) > 0) { + $reqPar = substr($buff, 0, strlen($buff) - 1); + } + return $reqPar; + } +} \ No newline at end of file