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\Fund\Transfer\RefundPlugin as FundTransferRefundPlugin; |
15
|
|
|
use Yansongda\Pay\Plugin\Alipay\V2\Pay\Agreement\Pay\RefundPlugin as AgreementRefundPlugin; |
16
|
|
|
use Yansongda\Pay\Plugin\Alipay\V2\Pay\App\RefundPlugin as AppRefundPlugin; |
17
|
|
|
use Yansongda\Pay\Plugin\Alipay\V2\Pay\Authorization\Pay\RefundPlugin as AuthorizationRefundPlugin; |
18
|
|
|
use Yansongda\Pay\Plugin\Alipay\V2\Pay\H5\RefundPlugin as H5RefundPlugin; |
19
|
|
|
use Yansongda\Pay\Plugin\Alipay\V2\Pay\Mini\RefundPlugin as MiniRefundPlugin; |
20
|
|
|
use Yansongda\Pay\Plugin\Alipay\V2\Pay\Pos\RefundPlugin as PosRefundPlugin; |
21
|
|
|
use Yansongda\Pay\Plugin\Alipay\V2\Pay\Scan\RefundPlugin as ScanRefundPlugin; |
22
|
|
|
use Yansongda\Pay\Plugin\Alipay\V2\Pay\Web\RefundPlugin as WebRefundPlugin; |
23
|
|
|
use Yansongda\Pay\Plugin\Alipay\V2\ResponsePlugin; |
24
|
|
|
use Yansongda\Pay\Plugin\Alipay\V2\StartPlugin; |
25
|
|
|
use Yansongda\Pay\Plugin\Alipay\V2\VerifySignaturePlugin; |
26
|
|
|
use Yansongda\Supports\Str; |
27
|
|
|
|
28
|
|
|
class RefundShortcut implements ShortcutInterface |
29
|
|
|
{ |
30
|
|
|
/** |
31
|
|
|
* @throws InvalidParamsException |
32
|
|
|
*/ |
33
|
|
|
public function getPlugins(array $params): array |
34
|
|
|
{ |
35
|
|
|
$method = Str::camel($params['_action'] ?? 'default').'Plugins'; |
36
|
|
|
|
37
|
|
|
if (method_exists($this, $method)) { |
38
|
|
|
return $this->{$method}(); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
throw new InvalidParamsException(Exception::PARAMS_SHORTCUT_ACTION_INVALID, "Refund action [{$method}] not supported"); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
protected function defaultPlugins(): array |
45
|
|
|
{ |
46
|
|
|
return $this->webPlugins(); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
protected function agreementPlugins(): array |
50
|
|
|
{ |
51
|
|
|
return [ |
52
|
|
|
StartPlugin::class, |
53
|
|
|
AgreementRefundPlugin::class, |
54
|
|
|
FormatPayloadBizContentPlugin::class, |
55
|
|
|
AddPayloadSignaturePlugin::class, |
56
|
|
|
AddRadarPlugin::class, |
57
|
|
|
VerifySignaturePlugin::class, |
58
|
|
|
ResponsePlugin::class, |
59
|
|
|
ParserPlugin::class, |
60
|
|
|
]; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
protected function appPlugins(): array |
64
|
|
|
{ |
65
|
|
|
return [ |
66
|
|
|
StartPlugin::class, |
67
|
|
|
AppRefundPlugin::class, |
68
|
|
|
FormatPayloadBizContentPlugin::class, |
69
|
|
|
AddPayloadSignaturePlugin::class, |
70
|
|
|
AddRadarPlugin::class, |
71
|
|
|
VerifySignaturePlugin::class, |
72
|
|
|
ResponsePlugin::class, |
73
|
|
|
ParserPlugin::class, |
74
|
|
|
]; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
protected function authorizationPlugins(): array |
78
|
|
|
{ |
79
|
|
|
return [ |
80
|
|
|
StartPlugin::class, |
81
|
|
|
AuthorizationRefundPlugin::class, |
82
|
|
|
FormatPayloadBizContentPlugin::class, |
83
|
|
|
AddPayloadSignaturePlugin::class, |
84
|
|
|
AddRadarPlugin::class, |
85
|
|
|
VerifySignaturePlugin::class, |
86
|
|
|
ResponsePlugin::class, |
87
|
|
|
ParserPlugin::class, |
88
|
|
|
]; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
protected function miniPlugins(): array |
92
|
|
|
{ |
93
|
|
|
return [ |
94
|
|
|
StartPlugin::class, |
95
|
|
|
MiniRefundPlugin::class, |
96
|
|
|
FormatPayloadBizContentPlugin::class, |
97
|
|
|
AddPayloadSignaturePlugin::class, |
98
|
|
|
AddRadarPlugin::class, |
99
|
|
|
VerifySignaturePlugin::class, |
100
|
|
|
ResponsePlugin::class, |
101
|
|
|
ParserPlugin::class, |
102
|
|
|
]; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
protected function posPlugins(): array |
106
|
|
|
{ |
107
|
|
|
return [ |
108
|
|
|
StartPlugin::class, |
109
|
|
|
PosRefundPlugin::class, |
110
|
|
|
FormatPayloadBizContentPlugin::class, |
111
|
|
|
AddPayloadSignaturePlugin::class, |
112
|
|
|
AddRadarPlugin::class, |
113
|
|
|
VerifySignaturePlugin::class, |
114
|
|
|
ResponsePlugin::class, |
115
|
|
|
ParserPlugin::class, |
116
|
|
|
]; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
protected function scanPlugins(): array |
120
|
|
|
{ |
121
|
|
|
return [ |
122
|
|
|
StartPlugin::class, |
123
|
|
|
ScanRefundPlugin::class, |
124
|
|
|
FormatPayloadBizContentPlugin::class, |
125
|
|
|
AddPayloadSignaturePlugin::class, |
126
|
|
|
AddRadarPlugin::class, |
127
|
|
|
VerifySignaturePlugin::class, |
128
|
|
|
ResponsePlugin::class, |
129
|
|
|
ParserPlugin::class, |
130
|
|
|
]; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
protected function h5Plugins(): array |
134
|
|
|
{ |
135
|
|
|
return [ |
136
|
|
|
StartPlugin::class, |
137
|
|
|
H5RefundPlugin::class, |
138
|
|
|
FormatPayloadBizContentPlugin::class, |
139
|
|
|
AddPayloadSignaturePlugin::class, |
140
|
|
|
AddRadarPlugin::class, |
141
|
|
|
VerifySignaturePlugin::class, |
142
|
|
|
ResponsePlugin::class, |
143
|
|
|
ParserPlugin::class, |
144
|
|
|
]; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
protected function webPlugins(): array |
148
|
|
|
{ |
149
|
|
|
return [ |
150
|
|
|
StartPlugin::class, |
151
|
|
|
WebRefundPlugin::class, |
152
|
|
|
FormatPayloadBizContentPlugin::class, |
153
|
|
|
AddPayloadSignaturePlugin::class, |
154
|
|
|
AddRadarPlugin::class, |
155
|
|
|
VerifySignaturePlugin::class, |
156
|
|
|
ResponsePlugin::class, |
157
|
|
|
ParserPlugin::class, |
158
|
|
|
]; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
protected function transferPlugins(): array |
162
|
|
|
{ |
163
|
|
|
return [ |
164
|
|
|
StartPlugin::class, |
165
|
|
|
FundTransferRefundPlugin::class, |
166
|
|
|
FormatPayloadBizContentPlugin::class, |
167
|
|
|
AddPayloadSignaturePlugin::class, |
168
|
|
|
AddRadarPlugin::class, |
169
|
|
|
VerifySignaturePlugin::class, |
170
|
|
|
ResponsePlugin::class, |
171
|
|
|
ParserPlugin::class, |
172
|
|
|
]; |
173
|
|
|
} |
174
|
|
|
} |
175
|
|
|
|