From d9528679fff98ef3fd63645cd856c30f625d591f Mon Sep 17 00:00:00 2001 From: xl Date: Tue, 7 Nov 2023 13:48:04 +0800 Subject: [PATCH] Default Changelist --- wchat/wx/V3/TransferBatches.php | 50 +++++++++++++++++++++++++++++++ wchat/wx/V3/WxV3NativePayment.php | 3 +- wchat/wx/V3/WxV3Payment.php | 3 +- wchat/wx/V3/WxV3Withdrawal.php | 2 +- 4 files changed, 53 insertions(+), 5 deletions(-) create mode 100644 wchat/wx/V3/TransferBatches.php diff --git a/wchat/wx/V3/TransferBatches.php b/wchat/wx/V3/TransferBatches.php new file mode 100644 index 0000000..17910f6 --- /dev/null +++ b/wchat/wx/V3/TransferBatches.php @@ -0,0 +1,50 @@ + "string"])] + public function request(string $orderNo, int $total, string $openId): array + { + $body['appid'] = $this->getConfig()->getAppid(); + $body['out_trade_no'] = $orderNo; + $body["batch_name"] = $this->getConfig()->getBody(); + $body["batch_remark"] = $this->getConfig()->getBody(); + $body["total_amount"] = $total; + $body["total_num"] = 1; + $body["transfer_detail_list"] = [ + [ + "out_detail_no" => $orderNo, + "transfer_amount" => $total, + "transfer_remark" => $this->getConfig()->getBody(), + "openid" => $openId, + ] + ]; + + $sign = $this->signature('POST', '/v3/transfer/batches', $json = json_encode($body, JSON_UNESCAPED_UNICODE)); + + $client = new Client('api.mch.weixin.qq.com', 443, TRUE); + $client->withAddedHeader('Authorization', $sign)->withContentType('application/json') + ->withAgent('application/json')->withBody($json) + ->post('/v3/transfer/batches'); + $client->close(); + + return json_decode($client->getBody(), TRUE); + } +} \ No newline at end of file diff --git a/wchat/wx/V3/WxV3NativePayment.php b/wchat/wx/V3/WxV3NativePayment.php index 3fba296..034122a 100644 --- a/wchat/wx/V3/WxV3NativePayment.php +++ b/wchat/wx/V3/WxV3NativePayment.php @@ -4,7 +4,6 @@ namespace wchat\wx\V3; use Exception; use Kiri\Client; -use Kiri\Message\Stream; use JetBrains\PhpStorm\ArrayShape; use wchat\wx\SmallProgram; @@ -32,7 +31,7 @@ class WxV3NativePayment extends SmallProgram $client = new Client('api.mch.weixin.qq.com', 443, TRUE); $client->withAddedHeader('Authorization', $sign)->withContentType('application/json') - ->withAgent('application/json')->withBody(new Stream($json)) + ->withAgent('application/json')->withBody($json) ->post('/v3/pay/transactions/native'); $client->close(); diff --git a/wchat/wx/V3/WxV3Payment.php b/wchat/wx/V3/WxV3Payment.php index 4c2d509..685bafe 100644 --- a/wchat/wx/V3/WxV3Payment.php +++ b/wchat/wx/V3/WxV3Payment.php @@ -4,7 +4,6 @@ namespace wchat\wx\V3; use Exception; use Kiri\Client; -use Kiri\Message\Stream; use wchat\wx\SmallProgram; class WxV3Payment extends SmallProgram @@ -34,7 +33,7 @@ class WxV3Payment extends SmallProgram $client->withAddedHeader('Authorization', $sign) ->withContentType('application/json') ->withAddedHeader('User-Agent', 'application/json') - ->withBody(new Stream($json)) + ->withBody($json) ->post('/v3/pay/transactions/jsapi'); $client->close(); diff --git a/wchat/wx/V3/WxV3Withdrawal.php b/wchat/wx/V3/WxV3Withdrawal.php index 434dfa8..6ac59ab 100644 --- a/wchat/wx/V3/WxV3Withdrawal.php +++ b/wchat/wx/V3/WxV3Withdrawal.php @@ -33,7 +33,7 @@ class WxV3Withdrawal extends SmallProgram $client->withAddedHeader('Authorization', $sign) ->withContentType('application/json') ->withAddedHeader('User-Agent', 'application/json') - ->withBody(new Stream($json)) + ->withBody($json) ->post('/v3/pay/transactions/batches'); $client->close();