This commit is contained in:
2023-12-06 16:37:52 +08:00
parent daa4034e39
commit 4f3eed59a0
+24
View File
@@ -4,6 +4,7 @@ namespace wchat\wx\V3;
use Exception; use Exception;
use Kiri\Client; use Kiri\Client;
use wchat\common\AppConfig;
use wchat\common\Help; 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 $http_method
* @param string $canonical_url * @param string $canonical_url