|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Yansongda\Pay\Shortcut\Wechat; |
|
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\Wechat\AddRadarPlugin; |
|
14
|
|
|
use Yansongda\Pay\Plugin\Wechat\ResponsePlugin; |
|
15
|
|
|
use Yansongda\Pay\Plugin\Wechat\V3\AddPayloadSignaturePlugin; |
|
16
|
|
|
use Yansongda\Pay\Plugin\Wechat\V3\Pay\App\RefundPlugin as AppRefundPlugin; |
|
17
|
|
|
use Yansongda\Pay\Plugin\Wechat\V3\Pay\Combine\RefundPlugin as CombineRefundPlugin; |
|
18
|
|
|
use Yansongda\Pay\Plugin\Wechat\V3\Pay\H5\RefundPlugin as H5RefundPlugin; |
|
19
|
|
|
use Yansongda\Pay\Plugin\Wechat\V3\Pay\Jsapi\RefundPlugin as JsapiRefundPlugin; |
|
20
|
|
|
use Yansongda\Pay\Plugin\Wechat\V3\Pay\Mini\RefundPlugin as MiniRefundPlugin; |
|
21
|
|
|
use Yansongda\Pay\Plugin\Wechat\V3\Pay\Native\RefundPlugin as NativeRefundPlugin; |
|
22
|
|
|
use Yansongda\Pay\Plugin\Wechat\V3\VerifySignaturePlugin; |
|
23
|
|
|
use Yansongda\Supports\Str; |
|
24
|
|
|
|
|
25
|
|
|
class RefundShortcut implements ShortcutInterface |
|
26
|
|
|
{ |
|
27
|
|
|
/** |
|
28
|
|
|
* @throws InvalidParamsException |
|
29
|
|
|
*/ |
|
30
|
|
|
public function getPlugins(array $params): array |
|
31
|
|
|
{ |
|
32
|
|
|
$method = Str::camel($params['_action'] ?? 'default').'Plugins'; |
|
33
|
|
|
|
|
34
|
|
|
if (method_exists($this, $method)) { |
|
35
|
|
|
return $this->{$method}(); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
throw new InvalidParamsException(Exception::PARAMS_SHORTCUT_ACTION_INVALID, "您所提供的 action 方法 [{$method}] 不支持,请参考文档或源码确认"); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
protected function defaultPlugins(): array |
|
42
|
|
|
{ |
|
43
|
|
|
return $this->jsapiPlugins(); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
protected function appPlugins(): array |
|
47
|
|
|
{ |
|
48
|
|
|
return [ |
|
49
|
|
|
StartPlugin::class, |
|
50
|
|
|
AppRefundPlugin::class, |
|
51
|
|
|
AddPayloadBodyPlugin::class, |
|
52
|
|
|
AddPayloadSignaturePlugin::class, |
|
53
|
|
|
AddRadarPlugin::class, |
|
54
|
|
|
VerifySignaturePlugin::class, |
|
55
|
|
|
ResponsePlugin::class, |
|
56
|
|
|
ParserPlugin::class, |
|
57
|
|
|
]; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
protected function combinePlugins(): array |
|
61
|
|
|
{ |
|
62
|
|
|
return [ |
|
63
|
|
|
StartPlugin::class, |
|
64
|
|
|
CombineRefundPlugin::class, |
|
65
|
|
|
AddPayloadBodyPlugin::class, |
|
66
|
|
|
AddPayloadSignaturePlugin::class, |
|
67
|
|
|
AddRadarPlugin::class, |
|
68
|
|
|
VerifySignaturePlugin::class, |
|
69
|
|
|
ResponsePlugin::class, |
|
70
|
|
|
ParserPlugin::class, |
|
71
|
|
|
]; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
protected function h5Plugins(): array |
|
75
|
|
|
{ |
|
76
|
|
|
return [ |
|
77
|
|
|
StartPlugin::class, |
|
78
|
|
|
H5RefundPlugin::class, |
|
79
|
|
|
AddPayloadBodyPlugin::class, |
|
80
|
|
|
AddPayloadSignaturePlugin::class, |
|
81
|
|
|
AddRadarPlugin::class, |
|
82
|
|
|
VerifySignaturePlugin::class, |
|
83
|
|
|
ResponsePlugin::class, |
|
84
|
|
|
ParserPlugin::class, |
|
85
|
|
|
]; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
protected function jsapiPlugins(): array |
|
89
|
|
|
{ |
|
90
|
|
|
return [ |
|
91
|
|
|
StartPlugin::class, |
|
92
|
|
|
JsapiRefundPlugin::class, |
|
93
|
|
|
AddPayloadBodyPlugin::class, |
|
94
|
|
|
AddPayloadSignaturePlugin::class, |
|
95
|
|
|
AddRadarPlugin::class, |
|
96
|
|
|
VerifySignaturePlugin::class, |
|
97
|
|
|
ResponsePlugin::class, |
|
98
|
|
|
ParserPlugin::class, |
|
99
|
|
|
]; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
protected function miniPlugins(): array |
|
103
|
|
|
{ |
|
104
|
|
|
return [ |
|
105
|
|
|
StartPlugin::class, |
|
106
|
|
|
MiniRefundPlugin::class, |
|
107
|
|
|
AddPayloadBodyPlugin::class, |
|
108
|
|
|
AddPayloadSignaturePlugin::class, |
|
109
|
|
|
AddRadarPlugin::class, |
|
110
|
|
|
VerifySignaturePlugin::class, |
|
111
|
|
|
ResponsePlugin::class, |
|
112
|
|
|
ParserPlugin::class, |
|
113
|
|
|
]; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
protected function nativePlugins(): array |
|
117
|
|
|
{ |
|
118
|
|
|
return [ |
|
119
|
|
|
StartPlugin::class, |
|
120
|
|
|
NativeRefundPlugin::class, |
|
121
|
|
|
AddPayloadBodyPlugin::class, |
|
122
|
|
|
AddPayloadSignaturePlugin::class, |
|
123
|
|
|
AddRadarPlugin::class, |
|
124
|
|
|
VerifySignaturePlugin::class, |
|
125
|
|
|
ResponsePlugin::class, |
|
126
|
|
|
ParserPlugin::class, |
|
127
|
|
|
]; |
|
128
|
|
|
} |
|
129
|
|
|
} |
|
130
|
|
|
|