1 | <?php |
||
5 | final class TerminalResponse |
||
6 | { |
||
7 | /** |
||
8 | * Payture error codes. |
||
9 | * |
||
10 | * @see https://payture.com/api#error-codes_ |
||
11 | */ |
||
12 | public const ERROR_NONE = 'NONE'; |
||
13 | public const ERROR_ORDER_TIME_OUT = 'ORDER_TIME_OUT'; |
||
14 | public const ERROR_ILLEGAL_ORDER_STATE = 'ILLEGAL_ORDER_STATE'; |
||
15 | public const ERROR_PROCESSING = 'PROCESSING_ERROR'; |
||
16 | public const ERROR_ISSUER_FAIL = 'ISSUER_FAIL'; |
||
17 | public const ERROR_AMOUNT = 'AMOUNT_ERROR'; |
||
18 | public const ERROR_PROCESSING_FRAUD = 'PROCESSING_FRAUD_ERROR'; |
||
19 | public const ERROR_ISSUER_BLOCKED_CARD = 'ISSUER_BLOCKED_CARD'; |
||
20 | |||
21 | private const STATUS_SUCCESS = 'True'; |
||
22 | |||
23 | private const STATE_NEW = 'New'; |
||
24 | private const STATE_PREAUTH_3DS = 'PreAuthorized3DS'; |
||
25 | private const STATE_PREAUTH_AF = 'PreAuthorizedAF'; |
||
26 | private const STATE_AUTHORIZED = 'Authorized'; |
||
27 | private const STATE_VOIDED = 'Voided'; // locked and unlocked |
||
28 | private const STATE_CHARGED = 'Charged'; |
||
29 | private const STATE_REFUNDED = 'Refunded'; |
||
30 | private const STATE_FORWARDED = 'Forwarded'; |
||
31 | private const STATE_ERROR = 'Error'; |
||
32 | |||
33 | // custom status, for case with error code NONE |
||
34 | private const STATE_PENDING = 'Pending'; |
||
35 | |||
36 | /** |
||
37 | * Operation success flag. |
||
38 | * |
||
39 | * @var bool |
||
40 | */ |
||
41 | private $success; |
||
42 | |||
43 | /** |
||
44 | * Payment ID in Merchant system. |
||
45 | * |
||
46 | * @var string |
||
47 | */ |
||
48 | private $orderId; |
||
49 | |||
50 | /** |
||
51 | * Operation amount. |
||
52 | * |
||
53 | * @var int |
||
54 | */ |
||
55 | private $amount = 0; |
||
56 | |||
57 | /** |
||
58 | * Payment status. |
||
59 | * |
||
60 | * @var string|null |
||
61 | */ |
||
62 | private $state; |
||
63 | |||
64 | /** |
||
65 | * Payment ID in Payture system. |
||
66 | * |
||
67 | * @var string |
||
68 | */ |
||
69 | private $sessionId = ''; |
||
70 | |||
71 | /** |
||
72 | * Unique transaction number assigned by the acquiring bank. |
||
73 | * |
||
74 | * @var string|null |
||
75 | */ |
||
76 | private $rrn; |
||
77 | |||
78 | /** Error code. |
||
79 | * |
||
80 | * @var string |
||
81 | */ |
||
82 | private $errorCode = ''; |
||
83 | |||
84 | /** |
||
85 | * @param string $success Operation success flag |
||
86 | * @param mixed $orderId Payment ID in Merchant system |
||
87 | */ |
||
88 | 4 | public function __construct(string $success, string $orderId) |
|
93 | |||
94 | 1 | public function isSuccess(): bool |
|
98 | |||
99 | 1 | public function getOrderId(): string |
|
103 | |||
104 | 1 | public function getAmount(): int |
|
108 | |||
109 | 1 | public function setAmount(int $amount): void |
|
113 | |||
114 | 1 | public function getRrn(): ?string |
|
118 | |||
119 | 1 | public function getSessionId(): string |
|
123 | |||
124 | 1 | public function setSessionId(string $sessionId): void |
|
128 | |||
129 | 3 | public function getErrorCode(): string |
|
133 | |||
134 | 3 | public function setErrorCode(string $errorCode): void |
|
151 | |||
152 | 1 | public function setState(string $state): void |
|
156 | |||
157 | 1 | public function setRrn(string $rrn): void |
|
161 | |||
162 | 1 | public function isNewState(): bool |
|
166 | |||
167 | 1 | public function isPreAuthorized3DSState(): bool |
|
171 | |||
172 | 1 | public function isPreAuthorizedAFState(): bool |
|
176 | |||
177 | 1 | public function isAuthorizedState(): bool |
|
181 | |||
182 | 1 | public function isVoidedState(): bool |
|
186 | |||
187 | 1 | public function isChargedState(): bool |
|
191 | |||
192 | 1 | public function isRefundedState(): bool |
|
196 | |||
197 | 1 | public function isForwardedState(): bool |
|
201 | |||
202 | 1 | public function isErrorState(): bool |
|
206 | |||
207 | 1 | public function isTimeout(): bool |
|
211 | |||
212 | 1 | public function isIllegalOrderState(): bool |
|
216 | |||
217 | 1 | public function isProcessingError(): bool |
|
221 | |||
222 | 1 | public function isFraudError(): bool |
|
226 | |||
227 | 1 | public function isAmountError(): bool |
|
231 | |||
232 | 1 | public function isIssuerFail(): bool |
|
236 | |||
237 | 1 | private function isStateEqual($expectedState): bool |
|
241 | } |
||
242 |