easywechat4.x升级到6.x

This commit is contained in:
Dev
2026-09-21 14:57:50 +08:00
parent 39882c6cf2
commit 5f4c8147ca
11 changed files with 263 additions and 185 deletions
+12 -11
View File
@@ -243,25 +243,26 @@ class Order extends Api
}
/**
* 支付回调
* 支付回调(微信支付 v3: 返回 JSON,失败时微信将按频率重试)
* @return void
* @throws \Exception
*/
public function payNotify()
{
header('Content-Type: text/xml; charset=utf-8');
header('Content-Type: application/json; charset=utf-8');
try {
$xml = OrderService::payNotify();
echo $xml;
// PSR-7 响应(SDK 已完成验签/解密,业务失败返回 500 由微信重试)
$response = OrderService::payNotify();
http_response_code($response->getStatusCode());
foreach ($response->getHeaders() as $name => $values) {
header($name . ': ' . implode(', ', $values));
}
echo $response->getBody()->getContents();
exit;
} catch (\Exception $e) {
$res = [
'return_code' => 'FAIL',
'return_msg' => $e->getMessage()
];
$xml = ToolService::ToXml($res);
Log::info('微信回调信息信息_result_error:' . json_encode(['res' => $res, 'xml' => $xml], JSON_UNESCAPED_UNICODE));
echo $xml;
Log::info('微信回调信息信息_result_error:' . json_encode(['msg' => $e->getMessage()], JSON_UNESCAPED_UNICODE));
http_response_code(500);
echo json_encode(['code' => 'FAIL', 'message' => $e->getMessage()], JSON_UNESCAPED_UNICODE);
exit;
}
}