Commit feb3ef25 by yeran

update getNotifyData for MiNotify by yeran

1 parent c86cffc0
<?php
date_default_timezone_set('Asia/Shanghai');
//die(date('Y-m-d H:i:s', '1541417375'));
require_once __DIR__ . '/../../autoload.php';
use Payment\Common\PayException;
use Payment\Client\Charge;
use Payment\Config;
date_default_timezone_set('Asia/Shanghai');
$miConfig = require_once 'MiConfig.php';
......
......@@ -108,6 +108,10 @@ final class MiConfig extends ConfigInterface
$this->trade_type = 'MINIAPP'; // 默认是小程序支付
}
if (key_exists('return_raw', $config)) {
$this->returnRaw = filter_var($config['return_raw'], FILTER_VALIDATE_BOOLEAN);
}
// 检查 异步通知的url
if (key_exists('notify_url', $config) && !empty($config['notify_url'])) {
$this->notifyUrl = trim($config['notify_url']);
......
......@@ -66,7 +66,7 @@ abstract class MiBaseStrategy implements BaseStrategy{
if ($responseTxt['error'] != 0) { //通信标识
throw new PayException('支付平台返回错误提示0:' . $responseTxt['message']);
throw new PayException('支付平台返回错误提示3:' . $responseTxt['message']);
}
// 格式化为数组
......@@ -79,7 +79,7 @@ abstract class MiBaseStrategy implements BaseStrategy{
// }
if ($retData['result_code'] != 'SUCCESS') {//交易标识
$msg = $retData['errmsg']?:'交易失败-系统繁忙';
throw new PayException('支付平台返回错误提示2:' . $msg);
throw new PayException('支付平台返回错误提示3:' . $msg);
}
return $retData;
......
......@@ -42,9 +42,9 @@ class MiNotify extends NotifyStrategy
public function getNotifyData()
{
$params = array();
foreach($_POST as $key=>$val) {//动态遍历获取所有收到的参数,此步非常关键
$params[$key] = $val;
}
// foreach($_POST as $key=>$val) {//动态遍历获取所有收到的参数,此步非常关键
// $params[$key] = $val;
// }
//支持直接读取input流
$data = @file_get_contents('php://input');
......@@ -125,7 +125,7 @@ class MiNotify extends NotifyStrategy
'buyer_id' => $data['sub_openid'],
'order_no' => $data['out_trade_sn'],//平台
'meepay_trade_no' => $data['meepay_trade_no'],//米付
// 'pay_time' => date('Y-m-d H:i:s', strtotime($data['time_end'])),// 支付完成时间
'pay_time' => date('Y-m-d H:i:s', $data['pay_time']),// 支付完成时间
'amount' => $data['total_amount'],
'trade_type' => $data['trade_type'],
'transaction_id' => $data['transaction_id'],//微信
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!