|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Yansongda\Pay\Config; |
|
6
|
|
|
|
|
7
|
|
|
use Yansongda\Pay\Pay; |
|
8
|
|
|
|
|
9
|
|
|
class AlipayConfig implements ConfigInterface |
|
10
|
|
|
{ |
|
11
|
|
|
public function __construct( |
|
12
|
|
|
public string $app_id, |
|
13
|
|
|
public string $app_secret_cert, |
|
14
|
|
|
public string $app_public_cert_path, |
|
15
|
|
|
public string $alipay_public_cert_path, |
|
16
|
|
|
public string $alipay_root_cert_path, |
|
17
|
|
|
public string $return_url = '', |
|
18
|
|
|
public string $notify_url = '', |
|
19
|
|
|
public string $app_auth_token = '', |
|
20
|
|
|
public string $service_provider_id = '', |
|
21
|
|
|
public int $mode = Pay::MODE_NORMAL, |
|
22
|
|
|
) { |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
public function toArray(): array |
|
26
|
|
|
{ |
|
27
|
|
|
return [ |
|
28
|
|
|
'app_id' => $this->app_id, |
|
29
|
|
|
'app_secret_cert' => $this->app_secret_cert, |
|
30
|
|
|
'app_public_cert_path' => $this->app_public_cert_path, |
|
31
|
|
|
'alipay_public_cert_path' => $this->alipay_public_cert_path, |
|
32
|
|
|
'alipay_root_cert_path' => $this->alipay_root_cert_path, |
|
33
|
|
|
'return_url' => $this->return_url, |
|
34
|
|
|
'notify_url' => $this->notify_url, |
|
35
|
|
|
'app_auth_token' => $this->app_auth_token, |
|
36
|
|
|
'service_provider_id' => $this->service_provider_id, |
|
37
|
|
|
'mode' => $this->mode, |
|
38
|
|
|
]; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public static function fromArray(array $config): self |
|
42
|
|
|
{ |
|
43
|
|
|
return new self( |
|
44
|
|
|
app_id: $config['app_id'] ?? '', |
|
45
|
|
|
app_secret_cert: $config['app_secret_cert'] ?? '', |
|
46
|
|
|
app_public_cert_path: $config['app_public_cert_path'] ?? '', |
|
47
|
|
|
alipay_public_cert_path: $config['alipay_public_cert_path'] ?? '', |
|
48
|
|
|
alipay_root_cert_path: $config['alipay_root_cert_path'] ?? '', |
|
49
|
|
|
return_url: $config['return_url'] ?? '', |
|
50
|
|
|
notify_url: $config['notify_url'] ?? '', |
|
51
|
|
|
app_auth_token: $config['app_auth_token'] ?? '', |
|
52
|
|
|
service_provider_id: $config['service_provider_id'] ?? '', |
|
53
|
|
|
mode: $config['mode'] ?? Pay::MODE_NORMAL, |
|
54
|
|
|
); |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|