Default Changelist
This commit is contained in:
@@ -12,56 +12,62 @@ class WxV3Withdrawal extends SmallProgram
|
||||
{
|
||||
|
||||
|
||||
use WxV3PaymentTait;
|
||||
use WxV3PaymentTait;
|
||||
|
||||
|
||||
/**
|
||||
* @param $orderNo
|
||||
* @param string $batch_name
|
||||
* @param string $batch_remark
|
||||
* @param TransferDetail[] $details
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public function payment($orderNo, string $batch_name, string $batch_remark, array $details): array
|
||||
{
|
||||
$body = $this->create($orderNo, $batch_name, $batch_remark, $details);
|
||||
/**
|
||||
* @param $orderNo
|
||||
* @param string $batch_name
|
||||
* @param string $batch_remark
|
||||
* @param TransferDetail[] $details
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public function payment($orderNo, string $batch_name, string $batch_remark, array $details): array
|
||||
{
|
||||
$body = $this->create($orderNo, $batch_name, $batch_remark, $details);
|
||||
|
||||
$sign = $this->signature('POST', '/v3/pay/transactions/batches', $json = json_encode($body, JSON_UNESCAPED_UNICODE));
|
||||
$sign = $this->signature('POST', '/v3/pay/transactions/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')
|
||||
->withAddedHeader('User-Agent', 'application/json')
|
||||
->withBody($json)
|
||||
->post('/v3/pay/transactions/batches');
|
||||
$client->close();
|
||||
$client = new Client('api.mch.weixin.qq.com', 443, TRUE);
|
||||
$client->withAddedHeader('Authorization', $sign)
|
||||
->withContentType('application/json')
|
||||
->withAddedHeader('User-Agent', 'application/json')
|
||||
->withBody($json)
|
||||
->withAddedHeader("Accept", "*/*");
|
||||
$proxyHost = $this->getConfig()->getProxyHost();
|
||||
$proxyPort = $this->getConfig()->getProxyPort();
|
||||
if (!empty($proxyHost) && $proxyPort > 0) {
|
||||
$client->withProxyHost($proxyHost)->withProxyPort($proxyPort);
|
||||
}
|
||||
$client->post('/v3/pay/transactions/batches');
|
||||
$client->close();
|
||||
|
||||
$json = json_decode($client->getBody(), TRUE);
|
||||
if (!isset($json['prepay_id'])) {
|
||||
throw new Exception('微信支付调用失败');
|
||||
}
|
||||
$json = json_decode($client->getBody(), TRUE);
|
||||
if (!isset($json['prepay_id'])) {
|
||||
throw new Exception('微信支付调用失败');
|
||||
}
|
||||
|
||||
return $this->createResponse($json, $body);
|
||||
}
|
||||
return $this->createResponse($json, $body);
|
||||
}
|
||||
|
||||
|
||||
#[ArrayShape(['transfer_detail_list' => "array", 'total_amount' => "int", 'total_num' => "int", 'batch_remark' => "string", 'batch_name' => "string", 'out_batch_no' => ""])]
|
||||
private function create($orderNo, string $batch_name, string $batch_remark, array $details): array
|
||||
{
|
||||
$total = 0;
|
||||
$body = ['transfer_detail_list' => []];
|
||||
$body['out_batch_no'] = $orderNo;
|
||||
$body['batch_name'] = $batch_name;
|
||||
$body['batch_remark'] = $batch_remark;
|
||||
$body['total_num'] = count($details);
|
||||
foreach ($details as $detail) {
|
||||
$total += $detail->transfer_amount;
|
||||
$body['transfer_detail_list'][] = $detail->toArray();
|
||||
}
|
||||
$body['total_amount'] = $total;
|
||||
return $body;
|
||||
}
|
||||
#[ArrayShape(['transfer_detail_list' => "array", 'total_amount' => "int", 'total_num' => "int", 'batch_remark' => "string", 'batch_name' => "string", 'out_batch_no' => ""])]
|
||||
private function create($orderNo, string $batch_name, string $batch_remark, array $details): array
|
||||
{
|
||||
$total = 0;
|
||||
$body = ['transfer_detail_list' => []];
|
||||
$body['out_batch_no'] = $orderNo;
|
||||
$body['batch_name'] = $batch_name;
|
||||
$body['batch_remark'] = $batch_remark;
|
||||
$body['total_num'] = count($details);
|
||||
foreach ($details as $detail) {
|
||||
$total += $detail->transfer_amount;
|
||||
$body['transfer_detail_list'][] = $detail->toArray();
|
||||
}
|
||||
$body['total_amount'] = $total;
|
||||
return $body;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user