1 | <?php declare(strict_types=1); |
||
10 | final class Notification implements \ArrayAccess, \IteratorAggregate, \JsonSerializable |
||
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 | * Create a new instance. |
||
28 | * |
||
29 | * @param array $values |
||
30 | */ |
||
31 | public function __construct(array $values) |
||
39 | |||
40 | /** |
||
41 | * Create a new instance from request instance. |
||
42 | * |
||
43 | * @param RequestInterface $request |
||
44 | * @return self |
||
45 | */ |
||
46 | public static function fromRequest(RequestInterface $request): self |
||
50 | |||
51 | /** |
||
52 | * Throws an exception if token is invalid. |
||
53 | * |
||
54 | * @param string $secret |
||
55 | * @throws InvalidToken |
||
56 | */ |
||
57 | public function validate(string $secret) |
||
66 | |||
67 | /** |
||
68 | * Is request successful? |
||
69 | * |
||
70 | * @return bool |
||
71 | */ |
||
72 | public function isSuccessful(): bool |
||
76 | |||
77 | /** |
||
78 | * Get current status. |
||
79 | * |
||
80 | * @return string|null |
||
81 | */ |
||
82 | public function getStatus() |
||
86 | |||
87 | /** |
||
88 | * Is request authorized? |
||
89 | * |
||
90 | * @return bool |
||
91 | */ |
||
92 | public function isAuthorized(): bool |
||
96 | |||
97 | /** |
||
98 | * Is request confirmed? |
||
99 | * |
||
100 | * @return bool |
||
101 | */ |
||
102 | public function isConfirmed(): bool |
||
106 | |||
107 | /** |
||
108 | * Is request reversed? |
||
109 | * |
||
110 | * @return bool |
||
111 | */ |
||
112 | public function isReversed(): bool |
||
116 | |||
117 | /** |
||
118 | * Is request refunded? |
||
119 | * |
||
120 | * @return bool |
||
121 | */ |
||
122 | public function isRefunded(): bool |
||
126 | |||
127 | /** |
||
128 | * Is request refunded? |
||
129 | * |
||
130 | * @return bool |
||
131 | */ |
||
132 | public function isPartialRefunded(): bool |
||
136 | |||
137 | /** |
||
138 | * Is request rejected? |
||
139 | * |
||
140 | * @return bool |
||
141 | */ |
||
142 | public function isRejected(): bool |
||
146 | |||
147 | /** |
||
148 | * Get a payment card instance if card id exists. |
||
149 | * |
||
150 | * @return PaymentCard|null |
||
151 | */ |
||
152 | public function getPaymentCard() |
||
158 | |||
159 | /** |
||
160 | * Get an iterator for the values. |
||
161 | * |
||
162 | * @return \ArrayIterator |
||
163 | */ |
||
164 | public function getIterator() |
||
168 | |||
169 | /** |
||
170 | * Determine if a value exists at an offset. |
||
171 | * |
||
172 | * @param mixed $key |
||
173 | * @return bool |
||
174 | */ |
||
175 | public function offsetExists($key) |
||
179 | |||
180 | /** |
||
181 | * Get a value at a given offset. |
||
182 | * |
||
183 | * @param mixed $key |
||
184 | * @return mixed |
||
185 | */ |
||
186 | public function offsetGet($key) |
||
190 | /** |
||
191 | * Set the value at a given offset. |
||
192 | * |
||
193 | * @param mixed $key |
||
194 | * @param mixed $value |
||
195 | * @return void |
||
196 | */ |
||
197 | public function offsetSet($key, $value) |
||
205 | /** |
||
206 | * Unset the value at a given offset. |
||
207 | * |
||
208 | * @param string $key |
||
209 | * @return void |
||
210 | */ |
||
211 | public function offsetUnset($key) |
||
215 | |||
216 | /** |
||
217 | * {@inheritdoc} |
||
218 | */ |
||
219 | public function jsonSerialize() |
||
223 | |||
224 | public function get(string $key) |
||
230 | |||
231 | /** |
||
232 | * Get all values as JSON. |
||
233 | * |
||
234 | * @param int $options |
||
235 | * @return string |
||
236 | */ |
||
237 | public function toJson($options = 0): string |
||
241 | |||
242 | /** |
||
243 | * Get all values as a plain array. |
||
244 | * |
||
245 | * @return array |
||
246 | */ |
||
247 | public function toArray(): array |
||
251 | } |
||
252 |