|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Yansongda\Pay\Shortcut\Douyin; |
|
6
|
|
|
|
|
7
|
|
|
use Yansongda\Artful\Contract\ShortcutInterface; |
|
8
|
|
|
use Yansongda\Artful\Exception\InvalidParamsException; |
|
9
|
|
|
use Yansongda\Artful\Plugin\AddPayloadBodyPlugin; |
|
10
|
|
|
use Yansongda\Artful\Plugin\ParserPlugin; |
|
11
|
|
|
use Yansongda\Artful\Plugin\StartPlugin; |
|
12
|
|
|
use Yansongda\Pay\Exception\Exception; |
|
13
|
|
|
use Yansongda\Pay\Plugin\Douyin\V1\Pay\AddPayloadSignaturePlugin; |
|
14
|
|
|
use Yansongda\Pay\Plugin\Douyin\V1\Pay\AddRadarPlugin; |
|
15
|
|
|
use Yansongda\Pay\Plugin\Douyin\V1\Pay\Mini\QueryPlugin as MiniQueryPlugin; |
|
16
|
|
|
use Yansongda\Pay\Plugin\Douyin\V1\Pay\Mini\QueryRefundPlugin as MiniQueryRefundPlugin; |
|
17
|
|
|
use Yansongda\Pay\Plugin\Douyin\V1\Pay\ResponsePlugin; |
|
18
|
|
|
use Yansongda\Supports\Str; |
|
19
|
|
|
|
|
20
|
|
|
class QueryShortcut implements ShortcutInterface |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* @throws InvalidParamsException |
|
24
|
|
|
*/ |
|
25
|
|
|
public function getPlugins(array $params): array |
|
26
|
|
|
{ |
|
27
|
|
|
$method = Str::camel($params['_action'] ?? 'default').'Plugins'; |
|
28
|
|
|
|
|
29
|
|
|
if (method_exists($this, $method)) { |
|
30
|
|
|
return $this->{$method}(); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
throw new InvalidParamsException(Exception::PARAMS_SHORTCUT_ACTION_INVALID, "您所提供的 action 方法 [{$method}] 不支持,请参考文档或源码确认"); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
protected function defaultPlugins(): array |
|
37
|
|
|
{ |
|
38
|
|
|
return $this->miniPlugins(); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
protected function refundPlugins(): array |
|
42
|
|
|
{ |
|
43
|
|
|
return $this->refundMiniPlugins(); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
protected function miniPlugins(): array |
|
47
|
|
|
{ |
|
48
|
|
|
return [ |
|
49
|
|
|
StartPlugin::class, |
|
50
|
|
|
MiniQueryPlugin::class, |
|
51
|
|
|
AddPayloadSignaturePlugin::class, |
|
52
|
|
|
AddPayloadBodyPlugin::class, |
|
53
|
|
|
AddRadarPlugin::class, |
|
54
|
|
|
ResponsePlugin::class, |
|
55
|
|
|
ParserPlugin::class, |
|
56
|
|
|
]; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
protected function refundMiniPlugins(): array |
|
60
|
|
|
{ |
|
61
|
|
|
return [ |
|
62
|
|
|
StartPlugin::class, |
|
63
|
|
|
MiniQueryRefundPlugin::class, |
|
64
|
|
|
AddPayloadSignaturePlugin::class, |
|
65
|
|
|
AddPayloadBodyPlugin::class, |
|
66
|
|
|
AddRadarPlugin::class, |
|
67
|
|
|
ResponsePlugin::class, |
|
68
|
|
|
ParserPlugin::class, |
|
69
|
|
|
]; |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|