1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace FluxSE\PayumStripe\Api; |
6
|
|
|
|
7
|
|
|
final class Keys implements KeysInterface |
8
|
|
|
{ |
9
|
|
|
/** @var string[] */ |
10
|
|
|
private $webhookSecretKeys; |
11
|
|
|
/** @var string */ |
12
|
|
|
private $publishable; |
13
|
|
|
/** @var string */ |
14
|
|
|
private $secret; |
15
|
|
|
/** @var string[] */ |
16
|
|
|
private $paymentMethodTypes; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @param string[] $webhookSecretKeys |
20
|
|
|
*/ |
21
|
|
|
public function __construct( |
22
|
|
|
string $publishable, |
23
|
|
|
string $secret, |
24
|
|
|
array $webhookSecretKeys = [], |
25
|
|
|
array $paymentMethodTypes = [] |
26
|
|
|
) { |
27
|
|
|
$this->publishable = $publishable; |
28
|
|
|
$this->secret = $secret; |
29
|
|
|
$this->webhookSecretKeys = $webhookSecretKeys; |
30
|
|
|
$this->paymentMethodTypes = $paymentMethodTypes; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function getSecretKey(): string |
34
|
|
|
{ |
35
|
|
|
return $this->secret; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function getPublishableKey(): string |
39
|
|
|
{ |
40
|
|
|
return $this->publishable; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function getWebhookSecretKeys(): array |
44
|
|
|
{ |
45
|
|
|
return $this->webhookSecretKeys; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function hasWebhookSecretKey(string $webhookSecretKey): bool |
49
|
|
|
{ |
50
|
|
|
return in_array($webhookSecretKey, $this->webhookSecretKeys); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function addWebhookSecretKey(string $webhookSecretKey): void |
54
|
|
|
{ |
55
|
|
|
if (!$this->hasWebhookSecretKey($webhookSecretKey)) { |
56
|
|
|
$this->webhookSecretKeys[] = $webhookSecretKey; |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function setWebhookSecretKeys(array $webhookSecretKeys): void |
61
|
|
|
{ |
62
|
|
|
$this->webhookSecretKeys = $webhookSecretKeys; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function getPaymentMethodTypes(): array |
66
|
|
|
{ |
67
|
|
|
return $this->paymentMethodTypes; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function hasPaymentMethodType(string $paymentMethodType): bool |
71
|
|
|
{ |
72
|
|
|
return in_array($paymentMethodType, $this->paymentMethodTypes); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function addPaymentMethodType(string $paymentMethodType): void |
76
|
|
|
{ |
77
|
|
|
if (!$this->hasPaymentMethodType($paymentMethodType)) { |
78
|
|
|
$this->paymentMethodTypes[] = $paymentMethodType; |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function setPaymentMethodTypes(array $paymentMethodTypes): void |
83
|
|
|
{ |
84
|
|
|
$this->paymentMethodTypes = $paymentMethodTypes; |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|