1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Yansongda\Pay\Shortcut\Alipay; |
6
|
|
|
|
7
|
|
|
use Yansongda\Artful\Contract\ShortcutInterface; |
8
|
|
|
use Yansongda\Artful\Exception\InvalidParamsException; |
9
|
|
|
use Yansongda\Artful\Plugin\ParserPlugin; |
10
|
|
|
use Yansongda\Pay\Exception\Exception; |
11
|
|
|
use Yansongda\Pay\Plugin\Alipay\V2\AddPayloadSignaturePlugin; |
12
|
|
|
use Yansongda\Pay\Plugin\Alipay\V2\AddRadarPlugin; |
13
|
|
|
use Yansongda\Pay\Plugin\Alipay\V2\FormatPayloadBizContentPlugin; |
14
|
|
|
use Yansongda\Pay\Plugin\Alipay\V2\Pay\Agreement\Pay\ClosePlugin as AgreementClosePlugin; |
15
|
|
|
use Yansongda\Pay\Plugin\Alipay\V2\Pay\App\ClosePlugin as AppClosePlugin; |
16
|
|
|
use Yansongda\Pay\Plugin\Alipay\V2\Pay\Authorization\Pay\ClosePlugin as AuthorizationClosePlugin; |
17
|
|
|
use Yansongda\Pay\Plugin\Alipay\V2\Pay\H5\ClosePlugin as H5ClosePlugin; |
18
|
|
|
use Yansongda\Pay\Plugin\Alipay\V2\Pay\Mini\ClosePlugin as MiniClosePlugin; |
19
|
|
|
use Yansongda\Pay\Plugin\Alipay\V2\Pay\Pos\ClosePlugin as PosClosePlugin; |
20
|
|
|
use Yansongda\Pay\Plugin\Alipay\V2\Pay\Scan\ClosePlugin as ScanClosePlugin; |
21
|
|
|
use Yansongda\Pay\Plugin\Alipay\V2\Pay\Web\ClosePlugin as WebClosePlugin; |
22
|
|
|
use Yansongda\Pay\Plugin\Alipay\V2\ResponsePlugin; |
23
|
|
|
use Yansongda\Pay\Plugin\Alipay\V2\StartPlugin; |
24
|
|
|
use Yansongda\Pay\Plugin\Alipay\V2\VerifySignaturePlugin; |
25
|
|
|
use Yansongda\Supports\Str; |
26
|
|
|
|
27
|
|
|
class CloseShortcut implements ShortcutInterface |
28
|
|
|
{ |
29
|
|
|
/** |
30
|
|
|
* @throws InvalidParamsException |
31
|
|
|
*/ |
32
|
|
|
public function getPlugins(array $params): array |
33
|
|
|
{ |
34
|
|
|
$method = Str::camel($params['_action'] ?? 'default').'Plugins'; |
35
|
|
|
|
36
|
|
|
if (method_exists($this, $method)) { |
37
|
|
|
return $this->{$method}(); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
throw new InvalidParamsException(Exception::PARAMS_SHORTCUT_ACTION_INVALID, "您所提供的 action 方法 [{$method}] 不支持,请参考文档或源码确认"); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
protected function defaultPlugins(): array |
44
|
|
|
{ |
45
|
|
|
return $this->webPlugins(); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
protected function agreementPlugins(): array |
49
|
|
|
{ |
50
|
|
|
return [ |
51
|
|
|
StartPlugin::class, |
52
|
|
|
AgreementClosePlugin::class, |
53
|
|
|
FormatPayloadBizContentPlugin::class, |
54
|
|
|
AddPayloadSignaturePlugin::class, |
55
|
|
|
AddRadarPlugin::class, |
56
|
|
|
VerifySignaturePlugin::class, |
57
|
|
|
ResponsePlugin::class, |
58
|
|
|
ParserPlugin::class, |
59
|
|
|
]; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
protected function appPlugins(): array |
63
|
|
|
{ |
64
|
|
|
return [ |
65
|
|
|
StartPlugin::class, |
66
|
|
|
AppClosePlugin::class, |
67
|
|
|
FormatPayloadBizContentPlugin::class, |
68
|
|
|
AddPayloadSignaturePlugin::class, |
69
|
|
|
AddRadarPlugin::class, |
70
|
|
|
VerifySignaturePlugin::class, |
71
|
|
|
ResponsePlugin::class, |
72
|
|
|
ParserPlugin::class, |
73
|
|
|
]; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
protected function authorizationPlugins(): array |
77
|
|
|
{ |
78
|
|
|
return [ |
79
|
|
|
StartPlugin::class, |
80
|
|
|
AuthorizationClosePlugin::class, |
81
|
|
|
FormatPayloadBizContentPlugin::class, |
82
|
|
|
AddPayloadSignaturePlugin::class, |
83
|
|
|
AddRadarPlugin::class, |
84
|
|
|
VerifySignaturePlugin::class, |
85
|
|
|
ResponsePlugin::class, |
86
|
|
|
ParserPlugin::class, |
87
|
|
|
]; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
protected function miniPlugins(): array |
91
|
|
|
{ |
92
|
|
|
return [ |
93
|
|
|
StartPlugin::class, |
94
|
|
|
MiniClosePlugin::class, |
95
|
|
|
FormatPayloadBizContentPlugin::class, |
96
|
|
|
AddPayloadSignaturePlugin::class, |
97
|
|
|
AddRadarPlugin::class, |
98
|
|
|
VerifySignaturePlugin::class, |
99
|
|
|
ResponsePlugin::class, |
100
|
|
|
ParserPlugin::class, |
101
|
|
|
]; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
protected function posPlugins(): array |
105
|
|
|
{ |
106
|
|
|
return [ |
107
|
|
|
StartPlugin::class, |
108
|
|
|
PosClosePlugin::class, |
109
|
|
|
FormatPayloadBizContentPlugin::class, |
110
|
|
|
AddPayloadSignaturePlugin::class, |
111
|
|
|
AddRadarPlugin::class, |
112
|
|
|
VerifySignaturePlugin::class, |
113
|
|
|
ResponsePlugin::class, |
114
|
|
|
ParserPlugin::class, |
115
|
|
|
]; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
protected function scanPlugins(): array |
119
|
|
|
{ |
120
|
|
|
return [ |
121
|
|
|
StartPlugin::class, |
122
|
|
|
ScanClosePlugin::class, |
123
|
|
|
FormatPayloadBizContentPlugin::class, |
124
|
|
|
AddPayloadSignaturePlugin::class, |
125
|
|
|
AddRadarPlugin::class, |
126
|
|
|
VerifySignaturePlugin::class, |
127
|
|
|
ResponsePlugin::class, |
128
|
|
|
ParserPlugin::class, |
129
|
|
|
]; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
protected function h5Plugins(): array |
133
|
|
|
{ |
134
|
|
|
return [ |
135
|
|
|
StartPlugin::class, |
136
|
|
|
H5ClosePlugin::class, |
137
|
|
|
FormatPayloadBizContentPlugin::class, |
138
|
|
|
AddPayloadSignaturePlugin::class, |
139
|
|
|
AddRadarPlugin::class, |
140
|
|
|
VerifySignaturePlugin::class, |
141
|
|
|
ResponsePlugin::class, |
142
|
|
|
ParserPlugin::class, |
143
|
|
|
]; |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
protected function webPlugins(): array |
147
|
|
|
{ |
148
|
|
|
return [ |
149
|
|
|
StartPlugin::class, |
150
|
|
|
WebClosePlugin::class, |
151
|
|
|
FormatPayloadBizContentPlugin::class, |
152
|
|
|
AddPayloadSignaturePlugin::class, |
153
|
|
|
AddRadarPlugin::class, |
154
|
|
|
VerifySignaturePlugin::class, |
155
|
|
|
ResponsePlugin::class, |
156
|
|
|
ParserPlugin::class, |
157
|
|
|
]; |
158
|
|
|
} |
159
|
|
|
} |
160
|
|
|
|