支付更新

This commit is contained in:
mkm 2024-06-22 19:10:12 +08:00
parent fb8460e1a9
commit 89db630313
192 changed files with 1341 additions and 404 deletions

View File

@ -48,7 +48,7 @@
"next/var-dumper": "^0.1.0",
"w7corp/easywechat": "^6.8",
"hyperf/pimple": "~2.2.0",
"yansongda/pay": "^3.7",
"yansongda/pay": "v3.7.7",
"webman/redis-queue": "^1.3",
"webman/push": "^1.0",
"ext-bcmath": "*",

21
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "86e88af6d3f2d3a637cb64522dc7ad21",
"content-hash": "24cc56580d39efa5995e2bddb25f89c5",
"packages": [
{
"name": "aliyuncs/oss-sdk-php",
@ -7786,23 +7786,17 @@
},
{
"name": "yansongda/pay",
"version": "v3.7.4",
"version": "v3.7.7",
"source": {
"type": "git",
"url": "https://github.com/yansongda/pay.git",
"reference": "a57a52f057aa4ca49afa14bd61b888885e1eed28"
"reference": "db85283ee5c8e462dc01392d49f1f576604cad7d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/yansongda/pay/zipball/a57a52f057aa4ca49afa14bd61b888885e1eed28",
"reference": "a57a52f057aa4ca49afa14bd61b888885e1eed28",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"url": "https://api.github.com/repos/yansongda/pay/zipball/db85283ee5c8e462dc01392d49f1f576604cad7d",
"reference": "db85283ee5c8e462dc01392d49f1f576604cad7d",
"shasum": ""
},
"require": {
"ext-bcmath": "*",
@ -7821,6 +7815,7 @@
"friendsofphp/php-cs-fixer": "^3.44",
"guzzlehttp/guzzle": "^7.0",
"hyperf/pimple": "^2.2",
"jetbrains/phpstorm-attributes": "^1.1",
"mockery/mockery": "^1.4",
"monolog/monolog": "^2.2",
"phpstan/phpstan": "^1.0.0",
@ -7860,7 +7855,7 @@
"issues": "https://github.com/yansongda/pay/issues",
"source": "https://github.com/yansongda/pay"
},
"time": "2024-05-16T13:31:29+00:00"
"time": "2024-06-22T02:21:34+00:00"
},
{
"name": "yansongda/supports",

View File

@ -7723,24 +7723,18 @@
},
{
"name": "yansongda/pay",
"version": "v3.7.4",
"version_normalized": "3.7.4.0",
"version": "v3.7.7",
"version_normalized": "3.7.7.0",
"source": {
"type": "git",
"url": "https://github.com/yansongda/pay.git",
"reference": "a57a52f057aa4ca49afa14bd61b888885e1eed28"
"reference": "db85283ee5c8e462dc01392d49f1f576604cad7d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/yansongda/pay/zipball/a57a52f057aa4ca49afa14bd61b888885e1eed28",
"reference": "a57a52f057aa4ca49afa14bd61b888885e1eed28",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"url": "https://api.github.com/repos/yansongda/pay/zipball/db85283ee5c8e462dc01392d49f1f576604cad7d",
"reference": "db85283ee5c8e462dc01392d49f1f576604cad7d",
"shasum": ""
},
"require": {
"ext-bcmath": "*",
@ -7759,6 +7753,7 @@
"friendsofphp/php-cs-fixer": "^3.44",
"guzzlehttp/guzzle": "^7.0",
"hyperf/pimple": "^2.2",
"jetbrains/phpstorm-attributes": "^1.1",
"mockery/mockery": "^1.4",
"monolog/monolog": "^2.2",
"phpstan/phpstan": "^1.0.0",
@ -7768,7 +7763,7 @@
"symfony/psr-http-message-bridge": "^2.1",
"symfony/var-dumper": "^5.1"
},
"time": "2024-05-16T13:31:29+00:00",
"time": "2024-06-22T02:21:34+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {

View File

@ -1074,9 +1074,9 @@
'dev_requirement' => false,
),
'yansongda/pay' => array(
'pretty_version' => 'v3.7.4',
'version' => '3.7.4.0',
'reference' => 'a57a52f057aa4ca49afa14bd61b888885e1eed28',
'pretty_version' => 'v3.7.7',
'version' => '3.7.7.0',
'reference' => 'db85283ee5c8e462dc01392d49f1f576604cad7d',
'type' => 'library',
'install_path' => __DIR__ . '/../yansongda/pay',
'aliases' => array(),

View File

@ -1,3 +1,30 @@
## 3.7.7
### added
- feat: 新增江苏银行e融支付(#1002)
## v3.7.6
### fixed
- fix: 微信关闭订单报解包错误的问题(#1000, #1001)
## v3.7.5
### fixed
- fix: 支付宝响应空签名时签名验证逻辑错误的问题(#998)
### optimized
- optimize: 优化微信 `ResponsePlugin` 插件去除不必要的返回参数(#996)
### deprecated
- deprecate: 微信 `StartPlugin` 改为使用 `yansongda/artful` 中的插件(#993)
- deprecate: `get_wechat_config`, `get_alipay_config`, `get_unipay_config` 方法已废弃,使用 `get_provider_config` 方法代替(#994)
## v3.7.4
### optimized

View File

@ -84,6 +84,11 @@ yansongda/pay 100% 兼容 支付宝/微信/银联 所有功能(包括服务商
- 刷卡支付
- 扫码支付
- ...
-
### 江苏银行(e融支付)
- 聚合扫码支付(微信,支付宝,银联,e融)
- ...
## 安装
```shell
@ -279,9 +284,80 @@ class WechatController
}
```
### 江苏银行(e融支付)
```php
<?php
namespace App\Http\Controllers;
use Yansongda\Pay\Pay;
class EpayController
{
protected $config = [
'jsb' => [
'default' => [
// 服务代码
'svr_code' => '',
// 必填-合作商ID
'partner_id' => '',
// 必填-公私钥对编号
'public_key_code' => '00',
// 必填-商户私钥(加密签名)
'mch_secret_cert_path' => '',
// 必填-商户公钥证书路径(提供江苏银行进行验证签名用)
'mch_public_cert_path' => '',
// 必填-江苏银行的公钥(用于解密江苏银行返回的数据)
'jsb_public_cert_path' => '',
//支付通知地址
'notify_url' => '',
// 选填-默认为正常模式。可选为: MODE_NORMAL:正式环境, MODE_SANDBOX:测试环境
'mode' => Pay::MODE_NORMAL,
]
],
'logger' => [ // optional
'enable' => false,
'file' => './logs/epay.log',
'level' => 'info', // 建议生产环境等级调整为 info开发环境为 debug
'type' => 'single', // optional, 可选 daily.
'max_file' => 30, // optional, 当 type 为 daily 时有效,默认 30 天
],
'http' => [ // optional
'timeout' => 5.0,
'connect_timeout' => 5.0,
// 更多配置项请参考 [Guzzle](https://guzzle-cn.readthedocs.io/zh_CN/latest/request-options.html)
],
];
public function index()
{
$order = [
'outTradeNo' => time().'',
'proInfo' => 'subject-测试',
'totalFee'=> 1,
];
$pay = Pay::jsb($this->config)->scan($order);
}
public function notifyCallback()
{
$pay = Pay::jsb($this->config);
try{
$data = $pay->callback(); // 是的,验签就这么简单!
} catch (\Exception $e) {
// $e->getMessage();
}
return $pay->success();
}
}
```
## 代码贡献
由于测试及使用环境的限制,本项目中只开发了「支付宝」和「微信支付」的相关支付网关。
由于测试及使用环境的限制,本项目中只开发了「支付宝」、「微信支付」、「银联」、「江苏银行」的相关支付网关。
如果您有其它支付网关的需求,或者发现本项目中需要改进的代码,**_欢迎 Fork 并提交 PR_**

View File

@ -36,7 +36,8 @@
"symfony/event-dispatcher": "^5.2.0",
"symfony/psr-http-message-bridge": "^2.1",
"hyperf/pimple": "^2.2",
"guzzlehttp/guzzle": "^7.0"
"guzzlehttp/guzzle": "^7.0",
"jetbrains/phpstorm-attributes": "^1.1"
},
"conflict": {
"hyperf/framework": "<3.0"

0
vendor/yansongda/pay/src/Event/CallbackReceived.php vendored Normal file → Executable file
View File

0
vendor/yansongda/pay/src/Event/MethodCalled.php vendored Normal file → Executable file
View File

0
vendor/yansongda/pay/src/Event/PayEnd.php vendored Normal file → Executable file
View File

0
vendor/yansongda/pay/src/Event/PayStart.php vendored Normal file → Executable file
View File

View File

@ -44,6 +44,8 @@ class Exception extends \Exception
public const RESPONSE_MISSING_NECESSARY_PARAMS = 9305;
public const RESPONSE_BUSINESS_CODE_WRONG = 9306;
/*
* 关于配置.
*/
@ -53,6 +55,8 @@ class Exception extends \Exception
public const CONFIG_UNIPAY_INVALID = 9403;
public const CONFIG_JSB_INVALID = 9404;
/**
* 关于签名.
*/

View File

@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Yansongda\Pay;
use JetBrains\PhpStorm\Deprecated;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Yansongda\Artful\Contract\ConfigInterface;
@ -13,15 +14,16 @@ use Yansongda\Artful\Exception\InvalidParamsException;
use Yansongda\Artful\Exception\ServiceNotFoundException;
use Yansongda\Artful\Plugin\AddPayloadBodyPlugin;
use Yansongda\Artful\Plugin\ParserPlugin;
use Yansongda\Artful\Plugin\StartPlugin;
use Yansongda\Pay\Exception\DecryptException;
use Yansongda\Pay\Exception\Exception;
use Yansongda\Pay\Exception\InvalidSignException;
use Yansongda\Pay\Plugin\Wechat\AddRadarPlugin;
use Yansongda\Pay\Plugin\Wechat\ResponsePlugin;
use Yansongda\Pay\Plugin\Wechat\StartPlugin;
use Yansongda\Pay\Plugin\Wechat\V3\AddPayloadSignaturePlugin;
use Yansongda\Pay\Plugin\Wechat\V3\WechatPublicCertsPlugin;
use Yansongda\Pay\Provider\Alipay;
use Yansongda\Pay\Provider\Jsb;
use Yansongda\Pay\Provider\Unipay;
use Yansongda\Pay\Provider\Wechat;
use Yansongda\Supports\Collection;
@ -63,6 +65,19 @@ function get_radar_url(array $config, ?Collection $payload): ?string
* @throws ContainerException
* @throws ServiceNotFoundException
*/
function get_provider_config(string $provider, array $params = []): array
{
/** @var ConfigInterface $config */
$config = Pay::get(ConfigInterface::class);
return $config->get($provider, [])[get_tenant($params)] ?? [];
}
/**
* @throws ContainerException
* @throws ServiceNotFoundException
*/
#[Deprecated(reason: '自 v3.7.5 开始废弃', replacement: 'get_provider_config')]
function get_alipay_config(array $params = []): array
{
$alipay = Pay::get(ConfigInterface::class)->get('alipay');
@ -113,6 +128,7 @@ function verify_alipay_sign(array $config, string $contents, string $sign): void
* @throws ContainerException
* @throws ServiceNotFoundException
*/
#[Deprecated(reason: '自 v3.7.5 开始废弃', replacement: 'get_provider_config')]
function get_wechat_config(array $params = []): array
{
$wechat = Pay::get(ConfigInterface::class)->get('wechat');
@ -231,7 +247,7 @@ function verify_wechat_sign(ResponseInterface|ServerRequestInterface $message, a
$body = (string) $message->getBody();
$content = $timestamp."\n".$random."\n".$body."\n";
$public = get_wechat_config($params)['wechat_public_cert_path'][$wechatSerial] ?? null;
$public = get_provider_config('wechat', $params)['wechat_public_cert_path'][$wechatSerial] ?? null;
if (empty($sign)) {
throw new InvalidSignException(Exception::SIGN_EMPTY, '签名异常: 微信签名为空', ['headers' => $message->getHeaders(), 'body' => $body]);
@ -308,7 +324,7 @@ function reload_wechat_public_certs(array $params, ?string $serialNo = null): st
$params
)->get('data', []);
$wechatConfig = get_wechat_config($params);
$wechatConfig = get_provider_config('wechat', $params);
foreach ($data as $item) {
$certs[$item['serial_no']] = decrypt_wechat_resource($item['encrypt_certificate'], $wechatConfig)['ciphertext'] ?? '';
@ -337,7 +353,7 @@ function get_wechat_public_certs(array $params = [], ?string $path = null): void
{
reload_wechat_public_certs($params);
$config = get_wechat_config($params);
$config = get_provider_config('wechat', $params);
if (empty($path)) {
var_dump($config['wechat_public_cert_path']);
@ -418,12 +434,12 @@ function get_wechat_serial_no(array $params): string
return $params['_serial_no'];
}
$config = get_wechat_config($params);
$config = get_provider_config('wechat', $params);
if (empty($config['wechat_public_cert_path'])) {
reload_wechat_public_certs($params);
$config = get_wechat_config($params);
$config = get_provider_config('wechat', $params);
}
mt_srand();
@ -466,6 +482,7 @@ function get_wechat_miniprogram_user_sign(string $sessionKey, string $payload):
* @throws ContainerException
* @throws ServiceNotFoundException
*/
#[Deprecated(reason: '自 v3.7.5 开始废弃', replacement: 'get_provider_config')]
function get_unipay_config(array $params = []): array
{
$unipay = Pay::get(ConfigInterface::class)->get('unipay');
@ -575,3 +592,40 @@ function verify_unipay_sign_qra(array $config, array $destination): void
throw new InvalidSignException(Exception::SIGN_ERROR, '签名异常: 验证银联签名失败', $destination);
}
}
function get_jsb_url(array $config, ?Collection $payload): string
{
$url = get_radar_url($config, $payload) ?? '';
if (str_starts_with($url, 'http')) {
return $url;
}
return Jsb::URL[$config['mode'] ?? Pay::MODE_NORMAL];
}
/**
* @throws InvalidConfigException
* @throws InvalidSignException
*/
function verify_jsb_sign(array $config, string $content, string $sign): void
{
if (empty($sign)) {
throw new InvalidSignException(Exception::SIGN_EMPTY, '签名异常: 江苏银行签名为空', func_get_args());
}
$publicCert = $config['jsb_public_cert_path'] ?? null;
if (empty($publicCert)) {
throw new InvalidConfigException(Exception::CONFIG_JSB_INVALID, '配置异常: 缺少配置参数 -- [jsb_public_cert_path]');
}
$result = 1 === openssl_verify(
$content,
base64_decode($sign),
get_public_cert($publicCert)
);
if (!$result) {
throw new InvalidSignException(Exception::SIGN_ERROR, '签名异常: 验证江苏银行签名失败', func_get_args());
}
}

View File

@ -10,9 +10,11 @@ use Yansongda\Artful\Artful;
use Yansongda\Artful\Exception\ContainerException;
use Yansongda\Artful\Exception\ServiceNotFoundException;
use Yansongda\Pay\Provider\Alipay;
use Yansongda\Pay\Provider\Jsb;
use Yansongda\Pay\Provider\Unipay;
use Yansongda\Pay\Provider\Wechat;
use Yansongda\Pay\Service\AlipayServiceProvider;
use Yansongda\Pay\Service\JsbServiceProvider;
use Yansongda\Pay\Service\UnipayServiceProvider;
use Yansongda\Pay\Service\WechatServiceProvider;
@ -20,6 +22,7 @@ use Yansongda\Pay\Service\WechatServiceProvider;
* @method static Alipay alipay(array $config = [], $container = null)
* @method static Wechat wechat(array $config = [], $container = null)
* @method static Unipay unipay(array $config = [], $container = null)
* @method static Jsb jsb(array $config = [], $container = null)
*/
class Pay
{
@ -42,6 +45,7 @@ class Pay
AlipayServiceProvider::class,
WechatServiceProvider::class,
UnipayServiceProvider::class,
JsbServiceProvider::class,
];
/**

View File

@ -13,8 +13,8 @@ use Yansongda\Artful\Logger;
use Yansongda\Artful\Rocket;
use Yansongda\Pay\Exception\Exception;
use function Yansongda\Pay\get_alipay_config;
use function Yansongda\Pay\get_private_cert;
use function Yansongda\Pay\get_provider_config;
class AddPayloadSignaturePlugin implements PluginInterface
{
@ -57,7 +57,7 @@ class AddPayloadSignaturePlugin implements PluginInterface
*/
protected function getPrivateKey(array $params): string
{
$privateKey = get_alipay_config($params)['app_secret_cert'] ?? null;
$privateKey = get_provider_config('alipay', $params)['app_secret_cert'] ?? null;
if (is_null($privateKey)) {
throw new InvalidConfigException(Exception::CONFIG_ALIPAY_INVALID, '配置异常: 缺少支付宝配置 -- [app_secret_cert]');

View File

@ -12,8 +12,8 @@ use Yansongda\Artful\Exception\ServiceNotFoundException;
use Yansongda\Artful\Logger;
use Yansongda\Artful\Rocket;
use function Yansongda\Pay\get_alipay_config;
use function Yansongda\Pay\get_alipay_url;
use function Yansongda\Pay\get_provider_config;
class AddRadarPlugin implements PluginInterface
{
@ -26,7 +26,7 @@ class AddRadarPlugin implements PluginInterface
Logger::debug('[Alipay][AddRadarPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_alipay_config($params);
$config = get_provider_config('alipay', $params);
$payload = $rocket->getPayload();
$rocket->setRadar(new Request(

View File

@ -16,7 +16,7 @@ use Yansongda\Pay\Exception\InvalidSignException;
use Yansongda\Supports\Collection;
use function Yansongda\Artful\filter_params;
use function Yansongda\Pay\get_alipay_config;
use function Yansongda\Pay\get_provider_config;
use function Yansongda\Pay\verify_alipay_sign;
class CallbackPlugin implements PluginInterface
@ -32,7 +32,7 @@ class CallbackPlugin implements PluginInterface
Logger::debug('[Alipay][CallbackPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_alipay_config($params);
$config = get_provider_config('alipay', $params);
$value = filter_params($params, fn ($k, $v) => '' !== $v && 'sign' != $k && 'sign_type' != $k);

View File

@ -6,14 +6,19 @@ namespace Yansongda\Pay\Plugin\Alipay\V2;
use Closure;
use Yansongda\Artful\Contract\PluginInterface;
use Yansongda\Artful\Exception\InvalidResponseException;
use Yansongda\Artful\Logger;
use Yansongda\Artful\Rocket;
use Yansongda\Pay\Exception\Exception;
use Yansongda\Supports\Collection;
use function Yansongda\Artful\should_do_http_request;
class ResponsePlugin implements PluginInterface
{
/**
* @throws InvalidResponseException
*/
public function assembly(Rocket $rocket, Closure $next): Rocket
{
/* @var Rocket $rocket */
@ -26,9 +31,16 @@ class ResponsePlugin implements PluginInterface
$resultKey = str_replace('.', '_', $payload->get('method')).'_response';
if (should_do_http_request($rocket->getDirection()) && $destination instanceof Collection) {
$sign = $destination->get('sign', '');
$response = $destination->get($resultKey, $destination->all());
if (empty($sign) && '10000' !== ($response['code'] ?? 'null')) {
throw new InvalidResponseException(Exception::RESPONSE_BUSINESS_CODE_WRONG, '支付宝网关响应异常: '.($response['sub_msg'] ?? $response['msg'] ?? '未知错误,请查看支付宝原始响应'), $rocket->getDestination());
}
$rocket->setDestination(new Collection(array_merge(
['_sign' => $destination->get('sign', '')],
$destination->get($resultKey, $destination->all())
['_sign' => $sign],
$response
)));
}

View File

@ -15,7 +15,7 @@ use Yansongda\Artful\Rocket;
use Yansongda\Pay\Exception\Exception;
use Yansongda\Pay\Pay;
use function Yansongda\Pay\get_alipay_config;
use function Yansongda\Pay\get_provider_config;
use function Yansongda\Pay\get_public_cert;
use function Yansongda\Pay\get_tenant;
@ -45,7 +45,7 @@ class StartPlugin implements PluginInterface
protected function getPayload(array $params): array
{
$tenant = get_tenant($params);
$config = get_alipay_config($params);
$config = get_provider_config('alipay', $params);
return [
'app_id' => $config['app_id'] ?? '',

View File

@ -17,7 +17,7 @@ use Yansongda\Pay\Exception\InvalidSignException;
use Yansongda\Supports\Collection;
use function Yansongda\Artful\should_do_http_request;
use function Yansongda\Pay\get_alipay_config;
use function Yansongda\Pay\get_provider_config;
use function Yansongda\Pay\verify_alipay_sign;
class VerifySignaturePlugin implements PluginInterface
@ -46,7 +46,7 @@ class VerifySignaturePlugin implements PluginInterface
throw new InvalidParamsException(Exception::RESPONSE_EMPTY, '参数异常: 支付宝验证签名时待验签参数不正确', $destination);
}
$config = get_alipay_config($rocket->getParams());
$config = get_provider_config('alipay', $rocket->getParams());
verify_alipay_sign($config, json_encode($result, JSON_UNESCAPED_UNICODE), $destination->get('_sign', ''));

View File

@ -0,0 +1,65 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Jsb;
use Closure;
use Yansongda\Artful\Contract\PluginInterface;
use Yansongda\Artful\Exception\ContainerException;
use Yansongda\Artful\Exception\InvalidConfigException;
use Yansongda\Artful\Exception\InvalidParamsException;
use Yansongda\Artful\Exception\ServiceNotFoundException;
use Yansongda\Artful\Logger;
use Yansongda\Artful\Rocket;
use Yansongda\Pay\Exception\Exception;
use Yansongda\Supports\Collection;
use function Yansongda\Pay\get_private_cert;
use function Yansongda\Pay\get_provider_config;
class AddPayloadSignPlugin implements PluginInterface
{
/**
* @throws ContainerException
* @throws InvalidConfigException
* @throws InvalidParamsException
* @throws ServiceNotFoundException
*/
public function assembly(Rocket $rocket, Closure $next): Rocket
{
Logger::info('[Jsb][AddPayloadSignPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_provider_config('jsb', $params);
$payload = $rocket->getPayload();
if (empty($payload) || $payload->isEmpty()) {
throw new InvalidParamsException(Exception::PARAMS_NECESSARY_PARAMS_MISSING, '参数异常: 缺少支付必要参数。可能插件用错顺序,应该先使用 `业务插件`');
}
$privateCertPath = $config['mch_secret_cert_path'] ?? '';
if (empty($privateCertPath)) {
throw new InvalidConfigException(Exception::CONFIG_JSB_INVALID, '配置异常: 缺少配置参数 -- [mch_secret_cert_path]');
}
$rocket->mergePayload([
'signType' => 'RSA',
'sign' => $this->getSignature(get_private_cert($privateCertPath), $payload),
]);
Logger::info('[Jsb][AddPayloadSignPlugin] 插件装载完毕', ['rocket' => $rocket]);
return $next($rocket);
}
protected function getSignature(string $pkey, Collection $payload): string
{
$content = $payload->sortKeys()->toString();
openssl_sign($content, $signature, $pkey);
return base64_encode($signature);
}
}

View File

@ -0,0 +1,68 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Jsb;
use Closure;
use GuzzleHttp\Psr7\Request;
use Yansongda\Artful\Contract\PluginInterface;
use Yansongda\Artful\Exception\ContainerException;
use Yansongda\Artful\Exception\ServiceNotFoundException;
use Yansongda\Artful\Logger;
use Yansongda\Artful\Rocket;
use Yansongda\Supports\Collection;
use function Yansongda\Pay\get_jsb_url;
use function Yansongda\Pay\get_provider_config;
class AddRadarPlugin implements PluginInterface
{
/**
* @throws ServiceNotFoundException
* @throws ContainerException
*/
public function assembly(Rocket $rocket, Closure $next): Rocket
{
Logger::info('[Jsb][AddRadarPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_provider_config('jsb', $params);
$payload = $rocket->getPayload();
$rocket->setRadar(new Request(
strtoupper($params['_method'] ?? 'POST'),
get_jsb_url($config, $payload),
$this->getHeaders(),
$this->getBody($payload),
));
Logger::info('[Jsb][AddRadarPlugin] 插件装载完毕', ['rocket' => $rocket]);
return $next($rocket);
}
protected function getHeaders(): array
{
return [
'Content-Type' => 'text/html',
'User-Agent' => 'yansongda/pay-v3',
];
}
protected function getBody(Collection $payload): string
{
$sign = $payload->get('sign');
$signType = $payload->get('signType');
$payload->forget('sign');
$payload->forget('signType');
$payload = $payload->sortKeys();
$payload->set('sign', $sign);
$payload->set('signType', $signType);
return $payload->toString();
}
}

View File

@ -0,0 +1,70 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Jsb;
use Closure;
use Yansongda\Artful\Contract\PluginInterface;
use Yansongda\Artful\Direction\NoHttpRequestDirection;
use Yansongda\Artful\Exception\ContainerException;
use Yansongda\Artful\Exception\InvalidConfigException;
use Yansongda\Artful\Exception\InvalidParamsException;
use Yansongda\Artful\Exception\ServiceNotFoundException;
use Yansongda\Artful\Logger;
use Yansongda\Artful\Rocket;
use Yansongda\Pay\Exception\Exception;
use Yansongda\Pay\Exception\InvalidSignException;
use Yansongda\Supports\Collection;
use function Yansongda\Pay\get_provider_config;
use function Yansongda\Pay\verify_jsb_sign;
class CallbackPlugin implements PluginInterface
{
/**
* @throws ContainerException
* @throws InvalidConfigException
* @throws InvalidParamsException
* @throws ServiceNotFoundException
* @throws InvalidSignException
*/
public function assembly(Rocket $rocket, Closure $next): Rocket
{
Logger::info('[Jsb][CallbackPlugin] 插件开始装载', ['rocket' => $rocket]);
$this->formatRequestAndParams($rocket);
$params = $rocket->getParams();
$config = get_provider_config('jsb', $params);
$payload = $rocket->getPayload();
$signature = $payload->get('sign');
$payload->forget('sign');
$payload->forget('signType');
verify_jsb_sign($config, $payload->sortKeys()->toString(), $signature);
$rocket->setDirection(NoHttpRequestDirection::class)
->setDestination($rocket->getPayload());
Logger::info('[Jsb][CallbackPlugin] 插件装载完毕', ['rocket' => $rocket]);
return $next($rocket);
}
/**
* @throws InvalidParamsException
*/
protected function formatRequestAndParams(Rocket $rocket): void
{
$request = $rocket->getParams()['request'] ?? null;
if (!$request instanceof Collection) {
throw new InvalidParamsException(Exception::PARAMS_CALLBACK_REQUEST_INVALID);
}
$rocket->setPayload($request)->setParams($rocket->getParams()['params'] ?? []);
}
}

View File

@ -0,0 +1,49 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Jsb\Pay\Scan;
use Closure;
use Yansongda\Artful\Contract\PluginInterface;
use Yansongda\Artful\Exception\ContainerException;
use Yansongda\Artful\Exception\InvalidConfigException;
use Yansongda\Artful\Exception\ServiceNotFoundException;
use Yansongda\Artful\Logger;
use Yansongda\Artful\Rocket;
use Yansongda\Pay\Exception\Exception;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://github.com/yansongda/pay/pull/1002
*/
class PayPlugin implements PluginInterface
{
/**
* @throws InvalidConfigException
* @throws ServiceNotFoundException
* @throws ContainerException
*/
public function assembly(Rocket $rocket, Closure $next): Rocket
{
Logger::debug('[Jsb][Pay][Scan][PayPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_provider_config('jsb', $params);
$backUrl = $rocket->getPayload()['notify_url'] ?? $config['notify_url'] ?? null;
if (!$backUrl) {
throw new InvalidConfigException(Exception::CONFIG_JSB_INVALID, '配置异常: 缺少配置参数 -- [notify_url]');
}
$rocket->mergePayload([
'service' => 'atPay',
'backUrl' => $backUrl,
]);
Logger::info('[Jsb][Pay][Scan][PayPlugin] 插件装载完毕', ['rocket' => $rocket]);
return $next($rocket);
}
}

View File

@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Jsb\Pay\Scan;
use Closure;
use Yansongda\Artful\Contract\PluginInterface;
use Yansongda\Artful\Logger;
use Yansongda\Artful\Rocket;
/**
* @see https://github.com/yansongda/pay/pull/1002
*/
class QueryPlugin implements PluginInterface
{
public function assembly(Rocket $rocket, Closure $next): Rocket
{
Logger::debug('[Jsb][Pay][Scan][QueryPlugin] 插件开始装载', ['rocket' => $rocket]);
$rocket->mergePayload([
'deviceNo' => '1234567890',
'service' => 'payCheck',
]);
Logger::info('[Jsb][Pay][Scan][QueryPlugin] 插件装载完毕', ['rocket' => $rocket]);
return $next($rocket);
}
}

View File

@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Jsb\Pay\Scan;
use Closure;
use Yansongda\Artful\Contract\PluginInterface;
use Yansongda\Artful\Logger;
use Yansongda\Artful\Rocket;
/**
* @see https://github.com/yansongda/pay/pull/1002
*/
class RefundPlugin implements PluginInterface
{
public function assembly(Rocket $rocket, Closure $next): Rocket
{
Logger::debug('[Jsb][Pay][Scan][RefundPlugin] 插件开始装载', ['rocket' => $rocket]);
$rocket->mergePayload([
'deviceNo' => '1234567890',
'service' => 'payRefund',
]);
Logger::info('[Jsb][Pay][Scan][RefundPlugin] 插件装载完毕', ['rocket' => $rocket]);
return $next($rocket);
}
}

View File

@ -0,0 +1,52 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Jsb;
use Closure;
use Psr\Http\Message\ResponseInterface;
use Yansongda\Artful\Contract\PluginInterface;
use Yansongda\Artful\Exception\InvalidResponseException;
use Yansongda\Artful\Logger;
use Yansongda\Artful\Rocket;
use Yansongda\Pay\Exception\Exception;
use Yansongda\Supports\Collection;
class ResponsePlugin implements PluginInterface
{
/**
* @throws InvalidResponseException
*/
public function assembly(Rocket $rocket, Closure $next): Rocket
{
/* @var Rocket $rocket */
$rocket = $next($rocket);
Logger::debug('[Jsb][ResponsePlugin] 插件开始装载', ['rocket' => $rocket]);
$this->validateResponse($rocket);
Logger::info('[Jsb][ResponsePlugin] 插件装载完毕', ['rocket' => $rocket]);
return $rocket;
}
/**
* @throws InvalidResponseException
*/
protected function validateResponse(Rocket $rocket): void
{
$destination = $rocket->getDestination();
$destinationOrigin = $rocket->getDestinationOrigin();
if ($destinationOrigin instanceof ResponseInterface
&& ($destinationOrigin->getStatusCode() < 200 || $destinationOrigin->getStatusCode() >= 300)) {
throw new InvalidResponseException(Exception::RESPONSE_CODE_WRONG, '江苏银行返回状态码异常,请检查参数是否错误', $rocket->getDestination());
}
if ($destination instanceof Collection && '000000' !== $destination->get('respCode')) {
throw new InvalidResponseException(Exception::RESPONSE_BUSINESS_CODE_WRONG, sprintf('江苏银行返回错误: respCode:%s respMsg:%s', $destination->get('respCode'), $destination->get('respMsg')), $rocket->getDestination());
}
}
}

View File

@ -0,0 +1,49 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Jsb;
use Closure;
use Yansongda\Artful\Contract\PluginInterface;
use Yansongda\Artful\Exception\ContainerException;
use Yansongda\Artful\Exception\ServiceNotFoundException;
use Yansongda\Artful\Logger;
use Yansongda\Artful\Packer\QueryPacker;
use Yansongda\Artful\Rocket;
use Yansongda\Supports\Str;
use function Yansongda\Pay\get_provider_config;
class StartPlugin implements PluginInterface
{
/**
* @throws ServiceNotFoundException
* @throws ContainerException
*/
public function assembly(Rocket $rocket, Closure $next): Rocket
{
Logger::info('[Jsb][StartPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_provider_config('jsb', $params);
$rocket->setPacker(QueryPacker::class)
->mergePayload(array_merge($params, [
'createData' => date('Ymd'),
'createTime' => date('His'),
'bizDate' => date('Ymd'),
'msgId' => Str::uuidV4(),
'svrCode' => $config['svr_code'] ?? '',
'partnerId' => $config['partner_id'] ?? '',
'channelNo' => 'm',
'publicKeyCode' => $config['public_key_code'] ?? '',
'version' => 'v1.0.0',
'charset' => 'utf-8',
]));
Logger::info('[Jsb][StartPlugin] 插件装载完毕', ['rocket' => $rocket]);
return $next($rocket);
}
}

View File

@ -0,0 +1,76 @@
<?php
declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Jsb;
use Closure;
use Yansongda\Artful\Contract\PluginInterface;
use Yansongda\Artful\Exception\ContainerException;
use Yansongda\Artful\Exception\InvalidConfigException;
use Yansongda\Artful\Exception\ServiceNotFoundException;
use Yansongda\Artful\Logger;
use Yansongda\Artful\Rocket;
use Yansongda\Pay\Exception\InvalidSignException;
use Yansongda\Supports\Arr;
use Yansongda\Supports\Collection;
use Yansongda\Supports\Str;
use function Yansongda\Artful\should_do_http_request;
use function Yansongda\Pay\get_provider_config;
use function Yansongda\Pay\verify_jsb_sign;
class VerifySignaturePlugin implements PluginInterface
{
/**
* @throws ContainerException
* @throws InvalidConfigException
* @throws InvalidSignException
* @throws ServiceNotFoundException
*/
public function assembly(Rocket $rocket, Closure $next): Rocket
{
/* @var Rocket $rocket */
$rocket = $next($rocket);
Logger::info('[Jsb][VerifySignaturePlugin] 插件开始装载', ['rocket' => $rocket]);
if (should_do_http_request($rocket->getDirection())) {
$params = $rocket->getParams();
$config = get_provider_config('jsb', $params);
$body = (string) $rocket->getDestinationOrigin()->getBody();
$signatureData = $this->getSignatureData($body);
verify_jsb_sign($config, $signatureData['data'] ?? '', $signatureData['sign'] ?? '');
}
Logger::info('[Jsb][VerifySignaturePlugin] 插件装载完毕', ['rocket' => $rocket]);
return $rocket;
}
private function getSignatureData(string $body): array
{
if (Str::contains($body, '&-&')) {
$beginIndex = strpos($body, '&signType=');
$endIndex = strpos($body, '&-&');
$data = substr($body, 0, $beginIndex).substr($body, $endIndex);
$signIndex = strpos($body, '&sign=');
$signature = substr($body, $signIndex + strlen('&sign='), $endIndex - ($signIndex + strlen('&sign=')));
} else {
$result = Arr::wrapQuery($body, true);
$result = Collection::wrap($result);
$signature = $result->get('sign');
$result->forget('sign');
$result->forget('signType');
$data = $result->sortKeys()->toString();
}
return [
'sign' => $signature,
'data' => $data,
];
}
}

View File

@ -14,8 +14,8 @@ use Yansongda\Artful\Logger;
use Yansongda\Artful\Rocket;
use function Yansongda\Artful\get_radar_method;
use function Yansongda\Pay\get_provider_config;
use function Yansongda\Pay\get_unipay_body;
use function Yansongda\Pay\get_unipay_config;
use function Yansongda\Pay\get_unipay_url;
class AddRadarPlugin implements PluginInterface
@ -30,7 +30,7 @@ class AddRadarPlugin implements PluginInterface
Logger::debug('[Unipay][AddRadarPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_unipay_config($params);
$config = get_provider_config('unipay', $params);
$payload = $rocket->getPayload();
$rocket->setRadar(new Request(

View File

@ -15,7 +15,7 @@ use Yansongda\Pay\Exception\Exception;
use Yansongda\Supports\Collection;
use function Yansongda\Artful\filter_params;
use function Yansongda\Pay\get_unipay_config;
use function Yansongda\Pay\get_provider_config;
class AddPayloadSignaturePlugin implements PluginInterface
{
@ -29,7 +29,7 @@ class AddPayloadSignaturePlugin implements PluginInterface
Logger::debug('[Unipay][AddPayloadSignaturePlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_unipay_config($params);
$config = get_provider_config('unipay', $params);
$payload = $rocket->getPayload();
if (empty($payload) || $payload->isEmpty()) {

View File

@ -15,7 +15,7 @@ use Yansongda\Artful\Rocket;
use Yansongda\Pay\Exception\InvalidSignException;
use function Yansongda\Artful\filter_params;
use function Yansongda\Pay\get_unipay_config;
use function Yansongda\Pay\get_provider_config;
use function Yansongda\Pay\verify_unipay_sign;
class CallbackPlugin implements PluginInterface
@ -31,7 +31,7 @@ class CallbackPlugin implements PluginInterface
Logger::debug('[Unipay][CallbackPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_unipay_config($params);
$config = get_provider_config('unipay', $params);
$rocket->setPayload($params);

View File

@ -12,7 +12,7 @@ use Yansongda\Artful\Exception\ServiceNotFoundException;
use Yansongda\Artful\Logger;
use Yansongda\Artful\Rocket;
use function Yansongda\Pay\get_unipay_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://open.unionpay.com/tjweb/acproduct/APIList?apiservId=453&acpAPIId=334&bussType=0
@ -28,7 +28,7 @@ class PayPlugin implements PluginInterface
Logger::debug('[Unipay][Pay][H5][PayPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_unipay_config($params);
$config = get_provider_config('unipay', $params);
$payload = $rocket->getPayload();
$rocket->setDirection(ResponseDirection::class)

View File

@ -12,7 +12,7 @@ use Yansongda\Artful\Logger;
use Yansongda\Artful\Packer\QueryPacker;
use Yansongda\Artful\Rocket;
use function Yansongda\Pay\get_unipay_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://open.unionpay.com/tjweb/acproduct/APIList?apiservId=468&acpAPIId=800&bussType=0
@ -28,7 +28,7 @@ class CancelPlugin implements PluginInterface
Logger::debug('[Unipay][Pay][QrCode][CancelPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_unipay_config($params);
$config = get_provider_config('unipay', $params);
$payload = $rocket->getPayload();
$rocket->setPacker(QueryPacker::class)

View File

@ -12,7 +12,7 @@ use Yansongda\Artful\Logger;
use Yansongda\Artful\Packer\QueryPacker;
use Yansongda\Artful\Rocket;
use function Yansongda\Pay\get_unipay_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://open.unionpay.com/tjweb/acproduct/APIList?acpAPIId=798&apiservId=468&version=V2.2&bussType=0
@ -28,7 +28,7 @@ class PosPlugin implements PluginInterface
Logger::debug('[Unipay][Pay][QrCode][PosPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_unipay_config($params);
$config = get_provider_config('unipay', $params);
$payload = $rocket->getPayload();
$rocket->setPacker(QueryPacker::class)

View File

@ -12,7 +12,7 @@ use Yansongda\Artful\Logger;
use Yansongda\Artful\Packer\QueryPacker;
use Yansongda\Artful\Rocket;
use function Yansongda\Pay\get_unipay_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://open.unionpay.com/tjweb/acproduct/APIList?acpAPIId=797&apiservId=468&version=V2.2&bussType=0
@ -28,7 +28,7 @@ class PosPreAuthPlugin implements PluginInterface
Logger::debug('[Unipay][Pay][QrCode][PosPreAuthPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_unipay_config($params);
$config = get_provider_config('unipay', $params);
$payload = $rocket->getPayload();
$rocket->setPacker(QueryPacker::class)

View File

@ -12,7 +12,7 @@ use Yansongda\Artful\Logger;
use Yansongda\Artful\Packer\QueryPacker;
use Yansongda\Artful\Rocket;
use function Yansongda\Pay\get_unipay_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://open.unionpay.com/tjweb/acproduct/APIList?acpAPIId=792&apiservId=468&version=V2.2&bussType=0
@ -28,7 +28,7 @@ class QueryPlugin implements PluginInterface
Logger::debug('[Unipay][Pay][QrCode][QueryPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_unipay_config($params);
$config = get_provider_config('unipay', $params);
$payload = $rocket->getPayload();
$rocket->setPacker(QueryPacker::class)

View File

@ -12,7 +12,7 @@ use Yansongda\Artful\Logger;
use Yansongda\Artful\Packer\QueryPacker;
use Yansongda\Artful\Rocket;
use function Yansongda\Pay\get_unipay_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://open.unionpay.com/tjweb/acproduct/APIList?acpAPIId=799&apiservId=468&version=V2.2&bussType=0
@ -28,7 +28,7 @@ class RefundPlugin implements PluginInterface
Logger::debug('[Unipay][QrCode][RefundPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_unipay_config($params);
$config = get_provider_config('unipay', $params);
$payload = $rocket->getPayload();
$rocket->setPacker(QueryPacker::class)

View File

@ -12,7 +12,7 @@ use Yansongda\Artful\Logger;
use Yansongda\Artful\Packer\QueryPacker;
use Yansongda\Artful\Rocket;
use function Yansongda\Pay\get_unipay_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://open.unionpay.com/tjweb/acproduct/APIList?acpAPIId=796&apiservId=468&version=V2.2&bussType=0
@ -28,7 +28,7 @@ class ScanFeePlugin implements PluginInterface
Logger::debug('[Unipay][Pay][QrCode][ScanFeePlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_unipay_config($params);
$config = get_provider_config('unipay', $params);
$payload = $rocket->getPayload();
$rocket->setPacker(QueryPacker::class)

View File

@ -12,7 +12,7 @@ use Yansongda\Artful\Logger;
use Yansongda\Artful\Packer\QueryPacker;
use Yansongda\Artful\Rocket;
use function Yansongda\Pay\get_unipay_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://open.unionpay.com/tjweb/acproduct/APIList?acpAPIId=793&apiservId=468&version=V2.2&bussType=0
@ -28,7 +28,7 @@ class ScanPlugin implements PluginInterface
Logger::debug('[Unipay][Pay][QrCode][ScanPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_unipay_config($params);
$config = get_provider_config('unipay', $params);
$payload = $rocket->getPayload();
$rocket->setPacker(QueryPacker::class)

View File

@ -12,7 +12,7 @@ use Yansongda\Artful\Logger;
use Yansongda\Artful\Packer\QueryPacker;
use Yansongda\Artful\Rocket;
use function Yansongda\Pay\get_unipay_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://open.unionpay.com/tjweb/acproduct/APIList?acpAPIId=794&apiservId=468&version=V2.2&bussType=0
@ -28,7 +28,7 @@ class ScanPreAuthPlugin implements PluginInterface
Logger::debug('[Unipay][Pay][QrCode][ScanPreAuthPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_unipay_config($params);
$config = get_provider_config('unipay', $params);
$payload = $rocket->getPayload();
$rocket->setPacker(QueryPacker::class)

View File

@ -12,7 +12,7 @@ use Yansongda\Artful\Logger;
use Yansongda\Artful\Packer\QueryPacker;
use Yansongda\Artful\Rocket;
use function Yansongda\Pay\get_unipay_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://open.unionpay.com/tjweb/acproduct/APIList?acpAPIId=795&apiservId=468&version=V2.2&bussType=0
@ -28,7 +28,7 @@ class ScanPreOrderPlugin implements PluginInterface
Logger::debug('[Unipay][Pay][QrCode][ScanPreOrderPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_unipay_config($params);
$config = get_provider_config('unipay', $params);
$payload = $rocket->getPayload();
$rocket->setPacker(QueryPacker::class)

View File

@ -12,7 +12,7 @@ use Yansongda\Artful\Logger;
use Yansongda\Artful\Packer\QueryPacker;
use Yansongda\Artful\Rocket;
use function Yansongda\Pay\get_unipay_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://open.unionpay.com/tjweb/acproduct/APIList?acpAPIId=755&apiservId=448&version=V2.2&bussType=0
@ -28,7 +28,7 @@ class CancelPlugin implements PluginInterface
Logger::debug('[Unipay][Pay][Web][CancelPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_unipay_config($params);
$config = get_provider_config('unipay', $params);
$payload = $rocket->getPayload();
$rocket->setPacker(QueryPacker::class)

View File

@ -13,7 +13,7 @@ use Yansongda\Artful\Logger;
use Yansongda\Artful\Packer\QueryPacker;
use Yansongda\Artful\Rocket;
use function Yansongda\Pay\get_unipay_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://open.unionpay.com/tjweb/acproduct/APIList?acpAPIId=754&apiservId=448&version=V2.2&bussType=0
@ -29,7 +29,7 @@ class PayPlugin implements PluginInterface
Logger::debug('[Unipay][Pay][Web][PayPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_unipay_config($params);
$config = get_provider_config('unipay', $params);
$payload = $rocket->getPayload();
$rocket->setPacker(QueryPacker::class)

View File

@ -12,7 +12,7 @@ use Yansongda\Artful\Logger;
use Yansongda\Artful\Packer\QueryPacker;
use Yansongda\Artful\Rocket;
use function Yansongda\Pay\get_unipay_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://open.unionpay.com/tjweb/acproduct/APIList?acpAPIId=757&apiservId=448&version=V2.2&bussType=0
@ -28,7 +28,7 @@ class QueryPlugin implements PluginInterface
Logger::debug('[Unipay][Pay][Web][QueryPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_unipay_config($params);
$config = get_provider_config('unipay', $params);
$payload = $rocket->getPayload();
$rocket->setPacker(QueryPacker::class)

View File

@ -12,7 +12,7 @@ use Yansongda\Artful\Logger;
use Yansongda\Artful\Packer\QueryPacker;
use Yansongda\Artful\Rocket;
use function Yansongda\Pay\get_unipay_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://open.unionpay.com/tjweb/acproduct/APIList?acpAPIId=756&apiservId=448&version=V2.2&bussType=0
@ -28,7 +28,7 @@ class RefundPlugin implements PluginInterface
Logger::debug('[Unipay][Pay][Web][RefundPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_unipay_config($params);
$config = get_provider_config('unipay', $params);
$payload = $rocket->getPayload();
$rocket->setPacker(QueryPacker::class)

View File

@ -15,8 +15,8 @@ use Yansongda\Artful\Rocket;
use Yansongda\Pay\Exception\Exception;
use Yansongda\Pay\Pay;
use function Yansongda\Pay\get_provider_config;
use function Yansongda\Pay\get_tenant;
use function Yansongda\Pay\get_unipay_config;
class StartPlugin implements PluginInterface
{
@ -30,7 +30,7 @@ class StartPlugin implements PluginInterface
Logger::debug('[Unipay][StartPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_unipay_config($params);
$config = get_provider_config('unipay', $params);
$tenant = get_tenant($params);
$rocket->mergePayload(array_merge($params, [

View File

@ -15,7 +15,7 @@ use Yansongda\Pay\Exception\InvalidSignException;
use Yansongda\Supports\Collection;
use function Yansongda\Artful\should_do_http_request;
use function Yansongda\Pay\get_unipay_config;
use function Yansongda\Pay\get_provider_config;
use function Yansongda\Pay\verify_unipay_sign;
class VerifySignaturePlugin implements PluginInterface
@ -44,7 +44,7 @@ class VerifySignaturePlugin implements PluginInterface
}
$params = $rocket->getParams();
$config = get_unipay_config($params);
$config = get_provider_config('unipay', $params);
verify_unipay_sign(
$config,

View File

@ -15,7 +15,7 @@ use Yansongda\Artful\Rocket;
use Yansongda\Pay\Exception\Exception;
use function Yansongda\Artful\filter_params;
use function Yansongda\Pay\get_unipay_config;
use function Yansongda\Pay\get_provider_config;
use function Yansongda\Pay\get_unipay_sign_qra;
class AddPayloadSignaturePlugin implements PluginInterface
@ -31,7 +31,7 @@ class AddPayloadSignaturePlugin implements PluginInterface
Logger::debug('[Unipay][Qra][AddPayloadSignaturePlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_unipay_config($params);
$config = get_provider_config('unipay', $params);
$payload = $rocket->getPayload();
if (empty($payload) || $payload->isEmpty()) {

View File

@ -15,7 +15,7 @@ use Yansongda\Artful\Rocket;
use Yansongda\Pay\Exception\InvalidSignException;
use function Yansongda\Artful\filter_params;
use function Yansongda\Pay\get_unipay_config;
use function Yansongda\Pay\get_provider_config;
use function Yansongda\Pay\verify_unipay_sign_qra;
class CallbackPlugin implements PluginInterface
@ -31,7 +31,7 @@ class CallbackPlugin implements PluginInterface
Logger::debug('[Unipay][Qra][CallbackPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_unipay_config($params);
$config = get_provider_config('unipay', $params);
$destination = filter_params($params);
if (isset($params['status']) && 0 == $params['status']) {

View File

@ -14,7 +14,7 @@ use Yansongda\Artful\Packer\XmlPacker;
use Yansongda\Artful\Rocket;
use Yansongda\Supports\Str;
use function Yansongda\Pay\get_unipay_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://up.95516.com/open/openapi/doc?index_1=2&index_2=1&chapter_1=274&chapter_2=294
@ -31,7 +31,7 @@ class CancelPlugin implements PluginInterface
Logger::debug('[Unipay][Qra][Pos][CancelPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_unipay_config($params);
$config = get_provider_config('unipay', $params);
$rocket->setPacker(XmlPacker::class)
->mergePayload([

View File

@ -14,7 +14,7 @@ use Yansongda\Artful\Packer\XmlPacker;
use Yansongda\Artful\Rocket;
use Yansongda\Supports\Str;
use function Yansongda\Pay\get_unipay_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://up.95516.com/open/openapi/doc?index_1=2&index_2=1&chapter_1=274&chapter_2=292
@ -31,7 +31,7 @@ class PayPlugin implements PluginInterface
Logger::debug('[Unipay][Qra][Pos][PayPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_unipay_config($params);
$config = get_provider_config('unipay', $params);
$rocket->setPacker(XmlPacker::class)
->mergePayload([

View File

@ -14,7 +14,7 @@ use Yansongda\Artful\Packer\XmlPacker;
use Yansongda\Artful\Rocket;
use Yansongda\Supports\Str;
use function Yansongda\Pay\get_unipay_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://up.95516.com/open/openapi/doc?index_1=2&index_2=1&chapter_1=274&chapter_2=300
@ -31,7 +31,7 @@ class QueryOpenIdPlugin implements PluginInterface
Logger::debug('[Unipay][Qra][Pos][QueryOpenIdPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_unipay_config($params);
$config = get_provider_config('unipay', $params);
$rocket->setPacker(XmlPacker::class)
->mergePayload([

View File

@ -14,7 +14,7 @@ use Yansongda\Artful\Packer\XmlPacker;
use Yansongda\Artful\Rocket;
use Yansongda\Supports\Str;
use function Yansongda\Pay\get_unipay_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://up.95516.com/open/openapi/doc?index_1=2&index_2=1&chapter_1=274&chapter_2=293
@ -31,7 +31,7 @@ class QueryPlugin implements PluginInterface
Logger::debug('[Unipay][Qra][Pos][QueryPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_unipay_config($params);
$config = get_provider_config('unipay', $params);
$rocket->setPacker(XmlPacker::class)
->mergePayload([

View File

@ -14,7 +14,7 @@ use Yansongda\Artful\Packer\XmlPacker;
use Yansongda\Artful\Rocket;
use Yansongda\Supports\Str;
use function Yansongda\Pay\get_unipay_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://up.95516.com/open/openapi/doc?index_1=2&index_2=1&chapter_1=274&chapter_2=296
@ -31,7 +31,7 @@ class QueryRefundPlugin implements PluginInterface
Logger::debug('[Unipay][Qra][Pos][QueryRefundPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_unipay_config($params);
$config = get_provider_config('unipay', $params);
$rocket->setPacker(XmlPacker::class)
->mergePayload([

View File

@ -14,7 +14,7 @@ use Yansongda\Artful\Packer\XmlPacker;
use Yansongda\Artful\Rocket;
use Yansongda\Supports\Str;
use function Yansongda\Pay\get_unipay_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://up.95516.com/open/openapi/doc?index_1=2&index_2=1&chapter_1=274&chapter_2=295
@ -31,7 +31,7 @@ class RefundPlugin implements PluginInterface
Logger::debug('[Unipay][Qra][Pos][RefundPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_unipay_config($params);
$config = get_provider_config('unipay', $params);
$rocket->setPacker(XmlPacker::class)
->mergePayload([

View File

@ -14,7 +14,7 @@ use Yansongda\Artful\Packer\XmlPacker;
use Yansongda\Artful\Rocket;
use Yansongda\Supports\Str;
use function Yansongda\Pay\get_unipay_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://up.95516.com/open/openapi/doc?index_1=1&index_2=1&chapter_1=235&chapter_2=255
@ -31,7 +31,7 @@ class ClosePlugin implements PluginInterface
Logger::debug('[Unipay][Qra][Scan][ClosePlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_unipay_config($params);
$config = get_provider_config('unipay', $params);
$rocket->setPacker(XmlPacker::class)
->mergePayload([

View File

@ -14,7 +14,7 @@ use Yansongda\Artful\Packer\XmlPacker;
use Yansongda\Artful\Rocket;
use Yansongda\Supports\Str;
use function Yansongda\Pay\get_unipay_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://up.95516.com/open/openapi/doc?index_1=1&index_2=1&chapter_1=235&chapter_2=253
@ -31,7 +31,7 @@ class PayPlugin implements PluginInterface
Logger::debug('[Unipay][Qra][Scan][PayPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_unipay_config($params);
$config = get_provider_config('unipay', $params);
$payload = $rocket->getPayload();
$rocket->setPacker(XmlPacker::class)

View File

@ -14,7 +14,7 @@ use Yansongda\Artful\Packer\XmlPacker;
use Yansongda\Artful\Rocket;
use Yansongda\Supports\Str;
use function Yansongda\Pay\get_unipay_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://up.95516.com/open/openapi/doc?index_1=1&index_2=1&chapter_1=235&chapter_2=254
@ -31,7 +31,7 @@ class QueryPlugin implements PluginInterface
Logger::debug('[Unipay][Qra][Scan][QueryPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_unipay_config($params);
$config = get_provider_config('unipay', $params);
$rocket->setPacker(XmlPacker::class)
->mergePayload([

View File

@ -14,7 +14,7 @@ use Yansongda\Artful\Packer\XmlPacker;
use Yansongda\Artful\Rocket;
use Yansongda\Supports\Str;
use function Yansongda\Pay\get_unipay_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://up.95516.com/open/openapi/doc?index_1=1&index_2=1&chapter_1=235&chapter_2=257
@ -31,7 +31,7 @@ class QueryRefundPlugin implements PluginInterface
Logger::debug('[Unipay][Qra][Scan][QueryRefundPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_unipay_config($params);
$config = get_provider_config('unipay', $params);
$rocket->setPacker(XmlPacker::class)
->mergePayload([

View File

@ -14,7 +14,7 @@ use Yansongda\Artful\Packer\XmlPacker;
use Yansongda\Artful\Rocket;
use Yansongda\Supports\Str;
use function Yansongda\Pay\get_unipay_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://up.95516.com/open/openapi/doc?index_1=1&index_2=1&chapter_1=235&chapter_2=256
@ -31,7 +31,7 @@ class RefundPlugin implements PluginInterface
Logger::debug('[Unipay][Qra][Scan][RefundPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_unipay_config($params);
$config = get_provider_config('unipay', $params);
$rocket->setPacker(XmlPacker::class)
->mergePayload([

View File

@ -14,7 +14,7 @@ use Yansongda\Artful\Rocket;
use Yansongda\Pay\Exception\InvalidSignException;
use function Yansongda\Artful\should_do_http_request;
use function Yansongda\Pay\get_unipay_config;
use function Yansongda\Pay\get_provider_config;
use function Yansongda\Pay\verify_unipay_sign_qra;
class VerifySignaturePlugin implements PluginInterface
@ -32,7 +32,7 @@ class VerifySignaturePlugin implements PluginInterface
Logger::debug('[Unipay][Qra][VerifySignaturePlugin] 插件开始装载', ['rocket' => $rocket]);
$config = get_unipay_config($rocket->getParams());
$config = get_provider_config('unipay', $rocket->getParams());
if (!should_do_http_request($rocket->getDirection())) {
return $rocket;

View File

@ -14,8 +14,8 @@ use Yansongda\Artful\Logger;
use Yansongda\Artful\Rocket;
use Yansongda\Supports\Collection;
use function Yansongda\Pay\get_provider_config;
use function Yansongda\Pay\get_wechat_body;
use function Yansongda\Pay\get_wechat_config;
use function Yansongda\Pay\get_wechat_method;
use function Yansongda\Pay\get_wechat_url;
@ -32,7 +32,7 @@ class AddRadarPlugin implements PluginInterface
$params = $rocket->getParams();
$payload = $rocket->getPayload();
$config = get_wechat_config($params);
$config = get_provider_config('wechat', $params);
$rocket->setRadar(new Request(
get_wechat_method($payload),

View File

@ -5,14 +5,12 @@ declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat;
use Closure;
use Psr\Http\Message\MessageInterface;
use Psr\Http\Message\ResponseInterface;
use Yansongda\Artful\Contract\PluginInterface;
use Yansongda\Artful\Exception\InvalidResponseException;
use Yansongda\Artful\Logger;
use Yansongda\Artful\Rocket;
use Yansongda\Pay\Exception\Exception;
use Yansongda\Supports\Collection;
class ResponsePlugin implements PluginInterface
{
@ -26,7 +24,7 @@ class ResponsePlugin implements PluginInterface
Logger::debug('[Wechat][ResponsePlugin] 插件开始装载', ['rocket' => $rocket]);
$rocket->setDestination($this->validateResponse($rocket));
$this->validateResponse($rocket);
Logger::info('[Wechat][ResponsePlugin] 插件装载完毕', ['rocket' => $rocket]);
@ -36,7 +34,7 @@ class ResponsePlugin implements PluginInterface
/**
* @throws InvalidResponseException
*/
protected function validateResponse(Rocket $rocket): null|Collection|MessageInterface
protected function validateResponse(Rocket $rocket): void
{
$response = $rocket->getDestinationOrigin();
@ -44,7 +42,5 @@ class ResponsePlugin implements PluginInterface
&& ($response->getStatusCode() < 200 || $response->getStatusCode() >= 300)) {
throw new InvalidResponseException(Exception::RESPONSE_CODE_WRONG, '微信返回状态码异常,请检查参数是否错误', $rocket->getDestination());
}
return $rocket->getDestination();
}
}

View File

@ -5,10 +5,12 @@ declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat;
use Closure;
use JetBrains\PhpStorm\Deprecated;
use Yansongda\Artful\Contract\PluginInterface;
use Yansongda\Artful\Logger;
use Yansongda\Artful\Rocket;
#[Deprecated(reason: '自 v3.7.5 版本已废弃', replacement: '`yansongda/artful` 包中的 `Yansongda\Artful\Plugin\StartPlugin`')]
class StartPlugin implements PluginInterface
{
public function assembly(Rocket $rocket, Closure $next): Rocket

View File

@ -13,7 +13,7 @@ use Yansongda\Artful\Logger;
use Yansongda\Artful\Rocket;
use function Yansongda\Artful\filter_params;
use function Yansongda\Pay\get_wechat_config;
use function Yansongda\Pay\get_provider_config;
use function Yansongda\Pay\get_wechat_sign_v2;
class AddPayloadSignaturePlugin implements PluginInterface
@ -27,7 +27,7 @@ class AddPayloadSignaturePlugin implements PluginInterface
{
Logger::debug('[Wechat][V2][AddPayloadSignaturePlugin] 插件开始装载', ['rocket' => $rocket]);
$config = get_wechat_config($rocket->getParams());
$config = get_provider_config('wechat', $rocket->getParams());
$rocket->mergePayload([
'sign' => get_wechat_sign_v2($config, filter_params($rocket->getPayload())->all()),

View File

@ -14,7 +14,7 @@ use Yansongda\Artful\Packer\XmlPacker;
use Yansongda\Artful\Rocket;
use Yansongda\Supports\Str;
use function Yansongda\Pay\get_wechat_config;
use function Yansongda\Pay\get_provider_config;
use function Yansongda\Pay\get_wechat_type_key;
/**
@ -32,7 +32,7 @@ class ApplyPlugin implements PluginInterface
Logger::debug('[Wechat][V2][Papay][Direct][ApplyPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_wechat_config($params);
$config = get_provider_config('wechat', $params);
$payload = $rocket->getPayload();
$rocket->setPacker(XmlPacker::class)

View File

@ -14,7 +14,7 @@ use Yansongda\Artful\Packer\XmlPacker;
use Yansongda\Artful\Rocket;
use Yansongda\Supports\Str;
use function Yansongda\Pay\get_wechat_config;
use function Yansongda\Pay\get_provider_config;
use function Yansongda\Pay\get_wechat_type_key;
/**
@ -32,7 +32,7 @@ class ContractOrderPlugin implements PluginInterface
Logger::debug('[Wechat][V2][Papay][Direct][ContractOrderPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_wechat_config($params);
$config = get_provider_config('wechat', $params);
$payload = $rocket->getPayload();
$rocket->setPacker(XmlPacker::class)

View File

@ -12,7 +12,7 @@ use Yansongda\Artful\Exception\ServiceNotFoundException;
use Yansongda\Artful\Logger;
use Yansongda\Artful\Rocket;
use function Yansongda\Pay\get_wechat_config;
use function Yansongda\Pay\get_provider_config;
use function Yansongda\Pay\get_wechat_type_key;
/**
@ -29,7 +29,7 @@ class MiniOnlyContractPlugin implements PluginInterface
Logger::debug('[Wechat][V2][Papay][Direct][OnlyContractPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_wechat_config($params);
$config = get_provider_config('wechat', $params);
$payload = $rocket->getPayload();
$rocket->setDirection(NoHttpRequestDirection::class)

View File

@ -19,7 +19,7 @@ use Yansongda\Supports\Collection;
use Yansongda\Supports\Config;
use Yansongda\Supports\Str;
use function Yansongda\Pay\get_wechat_config;
use function Yansongda\Pay\get_provider_config;
use function Yansongda\Pay\get_wechat_sign_v2;
/**
@ -51,7 +51,7 @@ class InvokePlugin implements PluginInterface
}
$params = $rocket->getParams();
$config = get_wechat_config($params);
$config = get_provider_config('wechat', $params);
$payload = $rocket->getPayload();
$rocket->setDestination($this->getInvokeConfig($payload, $config, $prepayId));

View File

@ -19,7 +19,7 @@ use Yansongda\Supports\Collection;
use Yansongda\Supports\Config;
use Yansongda\Supports\Str;
use function Yansongda\Pay\get_wechat_config;
use function Yansongda\Pay\get_provider_config;
use function Yansongda\Pay\get_wechat_sign_v2;
/**
@ -51,7 +51,7 @@ class InvokePlugin implements PluginInterface
}
$params = $rocket->getParams();
$config = get_wechat_config($params);
$config = get_provider_config('wechat', $params);
$payload = $rocket->getPayload();
$rocket->setDestination($this->getInvokeConfig($payload, $config, $prepayId));

View File

@ -14,7 +14,7 @@ use Yansongda\Artful\Packer\XmlPacker;
use Yansongda\Artful\Rocket;
use Yansongda\Supports\Str;
use function Yansongda\Pay\get_wechat_config;
use function Yansongda\Pay\get_provider_config;
use function Yansongda\Pay\get_wechat_type_key;
/**
@ -32,7 +32,7 @@ class CancelPlugin implements PluginInterface
Logger::debug('[Wechat][V2][Pay][Pos][CancelPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_wechat_config($params);
$config = get_provider_config('wechat', $params);
$rocket->setPacker(XmlPacker::class)
->mergePayload([

View File

@ -14,7 +14,7 @@ use Yansongda\Artful\Packer\XmlPacker;
use Yansongda\Artful\Rocket;
use Yansongda\Supports\Str;
use function Yansongda\Pay\get_wechat_config;
use function Yansongda\Pay\get_provider_config;
use function Yansongda\Pay\get_wechat_type_key;
/**
@ -32,7 +32,7 @@ class PayPlugin implements PluginInterface
Logger::debug('[Wechat][V2][Pay][Pos][PayPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_wechat_config($params);
$config = get_provider_config('wechat', $params);
$rocket->setPacker(XmlPacker::class)
->mergePayload([

View File

@ -14,7 +14,7 @@ use Yansongda\Artful\Packer\XmlPacker;
use Yansongda\Artful\Rocket;
use Yansongda\Supports\Str;
use function Yansongda\Pay\get_wechat_config;
use function Yansongda\Pay\get_provider_config;
use function Yansongda\Pay\get_wechat_type_key;
/**
@ -32,7 +32,7 @@ class QueryPlugin implements PluginInterface
Logger::debug('[Wechat][V2][Pay][Pos][QueryPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_wechat_config($params);
$config = get_provider_config('wechat', $params);
$rocket->setPacker(XmlPacker::class)
->mergePayload([

View File

@ -16,7 +16,7 @@ use Yansongda\Pay\Pay;
use Yansongda\Supports\Collection;
use Yansongda\Supports\Str;
use function Yansongda\Pay\get_wechat_config;
use function Yansongda\Pay\get_provider_config;
use function Yansongda\Pay\get_wechat_type_key;
/**
@ -34,7 +34,7 @@ class SendPlugin implements PluginInterface
Logger::debug('[Wechat][V2][Pay][Redpack][SendPlugin] 插件开始装载', ['rocket' => $rocket]);
$payload = $rocket->getPayload();
$params = $rocket->getParams();
$config = get_wechat_config($params);
$config = get_provider_config('wechat', $params);
if (Pay::MODE_SERVICE === ($config['mode'] ?? Pay::MODE_NORMAL)) {
$data = $this->service($payload, $config, $params);

View File

@ -14,7 +14,7 @@ use Yansongda\Artful\Rocket;
use Yansongda\Pay\Exception\InvalidSignException;
use function Yansongda\Artful\should_do_http_request;
use function Yansongda\Pay\get_wechat_config;
use function Yansongda\Pay\get_provider_config;
use function Yansongda\Pay\verify_wechat_sign_v2;
class VerifySignaturePlugin implements PluginInterface
@ -32,7 +32,7 @@ class VerifySignaturePlugin implements PluginInterface
Logger::debug('[Wechat][V2][VerifySignaturePlugin] 插件开始装载', ['rocket' => $rocket]);
$config = get_wechat_config($rocket->getParams());
$config = get_provider_config('wechat', $rocket->getParams());
if (!should_do_http_request($rocket->getDirection())) {
return $rocket;

View File

@ -17,9 +17,9 @@ use Yansongda\Pay\Exception\Exception;
use Yansongda\Supports\Collection;
use Yansongda\Supports\Str;
use function Yansongda\Pay\get_provider_config;
use function Yansongda\Pay\get_public_cert;
use function Yansongda\Pay\get_wechat_body;
use function Yansongda\Pay\get_wechat_config;
use function Yansongda\Pay\get_wechat_method;
use function Yansongda\Pay\get_wechat_sign;
use function Yansongda\Pay\get_wechat_url;
@ -37,7 +37,7 @@ class AddPayloadSignaturePlugin implements PluginInterface
{
Logger::debug('[Wechat][V3][AddPayloadSignaturePlugin] 插件开始装载', ['rocket' => $rocket]);
$config = get_wechat_config($rocket->getParams());
$config = get_provider_config('wechat', $rocket->getParams());
$payload = $rocket->getPayload();
$timestamp = time();

View File

@ -20,7 +20,7 @@ use Yansongda\Pay\Exception\InvalidSignException;
use Yansongda\Supports\Collection;
use function Yansongda\Pay\decrypt_wechat_resource;
use function Yansongda\Pay\get_wechat_config;
use function Yansongda\Pay\get_provider_config;
use function Yansongda\Pay\verify_wechat_sign;
class CallbackPlugin implements PluginInterface
@ -48,7 +48,7 @@ class CallbackPlugin implements PluginInterface
$rocket->setDirection(NoHttpRequestDirection::class)->setPayload(new Collection($body));
$body['resource'] = decrypt_wechat_resource($body['resource'] ?? [], get_wechat_config($params));
$body['resource'] = decrypt_wechat_resource($body['resource'] ?? [], get_provider_config('wechat', $params));
$rocket->setDestination(new Collection($body));

View File

@ -13,7 +13,7 @@ use Yansongda\Artful\Logger;
use Yansongda\Artful\Rocket;
use Yansongda\Pay\Exception\Exception;
use function Yansongda\Pay\get_wechat_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://pay.weixin.qq.com/docs/merchant/apis/consumer-complaint/complaints/complete-complaint-v2.html
@ -30,7 +30,7 @@ class CompletePlugin implements PluginInterface
{
Logger::debug('[Wechat][Extend][Complaints][CompletePlugin] 插件开始装载', ['rocket' => $rocket]);
$config = get_wechat_config($rocket->getParams());
$config = get_provider_config('wechat', $rocket->getParams());
$payload = $rocket->getPayload();
$complaintId = $payload?->get('complaint_id') ?? null;

View File

@ -16,7 +16,7 @@ use Yansongda\Pay\Exception\Exception;
use Yansongda\Supports\Collection;
use function Yansongda\Pay\decrypt_wechat_contents;
use function Yansongda\Pay\get_wechat_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://pay.weixin.qq.com/docs/merchant/apis/consumer-complaint/complaints/query-complaint-v2.html
@ -56,7 +56,7 @@ class QueryDetailPlugin implements PluginInterface
$destination = $rocket->getDestination();
if ($destination instanceof Collection && !empty($payerPhone = $destination->get('payer_phone'))) {
$decryptPayerPhone = decrypt_wechat_contents($payerPhone, get_wechat_config($rocket->getParams()));
$decryptPayerPhone = decrypt_wechat_contents($payerPhone, get_provider_config('wechat', $rocket->getParams()));
if (empty($decryptPayerPhone)) {
throw new InvalidConfigException(Exception::DECRYPT_WECHAT_ENCRYPTED_CONTENTS_INVALID, '参数异常: 查询投诉单详情,参数 `payer_phone` 解密失败');

View File

@ -13,7 +13,7 @@ use Yansongda\Artful\Logger;
use Yansongda\Artful\Rocket;
use Yansongda\Pay\Exception\Exception;
use function Yansongda\Pay\get_wechat_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://pay.weixin.qq.com/docs/merchant/apis/consumer-complaint/complaints/response-complaint-v2.html
@ -30,7 +30,7 @@ class ResponsePlugin implements PluginInterface
{
Logger::debug('[Wechat][Extend][Complaints][ResponsePlugin] 插件开始装载', ['rocket' => $rocket]);
$config = get_wechat_config($rocket->getParams());
$config = get_provider_config('wechat', $rocket->getParams());
$payload = $rocket->getPayload();
$complaintId = $payload?->get('complaint_id') ?? null;

View File

@ -18,7 +18,7 @@ use Yansongda\Pay\Pay;
use Yansongda\Supports\Collection;
use function Yansongda\Pay\encrypt_wechat_contents;
use function Yansongda\Pay\get_wechat_config;
use function Yansongda\Pay\get_provider_config;
use function Yansongda\Pay\get_wechat_public_key;
use function Yansongda\Pay\get_wechat_serial_no;
use function Yansongda\Pay\get_wechat_type_key;
@ -41,11 +41,11 @@ class AddReceiverPlugin implements PluginInterface
Logger::debug('[Wechat][Extend][ProfitSharing][AddReceiverPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_wechat_config($params);
$config = get_provider_config('wechat', $params);
$payload = $rocket->getPayload();
if (is_null($payload)) {
throw new InvalidParamsException(Exception::PARAMS_NECESSARY_PARAMS_MISSING, '参数异常: 缺少分账参数');
throw new InvalidParamsException(Exception::PARAMS_NECESSARY_PARAMS_MISSING, '参数异常: 缺少添加分账接收方参数');
}
if (Pay::MODE_SERVICE === ($config['mode'] ?? Pay::MODE_NORMAL)) {

View File

@ -18,7 +18,7 @@ use Yansongda\Pay\Pay;
use Yansongda\Supports\Collection;
use function Yansongda\Pay\encrypt_wechat_contents;
use function Yansongda\Pay\get_wechat_config;
use function Yansongda\Pay\get_provider_config;
use function Yansongda\Pay\get_wechat_public_key;
use function Yansongda\Pay\get_wechat_serial_no;
use function Yansongda\Pay\get_wechat_type_key;
@ -41,11 +41,11 @@ class CreatePlugin implements PluginInterface
Logger::debug('[Wechat][Extend][ProfitSharing][CreatePlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_wechat_config($params);
$config = get_provider_config('wechat', $params);
$payload = $rocket->getPayload();
if (is_null($payload)) {
throw new InvalidParamsException(Exception::PARAMS_NECESSARY_PARAMS_MISSING, '参数异常: 缺少分账参数');
throw new InvalidParamsException(Exception::PARAMS_NECESSARY_PARAMS_MISSING, '参数异常: 缺少请求分账参数');
}
if (Pay::MODE_SERVICE === ($config['mode'] ?? Pay::MODE_NORMAL)) {

View File

@ -15,7 +15,7 @@ use Yansongda\Pay\Exception\Exception;
use Yansongda\Pay\Pay;
use Yansongda\Supports\Collection;
use function Yansongda\Pay\get_wechat_config;
use function Yansongda\Pay\get_provider_config;
use function Yansongda\Pay\get_wechat_type_key;
/**
@ -34,7 +34,7 @@ class DeleteReceiverPlugin implements PluginInterface
Logger::debug('[Wechat][Extend][ProfitSharing][DeleteReceiverPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_wechat_config($params);
$config = get_provider_config('wechat', $params);
$payload = $rocket->getPayload();
if (is_null($payload)) {

View File

@ -14,7 +14,7 @@ use Yansongda\Artful\Rocket;
use Yansongda\Pay\Exception\Exception;
use Yansongda\Pay\Pay;
use function Yansongda\Pay\get_wechat_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://pay.weixin.qq.com/docs/partner/apis/profit-sharing/merchants/query-merchant-ratio.html
@ -31,7 +31,7 @@ class QueryMerchantConfigsPlugin implements PluginInterface
Logger::debug('[Wechat][Extend][ProfitSharing][QueryMerchantConfigsPlugin] 插件开始装载', ['rocket' => $rocket]);
$payload = $rocket->getPayload();
$config = get_wechat_config($rocket->getParams());
$config = get_provider_config('wechat', $rocket->getParams());
$subMchId = $payload?->get('sub_mch_id') ?? $config['sub_mch_id'] ?? 'null';
if (Pay::MODE_NORMAL === ($config['mode'] ?? Pay::MODE_NORMAL)) {

View File

@ -13,7 +13,7 @@ use Yansongda\Artful\Logger;
use Yansongda\Artful\Rocket;
use Yansongda\Pay\Exception\Exception;
use function Yansongda\Pay\get_wechat_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://pay.weixin.qq.com/docs/merchant/apis/profit-sharing/orders/query-order.html
@ -30,7 +30,7 @@ class QueryPlugin implements PluginInterface
{
Logger::debug('[Wechat][Extend][ProfitSharing][QueryPlugin] 插件开始装载', ['rocket' => $rocket]);
$config = get_wechat_config($rocket->getParams());
$config = get_provider_config('wechat', $rocket->getParams());
$payload = $rocket->getPayload();
$outOrderNo = $payload?->get('out_order_no') ?? null;
$transactionId = $payload?->get('transaction_id') ?? null;

View File

@ -13,7 +13,7 @@ use Yansongda\Artful\Logger;
use Yansongda\Artful\Rocket;
use Yansongda\Pay\Exception\Exception;
use function Yansongda\Pay\get_wechat_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://pay.weixin.qq.com/docs/merchant/apis/profit-sharing/return-orders/query-return-order.html
@ -30,7 +30,7 @@ class QueryReturnPlugin implements PluginInterface
{
Logger::debug('[Wechat][Extend][ProfitSharing][QueryReturnPlugin] 插件开始装载', ['rocket' => $rocket]);
$config = get_wechat_config($rocket->getParams());
$config = get_provider_config('wechat', $rocket->getParams());
$payload = $rocket->getPayload();
$outOrderNo = $payload?->get('out_order_no') ?? null;
$outReturnNo = $payload?->get('out_return_no') ?? null;

View File

@ -15,7 +15,7 @@ use Yansongda\Pay\Exception\Exception;
use Yansongda\Pay\Pay;
use Yansongda\Supports\Collection;
use function Yansongda\Pay\get_wechat_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://pay.weixin.qq.com/docs/merchant/apis/profit-sharing/return-orders/create-return-order.html
@ -33,11 +33,11 @@ class ReturnPlugin implements PluginInterface
Logger::debug('[Wechat][Extend][ProfitSharing][ReturnPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_wechat_config($params);
$config = get_provider_config('wechat', $params);
$payload = $rocket->getPayload();
if (is_null($payload)) {
throw new InvalidParamsException(Exception::PARAMS_NECESSARY_PARAMS_MISSING, '参数异常: 缺少分账参数');
throw new InvalidParamsException(Exception::PARAMS_NECESSARY_PARAMS_MISSING, '参数异常: 缺少分账退回参数');
}
if (Pay::MODE_SERVICE === ($config['mode'] ?? Pay::MODE_NORMAL)) {

View File

@ -15,7 +15,7 @@ use Yansongda\Pay\Exception\Exception;
use Yansongda\Pay\Pay;
use Yansongda\Supports\Collection;
use function Yansongda\Pay\get_wechat_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://pay.weixin.qq.com/docs/merchant/apis/profit-sharing/orders/unfreeze-order.html
@ -33,11 +33,11 @@ class UnfreezePlugin implements PluginInterface
Logger::debug('[Wechat][Extend][ProfitSharing][UnfreezePlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_wechat_config($params);
$config = get_provider_config('wechat', $params);
$payload = $rocket->getPayload();
if (is_null($payload)) {
throw new InvalidParamsException(Exception::PARAMS_NECESSARY_PARAMS_MISSING, '参数异常: 缺少分账参数');
throw new InvalidParamsException(Exception::PARAMS_NECESSARY_PARAMS_MISSING, '参数异常: 缺少分账解冻剩余资金参数');
}
if (Pay::MODE_SERVICE === ($config['mode'] ?? Pay::MODE_NORMAL)) {

View File

@ -11,7 +11,7 @@ use Yansongda\Artful\Exception\ServiceNotFoundException;
use Yansongda\Artful\Logger;
use Yansongda\Artful\Rocket;
use function Yansongda\Pay\get_wechat_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://pay.weixin.qq.com/docs/merchant/apis/cash-coupons/call-back-url/query-callback.html
@ -28,7 +28,7 @@ class QueryPlugin implements PluginInterface
Logger::debug('[Wechat][Marketing][Coupon][Callback][QueryPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_wechat_config($params);
$config = get_provider_config('wechat', $params);
$mchId = $rocket->getPayload()?->get('mchid') ?? $config['mch_id'] ?? 'null';
$rocket->setPayload([

View File

@ -11,7 +11,7 @@ use Yansongda\Artful\Exception\ServiceNotFoundException;
use Yansongda\Artful\Logger;
use Yansongda\Artful\Rocket;
use function Yansongda\Pay\get_wechat_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://pay.weixin.qq.com/docs/merchant/apis/cash-coupons/call-back-url/set-callback.html
@ -28,7 +28,7 @@ class SetPlugin implements PluginInterface
Logger::debug('[Wechat][V3][Marketing][Coupon][Callback][SetPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_wechat_config($params);
$config = get_provider_config('wechat', $params);
$payload = $rocket->getPayload();
$rocket->mergePayload(array_merge(

View File

@ -13,7 +13,7 @@ use Yansongda\Artful\Logger;
use Yansongda\Artful\Rocket;
use Yansongda\Pay\Exception\Exception;
use function Yansongda\Pay\get_wechat_config;
use function Yansongda\Pay\get_provider_config;
use function Yansongda\Pay\get_wechat_type_key;
/**
@ -32,7 +32,7 @@ class DetailPlugin implements PluginInterface
Logger::debug('[Wechat][V3][Marketing][Coupon][Coupons][DetailPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_wechat_config($params);
$config = get_provider_config('wechat', $params);
$payload = $rocket->getPayload();
$openId = $payload?->get('openid') ?? null;
$couponId = $payload?->get('coupon_id') ?? null;

View File

@ -15,7 +15,7 @@ use Yansongda\Pay\Exception\Exception;
use Yansongda\Supports\Collection;
use function Yansongda\Artful\filter_params;
use function Yansongda\Pay\get_wechat_config;
use function Yansongda\Pay\get_provider_config;
use function Yansongda\Pay\get_wechat_type_key;
/**
@ -34,7 +34,7 @@ class QueryUserPlugin implements PluginInterface
Logger::debug('[Wechat][V3][Marketing][Coupon][Coupons][QueryUserPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_wechat_config($params);
$config = get_provider_config('wechat', $params);
$payload = $rocket->getPayload();
$openId = $payload?->get('openid') ?? null;

View File

@ -14,7 +14,7 @@ use Yansongda\Artful\Rocket;
use Yansongda\Pay\Exception\Exception;
use Yansongda\Supports\Collection;
use function Yansongda\Pay\get_wechat_config;
use function Yansongda\Pay\get_provider_config;
use function Yansongda\Pay\get_wechat_type_key;
/**
@ -33,7 +33,7 @@ class SendPlugin implements PluginInterface
Logger::debug('[Wechat][V3][Marketing][Coupon][Coupons][SendPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_wechat_config($params);
$config = get_provider_config('wechat', $params);
$payload = $rocket->getPayload();
$openId = $payload?->get('openid') ?? null;

View File

@ -11,7 +11,7 @@ use Yansongda\Artful\Exception\ServiceNotFoundException;
use Yansongda\Artful\Logger;
use Yansongda\Artful\Rocket;
use function Yansongda\Pay\get_wechat_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://pay.weixin.qq.com/docs/merchant/apis/cash-coupons/stock/create-coupon-stock.html
@ -28,7 +28,7 @@ class CreatePlugin implements PluginInterface
Logger::debug('[Wechat][V3][Marketing][Coupon][Stock][CreatePlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_wechat_config($params);
$config = get_provider_config('wechat', $params);
$belongMerchant = $rocket->getPayload()?->get('belong_merchant') ?? $config['mch_id'];
$rocket->mergePayload([

View File

@ -13,7 +13,7 @@ use Yansongda\Artful\Logger;
use Yansongda\Artful\Rocket;
use Yansongda\Pay\Exception\Exception;
use function Yansongda\Pay\get_wechat_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://pay.weixin.qq.com/docs/merchant/apis/cash-coupons/stock/pause-stock.html
@ -31,7 +31,7 @@ class PausePlugin implements PluginInterface
Logger::debug('[Wechat][V3][Marketing][Coupon][Stock][PausePlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_wechat_config($params);
$config = get_provider_config('wechat', $params);
$payload = $rocket->getPayload();
$stockId = $payload?->get('stock_id') ?? null;
$stockCreatorMchId = $payload?->get('stock_creator_mchid') ?? $config['mch_id'] ?? '';

View File

@ -13,7 +13,7 @@ use Yansongda\Artful\Logger;
use Yansongda\Artful\Rocket;
use Yansongda\Pay\Exception\Exception;
use function Yansongda\Pay\get_wechat_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://pay.weixin.qq.com/docs/merchant/apis/cash-coupons/stock/query-stock.html
@ -31,7 +31,7 @@ class QueryDetailPlugin implements PluginInterface
Logger::debug('[Wechat][V3][Marketing][Coupon][Stock][QueryDetailPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_wechat_config($params);
$config = get_provider_config('wechat', $params);
$payload = $rocket->getPayload();
$stockId = $payload?->get('stock_id') ?? null;
$mchId = $payload?->get('stock_creator_mchid') ?? $config['mch_id'] ?? 'null';

View File

@ -15,7 +15,7 @@ use Yansongda\Pay\Exception\Exception;
use Yansongda\Supports\Collection;
use function Yansongda\Artful\filter_params;
use function Yansongda\Pay\get_wechat_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://pay.weixin.qq.com/docs/merchant/apis/cash-coupons/stock/list-available-singleitems.html
@ -33,7 +33,7 @@ class QueryItemsPlugin implements PluginInterface
Logger::debug('[Wechat][V3][Marketing][Coupon][Stock][QueryItemsPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_wechat_config($params);
$config = get_provider_config('wechat', $params);
$payload = $rocket->getPayload();
$stockId = $payload?->get('stock_id') ?? null;

View File

@ -15,7 +15,7 @@ use Yansongda\Pay\Exception\Exception;
use Yansongda\Supports\Collection;
use function Yansongda\Artful\filter_params;
use function Yansongda\Pay\get_wechat_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://pay.weixin.qq.com/docs/merchant/apis/cash-coupons/stock/list-available-merchants.html
@ -33,7 +33,7 @@ class QueryMerchantsPlugin implements PluginInterface
Logger::debug('[Wechat][V3][Marketing][Coupon][Stock][QueryMerchantsPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_wechat_config($params);
$config = get_provider_config('wechat', $params);
$payload = $rocket->getPayload();
$stockId = $payload?->get('stock_id') ?? null;

View File

@ -15,7 +15,7 @@ use Yansongda\Pay\Exception\Exception;
use Yansongda\Supports\Collection;
use function Yansongda\Artful\filter_params;
use function Yansongda\Pay\get_wechat_config;
use function Yansongda\Pay\get_provider_config;
/**
* @see https://pay.weixin.qq.com/docs/merchant/apis/cash-coupons/stock/list-stocks.html
@ -33,7 +33,7 @@ class QueryPlugin implements PluginInterface
Logger::debug('[Wechat][V3][Marketing][Coupon][Stock][QueryPlugin] 插件开始装载', ['rocket' => $rocket]);
$params = $rocket->getParams();
$config = get_wechat_config($params);
$config = get_provider_config('wechat', $params);
$payload = $rocket->getPayload();
if (is_null($payload)) {

Some files were not shown because too many files have changed in this diff Show More