|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Yansongda\Pay\Shortcut\Alipay; |
|
6
|
|
|
|
|
7
|
|
|
use Yansongda\Pay\Contract\ShortcutInterface; |
|
8
|
|
|
use Yansongda\Pay\Exception\Exception; |
|
9
|
|
|
use Yansongda\Pay\Exception\InvalidParamsException; |
|
10
|
|
|
use Yansongda\Pay\Plugin\Alipay\AddRadarPlugin; |
|
11
|
|
|
use Yansongda\Pay\Plugin\Alipay\AddSignaturePlugin; |
|
12
|
|
|
use Yansongda\Pay\Plugin\Alipay\FormatBizContentPlugin; |
|
13
|
|
|
use Yansongda\Pay\Plugin\Alipay\Pay\Agreement\CancelPlugin as AgreementCancelPlugin; |
|
14
|
|
|
use Yansongda\Pay\Plugin\Alipay\Pay\Authorization\CancelPlugin as AuthorizationCancelPlugin; |
|
15
|
|
|
use Yansongda\Pay\Plugin\Alipay\Pay\Mini\CancelPlugin as MiniCancelPlugin; |
|
16
|
|
|
use Yansongda\Pay\Plugin\Alipay\Pay\Pos\CancelPlugin as PosCancelPlugin; |
|
17
|
|
|
use Yansongda\Pay\Plugin\Alipay\Pay\Scan\CancelPlugin as ScanCancelPlugin; |
|
18
|
|
|
use Yansongda\Pay\Plugin\Alipay\ResponsePlugin; |
|
19
|
|
|
use Yansongda\Pay\Plugin\Alipay\StartPlugin; |
|
20
|
|
|
use Yansongda\Pay\Plugin\Alipay\VerifySignaturePlugin; |
|
21
|
|
|
use Yansongda\Pay\Plugin\ParserPlugin; |
|
22
|
|
|
use Yansongda\Supports\Str; |
|
23
|
|
|
|
|
24
|
|
|
class CancelShortcut implements ShortcutInterface |
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* @throws InvalidParamsException |
|
28
|
|
|
*/ |
|
29
|
|
|
public function getPlugins(array $params): array |
|
30
|
|
|
{ |
|
31
|
|
|
$method = Str::camel($params['_action'] ?? 'default').'Plugins'; |
|
32
|
|
|
|
|
33
|
|
|
if (method_exists($this, $method)) { |
|
34
|
|
|
return $this->{$method}(); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
throw new InvalidParamsException(Exception::SHORTCUT_MULTI_ACTION_ERROR, "Cancel action [{$method}] not supported"); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
protected function defaultPlugins(): array |
|
41
|
|
|
{ |
|
42
|
|
|
return [ |
|
43
|
|
|
StartPlugin::class, |
|
44
|
|
|
PosCancelPlugin::class, |
|
45
|
|
|
FormatBizContentPlugin::class, |
|
46
|
|
|
AddSignaturePlugin::class, |
|
47
|
|
|
AddRadarPlugin::class, |
|
48
|
|
|
VerifySignaturePlugin::class, |
|
49
|
|
|
ResponsePlugin::class, |
|
50
|
|
|
ParserPlugin::class, |
|
51
|
|
|
]; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
protected function agreementPlugins(): array |
|
55
|
|
|
{ |
|
56
|
|
|
return [ |
|
57
|
|
|
StartPlugin::class, |
|
58
|
|
|
AgreementCancelPlugin::class, |
|
59
|
|
|
FormatBizContentPlugin::class, |
|
60
|
|
|
AddSignaturePlugin::class, |
|
61
|
|
|
AddRadarPlugin::class, |
|
62
|
|
|
VerifySignaturePlugin::class, |
|
63
|
|
|
ResponsePlugin::class, |
|
64
|
|
|
ParserPlugin::class, |
|
65
|
|
|
]; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
protected function authorizationPlugins(): array |
|
69
|
|
|
{ |
|
70
|
|
|
return [ |
|
71
|
|
|
StartPlugin::class, |
|
72
|
|
|
AuthorizationCancelPlugin::class, |
|
73
|
|
|
FormatBizContentPlugin::class, |
|
74
|
|
|
AddSignaturePlugin::class, |
|
75
|
|
|
AddRadarPlugin::class, |
|
76
|
|
|
VerifySignaturePlugin::class, |
|
77
|
|
|
ResponsePlugin::class, |
|
78
|
|
|
ParserPlugin::class, |
|
79
|
|
|
]; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
protected function miniPlugins(): array |
|
83
|
|
|
{ |
|
84
|
|
|
return [ |
|
85
|
|
|
StartPlugin::class, |
|
86
|
|
|
MiniCancelPlugin::class, |
|
87
|
|
|
FormatBizContentPlugin::class, |
|
88
|
|
|
AddSignaturePlugin::class, |
|
89
|
|
|
AddRadarPlugin::class, |
|
90
|
|
|
VerifySignaturePlugin::class, |
|
91
|
|
|
ResponsePlugin::class, |
|
92
|
|
|
ParserPlugin::class, |
|
93
|
|
|
]; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
protected function posPlugins(): array |
|
97
|
|
|
{ |
|
98
|
|
|
return [ |
|
99
|
|
|
StartPlugin::class, |
|
100
|
|
|
PosCancelPlugin::class, |
|
101
|
|
|
FormatBizContentPlugin::class, |
|
102
|
|
|
AddSignaturePlugin::class, |
|
103
|
|
|
AddRadarPlugin::class, |
|
104
|
|
|
VerifySignaturePlugin::class, |
|
105
|
|
|
ResponsePlugin::class, |
|
106
|
|
|
ParserPlugin::class, |
|
107
|
|
|
]; |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
protected function scanPlugins(): array |
|
111
|
|
|
{ |
|
112
|
|
|
return [ |
|
113
|
|
|
StartPlugin::class, |
|
114
|
|
|
ScanCancelPlugin::class, |
|
115
|
|
|
FormatBizContentPlugin::class, |
|
116
|
|
|
AddSignaturePlugin::class, |
|
117
|
|
|
AddRadarPlugin::class, |
|
118
|
|
|
VerifySignaturePlugin::class, |
|
119
|
|
|
ResponsePlugin::class, |
|
120
|
|
|
ParserPlugin::class, |
|
121
|
|
|
]; |
|
122
|
|
|
} |
|
123
|
|
|
} |
|
124
|
|
|
|