mirror of
https://github.com/crmeb/CRMEB.git
synced 2026-01-06 04:18:11 +00:00
小程序支付回调文件丢失
This commit is contained in:
parent
6828ed3d71
commit
926b21dcf4
58
extend/service/RoutineNotify.php
Normal file
58
extend/service/RoutineNotify.php
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
namespace service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小程序支付异步通知
|
||||||
|
* Class RoutineNotify
|
||||||
|
* @package service
|
||||||
|
*/
|
||||||
|
class RoutineNotify
|
||||||
|
{
|
||||||
|
public static function options(){
|
||||||
|
$payment = SystemConfigService::more(['routine_appId','routine_appsecret','pay_routine_mchid','pay_routine_key']);
|
||||||
|
return $payment;
|
||||||
|
}
|
||||||
|
public static function notify()
|
||||||
|
{
|
||||||
|
$config = self::options();
|
||||||
|
$postStr = file_get_contents('php://input');
|
||||||
|
$postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
|
||||||
|
if ($postObj === false) die('parse xml error');
|
||||||
|
if ($postObj->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 '<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>';
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user