|
@@ -18,6 +18,9 @@ class Yspay extends Core
|
|
|
$set = explode('|', $config['key']);
|
|
|
$config['sub_appid'] = $set[0];
|
|
|
$config['sub_appsecret'] = $set[1];
|
|
|
+ if (isset($set[2])) {
|
|
|
+ $config['key'] = $set[2];
|
|
|
+ }
|
|
|
$this->config = $config;
|
|
|
}
|
|
|
|
|
@@ -32,19 +35,41 @@ class Yspay extends Core
|
|
|
} else {
|
|
|
$input = Dever::input();
|
|
|
}
|
|
|
- $this->log('支付回调-初始化', $input);
|
|
|
- echo 'FAILED';die;
|
|
|
- return;
|
|
|
+ $test = Dever::input('test');
|
|
|
+ if ($test == 1) {
|
|
|
+ $input = json_decode('{"msgType":"wx.notify","payTime":"2021-12-29 18:24:42","buyerCashPayAmt":"1","connectSys":"UNIONPAY","sign":"E82978003E0121B320D3520B1930FB4C2072B639126F3427351631F1D0A998CF","merName":"中食民安(北京)科技有限公司","mid":"89810007372106N","invoiceAmount":"1","settleDate":"2021-12-29","billFunds":"现金:1","buyerId":"otdJ_uD-zTNmDn7-u13oActXu8lA","mchntUuid":"2d9081bd7db8ad75017dbbe68981314f","tid":"DM098308","instMid":"MINIDEFAULT","receiptAmount":"1","couponAmount":"0","targetOrderId":"4200001344202112290882463274","signType":"SHA256","billFundsDesc":"现金支付0.01元。","subBuyerId":"oGlMn5e_vdYK8uAaCgyexarFKBrY","orderDesc":"中食民安(北>京)科技有限公司","seqId":"25267273719N","merOrderId":"138K_G202112297347788956443487","targetSys":"WXPay","bankInfo":"OTHERS","totalAmount":"1","createTime":"2021-12-29 18:24:38","buyerPayAmount":"1","iB":"KRHn","notifyId":"d4122965-b772-4f8f-b5c4-f3d483da0962","subInst":"100000","status":"TRADE_SUCCESS"}', true);
|
|
|
+ }
|
|
|
+ $sign = $input['sign'];
|
|
|
+ unset($input['sign']);
|
|
|
|
|
|
ksort($input);
|
|
|
- $input = http_build_query($input);
|
|
|
-
|
|
|
- $tools = new \Cmbc\Handle();
|
|
|
- $callback = $tools->get('notify', $this->config);
|
|
|
- $result = $callback->request($input, $this);
|
|
|
- if ($result) {
|
|
|
- $this->log('支付回调-获取数据', $result);
|
|
|
- $this->updateOrder($result['mhtOrderNo'], $result['mhtOrderAmt']);
|
|
|
+ $string = array();
|
|
|
+ foreach ($input as $k => $v) {
|
|
|
+ if (strstr($v, '&') || strstr($v, '@')) {
|
|
|
+ $v = urlencode($v);
|
|
|
+ }
|
|
|
+ $string[] = $k . '=' . $v;
|
|
|
+ }
|
|
|
+ $string = implode('&', $string);
|
|
|
+ $string .= $this->config['key'];
|
|
|
+
|
|
|
+ if ($input['signType'] == 'SHA256') {
|
|
|
+ $string = sha1($string);
|
|
|
+ } else {
|
|
|
+ $string = md5($string);
|
|
|
+ }
|
|
|
+
|
|
|
+ $string = strtoupper($string);
|
|
|
+
|
|
|
+ $input['sign'] = $sign;
|
|
|
+ $input['e_sign'] = $string;
|
|
|
+ $this->log('支付回调-初始化', $input);
|
|
|
+
|
|
|
+ if ($sign == $string) {
|
|
|
+ if (isset($this->config['prefix']) && $this->config['prefix']) {
|
|
|
+ $input['merOrderId'] = str_replace($this->config['prefix'] . '_', '', $input['merOrderId']);
|
|
|
+ }
|
|
|
+ $this->updateOrder($input['merOrderId'], $input['totalAmount']);
|
|
|
echo 'SUCCESS';die;
|
|
|
} else {
|
|
|
echo 'FAILED';die;
|