|
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\Marketing\MchTransfer\CancelPlugin; |
|
17
|
|
|
use Yansongda\Pay\Plugin\Wechat\V3\VerifySignaturePlugin; |
|
18
|
|
|
use Yansongda\Supports\Str; |
|
19
|
|
|
|
|
20
|
|
|
class CancelShortcut 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->mchTransferPlugins(); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
protected function mchTransferPlugins(): array |
|
42
|
|
|
{ |
|
43
|
|
|
return [ |
|
44
|
|
|
StartPlugin::class, |
|
45
|
|
|
CancelPlugin::class, |
|
46
|
|
|
AddPayloadBodyPlugin::class, |
|
47
|
|
|
AddPayloadSignaturePlugin::class, |
|
48
|
|
|
AddRadarPlugin::class, |
|
49
|
|
|
VerifySignaturePlugin::class, |
|
50
|
|
|
ResponsePlugin::class, |
|
51
|
|
|
ParserPlugin::class, |
|
52
|
|
|
]; |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|