2 Commits

Author SHA1 Message Date
as2252258 b87232bbc0 Default Changelist 2023-11-07 13:48:18 +08:00
as2252258 d9528679ff Default Changelist 2023-11-07 13:48:04 +08:00
5 changed files with 54 additions and 5 deletions
+1
View File
@@ -1,3 +1,4 @@
/.idea/php.xml
vendor/
composer.lock
.idea/*
+50
View File
@@ -0,0 +1,50 @@
<?php
namespace wchat\wx\V3;
use Exception;
use JetBrains\PhpStorm\ArrayShape;
use Kiri\Client;
use wchat\wx\SmallProgram;
class TransferBatches extends SmallProgram
{
use WxV3PaymentTait;
/**
* @param string $orderNo
* @param int $total
* @param string $openId
* @return array
* @throws Exception
*/
#[ArrayShape(['code_url' => "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);
}
}
+1 -2
View File
@@ -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();
+1 -2
View File
@@ -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();
+1 -1
View File
@@ -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();