1 | <?php declare(strict_types=1); |
||
10 | final class Notification |
||
11 | { |
||
12 | use HasSignature; |
||
13 | |||
14 | const AUTHORIZED = 'AUTHORIZED'; |
||
15 | const CONFIRMED = 'CONFIRMED'; |
||
16 | const PARTIAL_REFUNDED = 'PARTIAL_REFUNDED'; |
||
17 | const REFUNDED = 'REFUNDED'; |
||
18 | const REJECTED = 'REJECTED'; |
||
19 | const REVERSED = 'REVERSED'; |
||
20 | |||
21 | /** |
||
22 | * @var array |
||
23 | */ |
||
24 | private $values; |
||
25 | |||
26 | /** |
||
27 | * @var PaymentCard |
||
28 | */ |
||
29 | private $paymentCard; |
||
30 | |||
31 | /** |
||
32 | * Create a new instance. |
||
33 | * |
||
34 | * @param array $values |
||
35 | */ |
||
36 | public function __construct(array $values) |
||
44 | |||
45 | /** |
||
46 | * Create a new instance from request instance. |
||
47 | * |
||
48 | * @param RequestInterface $request |
||
49 | * @return self |
||
50 | */ |
||
51 | public static function fromRequest(RequestInterface $request): self |
||
55 | |||
56 | /** |
||
57 | * Throws an exception if token is invalid. |
||
58 | * |
||
59 | * @param string $secret |
||
60 | * @throws InvalidToken |
||
61 | */ |
||
62 | public function validate(string $secret) |
||
68 | |||
69 | /** |
||
70 | * Is request successful? |
||
71 | * |
||
72 | * @return bool |
||
73 | */ |
||
74 | public function isSuccessful(): bool |
||
78 | |||
79 | /** |
||
80 | * Is request authorized? |
||
81 | * |
||
82 | * @return bool |
||
83 | */ |
||
84 | public function isAuthorized(): bool |
||
88 | |||
89 | /** |
||
90 | * Is request confirmed? |
||
91 | * |
||
92 | * @return bool |
||
93 | */ |
||
94 | public function isConfirmed(): bool |
||
98 | |||
99 | /** |
||
100 | * Is request reversed? |
||
101 | * |
||
102 | * @return bool |
||
103 | */ |
||
104 | public function isReversed(): bool |
||
108 | |||
109 | /** |
||
110 | * Is request refunded? |
||
111 | * |
||
112 | * @return bool |
||
113 | */ |
||
114 | public function isRefunded(): bool |
||
118 | |||
119 | /** |
||
120 | * Is request refunded? |
||
121 | * |
||
122 | * @return bool |
||
123 | */ |
||
124 | public function isPartialRefunded(): bool |
||
128 | |||
129 | /** |
||
130 | * Is request rejected? |
||
131 | * |
||
132 | * @return bool |
||
133 | */ |
||
134 | public function isRejected(): bool |
||
138 | |||
139 | /** |
||
140 | * Get a payment card instance if card id exists. |
||
141 | * |
||
142 | * @return PaymentCard|null |
||
143 | */ |
||
144 | public function getPaymentCard() |
||
152 | |||
153 | /** |
||
154 | * Get same value by key. |
||
155 | * |
||
156 | * @param string $key |
||
157 | * @return string|null |
||
158 | */ |
||
159 | public function get(string $key) |
||
163 | |||
164 | /** |
||
165 | * Get all values as JSON. |
||
166 | * |
||
167 | * @param int $options |
||
168 | * @return string |
||
169 | */ |
||
170 | public function toJson($options = 0): string |
||
174 | |||
175 | /** |
||
176 | * Get all values as a plain array. |
||
177 | * |
||
178 | * @return array |
||
179 | */ |
||
180 | public function toArray(): array |
||
184 | } |
||
185 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: