- 框架初始化
 - 安装插件
 - 修复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,21 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Papay;
use Yansongda\Pay\Plugin\Wechat\GeneralV2Plugin;
use Yansongda\Pay\Rocket;
/**
* 申请代扣.
*
* @see https://pay.weixin.qq.com/wiki/doc/api/wxpay_v2/papay/chapter3_8.shtml
*/
class ApplyPlugin extends GeneralV2Plugin
{
protected function getUri(Rocket $rocket): string
{
return 'pay/pappayapply';
}
}

View File

@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Papay;
use Yansongda\Pay\Plugin\Wechat\GeneralV2Plugin;
use Yansongda\Pay\Rocket;
/**
* 支付中签约.
*
* @see https://pay.weixin.qq.com/wiki/doc/api/wxpay_v2/papay/chapter3_5.shtml
*/
class ContractOrderPlugin extends GeneralV2Plugin
{
protected function getUri(Rocket $rocket): string
{
return 'pay/contractorder';
}
}

View File

@@ -0,0 +1,70 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat\Papay;
use Closure;
use Yansongda\Pay\Contract\PluginInterface;
use Yansongda\Pay\Direction\NoHttpRequestDirection;
use Yansongda\Pay\Exception\ContainerException;
use Yansongda\Pay\Exception\InvalidConfigException;
use Yansongda\Pay\Exception\ServiceNotFoundException;
use Yansongda\Pay\Rocket;
use function Yansongda\Pay\get_wechat_config;
use function Yansongda\Pay\get_wechat_sign_v2;
/**
* 返回只签约(委托代扣)参数.
*
* @see https://pay.weixin.qq.com/wiki/doc/api/wxpay_v2/papay/chapter3_3.shtml
*/
class OnlyContractPlugin implements PluginInterface
{
/**
* @throws ContainerException
* @throws InvalidConfigException
* @throws ServiceNotFoundException
*/
public function assembly(Rocket $rocket, Closure $next): Rocket
{
$config = get_wechat_config($rocket->getParams());
$wechatId = $this->getWechatId($config, $rocket->getParams());
if (!$rocket->getPayload()->has('notify_url')) {
$wechatId['notify_url'] = $config['notify_url'] ?? '';
}
$rocket->mergePayload($wechatId);
$rocket->mergePayload([
'sign' => get_wechat_sign_v2($rocket->getParams(), $rocket->getPayload()->all()),
]);
$rocket->setDestination($rocket->getPayload());
$rocket->setDirection(NoHttpRequestDirection::class);
return $next($rocket);
}
protected function getWechatId(array $config, ?array $params): array
{
$configKey = $this->getConfigKey($params);
return [
'appid' => $config[$configKey] ?? '',
'mch_id' => $config['mch_id'] ?? '',
];
}
protected function getConfigKey(array $params): string
{
$key = ($params['_type'] ?? 'mp').'_app_id';
if ('app_app_id' === $key) {
$key = 'app_id';
}
return $key;
}
}