mirror of
https://gitee.com/niucloud-team/niucloud.git
synced 2025-12-13 18:12:49 +00:00
up
This commit is contained in:
parent
c19349e588
commit
0964fcfe43
96
niucloud/vendor/composer/ClassLoader.php
vendored
96
niucloud/vendor/composer/ClassLoader.php
vendored
@ -45,35 +45,34 @@ class ClassLoader
|
||||
/** @var \Closure(string):void */
|
||||
private static $includeFile;
|
||||
|
||||
/** @var ?string */
|
||||
/** @var string|null */
|
||||
private $vendorDir;
|
||||
|
||||
// PSR-4
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, array<string, int>>
|
||||
* @var array<string, array<string, int>>
|
||||
*/
|
||||
private $prefixLengthsPsr4 = array();
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, array<int, string>>
|
||||
* @var array<string, list<string>>
|
||||
*/
|
||||
private $prefixDirsPsr4 = array();
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, string>
|
||||
* @var list<string>
|
||||
*/
|
||||
private $fallbackDirsPsr4 = array();
|
||||
|
||||
// PSR-0
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, array<string, string[]>>
|
||||
* List of PSR-0 prefixes
|
||||
*
|
||||
* Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2')))
|
||||
*
|
||||
* @var array<string, array<string, list<string>>>
|
||||
*/
|
||||
private $prefixesPsr0 = array();
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, string>
|
||||
* @var list<string>
|
||||
*/
|
||||
private $fallbackDirsPsr0 = array();
|
||||
|
||||
@ -81,8 +80,7 @@ class ClassLoader
|
||||
private $useIncludePath = false;
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
* @psalm-var array<string, string>
|
||||
* @var array<string, string>
|
||||
*/
|
||||
private $classMap = array();
|
||||
|
||||
@ -90,21 +88,20 @@ class ClassLoader
|
||||
private $classMapAuthoritative = false;
|
||||
|
||||
/**
|
||||
* @var bool[]
|
||||
* @psalm-var array<string, bool>
|
||||
* @var array<string, bool>
|
||||
*/
|
||||
private $missingClasses = array();
|
||||
|
||||
/** @var ?string */
|
||||
/** @var string|null */
|
||||
private $apcuPrefix;
|
||||
|
||||
/**
|
||||
* @var self[]
|
||||
* @var array<string, self>
|
||||
*/
|
||||
private static $registeredLoaders = array();
|
||||
|
||||
/**
|
||||
* @param ?string $vendorDir
|
||||
* @param string|null $vendorDir
|
||||
*/
|
||||
public function __construct($vendorDir = null)
|
||||
{
|
||||
@ -113,7 +110,7 @@ class ClassLoader
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
* @return array<string, list<string>>
|
||||
*/
|
||||
public function getPrefixes()
|
||||
{
|
||||
@ -125,8 +122,7 @@ class ClassLoader
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
* @psalm-return array<string, array<int, string>>
|
||||
* @return array<string, list<string>>
|
||||
*/
|
||||
public function getPrefixesPsr4()
|
||||
{
|
||||
@ -134,8 +130,7 @@ class ClassLoader
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
* @psalm-return array<string, string>
|
||||
* @return list<string>
|
||||
*/
|
||||
public function getFallbackDirs()
|
||||
{
|
||||
@ -143,8 +138,7 @@ class ClassLoader
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
* @psalm-return array<string, string>
|
||||
* @return list<string>
|
||||
*/
|
||||
public function getFallbackDirsPsr4()
|
||||
{
|
||||
@ -152,8 +146,7 @@ class ClassLoader
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[] Array of classname => path
|
||||
* @psalm-return array<string, string>
|
||||
* @return array<string, string> Array of classname => path
|
||||
*/
|
||||
public function getClassMap()
|
||||
{
|
||||
@ -161,8 +154,7 @@ class ClassLoader
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $classMap Class to filename map
|
||||
* @psalm-param array<string, string> $classMap
|
||||
* @param array<string, string> $classMap Class to filename map
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@ -179,24 +171,25 @@ class ClassLoader
|
||||
* Registers a set of PSR-0 directories for a given prefix, either
|
||||
* appending or prepending to the ones previously set for this prefix.
|
||||
*
|
||||
* @param string $prefix The prefix
|
||||
* @param string[]|string $paths The PSR-0 root directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
* @param string $prefix The prefix
|
||||
* @param list<string>|string $paths The PSR-0 root directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function add($prefix, $paths, $prepend = false)
|
||||
{
|
||||
$paths = (array) $paths;
|
||||
if (!$prefix) {
|
||||
if ($prepend) {
|
||||
$this->fallbackDirsPsr0 = array_merge(
|
||||
(array) $paths,
|
||||
$paths,
|
||||
$this->fallbackDirsPsr0
|
||||
);
|
||||
} else {
|
||||
$this->fallbackDirsPsr0 = array_merge(
|
||||
$this->fallbackDirsPsr0,
|
||||
(array) $paths
|
||||
$paths
|
||||
);
|
||||
}
|
||||
|
||||
@ -205,19 +198,19 @@ class ClassLoader
|
||||
|
||||
$first = $prefix[0];
|
||||
if (!isset($this->prefixesPsr0[$first][$prefix])) {
|
||||
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
|
||||
$this->prefixesPsr0[$first][$prefix] = $paths;
|
||||
|
||||
return;
|
||||
}
|
||||
if ($prepend) {
|
||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||
(array) $paths,
|
||||
$paths,
|
||||
$this->prefixesPsr0[$first][$prefix]
|
||||
);
|
||||
} else {
|
||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||
$this->prefixesPsr0[$first][$prefix],
|
||||
(array) $paths
|
||||
$paths
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -226,9 +219,9 @@ class ClassLoader
|
||||
* Registers a set of PSR-4 directories for a given namespace, either
|
||||
* appending or prepending to the ones previously set for this namespace.
|
||||
*
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param string[]|string $paths The PSR-4 base directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param list<string>|string $paths The PSR-4 base directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
@ -236,17 +229,18 @@ class ClassLoader
|
||||
*/
|
||||
public function addPsr4($prefix, $paths, $prepend = false)
|
||||
{
|
||||
$paths = (array) $paths;
|
||||
if (!$prefix) {
|
||||
// Register directories for the root namespace.
|
||||
if ($prepend) {
|
||||
$this->fallbackDirsPsr4 = array_merge(
|
||||
(array) $paths,
|
||||
$paths,
|
||||
$this->fallbackDirsPsr4
|
||||
);
|
||||
} else {
|
||||
$this->fallbackDirsPsr4 = array_merge(
|
||||
$this->fallbackDirsPsr4,
|
||||
(array) $paths
|
||||
$paths
|
||||
);
|
||||
}
|
||||
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
||||
@ -256,18 +250,18 @@ class ClassLoader
|
||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||
}
|
||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
||||
$this->prefixDirsPsr4[$prefix] = $paths;
|
||||
} elseif ($prepend) {
|
||||
// Prepend directories for an already registered namespace.
|
||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||
(array) $paths,
|
||||
$paths,
|
||||
$this->prefixDirsPsr4[$prefix]
|
||||
);
|
||||
} else {
|
||||
// Append directories for an already registered namespace.
|
||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||
$this->prefixDirsPsr4[$prefix],
|
||||
(array) $paths
|
||||
$paths
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -276,8 +270,8 @@ class ClassLoader
|
||||
* Registers a set of PSR-0 directories for a given prefix,
|
||||
* replacing any others previously set for this prefix.
|
||||
*
|
||||
* @param string $prefix The prefix
|
||||
* @param string[]|string $paths The PSR-0 base directories
|
||||
* @param string $prefix The prefix
|
||||
* @param list<string>|string $paths The PSR-0 base directories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@ -294,8 +288,8 @@ class ClassLoader
|
||||
* Registers a set of PSR-4 directories for a given namespace,
|
||||
* replacing any others previously set for this namespace.
|
||||
*
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param string[]|string $paths The PSR-4 base directories
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param list<string>|string $paths The PSR-4 base directories
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
@ -481,9 +475,9 @@ class ClassLoader
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the currently registered loaders indexed by their corresponding vendor directories.
|
||||
* Returns the currently registered loaders keyed by their corresponding vendor directories.
|
||||
*
|
||||
* @return self[]
|
||||
* @return array<string, self>
|
||||
*/
|
||||
public static function getRegisteredLoaders()
|
||||
{
|
||||
|
||||
27
niucloud/vendor/composer/InstalledVersions.php
vendored
27
niucloud/vendor/composer/InstalledVersions.php
vendored
@ -32,6 +32,11 @@ class InstalledVersions
|
||||
*/
|
||||
private static $installed;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private static $installedIsLocalDir;
|
||||
|
||||
/**
|
||||
* @var bool|null
|
||||
*/
|
||||
@ -309,6 +314,12 @@ class InstalledVersions
|
||||
{
|
||||
self::$installed = $data;
|
||||
self::$installedByVendor = array();
|
||||
|
||||
// when using reload, we disable the duplicate protection to ensure that self::$installed data is
|
||||
// always returned, but we cannot know whether it comes from the installed.php in __DIR__ or not,
|
||||
// so we have to assume it does not, and that may result in duplicate data being returned when listing
|
||||
// all installed packages for example
|
||||
self::$installedIsLocalDir = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -322,19 +333,27 @@ class InstalledVersions
|
||||
}
|
||||
|
||||
$installed = array();
|
||||
$copiedLocalDir = false;
|
||||
|
||||
if (self::$canGetVendors) {
|
||||
$selfDir = strtr(__DIR__, '\\', '/');
|
||||
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
|
||||
$vendorDir = strtr($vendorDir, '\\', '/');
|
||||
if (isset(self::$installedByVendor[$vendorDir])) {
|
||||
$installed[] = self::$installedByVendor[$vendorDir];
|
||||
} elseif (is_file($vendorDir.'/composer/installed.php')) {
|
||||
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
|
||||
$required = require $vendorDir.'/composer/installed.php';
|
||||
$installed[] = self::$installedByVendor[$vendorDir] = $required;
|
||||
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
|
||||
self::$installed = $installed[count($installed) - 1];
|
||||
self::$installedByVendor[$vendorDir] = $required;
|
||||
$installed[] = $required;
|
||||
if (self::$installed === null && $vendorDir.'/composer' === $selfDir) {
|
||||
self::$installed = $required;
|
||||
self::$installedIsLocalDir = true;
|
||||
}
|
||||
}
|
||||
if (self::$installedIsLocalDir && $vendorDir.'/composer' === $selfDir) {
|
||||
$copiedLocalDir = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -350,7 +369,7 @@ class InstalledVersions
|
||||
}
|
||||
}
|
||||
|
||||
if (self::$installed !== array()) {
|
||||
if (self::$installed !== array() && !$copiedLocalDir) {
|
||||
$installed[] = self::$installed;
|
||||
}
|
||||
|
||||
|
||||
4
niucloud/vendor/composer/autoload_psr4.php
vendored
4
niucloud/vendor/composer/autoload_psr4.php
vendored
@ -10,7 +10,7 @@ return array(
|
||||
'think\\trace\\' => array($vendorDir . '/topthink/think-trace/src'),
|
||||
'think\\captcha\\' => array($vendorDir . '/topthink/think-captcha/src'),
|
||||
'think\\app\\' => array($vendorDir . '/topthink/think-multi-app/src'),
|
||||
'think\\' => array($vendorDir . '/topthink/framework/src/think', $vendorDir . '/topthink/think-filesystem/src', $vendorDir . '/topthink/think-helper/src', $vendorDir . '/topthink/think-image/src', $vendorDir . '/topthink/think-orm/src', $vendorDir . '/topthink/think-template/src'),
|
||||
'think\\' => array($vendorDir . '/topthink/think-image/src', $vendorDir . '/topthink/think-filesystem/src', $vendorDir . '/topthink/think-template/src', $vendorDir . '/topthink/framework/src/think', $vendorDir . '/topthink/think-orm/src', $vendorDir . '/topthink/think-helper/src'),
|
||||
'dh2y\\qrcode\\' => array($vendorDir . '/dh2y/think-qrcode/src'),
|
||||
'core\\' => array($baseDir . '/core'),
|
||||
'clagiordano\\weblibs\\configmanager\\' => array($vendorDir . '/clagiordano/weblibs-configmanager/src'),
|
||||
@ -26,7 +26,7 @@ return array(
|
||||
'Workerman\\Crontab\\' => array($vendorDir . '/workerman/crontab/src'),
|
||||
'Workerman\\' => array($vendorDir . '/workerman/workerman'),
|
||||
'Webmozart\\Assert\\' => array($vendorDir . '/webmozart/assert/src'),
|
||||
'TencentCloud\\' => array($vendorDir . '/tencentcloud/common/src/TencentCloud', $vendorDir . '/tencentcloud/sms/src/TencentCloud'),
|
||||
'TencentCloud\\' => array($vendorDir . '/tencentcloud/sms/src/TencentCloud', $vendorDir . '/tencentcloud/common/src/TencentCloud'),
|
||||
'Symfony\\Polyfill\\Php81\\' => array($vendorDir . '/symfony/polyfill-php81'),
|
||||
'Symfony\\Polyfill\\Php80\\' => array($vendorDir . '/symfony/polyfill-php80'),
|
||||
'Symfony\\Polyfill\\Php72\\' => array($vendorDir . '/symfony/polyfill-php72'),
|
||||
|
||||
12
niucloud/vendor/composer/autoload_static.php
vendored
12
niucloud/vendor/composer/autoload_static.php
vendored
@ -223,12 +223,12 @@ class ComposerStaticInitf082efa3600aae2b847c3e8b4e641a4e
|
||||
),
|
||||
'think\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/topthink/framework/src/think',
|
||||
0 => __DIR__ . '/..' . '/topthink/think-image/src',
|
||||
1 => __DIR__ . '/..' . '/topthink/think-filesystem/src',
|
||||
2 => __DIR__ . '/..' . '/topthink/think-helper/src',
|
||||
3 => __DIR__ . '/..' . '/topthink/think-image/src',
|
||||
2 => __DIR__ . '/..' . '/topthink/think-template/src',
|
||||
3 => __DIR__ . '/..' . '/topthink/framework/src/think',
|
||||
4 => __DIR__ . '/..' . '/topthink/think-orm/src',
|
||||
5 => __DIR__ . '/..' . '/topthink/think-template/src',
|
||||
5 => __DIR__ . '/..' . '/topthink/think-helper/src',
|
||||
),
|
||||
'dh2y\\qrcode\\' =>
|
||||
array (
|
||||
@ -292,8 +292,8 @@ class ComposerStaticInitf082efa3600aae2b847c3e8b4e641a4e
|
||||
),
|
||||
'TencentCloud\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/tencentcloud/common/src/TencentCloud',
|
||||
1 => __DIR__ . '/..' . '/tencentcloud/sms/src/TencentCloud',
|
||||
0 => __DIR__ . '/..' . '/tencentcloud/sms/src/TencentCloud',
|
||||
1 => __DIR__ . '/..' . '/tencentcloud/common/src/TencentCloud',
|
||||
),
|
||||
'Symfony\\Polyfill\\Php81\\' =>
|
||||
array (
|
||||
|
||||
45
niucloud/vendor/composer/installed.json
vendored
45
niucloud/vendor/composer/installed.json
vendored
@ -6868,17 +6868,17 @@
|
||||
},
|
||||
{
|
||||
"name": "yansongda/artful",
|
||||
"version": "v1.0.9",
|
||||
"version_normalized": "1.0.9.0",
|
||||
"version": "v1.1.2",
|
||||
"version_normalized": "1.1.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/yansongda/artful.git",
|
||||
"reference": "1fbf987c0deb95a9b67eb343f2b96c8489635e6f"
|
||||
"reference": "bad726c6287aca219750823bff46f70287ec3995"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/yansongda/artful/zipball/1fbf987c0deb95a9b67eb343f2b96c8489635e6f",
|
||||
"reference": "1fbf987c0deb95a9b67eb343f2b96c8489635e6f",
|
||||
"url": "https://api.github.com/repos/yansongda/artful/zipball/bad726c6287aca219750823bff46f70287ec3995",
|
||||
"reference": "bad726c6287aca219750823bff46f70287ec3995",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
@ -6895,7 +6895,7 @@
|
||||
"psr/http-client": "^1.0",
|
||||
"psr/http-message": "^1.1 || ^2.0",
|
||||
"psr/log": "^1.1 || ^2.0 || ^3.0",
|
||||
"yansongda/supports": "~4.0.9"
|
||||
"yansongda/supports": "~4.0.10"
|
||||
},
|
||||
"require-dev": {
|
||||
"friendsofphp/php-cs-fixer": "^3.44",
|
||||
@ -6903,7 +6903,7 @@
|
||||
"hyperf/pimple": "^2.2",
|
||||
"mockery/mockery": "^1.4",
|
||||
"monolog/monolog": "^2.2",
|
||||
"phpstan/phpstan": "^1.0.0",
|
||||
"phpstan/phpstan": "^1.0.0 || ^2.0.0",
|
||||
"phpunit/phpunit": "^9.0",
|
||||
"symfony/event-dispatcher": "^5.2.0",
|
||||
"symfony/http-foundation": "^5.2.0",
|
||||
@ -6914,7 +6914,7 @@
|
||||
"hyperf/pimple": "其它/无框架下使用 SDK,请安装,任选其一",
|
||||
"illuminate/container": "其它/无框架下使用 SDK,请安装,任选其一"
|
||||
},
|
||||
"time": "2024-02-06T13:19:54+00:00",
|
||||
"time": "2025-01-09T12:39:39+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
@ -6951,17 +6951,17 @@
|
||||
},
|
||||
{
|
||||
"name": "yansongda/pay",
|
||||
"version": "v3.6.3",
|
||||
"version_normalized": "3.6.3.0",
|
||||
"version": "v3.7.11",
|
||||
"version_normalized": "3.7.11.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/yansongda/pay.git",
|
||||
"reference": "fba0bb30636cb936eed9e9078d781e0dc4e4282b"
|
||||
"reference": "0c8bcb8f67b56fae6c852a5b3ec0a1793f5c8ddb"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/yansongda/pay/zipball/fba0bb30636cb936eed9e9078d781e0dc4e4282b",
|
||||
"reference": "fba0bb30636cb936eed9e9078d781e0dc4e4282b",
|
||||
"url": "https://api.github.com/repos/yansongda/pay/zipball/0c8bcb8f67b56fae6c852a5b3ec0a1793f5c8ddb",
|
||||
"reference": "0c8bcb8f67b56fae6c852a5b3ec0a1793f5c8ddb",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
@ -6977,8 +6977,8 @@
|
||||
"ext-openssl": "*",
|
||||
"ext-simplexml": "*",
|
||||
"php": ">=8.0",
|
||||
"yansongda/artful": "~1.0.9",
|
||||
"yansongda/supports": "~4.0.9"
|
||||
"yansongda/artful": "~1.1.1",
|
||||
"yansongda/supports": "~4.0.10"
|
||||
},
|
||||
"conflict": {
|
||||
"hyperf/framework": "<3.0"
|
||||
@ -6987,6 +6987,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",
|
||||
@ -6996,7 +6997,7 @@
|
||||
"symfony/psr-http-message-bridge": "^2.1",
|
||||
"symfony/var-dumper": "^5.1"
|
||||
},
|
||||
"time": "2024-02-29T12:19:11+00:00",
|
||||
"time": "2024-11-23T03:29:59+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
@ -7032,17 +7033,17 @@
|
||||
},
|
||||
{
|
||||
"name": "yansongda/supports",
|
||||
"version": "v4.0.9",
|
||||
"version_normalized": "4.0.9.0",
|
||||
"version": "v4.0.10",
|
||||
"version_normalized": "4.0.10.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/yansongda/supports.git",
|
||||
"reference": "c3479723be665360a5635c15f184a1d0a8dc995a"
|
||||
"reference": "11cc73776e6d4d763a84c8c733f64820abdc44e5"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/yansongda/supports/zipball/c3479723be665360a5635c15f184a1d0a8dc995a",
|
||||
"reference": "c3479723be665360a5635c15f184a1d0a8dc995a",
|
||||
"url": "https://api.github.com/repos/yansongda/supports/zipball/11cc73776e6d4d763a84c8c733f64820abdc44e5",
|
||||
"reference": "11cc73776e6d4d763a84c8c733f64820abdc44e5",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
@ -7064,7 +7065,7 @@
|
||||
"monolog/monolog": "Use logger",
|
||||
"symfony/console": "Use stdout logger"
|
||||
},
|
||||
"time": "2024-01-06T05:14:33+00:00",
|
||||
"time": "2024-06-09T15:49:21+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
|
||||
22
niucloud/vendor/composer/installed.php
vendored
22
niucloud/vendor/composer/installed.php
vendored
@ -3,7 +3,7 @@
|
||||
'name' => 'topthink/think',
|
||||
'pretty_version' => 'dev-master',
|
||||
'version' => 'dev-master',
|
||||
'reference' => 'ce5a9834a9b2c9f70dbc00270fad24bd80a0c025',
|
||||
'reference' => 'ab5c2b41d3c3d721eb012dcfb43b3418b064bd7c',
|
||||
'type' => 'project',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
@ -792,7 +792,7 @@
|
||||
'topthink/think' => array(
|
||||
'pretty_version' => 'dev-master',
|
||||
'version' => 'dev-master',
|
||||
'reference' => 'ce5a9834a9b2c9f70dbc00270fad24bd80a0c025',
|
||||
'reference' => 'ab5c2b41d3c3d721eb012dcfb43b3418b064bd7c',
|
||||
'type' => 'project',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
@ -934,27 +934,27 @@
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'yansongda/artful' => array(
|
||||
'pretty_version' => 'v1.0.9',
|
||||
'version' => '1.0.9.0',
|
||||
'reference' => '1fbf987c0deb95a9b67eb343f2b96c8489635e6f',
|
||||
'pretty_version' => 'v1.1.2',
|
||||
'version' => '1.1.2.0',
|
||||
'reference' => 'bad726c6287aca219750823bff46f70287ec3995',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../yansongda/artful',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'yansongda/pay' => array(
|
||||
'pretty_version' => 'v3.6.3',
|
||||
'version' => '3.6.3.0',
|
||||
'reference' => 'fba0bb30636cb936eed9e9078d781e0dc4e4282b',
|
||||
'pretty_version' => 'v3.7.11',
|
||||
'version' => '3.7.11.0',
|
||||
'reference' => '0c8bcb8f67b56fae6c852a5b3ec0a1793f5c8ddb',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../yansongda/pay',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'yansongda/supports' => array(
|
||||
'pretty_version' => 'v4.0.9',
|
||||
'version' => '4.0.9.0',
|
||||
'reference' => 'c3479723be665360a5635c15f184a1d0a8dc995a',
|
||||
'pretty_version' => 'v4.0.10',
|
||||
'version' => '4.0.10.0',
|
||||
'reference' => '11cc73776e6d4d763a84c8c733f64820abdc44e5',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../yansongda/supports',
|
||||
'aliases' => array(),
|
||||
|
||||
@ -115,7 +115,7 @@ if (!defined('QRCODEDEFS')) {
|
||||
/**
|
||||
* Encoding mode alphanumeric (0-9A-Z $%*+-./:) 45characters. 2 characters are encoded to 11bit length. In theory, 4296 characters or less can be stored in a QRcode.
|
||||
*/
|
||||
if (!defined('QR_MODE_AN'))
|
||||
if (!defined('QR_MODE_AN')) {
|
||||
define('QR_MODE_AN', 1);
|
||||
}
|
||||
|
||||
|
||||
2
niucloud/vendor/services.php
vendored
2
niucloud/vendor/services.php
vendored
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
// This file is automatically generated at:2024-07-05 17:18:51
|
||||
// This file is automatically generated at:2025-03-04 12:00:06
|
||||
declare (strict_types = 1);
|
||||
return array (
|
||||
0 => 'think\\captcha\\CaptchaService',
|
||||
|
||||
12
niucloud/vendor/yansongda/artful/CHANGELOG.md
vendored
12
niucloud/vendor/yansongda/artful/CHANGELOG.md
vendored
@ -1,3 +1,15 @@
|
||||
## v1.1.1
|
||||
|
||||
### chore
|
||||
|
||||
- chore: 升级 `yansongda/supports` 版本以解决潜在的问题(#19)
|
||||
|
||||
## v1.1.0
|
||||
|
||||
### changed
|
||||
|
||||
- change: http 配置项由 `httpFactory` 修改为 `http`(#17)
|
||||
|
||||
## v1.0.9
|
||||
|
||||
### fixed
|
||||
|
||||
2
niucloud/vendor/yansongda/artful/README.md
vendored
2
niucloud/vendor/yansongda/artful/README.md
vendored
@ -17,7 +17,7 @@ Api RequesT Framework U Like - 你喜欢的 API 请求框架
|
||||
## 安装
|
||||
|
||||
```shell
|
||||
composer require yansongda/artful:~1.0.0 -vvv
|
||||
composer require yansongda/artful:~1.1.0 -vvv
|
||||
```
|
||||
|
||||
## 文档
|
||||
|
||||
@ -22,14 +22,14 @@
|
||||
"psr/container": "^1.1 || ^2.0",
|
||||
"psr/http-client": "^1.0",
|
||||
"psr/http-message": "^1.1 || ^2.0",
|
||||
"yansongda/supports": "~4.0.9",
|
||||
"yansongda/supports": "~4.0.10",
|
||||
"guzzlehttp/psr7": "^2.6"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^9.0",
|
||||
"mockery/mockery": "^1.4",
|
||||
"friendsofphp/php-cs-fixer": "^3.44",
|
||||
"phpstan/phpstan": "^1.0.0",
|
||||
"phpstan/phpstan": "^1.0.0 || ^2.0.0",
|
||||
"monolog/monolog": "^2.2",
|
||||
"symfony/var-dumper": "^5.1",
|
||||
"symfony/http-foundation": "^5.2.0",
|
||||
|
||||
@ -52,7 +52,7 @@ class Artful
|
||||
/**
|
||||
* @throws ContainerException
|
||||
*/
|
||||
private function __construct(array $config, Closure|ContainerInterface $container = null)
|
||||
private function __construct(array $config, null|Closure|ContainerInterface $container = null)
|
||||
{
|
||||
$this->registerServices($config, $container);
|
||||
|
||||
@ -78,7 +78,7 @@ class Artful
|
||||
/**
|
||||
* @throws ContainerException
|
||||
*/
|
||||
public static function config(array $config = [], Closure|ContainerInterface $container = null): bool
|
||||
public static function config(array $config = [], null|Closure|ContainerInterface $container = null): bool
|
||||
{
|
||||
if (self::hasContainer() && !($config['_force'] ?? false)) {
|
||||
return false;
|
||||
@ -288,7 +288,7 @@ class Artful
|
||||
|
||||
Logger::info('[Artful] 准备请求第三方 API', $rocket->toArray());
|
||||
|
||||
$http = $httpFactory->create(array_merge($config->get('httpFactory', []), $rocket->getPayload()?->get('_http') ?? []));
|
||||
$http = $httpFactory->create(array_merge($config->get('http', []), $rocket->getPayload()?->get('_http') ?? []));
|
||||
|
||||
Event::dispatch(new Event\HttpStart($rocket));
|
||||
|
||||
@ -333,7 +333,7 @@ class Artful
|
||||
/**
|
||||
* @throws ContainerException
|
||||
*/
|
||||
private function registerServices(array $config, Closure|ContainerInterface $container = null): void
|
||||
private function registerServices(array $config, null|Closure|ContainerInterface $container = null): void
|
||||
{
|
||||
foreach ($this->coreService as $service) {
|
||||
self::registerService($service, ContainerServiceProvider::class == $service ? $container : $config);
|
||||
|
||||
@ -86,3 +86,8 @@ function get_radar_body(?Collection $payload): mixed
|
||||
{
|
||||
return $payload?->get('_body') ?? null;
|
||||
}
|
||||
|
||||
function get_radar_headers(?Collection $payload): mixed
|
||||
{
|
||||
return $payload?->get('_headers') ?? null;
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@ use Yansongda\Artful\Logger;
|
||||
use Yansongda\Artful\Rocket;
|
||||
|
||||
use function Yansongda\Artful\get_radar_body;
|
||||
use function Yansongda\Artful\get_radar_headers;
|
||||
use function Yansongda\Artful\get_radar_method;
|
||||
use function Yansongda\Artful\get_radar_url;
|
||||
|
||||
@ -25,7 +26,7 @@ class AddRadarPlugin implements PluginInterface
|
||||
$rocket->setRadar(new Request(
|
||||
get_radar_method($payload) ?? 'POST',
|
||||
get_radar_url($payload),
|
||||
$this->getHeaders(),
|
||||
get_radar_headers($payload) ?? $this->getHeaders(),
|
||||
get_radar_body($payload),
|
||||
));
|
||||
|
||||
|
||||
113
niucloud/vendor/yansongda/pay/CHANGELOG.md
vendored
113
niucloud/vendor/yansongda/pay/CHANGELOG.md
vendored
@ -1,3 +1,116 @@
|
||||
## v3.7.13
|
||||
|
||||
### added
|
||||
|
||||
- feat: 新增支付宝APP同步回调验签 (#1061, #1064)
|
||||
|
||||
## v3.7.12
|
||||
|
||||
### added
|
||||
|
||||
- feat: 支持最新版微信商户转账 (#1058)
|
||||
|
||||
## v3.7.11
|
||||
|
||||
### added
|
||||
|
||||
- feat: 新增微信分账申请分账账单插件 (#1041)
|
||||
|
||||
## v3.7.10
|
||||
|
||||
### fixed
|
||||
|
||||
- fix: 未配置微信证书时,自动获取证书后仍然使用之前的微信配置(#1026)
|
||||
|
||||
## v3.7.9
|
||||
|
||||
### added
|
||||
|
||||
- feat: 新增抖音支付(#1014)
|
||||
|
||||
## v3.7.8
|
||||
|
||||
### added
|
||||
|
||||
- feat: 新增 v3 付款码服务商模式(#1010)
|
||||
|
||||
## v3.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
|
||||
|
||||
- optimize: 使用 is_file 代替字符串结尾判断(#982)
|
||||
|
||||
## v3.7.3
|
||||
|
||||
### fixed
|
||||
|
||||
- fix: 修复商家转账参数缺失的问题(#977)
|
||||
|
||||
## v3.7.2
|
||||
|
||||
### added
|
||||
|
||||
- feat: 微信V2版本支持普通红包(#973)
|
||||
|
||||
### chore
|
||||
|
||||
- chore: 升级 `yansongda/artful` 到最新版解决 http 配置不生效的问题(#974)
|
||||
|
||||
## v3.7.1
|
||||
|
||||
### fixed
|
||||
|
||||
- fix: 修复微信付款码 shortcut 支付插件执行顺序错误(#972)
|
||||
|
||||
## v3.7.0
|
||||
|
||||
### added
|
||||
|
||||
- feat: 支持微信 v3 版付款码支付(#969)
|
||||
|
||||
### changed
|
||||
|
||||
- changed: 微信付款码支付更改为 v3 版(#969)
|
||||
|
||||
## v3.6.5
|
||||
|
||||
### added
|
||||
|
||||
- feat: 支付宝根证书配置支持直接配置内容(#959)
|
||||
|
||||
## v3.6.4
|
||||
|
||||
### fixed
|
||||
|
||||
- fix: 修复支付宝授权访问令牌插件参数问题(#954)
|
||||
|
||||
## v3.6.3
|
||||
|
||||
### optimized
|
||||
|
||||
204
niucloud/vendor/yansongda/pay/README.md
vendored
204
niucloud/vendor/yansongda/pay/README.md
vendored
@ -77,6 +77,11 @@ yansongda/pay 100% 兼容 支付宝/微信/银联 所有功能(包括服务商
|
||||
- 刷卡支付
|
||||
- ...
|
||||
|
||||
### 抖音
|
||||
|
||||
- 小程序支付
|
||||
- ...
|
||||
|
||||
### 银联
|
||||
|
||||
- 手机网站支付
|
||||
@ -84,10 +89,15 @@ yansongda/pay 100% 兼容 支付宝/微信/银联 所有功能(包括服务商
|
||||
- 刷卡支付
|
||||
- 扫码支付
|
||||
- ...
|
||||
-
|
||||
### 江苏银行(e融支付)
|
||||
|
||||
- 聚合扫码支付(微信,支付宝,银联,e融)
|
||||
- ...
|
||||
|
||||
## 安装
|
||||
```shell
|
||||
composer require yansongda/pay:~3.6.0 -vvv
|
||||
composer require yansongda/pay:~3.7.0 -vvv
|
||||
```
|
||||
|
||||
## 深情一撇
|
||||
@ -141,7 +151,9 @@ class AlipayController
|
||||
|
||||
public function web()
|
||||
{
|
||||
$result = Pay::alipay($this->config)->web([
|
||||
Pay::config($this->config);
|
||||
|
||||
$result = Pay::alipay()->web([
|
||||
'out_trade_no' => ''.time(),
|
||||
'total_amount' => '0.01',
|
||||
'subject' => 'yansongda 测试 - 1',
|
||||
@ -152,7 +164,9 @@ class AlipayController
|
||||
|
||||
public function returnCallback()
|
||||
{
|
||||
$data = Pay::alipay($this->config)->callback(); // 是的,验签就这么简单!
|
||||
Pay::config($this->config);
|
||||
|
||||
$data = Pay::alipay()->callback(); // 是的,验签就这么简单!
|
||||
|
||||
// 订单号:$data->out_trade_no
|
||||
// 支付宝交易号:$data->trade_no
|
||||
@ -161,10 +175,10 @@ class AlipayController
|
||||
|
||||
public function notifyCallback()
|
||||
{
|
||||
$alipay = Pay::alipay($this->config);
|
||||
|
||||
Pay::config($this->config);
|
||||
|
||||
try{
|
||||
$data = $alipay->callback(); // 是的,验签就这么简单!
|
||||
$data = Pay::alipay()->callback(); // 是的,验签就这么简单!
|
||||
|
||||
// 请自行对 trade_status 进行判断及其它逻辑进行判断,在支付宝的业务通知中,只有交易通知状态为 TRADE_SUCCESS 或 TRADE_FINISHED 时,支付宝才会认定为买家付款成功。
|
||||
// 1、商户需要验证该通知数据中的out_trade_no是否为商户系统中创建的订单号;
|
||||
@ -172,11 +186,11 @@ class AlipayController
|
||||
// 3、校验通知中的seller_id(或者seller_email) 是否为out_trade_no这笔单据的对应的操作方(有的时候,一个商户可能有多个seller_id/seller_email);
|
||||
// 4、验证app_id是否为该商户本身。
|
||||
// 5、其它业务逻辑情况
|
||||
} catch (\Exception $e) {
|
||||
// $e->getMessage();
|
||||
} catch (\Throwable $e) {
|
||||
dd($e);
|
||||
}
|
||||
|
||||
return $alipay->success();
|
||||
return Pay::alipay()->success();
|
||||
}
|
||||
}
|
||||
```
|
||||
@ -244,6 +258,8 @@ class WechatController
|
||||
|
||||
public function index()
|
||||
{
|
||||
Pay::config($this->config);
|
||||
|
||||
$order = [
|
||||
'out_trade_no' => time().'',
|
||||
'description' => 'subject-测试',
|
||||
@ -255,7 +271,7 @@ class WechatController
|
||||
],
|
||||
];
|
||||
|
||||
$pay = Pay::wechat($this->config)->mp($order);
|
||||
$pay = Pay::wechat()->mp($order);
|
||||
|
||||
// $pay->appId
|
||||
// $pay->timeStamp
|
||||
@ -264,24 +280,176 @@ class WechatController
|
||||
// $pay->signType
|
||||
}
|
||||
|
||||
public function notifyCallback()
|
||||
public function callback()
|
||||
{
|
||||
$pay = Pay::wechat($this->config);
|
||||
|
||||
Pay::config($this->config);
|
||||
|
||||
try{
|
||||
$data = $pay->callback(); // 是的,验签就这么简单!
|
||||
} catch (\Exception $e) {
|
||||
// $e->getMessage();
|
||||
$data = Pay::wechat()->callback(); // 是的,验签就这么简单!
|
||||
} catch (\Throwable $e) {
|
||||
dd($e);
|
||||
}
|
||||
|
||||
return $pay->success();
|
||||
return Pay::wechat()->success();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 抖音
|
||||
```php
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Yansongda\Pay\Pay;
|
||||
|
||||
class DouyinController
|
||||
{
|
||||
protected $config = [
|
||||
'douyin' => [
|
||||
'default' => [
|
||||
// 选填-商户号
|
||||
// 抖音开放平台 --> 应用详情 --> 支付信息 --> 产品管理 --> 商户号
|
||||
'mch_id' => '73744242495132490630',
|
||||
// 必填-支付 Token,用于支付回调签名
|
||||
// 抖音开放平台 --> 应用详情 --> 支付信息 --> 支付设置 --> Token(令牌)
|
||||
'mch_secret_token' => 'douyin_mini_token',
|
||||
// 必填-支付 SALT,用于支付签名
|
||||
// 抖音开放平台 --> 应用详情 --> 支付信息 --> 支付设置 --> SALT
|
||||
'mch_secret_salt' => 'oDxWDBr4U7FAAQ8hnGDm29i4A6pbTMDKme4WLLvA',
|
||||
// 必填-小程序 app_id
|
||||
// 抖音开放平台 --> 应用详情 --> 支付信息 --> 支付设置 --> 小程序appid
|
||||
'mini_app_id' => 'tt226e54d3bd581bf801',
|
||||
// 选填-抖音开放平台服务商id
|
||||
'thirdparty_id' => '',
|
||||
// 选填-抖音支付回调地址
|
||||
'notify_url' => 'https://yansongda.cn/douyin/notify',
|
||||
],
|
||||
],
|
||||
'logger' => [ // optional
|
||||
'enable' => false,
|
||||
'file' => './logs/alipay.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 pay()
|
||||
{
|
||||
Pay::config($this->config);
|
||||
|
||||
$result = Pay::douyin()->mini([
|
||||
'out_order_no' => date('YmdHis').mt_rand(1000, 9999),
|
||||
'total_amount' => 1,
|
||||
'subject' => '闫嵩达 - test - subject - 01',
|
||||
'body' => '闫嵩达 - test - body - 01',
|
||||
'valid_time' => 600,
|
||||
'expand_order_info' => json_encode([
|
||||
'original_delivery_fee' => 15,
|
||||
'actual_delivery_fee' => 10
|
||||
])
|
||||
]);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function callback()
|
||||
{
|
||||
Pay::config($this->config);
|
||||
|
||||
try{
|
||||
$data = Pay::douyin()->callback(); // 是的,验签就这么简单!
|
||||
} catch (\Throwable $e) {
|
||||
dd($e)
|
||||
}
|
||||
|
||||
return Pay::douyin()->success();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 江苏银行(e融支付)
|
||||
```php
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Yansongda\Pay\Pay;
|
||||
|
||||
class JsbController
|
||||
{
|
||||
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()
|
||||
{
|
||||
Pay::config($this->config);
|
||||
|
||||
$order = [
|
||||
'outTradeNo' => time().'',
|
||||
'proInfo' => 'subject-测试',
|
||||
'totalFee'=> 1,
|
||||
];
|
||||
|
||||
$pay = Pay::jsb()->scan($order);
|
||||
}
|
||||
|
||||
public function notifyCallback()
|
||||
{
|
||||
Pay::config($this->config);
|
||||
|
||||
try{
|
||||
$data = Pay::jsb()->callback(); // 是的,验签就这么简单!
|
||||
} catch (\Throwable $e) {
|
||||
dd($e);
|
||||
}
|
||||
|
||||
return Pay::jsb()->success();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 代码贡献
|
||||
|
||||
由于测试及使用环境的限制,本项目中只开发了「支付宝」和「微信支付」的相关支付网关。
|
||||
由于测试及使用环境的限制,本项目中只开发了「支付宝」、「微信支付」、「抖音支付」、「银联」、「江苏银行」的相关支付网关。
|
||||
|
||||
如果您有其它支付网关的需求,或者发现本项目中需要改进的代码,**_欢迎 Fork 并提交 PR!_**
|
||||
|
||||
|
||||
9
niucloud/vendor/yansongda/pay/composer.json
vendored
9
niucloud/vendor/yansongda/pay/composer.json
vendored
@ -22,21 +22,22 @@
|
||||
"ext-libxml": "*",
|
||||
"ext-json": "*",
|
||||
"ext-bcmath": "*",
|
||||
"yansongda/artful": "~1.0.9",
|
||||
"yansongda/supports": "~4.0.9"
|
||||
"yansongda/artful": "~1.1.1",
|
||||
"yansongda/supports": "~4.0.10"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^9.0",
|
||||
"mockery/mockery": "^1.4",
|
||||
"friendsofphp/php-cs-fixer": "^3.44",
|
||||
"phpstan/phpstan": "^1.0.0",
|
||||
"phpstan/phpstan": "^1.0.0 || ^2.0.0",
|
||||
"monolog/monolog": "^2.2",
|
||||
"symfony/var-dumper": "^5.1",
|
||||
"symfony/http-foundation": "^5.2.0",
|
||||
"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"
|
||||
|
||||
@ -37,6 +37,8 @@ class Exception extends \Exception
|
||||
|
||||
public const PARAMS_CALLBACK_REQUEST_INVALID = 9221;
|
||||
|
||||
public const PARAMS_DOUYIN_URL_MISSING = 9222;
|
||||
|
||||
/**
|
||||
* 关于响应.
|
||||
*/
|
||||
@ -44,6 +46,8 @@ class Exception extends \Exception
|
||||
|
||||
public const RESPONSE_MISSING_NECESSARY_PARAMS = 9305;
|
||||
|
||||
public const RESPONSE_BUSINESS_CODE_WRONG = 9306;
|
||||
|
||||
/*
|
||||
* 关于配置.
|
||||
*/
|
||||
@ -53,6 +57,10 @@ class Exception extends \Exception
|
||||
|
||||
public const CONFIG_UNIPAY_INVALID = 9403;
|
||||
|
||||
public const CONFIG_JSB_INVALID = 9404;
|
||||
|
||||
public const CONFIG_DOUYIN_INVALID = 9405;
|
||||
|
||||
/**
|
||||
* 关于签名.
|
||||
*/
|
||||
|
||||
93
niucloud/vendor/yansongda/pay/src/Functions.php
vendored
93
niucloud/vendor/yansongda/pay/src/Functions.php
vendored
@ -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,19 +14,20 @@ 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\Douyin;
|
||||
use Yansongda\Pay\Provider\Jsb;
|
||||
use Yansongda\Pay\Provider\Unipay;
|
||||
use Yansongda\Pay\Provider\Wechat;
|
||||
use Yansongda\Supports\Collection;
|
||||
use Yansongda\Supports\Str;
|
||||
|
||||
use function Yansongda\Artful\get_radar_body;
|
||||
use function Yansongda\Artful\get_radar_method;
|
||||
@ -37,12 +39,12 @@ function get_tenant(array $params = []): string
|
||||
|
||||
function get_public_cert(string $key): string
|
||||
{
|
||||
return Str::endsWith($key, ['.cer', '.crt', '.pem']) ? file_get_contents($key) : $key;
|
||||
return is_file($key) ? file_get_contents($key) : $key;
|
||||
}
|
||||
|
||||
function get_private_cert(string $key): string
|
||||
{
|
||||
if (Str::endsWith($key, ['.crt', '.pem'])) {
|
||||
if (is_file($key)) {
|
||||
return file_get_contents($key);
|
||||
}
|
||||
|
||||
@ -64,6 +66,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');
|
||||
@ -114,6 +129,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');
|
||||
@ -232,7 +248,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]);
|
||||
@ -309,7 +325,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'] ?? '';
|
||||
@ -338,7 +354,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']);
|
||||
@ -419,12 +435,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();
|
||||
@ -440,7 +456,7 @@ function get_wechat_public_key(array $config, string $serialNo): string
|
||||
$publicKey = $config['wechat_public_cert_path'][$serialNo] ?? null;
|
||||
|
||||
if (empty($publicKey)) {
|
||||
throw new InvalidParamsException(Exception::PARAMS_WECHAT_SERIAL_NOT_FOUND, '参数异常: 微信公钥序列号为找到 -'.$serialNo);
|
||||
throw new InvalidParamsException(Exception::PARAMS_WECHAT_SERIAL_NOT_FOUND, '参数异常: 微信公钥序列号未找到 - '.$serialNo);
|
||||
}
|
||||
|
||||
return $publicKey;
|
||||
@ -467,6 +483,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');
|
||||
@ -576,3 +593,59 @@ 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());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws InvalidParamsException
|
||||
*/
|
||||
function get_douyin_url(array $config, ?Collection $payload): string
|
||||
{
|
||||
$url = get_radar_url($config, $payload);
|
||||
|
||||
if (empty($url)) {
|
||||
throw new InvalidParamsException(Exception::PARAMS_DOUYIN_URL_MISSING, '参数异常: 抖音 `_url` 参数缺失:你可能用错插件顺序,应该先使用 `业务插件`');
|
||||
}
|
||||
|
||||
if (str_starts_with($url, 'http')) {
|
||||
return $url;
|
||||
}
|
||||
|
||||
return Douyin::URL[$config['mode'] ?? Pay::MODE_NORMAL].$url;
|
||||
}
|
||||
|
||||
10
niucloud/vendor/yansongda/pay/src/Pay.php
vendored
10
niucloud/vendor/yansongda/pay/src/Pay.php
vendored
@ -10,9 +10,13 @@ use Yansongda\Artful\Artful;
|
||||
use Yansongda\Artful\Exception\ContainerException;
|
||||
use Yansongda\Artful\Exception\ServiceNotFoundException;
|
||||
use Yansongda\Pay\Provider\Alipay;
|
||||
use Yansongda\Pay\Provider\Douyin;
|
||||
use Yansongda\Pay\Provider\Jsb;
|
||||
use Yansongda\Pay\Provider\Unipay;
|
||||
use Yansongda\Pay\Provider\Wechat;
|
||||
use Yansongda\Pay\Service\AlipayServiceProvider;
|
||||
use Yansongda\Pay\Service\DouyinServiceProvider;
|
||||
use Yansongda\Pay\Service\JsbServiceProvider;
|
||||
use Yansongda\Pay\Service\UnipayServiceProvider;
|
||||
use Yansongda\Pay\Service\WechatServiceProvider;
|
||||
|
||||
@ -20,6 +24,8 @@ 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)
|
||||
* @method static Douyin douyin(array $config = [], $container = null)
|
||||
*/
|
||||
class Pay
|
||||
{
|
||||
@ -42,6 +48,8 @@ class Pay
|
||||
AlipayServiceProvider::class,
|
||||
WechatServiceProvider::class,
|
||||
UnipayServiceProvider::class,
|
||||
JsbServiceProvider::class,
|
||||
DouyinServiceProvider::class,
|
||||
];
|
||||
|
||||
/**
|
||||
@ -60,7 +68,7 @@ class Pay
|
||||
/**
|
||||
* @throws ContainerException
|
||||
*/
|
||||
public static function config(array $config = [], Closure|ContainerInterface $container = null): bool
|
||||
public static function config(array $config = [], null|Closure|ContainerInterface $container = null): bool
|
||||
{
|
||||
$result = Artful::config($config, $container);
|
||||
|
||||
|
||||
@ -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]');
|
||||
|
||||
@ -11,9 +11,11 @@ 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_alipay_config;
|
||||
use function Yansongda\Artful\get_radar_method;
|
||||
use function Yansongda\Pay\get_alipay_url;
|
||||
use function Yansongda\Pay\get_provider_config;
|
||||
|
||||
class AddRadarPlugin implements PluginInterface
|
||||
{
|
||||
@ -26,11 +28,12 @@ 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(
|
||||
strtoupper($params['_method'] ?? 'POST'),
|
||||
// 这里因为支付宝的 payload 里不包含 _method,所以需要取 params 中的
|
||||
get_radar_method(new Collection($params)) ?? 'POST',
|
||||
get_alipay_url($config, $payload),
|
||||
$this->getHeaders(),
|
||||
// 不能用 packer,支付宝接收的是 x-www-form-urlencoded 返回的又是 json,packer 用的是返回.
|
||||
|
||||
55
niucloud/vendor/yansongda/pay/src/Plugin/Alipay/V2/AppCallbackPlugin.php
vendored
Normal file
55
niucloud/vendor/yansongda/pay/src/Plugin/Alipay/V2/AppCallbackPlugin.php
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Yansongda\Pay\Plugin\Alipay\V2;
|
||||
|
||||
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 function Yansongda\Artful\filter_params;
|
||||
use function Yansongda\Pay\get_provider_config;
|
||||
use function Yansongda\Pay\verify_alipay_sign;
|
||||
|
||||
class AppCallbackPlugin implements PluginInterface
|
||||
{
|
||||
/**
|
||||
* @throws ContainerException
|
||||
* @throws InvalidConfigException
|
||||
* @throws ServiceNotFoundException
|
||||
* @throws InvalidSignException
|
||||
* @throws InvalidParamsException
|
||||
*/
|
||||
public function assembly(Rocket $rocket, Closure $next): Rocket
|
||||
{
|
||||
Logger::debug('[Alipay][AppCallbackPlugin] 插件开始装载', ['rocket' => $rocket]);
|
||||
|
||||
$params = $rocket->getParams();
|
||||
$config = get_provider_config('alipay', $params);
|
||||
|
||||
if (empty($params['alipay_trade_app_pay_response'])) {
|
||||
throw new InvalidParamsException(Exception::PARAMS_CALLBACK_REQUEST_INVALID);
|
||||
}
|
||||
|
||||
$value = filter_params($params['alipay_trade_app_pay_response']);
|
||||
|
||||
verify_alipay_sign($config, $value->toJson(), $params['sign'] ?? '');
|
||||
|
||||
$rocket->setPayload($params)
|
||||
->setDirection(NoHttpRequestDirection::class)
|
||||
->setDestination($rocket->getPayload());
|
||||
|
||||
Logger::info('[Alipay][AppCallbackPlugin] 插件装载完毕', ['rocket' => $rocket]);
|
||||
|
||||
return $next($rocket);
|
||||
}
|
||||
}
|
||||
@ -13,10 +13,9 @@ use Yansongda\Artful\Exception\ServiceNotFoundException;
|
||||
use Yansongda\Artful\Logger;
|
||||
use Yansongda\Artful\Rocket;
|
||||
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,11 +31,11 @@ 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);
|
||||
|
||||
verify_alipay_sign($config, Collection::wrap($value)->sortKeys()->toString(), $params['sign'] ?? '');
|
||||
verify_alipay_sign($config, $value->sortKeys()->toString(), $params['sign'] ?? '');
|
||||
|
||||
$rocket->setPayload($params)
|
||||
->setDirection(NoHttpRequestDirection::class)
|
||||
|
||||
@ -18,10 +18,12 @@ class TokenPlugin implements PluginInterface
|
||||
{
|
||||
Logger::debug('[Alipay][Member][Authorization][TokenPlugin] 插件开始装载', ['rocket' => $rocket]);
|
||||
|
||||
$rocket->mergePayload([
|
||||
'method' => 'alipay.system.oauth.token',
|
||||
'biz_content' => $rocket->getParams(),
|
||||
]);
|
||||
$rocket->mergePayload(array_merge(
|
||||
[
|
||||
'method' => 'alipay.system.oauth.token',
|
||||
],
|
||||
$rocket->getParams(),
|
||||
));
|
||||
|
||||
Logger::info('[Alipay][Member][Authorization][TokenPlugin] 插件装载完毕', ['rocket' => $rocket]);
|
||||
|
||||
|
||||
@ -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
|
||||
)));
|
||||
}
|
||||
|
||||
|
||||
@ -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'] ?? '',
|
||||
@ -112,7 +112,7 @@ class StartPlugin implements PluginInterface
|
||||
$ssl = openssl_x509_parse(get_public_cert($path));
|
||||
|
||||
if (false === $ssl) {
|
||||
throw new InvalidConfigException(Exception::CONFIG_ALIPAY_INVALID, 'Parse `app_public_cert_path` Error');
|
||||
throw new InvalidConfigException(Exception::CONFIG_ALIPAY_INVALID, '配置异常: 解析 `app_public_cert_path` 失败');
|
||||
}
|
||||
|
||||
$result = $this->getCertSn($ssl['issuer'] ?? [], $ssl['serialNumber'] ?? '');
|
||||
@ -136,11 +136,11 @@ class StartPlugin implements PluginInterface
|
||||
$path = $config['alipay_root_cert_path'] ?? null;
|
||||
|
||||
if (is_null($path)) {
|
||||
throw new InvalidConfigException(Exception::CONFIG_ALIPAY_INVALID, 'Missing Alipay Config -- [alipay_root_cert_path]');
|
||||
throw new InvalidConfigException(Exception::CONFIG_ALIPAY_INVALID, '配置异常: 缺少支付宝配置 -- [alipay_root_cert_path]');
|
||||
}
|
||||
|
||||
$sn = '';
|
||||
$exploded = explode('-----END CERTIFICATE-----', file_get_contents($path));
|
||||
$exploded = explode('-----END CERTIFICATE-----', get_public_cert($path));
|
||||
|
||||
foreach ($exploded as $cert) {
|
||||
if (empty(trim($cert))) {
|
||||
@ -150,7 +150,7 @@ class StartPlugin implements PluginInterface
|
||||
$ssl = openssl_x509_parse($cert.'-----END CERTIFICATE-----');
|
||||
|
||||
if (false === $ssl) {
|
||||
throw new InvalidConfigException(Exception::CONFIG_ALIPAY_INVALID, 'Invalid alipay_root_cert');
|
||||
throw new InvalidConfigException(Exception::CONFIG_ALIPAY_INVALID, '配置异常: 解析 `alipay_root_cert` 失败');
|
||||
}
|
||||
|
||||
$detail = $this->formatCert($ssl);
|
||||
|
||||
@ -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', ''));
|
||||
|
||||
|
||||
94
niucloud/vendor/yansongda/pay/src/Plugin/Douyin/V1/Pay/AddPayloadSignaturePlugin.php
vendored
Normal file
94
niucloud/vendor/yansongda/pay/src/Plugin/Douyin/V1/Pay/AddPayloadSignaturePlugin.php
vendored
Normal file
@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Yansongda\Pay\Plugin\Douyin\V1\Pay;
|
||||
|
||||
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 Yansongda\Supports\Collection;
|
||||
|
||||
use function Yansongda\Artful\filter_params;
|
||||
use function Yansongda\Pay\get_provider_config;
|
||||
|
||||
class AddPayloadSignaturePlugin implements PluginInterface
|
||||
{
|
||||
/**
|
||||
* @throws ContainerException
|
||||
* @throws InvalidConfigException
|
||||
* @throws ServiceNotFoundException
|
||||
*/
|
||||
public function assembly(Rocket $rocket, Closure $next): Rocket
|
||||
{
|
||||
Logger::debug('[Douyin][V1][Pay][AddPayloadSignaturePlugin] 插件开始装载', ['rocket' => $rocket]);
|
||||
|
||||
$config = get_provider_config('douyin', $rocket->getParams());
|
||||
$payload = $rocket->getPayload();
|
||||
|
||||
$rocket->mergePayload(['sign' => $this->getSign($config, filter_params($payload))]);
|
||||
|
||||
Logger::info('[Douyin][V1][Pay][AddPayloadSignaturePlugin] 插件装载完毕', ['rocket' => $rocket]);
|
||||
|
||||
return $next($rocket);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
protected function getSign(array $config, Collection $payload): string
|
||||
{
|
||||
$salt = $config['mch_secret_salt'] ?? null;
|
||||
|
||||
if (empty($salt)) {
|
||||
throw new InvalidConfigException(Exception::CONFIG_DOUYIN_INVALID, '配置异常: 缺少抖音配置 -- [mch_secret_salt]');
|
||||
}
|
||||
|
||||
foreach ($payload as $key => $value) {
|
||||
if (is_string($value)) {
|
||||
$value = trim($value);
|
||||
}
|
||||
|
||||
if (in_array($key, ['other_settle_params', 'app_id', 'sign', 'thirdparty_id']) || empty($value) || 'null' === $value) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_array($value)) {
|
||||
$value = $this->arrayToString($value);
|
||||
}
|
||||
|
||||
$signData[] = $value;
|
||||
}
|
||||
|
||||
$signData[] = $salt;
|
||||
|
||||
sort($signData, SORT_STRING);
|
||||
|
||||
return md5(implode('&', $signData));
|
||||
}
|
||||
|
||||
protected function arrayToString(array $value): string
|
||||
{
|
||||
$isJsonArray = isset($value[0]);
|
||||
$keys = array_keys($value);
|
||||
|
||||
if ($isJsonArray) {
|
||||
sort($keys);
|
||||
}
|
||||
|
||||
foreach ($keys as $key) {
|
||||
$val = $value[$key];
|
||||
|
||||
$result[] = is_array($val) ? $this->arrayToString($val) : (($isJsonArray ? '' : $key.':').trim(strval($val)));
|
||||
}
|
||||
|
||||
$result = '['.implode(' ', $result ?? []).']';
|
||||
|
||||
return ($isJsonArray ? '' : 'map').$result;
|
||||
}
|
||||
}
|
||||
55
niucloud/vendor/yansongda/pay/src/Plugin/Douyin/V1/Pay/AddRadarPlugin.php
vendored
Normal file
55
niucloud/vendor/yansongda/pay/src/Plugin/Douyin/V1/Pay/AddRadarPlugin.php
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Yansongda\Pay\Plugin\Douyin\V1\Pay;
|
||||
|
||||
use Closure;
|
||||
use GuzzleHttp\Psr7\Request;
|
||||
use Yansongda\Artful\Contract\PluginInterface;
|
||||
use Yansongda\Artful\Exception\ContainerException;
|
||||
use Yansongda\Artful\Exception\InvalidParamsException;
|
||||
use Yansongda\Artful\Exception\ServiceNotFoundException;
|
||||
use Yansongda\Artful\Logger;
|
||||
use Yansongda\Artful\Rocket;
|
||||
|
||||
use function Yansongda\Artful\get_radar_body;
|
||||
use function Yansongda\Artful\get_radar_method;
|
||||
use function Yansongda\Pay\get_douyin_url;
|
||||
use function Yansongda\Pay\get_provider_config;
|
||||
|
||||
class AddRadarPlugin implements PluginInterface
|
||||
{
|
||||
/**
|
||||
* @throws ContainerException
|
||||
* @throws InvalidParamsException
|
||||
* @throws ServiceNotFoundException
|
||||
*/
|
||||
public function assembly(Rocket $rocket, Closure $next): Rocket
|
||||
{
|
||||
Logger::debug('[Douyin][V1][Pay][AddRadarPlugin] 插件开始装载', ['rocket' => $rocket]);
|
||||
|
||||
$params = $rocket->getParams();
|
||||
$payload = $rocket->getPayload();
|
||||
$config = get_provider_config('douyin', $params);
|
||||
|
||||
$rocket->setRadar(new Request(
|
||||
get_radar_method($payload),
|
||||
get_douyin_url($config, $payload),
|
||||
$this->getHeaders(),
|
||||
get_radar_body($payload),
|
||||
));
|
||||
|
||||
Logger::info('[Douyin][V1][Pay][AddRadarPlugin] 插件装载完毕', ['rocket' => $rocket]);
|
||||
|
||||
return $next($rocket);
|
||||
}
|
||||
|
||||
protected function getHeaders(): array
|
||||
{
|
||||
return [
|
||||
'User-Agent' => 'yansongda/pay-v3',
|
||||
'Content-Type' => 'application/json; charset=utf-8',
|
||||
];
|
||||
}
|
||||
}
|
||||
74
niucloud/vendor/yansongda/pay/src/Plugin/Douyin/V1/Pay/CallbackPlugin.php
vendored
Normal file
74
niucloud/vendor/yansongda/pay/src/Plugin/Douyin/V1/Pay/CallbackPlugin.php
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Yansongda\Pay\Plugin\Douyin\V1\Pay;
|
||||
|
||||
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\ServiceNotFoundException;
|
||||
use Yansongda\Artful\Logger;
|
||||
use Yansongda\Artful\Rocket;
|
||||
use Yansongda\Pay\Exception\Exception;
|
||||
use Yansongda\Pay\Exception\InvalidSignException;
|
||||
|
||||
use function Yansongda\Artful\filter_params;
|
||||
use function Yansongda\Pay\get_provider_config;
|
||||
|
||||
class CallbackPlugin implements PluginInterface
|
||||
{
|
||||
/**
|
||||
* @throws ContainerException
|
||||
* @throws InvalidConfigException
|
||||
* @throws InvalidSignException
|
||||
* @throws ServiceNotFoundException
|
||||
*/
|
||||
public function assembly(Rocket $rocket, Closure $next): Rocket
|
||||
{
|
||||
Logger::debug('[Douyin][V1][Pay][CallbackPlugin] 插件开始装载', ['rocket' => $rocket]);
|
||||
|
||||
$params = $rocket->getParams();
|
||||
$config = get_provider_config('douyin', $params);
|
||||
|
||||
$value = filter_params($params, fn ($k, $v) => '' !== $v && 'msg_signature' != $k && 'type' != $k);
|
||||
|
||||
$this->verifySign($config, $value->all(), $params['msg_signature'] ?? '');
|
||||
|
||||
$rocket->setPayload($params)
|
||||
->setDirection(NoHttpRequestDirection::class)
|
||||
->setDestination($rocket->getPayload());
|
||||
|
||||
Logger::info('[Douyin][V1][Pay][CallbackPlugin] 插件装载完毕', ['rocket' => $rocket]);
|
||||
|
||||
return $next($rocket);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws InvalidConfigException
|
||||
* @throws InvalidSignException
|
||||
*/
|
||||
protected function verifySign(array $config, array $contents, string $sign): void
|
||||
{
|
||||
if (empty($sign)) {
|
||||
throw new InvalidSignException(Exception::SIGN_EMPTY, '签名异常: 验证抖音签名失败-抖音签名为空', func_get_args());
|
||||
}
|
||||
|
||||
$contents['token'] = $config['mch_secret_token'] ?? null;
|
||||
|
||||
if (empty($contents['token'])) {
|
||||
throw new InvalidConfigException(Exception::CONFIG_DOUYIN_INVALID, '配置异常: 缺少抖音配置 -- [mch_secret_token]');
|
||||
}
|
||||
|
||||
sort($contents, SORT_STRING);
|
||||
$data = trim(implode('', $contents));
|
||||
|
||||
$result = $sign === sha1($data);
|
||||
|
||||
if (!$result) {
|
||||
throw new InvalidSignException(Exception::SIGN_ERROR, '签名异常: 验证抖音签名失败', func_get_args());
|
||||
}
|
||||
}
|
||||
}
|
||||
72
niucloud/vendor/yansongda/pay/src/Plugin/Douyin/V1/Pay/Mini/PayPlugin.php
vendored
Normal file
72
niucloud/vendor/yansongda/pay/src/Plugin/Douyin/V1/Pay/Mini/PayPlugin.php
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Yansongda\Pay\Plugin\Douyin\V1\Pay\Mini;
|
||||
|
||||
use Closure;
|
||||
use Yansongda\Artful\Contract\PluginInterface;
|
||||
use Yansongda\Artful\Exception\ContainerException;
|
||||
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\Pay;
|
||||
use Yansongda\Supports\Collection;
|
||||
|
||||
use function Yansongda\Pay\get_provider_config;
|
||||
|
||||
/**
|
||||
* @see https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/server/ecpay/pay-list/pay
|
||||
*/
|
||||
class PayPlugin implements PluginInterface
|
||||
{
|
||||
/**
|
||||
* @throws ContainerException
|
||||
* @throws InvalidParamsException
|
||||
* @throws ServiceNotFoundException
|
||||
*/
|
||||
public function assembly(Rocket $rocket, Closure $next): Rocket
|
||||
{
|
||||
Logger::debug('[Douyin][V1][Pay][Mini][PayPlugin] 插件开始装载', ['rocket' => $rocket]);
|
||||
|
||||
$payload = $rocket->getPayload();
|
||||
$params = $rocket->getParams();
|
||||
$config = get_provider_config('douyin', $params);
|
||||
|
||||
if (is_null($payload)) {
|
||||
throw new InvalidParamsException(Exception::PARAMS_NECESSARY_PARAMS_MISSING, '参数异常: 抖音小程序下单,参数为空');
|
||||
}
|
||||
|
||||
if (Pay::MODE_SERVICE === ($config['mode'] ?? Pay::MODE_NORMAL)) {
|
||||
$data = $this->service($payload, $config);
|
||||
}
|
||||
|
||||
$rocket->mergePayload(array_merge(
|
||||
[
|
||||
'_method' => 'POST',
|
||||
'_url' => 'api/apps/ecpay/v1/create_order',
|
||||
'app_id' => $config['mini_app_id'] ?? '',
|
||||
'notify_url' => $payload->get('notify_url') ?? $this->getNotifyUrl($config),
|
||||
],
|
||||
$data ?? [],
|
||||
));
|
||||
|
||||
Logger::info('[Douyin][V1][Pay][Mini][PayPlugin] 插件装载完毕', ['rocket' => $rocket]);
|
||||
|
||||
return $next($rocket);
|
||||
}
|
||||
|
||||
protected function service(Collection $payload, array $config): array
|
||||
{
|
||||
return [
|
||||
'thirdparty_id' => $payload->get('thirdparty_id', $config['thirdparty_id'] ?? ''),
|
||||
];
|
||||
}
|
||||
|
||||
protected function getNotifyUrl(array $config): ?string
|
||||
{
|
||||
return empty($config['notify_url']) ? null : $config['notify_url'];
|
||||
}
|
||||
}
|
||||
66
niucloud/vendor/yansongda/pay/src/Plugin/Douyin/V1/Pay/Mini/QueryPlugin.php
vendored
Normal file
66
niucloud/vendor/yansongda/pay/src/Plugin/Douyin/V1/Pay/Mini/QueryPlugin.php
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Yansongda\Pay\Plugin\Douyin\V1\Pay\Mini;
|
||||
|
||||
use Closure;
|
||||
use Yansongda\Artful\Contract\PluginInterface;
|
||||
use Yansongda\Artful\Exception\ContainerException;
|
||||
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\Pay;
|
||||
use Yansongda\Supports\Collection;
|
||||
|
||||
use function Yansongda\Pay\get_provider_config;
|
||||
|
||||
/**
|
||||
* @see https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/server/ecpay/pay-list/query
|
||||
*/
|
||||
class QueryPlugin implements PluginInterface
|
||||
{
|
||||
/**
|
||||
* @throws ContainerException
|
||||
* @throws InvalidParamsException
|
||||
* @throws ServiceNotFoundException
|
||||
*/
|
||||
public function assembly(Rocket $rocket, Closure $next): Rocket
|
||||
{
|
||||
Logger::debug('[Douyin][V1][Pay][Mini][QueryPlugin] 插件开始装载', ['rocket' => $rocket]);
|
||||
|
||||
$payload = $rocket->getPayload();
|
||||
$params = $rocket->getParams();
|
||||
$config = get_provider_config('douyin', $params);
|
||||
|
||||
if (is_null($payload)) {
|
||||
throw new InvalidParamsException(Exception::PARAMS_NECESSARY_PARAMS_MISSING, '参数异常: 抖音小程序查询订单,参数为空');
|
||||
}
|
||||
|
||||
if (Pay::MODE_SERVICE === ($config['mode'] ?? Pay::MODE_NORMAL)) {
|
||||
$data = $this->service($payload, $config);
|
||||
}
|
||||
|
||||
$rocket->mergePayload(array_merge(
|
||||
[
|
||||
'_method' => 'POST',
|
||||
'_url' => 'api/apps/ecpay/v1/query_order',
|
||||
'app_id' => $config['mini_app_id'] ?? '',
|
||||
],
|
||||
$data ?? [],
|
||||
));
|
||||
|
||||
Logger::info('[Douyin][V1][Pay][Mini][QueryPlugin] 插件装载完毕', ['rocket' => $rocket]);
|
||||
|
||||
return $next($rocket);
|
||||
}
|
||||
|
||||
protected function service(Collection $payload, array $config): array
|
||||
{
|
||||
return [
|
||||
'thirdparty_id' => $payload->get('thirdparty_id', $config['thirdparty_id'] ?? ''),
|
||||
];
|
||||
}
|
||||
}
|
||||
66
niucloud/vendor/yansongda/pay/src/Plugin/Douyin/V1/Pay/Mini/QueryRefundPlugin.php
vendored
Normal file
66
niucloud/vendor/yansongda/pay/src/Plugin/Douyin/V1/Pay/Mini/QueryRefundPlugin.php
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Yansongda\Pay\Plugin\Douyin\V1\Pay\Mini;
|
||||
|
||||
use Closure;
|
||||
use Yansongda\Artful\Contract\PluginInterface;
|
||||
use Yansongda\Artful\Exception\ContainerException;
|
||||
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\Pay;
|
||||
use Yansongda\Supports\Collection;
|
||||
|
||||
use function Yansongda\Pay\get_provider_config;
|
||||
|
||||
/**
|
||||
* @see https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/server/ecpay/refund-list/query
|
||||
*/
|
||||
class QueryRefundPlugin implements PluginInterface
|
||||
{
|
||||
/**
|
||||
* @throws ContainerException
|
||||
* @throws InvalidParamsException
|
||||
* @throws ServiceNotFoundException
|
||||
*/
|
||||
public function assembly(Rocket $rocket, Closure $next): Rocket
|
||||
{
|
||||
Logger::debug('[Douyin][V1][Pay][Mini][QueryRefundPlugin] 插件开始装载', ['rocket' => $rocket]);
|
||||
|
||||
$payload = $rocket->getPayload();
|
||||
$params = $rocket->getParams();
|
||||
$config = get_provider_config('douyin', $params);
|
||||
|
||||
if (is_null($payload)) {
|
||||
throw new InvalidParamsException(Exception::PARAMS_NECESSARY_PARAMS_MISSING, '参数异常: 抖音小程序查询退款订单,参数为空');
|
||||
}
|
||||
|
||||
if (Pay::MODE_SERVICE === ($config['mode'] ?? Pay::MODE_NORMAL)) {
|
||||
$data = $this->service($payload, $config);
|
||||
}
|
||||
|
||||
$rocket->mergePayload(array_merge(
|
||||
[
|
||||
'_method' => 'POST',
|
||||
'_url' => 'api/apps/ecpay/v1/query_refund',
|
||||
'app_id' => $config['mini_app_id'] ?? '',
|
||||
],
|
||||
$data ?? [],
|
||||
));
|
||||
|
||||
Logger::info('[Douyin][V1][Pay][Mini][QueryRefundPlugin] 插件装载完毕', ['rocket' => $rocket]);
|
||||
|
||||
return $next($rocket);
|
||||
}
|
||||
|
||||
protected function service(Collection $payload, array $config): array
|
||||
{
|
||||
return [
|
||||
'thirdparty_id' => $payload->get('thirdparty_id', $config['thirdparty_id'] ?? ''),
|
||||
];
|
||||
}
|
||||
}
|
||||
72
niucloud/vendor/yansongda/pay/src/Plugin/Douyin/V1/Pay/Mini/RefundPlugin.php
vendored
Normal file
72
niucloud/vendor/yansongda/pay/src/Plugin/Douyin/V1/Pay/Mini/RefundPlugin.php
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Yansongda\Pay\Plugin\Douyin\V1\Pay\Mini;
|
||||
|
||||
use Closure;
|
||||
use Yansongda\Artful\Contract\PluginInterface;
|
||||
use Yansongda\Artful\Exception\ContainerException;
|
||||
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\Pay;
|
||||
use Yansongda\Supports\Collection;
|
||||
|
||||
use function Yansongda\Pay\get_provider_config;
|
||||
|
||||
/**
|
||||
* @see https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/server/ecpay/refund-list/refund
|
||||
*/
|
||||
class RefundPlugin implements PluginInterface
|
||||
{
|
||||
/**
|
||||
* @throws ContainerException
|
||||
* @throws InvalidParamsException
|
||||
* @throws ServiceNotFoundException
|
||||
*/
|
||||
public function assembly(Rocket $rocket, Closure $next): Rocket
|
||||
{
|
||||
Logger::debug('[Douyin][V1][Pay][Mini][RefundPlugin] 插件开始装载', ['rocket' => $rocket]);
|
||||
|
||||
$payload = $rocket->getPayload();
|
||||
$params = $rocket->getParams();
|
||||
$config = get_provider_config('douyin', $params);
|
||||
|
||||
if (is_null($payload)) {
|
||||
throw new InvalidParamsException(Exception::PARAMS_NECESSARY_PARAMS_MISSING, '参数异常: 抖音小程序退款订单,参数为空');
|
||||
}
|
||||
|
||||
if (Pay::MODE_SERVICE === ($config['mode'] ?? Pay::MODE_NORMAL)) {
|
||||
$data = $this->service($payload, $config);
|
||||
}
|
||||
|
||||
$rocket->mergePayload(array_merge(
|
||||
[
|
||||
'_method' => 'POST',
|
||||
'_url' => 'api/apps/ecpay/v1/create_refund',
|
||||
'app_id' => $config['mini_app_id'] ?? '',
|
||||
'notify_url' => $payload->get('notify_url') ?? $this->getNotifyUrl($config),
|
||||
],
|
||||
$data ?? [],
|
||||
));
|
||||
|
||||
Logger::info('[Douyin][V1][Pay][Mini][RefundPlugin] 插件装载完毕', ['rocket' => $rocket]);
|
||||
|
||||
return $next($rocket);
|
||||
}
|
||||
|
||||
protected function service(Collection $payload, array $config): array
|
||||
{
|
||||
return [
|
||||
'thirdparty_id' => $payload->get('thirdparty_id', $config['thirdparty_id'] ?? ''),
|
||||
];
|
||||
}
|
||||
|
||||
protected function getNotifyUrl(array $config): ?string
|
||||
{
|
||||
return empty($config['notify_url']) ? null : $config['notify_url'];
|
||||
}
|
||||
}
|
||||
51
niucloud/vendor/yansongda/pay/src/Plugin/Douyin/V1/Pay/ResponsePlugin.php
vendored
Normal file
51
niucloud/vendor/yansongda/pay/src/Plugin/Douyin/V1/Pay/ResponsePlugin.php
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Yansongda\Pay\Plugin\Douyin\V1\Pay;
|
||||
|
||||
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;
|
||||
|
||||
class ResponsePlugin implements PluginInterface
|
||||
{
|
||||
/**
|
||||
* @throws InvalidResponseException
|
||||
*/
|
||||
public function assembly(Rocket $rocket, Closure $next): Rocket
|
||||
{
|
||||
/* @var Rocket $rocket */
|
||||
$rocket = $next($rocket);
|
||||
|
||||
Logger::debug('[Douyin][V1][Pay][ResponsePlugin] 插件开始装载', ['rocket' => $rocket]);
|
||||
|
||||
$this->validateResponse($rocket);
|
||||
|
||||
Logger::info('[Douyin][V1][Pay][ResponsePlugin] 插件装载完毕', ['rocket' => $rocket]);
|
||||
|
||||
return $rocket;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws InvalidResponseException
|
||||
*/
|
||||
protected function validateResponse(Rocket $rocket): void
|
||||
{
|
||||
$destination = $rocket->getDestination();
|
||||
$response = $rocket->getDestinationOrigin();
|
||||
|
||||
if ($response instanceof ResponseInterface
|
||||
&& ($response->getStatusCode() < 200 || $response->getStatusCode() >= 300)) {
|
||||
throw new InvalidResponseException(Exception::RESPONSE_CODE_WRONG, '抖音返回状态码异常,请检查参数是否错误', $destination);
|
||||
}
|
||||
|
||||
if (0 !== $destination->get('err_no')) {
|
||||
throw new InvalidResponseException(Exception::RESPONSE_BUSINESS_CODE_WRONG, '抖音返回业务异常: '.$destination->get('err_tips'), $destination);
|
||||
}
|
||||
}
|
||||
}
|
||||
65
niucloud/vendor/yansongda/pay/src/Plugin/Jsb/AddPayloadSignPlugin.php
vendored
Normal file
65
niucloud/vendor/yansongda/pay/src/Plugin/Jsb/AddPayloadSignPlugin.php
vendored
Normal 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);
|
||||
}
|
||||
}
|
||||
68
niucloud/vendor/yansongda/pay/src/Plugin/Jsb/AddRadarPlugin.php
vendored
Normal file
68
niucloud/vendor/yansongda/pay/src/Plugin/Jsb/AddRadarPlugin.php
vendored
Normal 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();
|
||||
}
|
||||
}
|
||||
70
niucloud/vendor/yansongda/pay/src/Plugin/Jsb/CallbackPlugin.php
vendored
Normal file
70
niucloud/vendor/yansongda/pay/src/Plugin/Jsb/CallbackPlugin.php
vendored
Normal 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'] ?? []);
|
||||
}
|
||||
}
|
||||
49
niucloud/vendor/yansongda/pay/src/Plugin/Jsb/Pay/Scan/PayPlugin.php
vendored
Normal file
49
niucloud/vendor/yansongda/pay/src/Plugin/Jsb/Pay/Scan/PayPlugin.php
vendored
Normal 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);
|
||||
}
|
||||
}
|
||||
30
niucloud/vendor/yansongda/pay/src/Plugin/Jsb/Pay/Scan/QueryPlugin.php
vendored
Normal file
30
niucloud/vendor/yansongda/pay/src/Plugin/Jsb/Pay/Scan/QueryPlugin.php
vendored
Normal 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);
|
||||
}
|
||||
}
|
||||
30
niucloud/vendor/yansongda/pay/src/Plugin/Jsb/Pay/Scan/RefundPlugin.php
vendored
Normal file
30
niucloud/vendor/yansongda/pay/src/Plugin/Jsb/Pay/Scan/RefundPlugin.php
vendored
Normal 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);
|
||||
}
|
||||
}
|
||||
52
niucloud/vendor/yansongda/pay/src/Plugin/Jsb/ResponsePlugin.php
vendored
Normal file
52
niucloud/vendor/yansongda/pay/src/Plugin/Jsb/ResponsePlugin.php
vendored
Normal 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
49
niucloud/vendor/yansongda/pay/src/Plugin/Jsb/StartPlugin.php
vendored
Normal file
49
niucloud/vendor/yansongda/pay/src/Plugin/Jsb/StartPlugin.php
vendored
Normal 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);
|
||||
}
|
||||
}
|
||||
76
niucloud/vendor/yansongda/pay/src/Plugin/Jsb/VerifySignaturePlugin.php
vendored
Normal file
76
niucloud/vendor/yansongda/pay/src/Plugin/Jsb/VerifySignaturePlugin.php
vendored
Normal 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,
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -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(
|
||||
|
||||
@ -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()) {
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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, [
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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()) {
|
||||
|
||||
@ -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']) {
|
||||
|
||||
@ -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([
|
||||
|
||||
@ -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([
|
||||
|
||||
@ -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([
|
||||
|
||||
@ -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([
|
||||
|
||||
@ -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([
|
||||
|
||||
@ -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([
|
||||
|
||||
@ -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([
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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([
|
||||
|
||||
@ -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([
|
||||
|
||||
@ -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([
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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),
|
||||
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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()),
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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));
|
||||
|
||||
@ -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));
|
||||
|
||||
@ -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([
|
||||
|
||||
@ -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([
|
||||
|
||||
@ -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([
|
||||
|
||||
81
niucloud/vendor/yansongda/pay/src/Plugin/Wechat/V2/Pay/Redpack/SendPlugin.php
vendored
Normal file
81
niucloud/vendor/yansongda/pay/src/Plugin/Wechat/V2/Pay/Redpack/SendPlugin.php
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Yansongda\Pay\Plugin\Wechat\V2\Pay\Redpack;
|
||||
|
||||
use Closure;
|
||||
use Throwable;
|
||||
use Yansongda\Artful\Contract\PluginInterface;
|
||||
use Yansongda\Artful\Exception\ContainerException;
|
||||
use Yansongda\Artful\Exception\ServiceNotFoundException;
|
||||
use Yansongda\Artful\Logger;
|
||||
use Yansongda\Artful\Packer\XmlPacker;
|
||||
use Yansongda\Artful\Rocket;
|
||||
use Yansongda\Pay\Pay;
|
||||
use Yansongda\Supports\Collection;
|
||||
use Yansongda\Supports\Str;
|
||||
|
||||
use function Yansongda\Pay\get_provider_config;
|
||||
use function Yansongda\Pay\get_wechat_type_key;
|
||||
|
||||
/**
|
||||
* @see https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon_sl.php?chapter=13_4&index=3
|
||||
*/
|
||||
class SendPlugin implements PluginInterface
|
||||
{
|
||||
/**
|
||||
* @throws ContainerException
|
||||
* @throws ServiceNotFoundException
|
||||
* @throws Throwable 随机字符串生成失败
|
||||
*/
|
||||
public function assembly(Rocket $rocket, Closure $next): Rocket
|
||||
{
|
||||
Logger::debug('[Wechat][V2][Pay][Redpack][SendPlugin] 插件开始装载', ['rocket' => $rocket]);
|
||||
$payload = $rocket->getPayload();
|
||||
$params = $rocket->getParams();
|
||||
$config = get_provider_config('wechat', $params);
|
||||
|
||||
if (Pay::MODE_SERVICE === ($config['mode'] ?? Pay::MODE_NORMAL)) {
|
||||
$data = $this->service($payload, $config, $params);
|
||||
}
|
||||
|
||||
$rocket->setPacker(XmlPacker::class)
|
||||
->mergePayload(array_merge(
|
||||
[
|
||||
'_url' => 'mmpaymkttransfers/sendredpack',
|
||||
'_content_type' => 'application/xml',
|
||||
'nonce_str' => Str::random(32),
|
||||
'_http' => [
|
||||
'ssl_key' => $config['mch_secret_cert'],
|
||||
'cert' => $config['mch_public_cert_path'],
|
||||
],
|
||||
],
|
||||
$data ?? $this->normal($config, $params)
|
||||
));
|
||||
|
||||
Logger::info('[Wechat][V2][Pay][Pos][PayPlugin] 插件装载完毕', ['rocket' => $rocket]);
|
||||
|
||||
return $next($rocket);
|
||||
}
|
||||
|
||||
protected function normal(array $config, array $params): array
|
||||
{
|
||||
return [
|
||||
'wxappid' => $config[get_wechat_type_key($params)] ?? '',
|
||||
'mch_id' => $config['mch_id'] ?? '',
|
||||
];
|
||||
}
|
||||
|
||||
protected function service(Collection $payload, array $config, array $params): array
|
||||
{
|
||||
$wechatTypeKey = get_wechat_type_key($params);
|
||||
|
||||
return [
|
||||
'wxappid' => $config[$wechatTypeKey] ?? '',
|
||||
'mch_id' => $config['mch_id'] ?? '',
|
||||
'sub_mch_id' => $payload->get('sub_mch_id', $config['sub_mch_id'] ?? ''),
|
||||
'msgappid' => $config['sub_'.$wechatTypeKey],
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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));
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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` 解密失败');
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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)) {
|
||||
@ -123,6 +123,8 @@ class AddReceiverPlugin implements PluginInterface
|
||||
protected function encryptSensitiveData(array $params, array $config, Collection $payload): array
|
||||
{
|
||||
$data['_serial_no'] = get_wechat_serial_no($params);
|
||||
|
||||
$config = get_provider_config('wechat', $params);
|
||||
$publicKey = get_wechat_public_key($config, $data['_serial_no']);
|
||||
|
||||
$data['name'] = encrypt_wechat_contents($payload->get('name'), $publicKey);
|
||||
|
||||
@ -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)) {
|
||||
@ -123,6 +123,8 @@ class CreatePlugin implements PluginInterface
|
||||
protected function encryptSensitiveData(array $params, array $config, Collection $payload): array
|
||||
{
|
||||
$data['_serial_no'] = get_wechat_serial_no($params);
|
||||
|
||||
$config = get_provider_config('wechat', $params);
|
||||
$publicKey = get_wechat_public_key($config, $data['_serial_no']);
|
||||
|
||||
foreach ($payload->get('receivers', []) as $key => $list) {
|
||||
|
||||
@ -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)) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user