|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Yansongda\Pay\Shortcut\Unipay; |
|
6
|
|
|
|
|
7
|
|
|
use Yansongda\Pay\Contract\ShortcutInterface; |
|
8
|
|
|
use Yansongda\Pay\Exception\Exception; |
|
9
|
|
|
use Yansongda\Pay\Exception\InvalidParamsException; |
|
10
|
|
|
use Yansongda\Pay\Plugin\ParserPlugin; |
|
11
|
|
|
use Yansongda\Pay\Plugin\Unipay\LaunchPlugin; |
|
12
|
|
|
use Yansongda\Pay\Plugin\Unipay\PreparePlugin; |
|
13
|
|
|
use Yansongda\Pay\Plugin\Unipay\QrCode\ScanFeePlugin; |
|
14
|
|
|
use Yansongda\Pay\Plugin\Unipay\QrCode\ScanNormalPlugin; |
|
15
|
|
|
use Yansongda\Pay\Plugin\Unipay\QrCode\ScanPreAuthPlugin; |
|
16
|
|
|
use Yansongda\Pay\Plugin\Unipay\QrCode\ScanPreOrderPlugin; |
|
17
|
|
|
use Yansongda\Pay\Plugin\Unipay\RadarSignPlugin; |
|
18
|
|
|
use Yansongda\Supports\Str; |
|
19
|
|
|
|
|
20
|
|
|
class ScanShortcut implements ShortcutInterface |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* @throws InvalidParamsException |
|
24
|
|
|
*/ |
|
25
|
|
|
public function getPlugins(array $params): array |
|
26
|
|
|
{ |
|
27
|
|
|
$typeMethod = Str::camel($params['_action'] ?? 'default').'Plugins'; |
|
28
|
|
|
|
|
29
|
|
|
if (method_exists($this, $typeMethod)) { |
|
30
|
|
|
return $this->{$typeMethod}(); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
throw new InvalidParamsException(Exception::PARAMS_SHORTCUT_ACTION_INVALID, "Scan action [{$typeMethod}] not supported"); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
protected function defaultPlugins(): array |
|
37
|
|
|
{ |
|
38
|
|
|
return [ |
|
39
|
|
|
PreparePlugin::class, |
|
40
|
|
|
ScanNormalPlugin::class, |
|
41
|
|
|
RadarSignPlugin::class, |
|
42
|
|
|
LaunchPlugin::class, |
|
43
|
|
|
ParserPlugin::class, |
|
44
|
|
|
]; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
protected function preAuthPlugins(): array |
|
48
|
|
|
{ |
|
49
|
|
|
return [ |
|
50
|
|
|
PreparePlugin::class, |
|
51
|
|
|
ScanPreAuthPlugin::class, |
|
52
|
|
|
RadarSignPlugin::class, |
|
53
|
|
|
LaunchPlugin::class, |
|
54
|
|
|
ParserPlugin::class, |
|
55
|
|
|
]; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
protected function preOrderPlugins(): array |
|
59
|
|
|
{ |
|
60
|
|
|
return [ |
|
61
|
|
|
PreparePlugin::class, |
|
62
|
|
|
ScanPreOrderPlugin::class, |
|
63
|
|
|
RadarSignPlugin::class, |
|
64
|
|
|
LaunchPlugin::class, |
|
65
|
|
|
ParserPlugin::class, |
|
66
|
|
|
]; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
protected function feePlugins(): array |
|
70
|
|
|
{ |
|
71
|
|
|
return [ |
|
72
|
|
|
PreparePlugin::class, |
|
73
|
|
|
ScanFeePlugin::class, |
|
74
|
|
|
RadarSignPlugin::class, |
|
75
|
|
|
LaunchPlugin::class, |
|
76
|
|
|
ParserPlugin::class, |
|
77
|
|
|
]; |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|