- 框架初始化
 - 安装插件
 - 修复PHP8.4报错
This commit is contained in:
2025-04-19 17:21:20 +08:00
commit c6a4e1f5f6
5306 changed files with 967782 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Fund\Balance;
use Yansongda\Pay\Exception\Exception;
use Yansongda\Pay\Exception\InvalidParamsException;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
class QueryDayEndPlugin extends GeneralPlugin
{
protected function getMethod(): string
{
return 'GET';
}
protected function doSomething(Rocket $rocket): void
{
}
/**
* @throws InvalidParamsException
*/
protected function getUri(Rocket $rocket): string
{
$payload = $rocket->getPayload();
if (!$payload->has('account_type') || !$payload->has('date')) {
throw new InvalidParamsException(Exception::MISSING_NECESSARY_PARAMS);
}
return 'v3/merchant/fund/dayendbalance/'.
$payload->get('account_type').
'?date='.$payload->get('date');
}
}

View File

@@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Fund\Balance;
use Yansongda\Pay\Exception\Exception;
use Yansongda\Pay\Exception\InvalidParamsException;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
class QueryPlugin extends GeneralPlugin
{
protected function getMethod(): string
{
return 'GET';
}
protected function doSomething(Rocket $rocket): void
{
}
/**
* @throws InvalidParamsException
*/
protected function getUri(Rocket $rocket): string
{
$payload = $rocket->getPayload();
if (!$payload->has('account_type')) {
throw new InvalidParamsException(Exception::MISSING_NECESSARY_PARAMS);
}
return 'v3/merchant/fund/balance/'.
$payload->get('account_type');
}
}

View File

@@ -0,0 +1,83 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Fund\Profitsharing;
use Yansongda\Pay\Exception\ContainerException;
use Yansongda\Pay\Exception\InvalidConfigException;
use Yansongda\Pay\Exception\InvalidParamsException;
use Yansongda\Pay\Exception\InvalidResponseException;
use Yansongda\Pay\Exception\ServiceNotFoundException;
use Yansongda\Pay\Pay;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
use Yansongda\Pay\Traits\HasWechatEncryption;
use Yansongda\Supports\Collection;
use function Yansongda\Pay\encrypt_wechat_contents;
use function Yansongda\Pay\get_wechat_config;
/**
* @see https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_8.shtml
*/
class AddReceiverPlugin extends GeneralPlugin
{
use HasWechatEncryption;
/**
* @throws ContainerException
* @throws InvalidConfigException
* @throws InvalidParamsException
* @throws InvalidResponseException
* @throws ServiceNotFoundException
*/
protected function doSomething(Rocket $rocket): void
{
$params = $rocket->getParams();
$config = get_wechat_config($rocket->getParams());
$extra = $this->getWechatId($config, $rocket->getPayload());
if (!empty($params['name'] ?? '')) {
$params = $this->loadSerialNo($params);
$name = $this->getEncryptUserName($params);
$params['name'] = $name;
$extra['name'] = $name;
$rocket->setParams($params);
}
$rocket->mergePayload($extra);
}
protected function getUri(Rocket $rocket): string
{
return 'v3/profitsharing/receivers/add';
}
protected function getWechatId(array $config, Collection $payload): array
{
$wechatId = [
'appid' => $config['mp_app_id'] ?? null,
];
if (Pay::MODE_SERVICE === ($config['mode'] ?? null)) {
$wechatId['sub_mchid'] = $payload->get('sub_mchid', $config['sub_mch_id'] ?? '');
}
return $wechatId;
}
/**
* @throws ContainerException
* @throws InvalidParamsException
* @throws ServiceNotFoundException
*/
protected function getEncryptUserName(array $params): string
{
$name = $params['name'] ?? '';
$publicKey = $this->getPublicKey($params, $params['_serial_no'] ?? '');
return encrypt_wechat_contents($name, $publicKey);
}
}

View File

@@ -0,0 +1,89 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Fund\Profitsharing;
use Yansongda\Pay\Exception\ContainerException;
use Yansongda\Pay\Exception\InvalidConfigException;
use Yansongda\Pay\Exception\InvalidParamsException;
use Yansongda\Pay\Exception\InvalidResponseException;
use Yansongda\Pay\Exception\ServiceNotFoundException;
use Yansongda\Pay\Pay;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
use Yansongda\Pay\Traits\HasWechatEncryption;
use Yansongda\Supports\Collection;
use function Yansongda\Pay\encrypt_wechat_contents;
use function Yansongda\Pay\get_wechat_config;
/**
* @see https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_1.shtml
*/
class CreatePlugin extends GeneralPlugin
{
use HasWechatEncryption;
/**
* @throws ContainerException
* @throws InvalidConfigException
* @throws InvalidParamsException
* @throws InvalidResponseException
* @throws ServiceNotFoundException
*/
protected function doSomething(Rocket $rocket): void
{
$payload = $rocket->getPayload();
$params = $this->loadSerialNo($rocket->getParams());
$extra = $this->getWechatExtra($params, $payload);
$extra['receivers'] = $this->getReceivers($params);
$rocket->setParams($params);
$rocket->mergePayload($extra);
}
protected function getUri(Rocket $rocket): string
{
return 'v3/profitsharing/orders';
}
/**
* @throws ContainerException
* @throws ServiceNotFoundException
*/
protected function getWechatExtra(array $params, Collection $payload): array
{
$config = get_wechat_config($params);
$extra = [
'appid' => $config['mp_app_id'] ?? null,
];
if (Pay::MODE_SERVICE === ($config['mode'] ?? null)) {
$extra['sub_mchid'] = $payload->get('sub_mchid', $config['sub_mch_id'] ?? '');
}
return $extra;
}
/**
* @throws ContainerException
* @throws InvalidParamsException
* @throws ServiceNotFoundException
*/
protected function getReceivers(array $params): array
{
$publicKey = $this->getPublicKey($params, $params['_serial_no'] ?? '');
$receivers = $params['receivers'] ?? [];
foreach ($receivers as $key => $receiver) {
if (!empty($receiver['name'])) {
$receivers[$key]['name'] = encrypt_wechat_contents($receiver['name'], $publicKey);
}
}
return $receivers;
}
}

View File

@@ -0,0 +1,45 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Fund\Profitsharing;
use Yansongda\Pay\Exception\ContainerException;
use Yansongda\Pay\Exception\ServiceNotFoundException;
use Yansongda\Pay\Pay;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
use function Yansongda\Pay\get_wechat_config;
/**
* @see https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_9.shtml
*/
class DeleteReceiverPlugin extends GeneralPlugin
{
/**
* @throws ContainerException
* @throws ServiceNotFoundException
*/
protected function doSomething(Rocket $rocket): void
{
$config = get_wechat_config($rocket->getParams());
$wechatId = [
'appid' => $config['mp_app_id'] ?? null,
];
if (Pay::MODE_SERVICE === ($config['mode'] ?? null)) {
$wechatId['sub_mchid'] = $rocket->getPayload()
->get('sub_mchid', $config['sub_mch_id'] ?? '')
;
}
$rocket->mergePayload($wechatId);
}
protected function getUri(Rocket $rocket): string
{
return 'v3/profitsharing/receivers/delete';
}
}

View File

@@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Fund\Profitsharing;
use Yansongda\Pay\Direction\OriginResponseDirection;
use Yansongda\Pay\Exception\Exception;
use Yansongda\Pay\Exception\InvalidParamsException;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
/**
* @see https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_12.shtml
*/
class DownloadBillPlugin extends GeneralPlugin
{
/**
* @throws InvalidParamsException
*/
protected function getUri(Rocket $rocket): string
{
$payload = $rocket->getPayload();
if (!$payload->has('download_url')) {
throw new InvalidParamsException(Exception::MISSING_NECESSARY_PARAMS);
}
return $payload->get('download_url');
}
protected function getMethod(): string
{
return 'GET';
}
protected function doSomething(Rocket $rocket): void
{
$rocket->setDirection(OriginResponseDirection::class);
$rocket->setPayload(null);
}
}

View File

@@ -0,0 +1,42 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Fund\Profitsharing;
use Yansongda\Pay\Exception\Exception;
use Yansongda\Pay\Exception\InvalidParamsException;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
/**
* @see https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_6.shtml
*/
class QueryAmountsPlugin extends GeneralPlugin
{
protected function getMethod(): string
{
return 'GET';
}
protected function doSomething(Rocket $rocket): void
{
$rocket->setPayload(null);
}
/**
* @throws InvalidParamsException
*/
protected function getUri(Rocket $rocket): string
{
$payload = $rocket->getPayload();
if (!$payload->has('transaction_id')) {
throw new InvalidParamsException(Exception::MISSING_NECESSARY_PARAMS);
}
return 'v3/profitsharing/transactions/'.
$payload->get('transaction_id').
'/amounts';
}
}

View File

@@ -0,0 +1,49 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Fund\Profitsharing;
use Yansongda\Pay\Exception\ContainerException;
use Yansongda\Pay\Exception\Exception;
use Yansongda\Pay\Exception\InvalidParamsException;
use Yansongda\Pay\Exception\ServiceNotFoundException;
use Yansongda\Pay\Pay;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
use function Yansongda\Pay\get_wechat_config;
/**
* @see https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_1_7.shtml
*/
class QueryMerchantConfigsPlugin extends GeneralPlugin
{
protected function getMethod(): string
{
return 'GET';
}
protected function doSomething(Rocket $rocket): void
{
$rocket->setPayload(null);
}
/**
* @throws ContainerException
* @throws InvalidParamsException
* @throws ServiceNotFoundException
*/
protected function getUri(Rocket $rocket): string
{
$config = get_wechat_config($rocket->getParams());
$payload = $rocket->getPayload();
if (Pay::MODE_SERVICE !== ($config['mode'] ?? Pay::MODE_NORMAL)) {
throw new InvalidParamsException(Exception::METHOD_NOT_SUPPORTED);
}
return 'v3/profitsharing/merchant-configs/'.
$payload->get('sub_mchid', $config['sub_mch_id'] ?? '');
}
}

View File

@@ -0,0 +1,56 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Fund\Profitsharing;
use Yansongda\Pay\Exception\ContainerException;
use Yansongda\Pay\Exception\Exception;
use Yansongda\Pay\Exception\InvalidParamsException;
use Yansongda\Pay\Exception\ServiceNotFoundException;
use Yansongda\Pay\Pay;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
use function Yansongda\Pay\get_wechat_config;
/**
* @see https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_2.shtml
*/
class QueryPlugin extends GeneralPlugin
{
protected function getMethod(): string
{
return 'GET';
}
protected function doSomething(Rocket $rocket): void
{
$rocket->setPayload(null);
}
/**
* @throws ContainerException
* @throws InvalidParamsException
* @throws ServiceNotFoundException
*/
protected function getUri(Rocket $rocket): string
{
$payload = $rocket->getPayload();
$config = get_wechat_config($rocket->getParams());
if (!$payload->has('out_order_no') || !$payload->has('transaction_id')) {
throw new InvalidParamsException(Exception::MISSING_NECESSARY_PARAMS);
}
$url = 'v3/profitsharing/orders/'.
$payload->get('out_order_no').
'?transaction_id='.$payload->get('transaction_id');
if (Pay::MODE_SERVICE === ($config['mode'] ?? null)) {
$url .= '&sub_mchid='.$payload->get('sub_mchid', $config['sub_mch_id'] ?? '');
}
return $url;
}
}

View File

@@ -0,0 +1,56 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Fund\Profitsharing;
use Yansongda\Pay\Exception\ContainerException;
use Yansongda\Pay\Exception\Exception;
use Yansongda\Pay\Exception\InvalidParamsException;
use Yansongda\Pay\Exception\ServiceNotFoundException;
use Yansongda\Pay\Pay;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
use function Yansongda\Pay\get_wechat_config;
/**
* @see https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_4.shtml
*/
class QueryReturnPlugin extends GeneralPlugin
{
protected function getMethod(): string
{
return 'GET';
}
protected function doSomething(Rocket $rocket): void
{
$rocket->setPayload(null);
}
/**
* @throws ContainerException
* @throws InvalidParamsException
* @throws ServiceNotFoundException
*/
protected function getUri(Rocket $rocket): string
{
$payload = $rocket->getPayload();
$config = get_wechat_config($rocket->getParams());
if (!$payload->has('out_return_no') || !$payload->has('out_order_no')) {
throw new InvalidParamsException(Exception::MISSING_NECESSARY_PARAMS);
}
$url = 'v3/profitsharing/return-orders/'.
$payload->get('out_return_no').
'?out_order_no='.$payload->get('out_order_no');
if (Pay::MODE_SERVICE === ($config['mode'] ?? null)) {
$url .= '&sub_mchid='.$payload->get('sub_mchid', $config['sub_mch_id'] ?? '');
}
return $url;
}
}

View File

@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Fund\Profitsharing;
use Yansongda\Pay\Exception\ContainerException;
use Yansongda\Pay\Exception\ServiceNotFoundException;
use Yansongda\Pay\Pay;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
use function Yansongda\Pay\get_wechat_config;
/**
* @see https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_3.shtml
*/
class ReturnPlugin extends GeneralPlugin
{
/**
* @throws ContainerException
* @throws ServiceNotFoundException
*/
protected function doSomething(Rocket $rocket): void
{
$config = get_wechat_config($rocket->getParams());
if (Pay::MODE_SERVICE === ($config['mode'] ?? null)) {
$rocket->mergePayload([
'sub_mchid' => $rocket->getPayload()
->get('sub_mchid', $config['sub_mch_id'] ?? ''),
]);
}
}
protected function getUri(Rocket $rocket): string
{
return 'v3/profitsharing/return-orders';
}
}

View File

@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Fund\Profitsharing;
use Yansongda\Pay\Exception\ContainerException;
use Yansongda\Pay\Exception\ServiceNotFoundException;
use Yansongda\Pay\Pay;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
use function Yansongda\Pay\get_wechat_config;
/**
* @see https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_5.shtml
*/
class UnfreezePlugin extends GeneralPlugin
{
/**
* @throws ContainerException
* @throws ServiceNotFoundException
*/
protected function doSomething(Rocket $rocket): void
{
$payload = $rocket->getPayload();
$config = get_wechat_config($rocket->getParams());
if (Pay::MODE_SERVICE === ($config['mode'] ?? null) && !$payload->has('sub_mchid')) {
$rocket->mergePayload([
'sub_mchid' => $config['sub_mch_id'] ?? '',
]);
}
}
protected function getUri(Rocket $rocket): string
{
return 'v3/profitsharing/orders/unfreeze';
}
}

View File

@@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Fund\Transfer;
use Yansongda\Pay\Exception\Exception;
use Yansongda\Pay\Exception\InvalidParamsException;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
/**
* @see https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter4_3_7.shtml
*/
class CreateBillReceiptPlugin extends GeneralPlugin
{
/**
* @throws InvalidParamsException
*/
protected function doSomething(Rocket $rocket): void
{
$payload = $rocket->getPayload();
if (!$payload->has('out_batch_no')) {
throw new InvalidParamsException(Exception::MISSING_NECESSARY_PARAMS);
}
}
protected function getUri(Rocket $rocket): string
{
return 'v3/transfer/bill-receipt';
}
}

View File

@@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Fund\Transfer;
use Yansongda\Pay\Exception\Exception;
use Yansongda\Pay\Exception\InvalidParamsException;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
/**
* @see https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter4_3_9.shtml
*/
class CreateDetailReceiptPlugin extends GeneralPlugin
{
/**
* @throws InvalidParamsException
*/
protected function doSomething(Rocket $rocket): void
{
$payload = $rocket->getPayload();
if (!$payload->has('out_detail_no') || !$payload->has('accept_type')) {
throw new InvalidParamsException(Exception::MISSING_NECESSARY_PARAMS);
}
}
protected function getUri(Rocket $rocket): string
{
return 'v3/transfer-detail/electronic-receipts';
}
}

View File

@@ -0,0 +1,99 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Fund\Transfer;
use Yansongda\Pay\Exception\ContainerException;
use Yansongda\Pay\Exception\InvalidConfigException;
use Yansongda\Pay\Exception\InvalidParamsException;
use Yansongda\Pay\Exception\InvalidResponseException;
use Yansongda\Pay\Exception\ServiceNotFoundException;
use Yansongda\Pay\Pay;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
use Yansongda\Pay\Traits\HasWechatEncryption;
use Yansongda\Supports\Collection;
use function Yansongda\Pay\encrypt_wechat_contents;
use function Yansongda\Pay\get_wechat_config;
/**
* @see https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter4_3_1.shtml
*/
class CreatePlugin extends GeneralPlugin
{
use HasWechatEncryption;
/**
* @throws ContainerException
* @throws InvalidConfigException
* @throws InvalidParamsException
* @throws InvalidResponseException
* @throws ServiceNotFoundException
*/
protected function doSomething(Rocket $rocket): void
{
$params = $rocket->getParams();
$extra = $this->getWechatId($params, $rocket->getPayload());
if (!empty($params['transfer_detail_list'][0]['user_name'] ?? '')) {
$params = $this->loadSerialNo($params);
$rocket->setParams($params);
$extra['transfer_detail_list'] = $this->getEncryptUserName($params);
}
$rocket->mergePayload($extra);
}
protected function getUri(Rocket $rocket): string
{
return 'v3/transfer/batches';
}
protected function getPartnerUri(Rocket $rocket): string
{
return 'v3/partner-transfer/batches';
}
/**
* @throws ContainerException
* @throws ServiceNotFoundException
*/
protected function getWechatId(array $params, Collection $payload): array
{
$config = get_wechat_config($params);
$key = $this->getConfigKey($params);
$appId = [
'appid' => $payload->get('appid', $config[$key] ?? ''),
];
if (Pay::MODE_SERVICE === ($config['mode'] ?? null)) {
$appId = [
'sub_mchid' => $payload->get('sub_mchid', $config['sub_mch_id'] ?? ''),
];
}
return $appId;
}
/**
* @throws ContainerException
* @throws InvalidParamsException
* @throws ServiceNotFoundException
*/
protected function getEncryptUserName(array $params): array
{
$lists = $params['transfer_detail_list'] ?? [];
$publicKey = $this->getPublicKey($params, $params['_serial_no'] ?? '');
foreach ($lists as $key => $list) {
$lists[$key]['user_name'] = encrypt_wechat_contents($list['user_name'], $publicKey);
}
return $lists;
}
}

View File

@@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Fund\Transfer;
use Yansongda\Pay\Direction\OriginResponseDirection;
use Yansongda\Pay\Exception\Exception;
use Yansongda\Pay\Exception\InvalidParamsException;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
/**
* @see https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter4_3_11.shtml
*/
class DownloadReceiptPlugin extends GeneralPlugin
{
/**
* @throws InvalidParamsException
*/
protected function getUri(Rocket $rocket): string
{
$payload = $rocket->getPayload();
if (!$payload->has('download_url')) {
throw new InvalidParamsException(Exception::MISSING_NECESSARY_PARAMS);
}
return $payload->get('download_url');
}
protected function getMethod(): string
{
return 'GET';
}
protected function doSomething(Rocket $rocket): void
{
$rocket->setDirection(OriginResponseDirection::class);
$rocket->setPayload(null);
}
}

View File

@@ -0,0 +1,60 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Fund\Transfer;
use Yansongda\Pay\Exception\Exception;
use Yansongda\Pay\Exception\InvalidParamsException;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
/**
* @see https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter4_3_3.shtml
*/
class QueryBatchDetailIdPlugin extends GeneralPlugin
{
protected function getMethod(): string
{
return 'GET';
}
protected function doSomething(Rocket $rocket): void
{
$rocket->setPayload(null);
}
/**
* @throws InvalidParamsException
*/
protected function getUri(Rocket $rocket): string
{
$payload = $rocket->getPayload();
if (!$payload->has('batch_id') || !$payload->get('detail_id')) {
throw new InvalidParamsException(Exception::MISSING_NECESSARY_PARAMS);
}
return 'v3/transfer/batches/batch-id/'.
$payload->get('batch_id').
'/details/detail-id/'.
$payload->get('detail_id');
}
/**
* @throws InvalidParamsException
*/
protected function getPartnerUri(Rocket $rocket): string
{
$payload = $rocket->getPayload();
if (!$payload->has('batch_id') || !$payload->has('detail_id')) {
throw new InvalidParamsException(Exception::MISSING_NECESSARY_PARAMS);
}
return 'v3/partner-transfer/batches/batch-id/'.
$payload->get('batch_id').
'/details/detail-id/'.
$payload->get('detail_id');
}
}

View File

@@ -0,0 +1,64 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Fund\Transfer;
use Yansongda\Pay\Exception\Exception;
use Yansongda\Pay\Exception\InvalidParamsException;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
/**
* @see https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter4_3_2.shtml
*/
class QueryBatchIdPlugin extends GeneralPlugin
{
protected function getMethod(): string
{
return 'GET';
}
protected function doSomething(Rocket $rocket): void
{
$rocket->setPayload(null);
}
/**
* @throws InvalidParamsException
*/
protected function getUri(Rocket $rocket): string
{
$payload = $rocket->getPayload();
if (!$payload->has('batch_id') || !$payload->has('need_query_detail')) {
throw new InvalidParamsException(Exception::MISSING_NECESSARY_PARAMS);
}
$batchId = $payload->get('batch_id');
$payload->forget('batch_id');
return 'v3/transfer/batches/batch-id/'.$batchId.
'?'.$payload->query();
}
/**
* @throws InvalidParamsException
*/
protected function getPartnerUri(Rocket $rocket): string
{
$payload = $rocket->getPayload();
if (!$payload->has('batch_id') || !$payload->has('need_query_detail')) {
throw new InvalidParamsException(Exception::MISSING_NECESSARY_PARAMS);
}
$batchId = $payload->get('batch_id');
$payload->forget('batch_id');
return 'v3/partner-transfer/batches/batch-id/'.$batchId.
'?'.$payload->query();
}
}

View File

@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Fund\Transfer;
use Yansongda\Pay\Exception\Exception;
use Yansongda\Pay\Exception\InvalidParamsException;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
/**
* @see https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter4_3_8.shtml
*/
class QueryBillReceiptPlugin extends GeneralPlugin
{
protected function getMethod(): string
{
return 'GET';
}
protected function doSomething(Rocket $rocket): void
{
$rocket->setPayload(null);
}
/**
* @throws InvalidParamsException
*/
protected function getUri(Rocket $rocket): string
{
$payload = $rocket->getPayload();
if (!$payload->has('out_batch_no')) {
throw new InvalidParamsException(Exception::MISSING_NECESSARY_PARAMS);
}
return 'v3/transfer/bill-receipt/'.$payload->get('out_batch_no');
}
}

View File

@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Fund\Transfer;
use Yansongda\Pay\Exception\Exception;
use Yansongda\Pay\Exception\InvalidParamsException;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
/**
* @see https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter4_3_10.shtml
*/
class QueryDetailReceiptPlugin extends GeneralPlugin
{
protected function getMethod(): string
{
return 'GET';
}
/**
* @throws InvalidParamsException
*/
protected function doSomething(Rocket $rocket): void
{
$payload = $rocket->getPayload();
if (!$payload->has('out_detail_no') || !$payload->has('accept_type')) {
throw new InvalidParamsException(Exception::MISSING_NECESSARY_PARAMS);
}
$rocket->setPayload(null);
}
protected function getUri(Rocket $rocket): string
{
return 'v3/transfer-detail/electronic-receipts?'.$rocket->getPayload()->query();
}
}

View File

@@ -0,0 +1,60 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Fund\Transfer;
use Yansongda\Pay\Exception\Exception;
use Yansongda\Pay\Exception\InvalidParamsException;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
/**
* @see https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter4_3_6.shtml
*/
class QueryOutBatchDetailNoPlugin extends GeneralPlugin
{
protected function getMethod(): string
{
return 'GET';
}
protected function doSomething(Rocket $rocket): void
{
$rocket->setPayload(null);
}
/**
* @throws InvalidParamsException
*/
protected function getUri(Rocket $rocket): string
{
$payload = $rocket->getPayload();
if (!$payload->has('out_batch_no') || !$payload->has('out_detail_no')) {
throw new InvalidParamsException(Exception::MISSING_NECESSARY_PARAMS);
}
return 'v3/transfer/batches/out-batch-no/'.
$payload->get('out_batch_no').
'/details/out-detail-no/'.
$payload->get('out_detail_no');
}
/**
* @throws InvalidParamsException
*/
protected function getPartnerUri(Rocket $rocket): string
{
$payload = $rocket->getPayload();
if (!$payload->has('out_batch_no') || !$payload->has('out_detail_no')) {
throw new InvalidParamsException(Exception::MISSING_NECESSARY_PARAMS);
}
return 'v3/partner-transfer/batches/out-batch-no/'.
$payload->get('out_batch_no').
'/details/out-detail-no/'.
$payload->get('out_detail_no');
}
}

View File

@@ -0,0 +1,64 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Fund\Transfer;
use Yansongda\Pay\Exception\Exception;
use Yansongda\Pay\Exception\InvalidParamsException;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
/**
* @see https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter4_3_5.shtml
*/
class QueryOutBatchNoPlugin extends GeneralPlugin
{
protected function getMethod(): string
{
return 'GET';
}
protected function doSomething(Rocket $rocket): void
{
$rocket->setPayload(null);
}
/**
* @throws InvalidParamsException
*/
protected function getUri(Rocket $rocket): string
{
$payload = $rocket->getPayload();
if (!$payload->has('out_batch_no') || !$payload->has('need_query_detail')) {
throw new InvalidParamsException(Exception::MISSING_NECESSARY_PARAMS);
}
$outBatchNo = $payload->get('out_batch_no');
$payload->forget('out_batch_no');
return 'v3/transfer/batches/out-batch-no/'.$outBatchNo.
'?'.$payload->query();
}
/**
* @throws InvalidParamsException
*/
protected function getPartnerUri(Rocket $rocket): string
{
$payload = $rocket->getPayload();
if (!$payload->has('out_batch_no') || !$payload->has('need_query_detail')) {
throw new InvalidParamsException(Exception::MISSING_NECESSARY_PARAMS);
}
$outBatchNo = $payload->get('out_batch_no');
$payload->forget('out_batch_no');
return 'v3/partner-transfer/batches/out-batch-no/'.$outBatchNo.
'?'.$payload->query();
}
}