From 4f3eed59a002062e22c9df32a653e793528ab530 Mon Sep 17 00:00:00 2001 From: whwyy Date: Wed, 6 Dec 2023 16:37:52 +0800 Subject: [PATCH] eee --- wx/V3/WxV3PaymentTait.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/wx/V3/WxV3PaymentTait.php b/wx/V3/WxV3PaymentTait.php index f38e8f9..ffa0a54 100644 --- a/wx/V3/WxV3PaymentTait.php +++ b/wx/V3/WxV3PaymentTait.php @@ -4,6 +4,7 @@ namespace wchat\wx\V3; use Exception; use Kiri\Client; +use wchat\common\AppConfig; use wchat\common\Help; @@ -63,6 +64,29 @@ trait WxV3PaymentTait } + /** + * @param string $orderNo + * @param AppConfig $config + * @return array + * @throws Exception + */ + public function searchByOutTradeNo(string $orderNo, AppConfig $config): array + { + $sign = $this->signature('POST', '/v3/pay/transactions/out-trade-no/' . $orderNo . '?mchid=' . $config->pay->wx->mchId, null); + + $client = $this->createClient($sign, null); + $client->get('/v3/pay/transactions/out-trade-no/' . $orderNo, ['mchid' => $config->pay->wx->mchId]); + $client->close(); + + $json = json_decode($client->getBody(), TRUE); + if (!isset($json['prepay_id'])) { + throw new Exception('微信支付调用失败: ' . $client->getBody()); + } + + return $this->createResponse($json, null); + } + + /** * @param string $http_method * @param string $canonical_url