1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Omnipay\IcepayPayments\Message; |
4
|
|
|
|
5
|
|
|
use Omnipay\Common\Message\AbstractResponse as OmnipayAbstractResponse; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Provides the base implementation for possible responses. |
9
|
|
|
* |
10
|
|
|
* @see http://docs2.icepay.com/payment-process/transaction-status-flow/transaction-statuses/ |
11
|
|
|
*/ |
12
|
|
|
abstract class AbstractResponse extends OmnipayAbstractResponse |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* The transaction has been cancelled by the consumer. |
16
|
|
|
* |
17
|
|
|
* @var string |
18
|
|
|
*/ |
19
|
|
|
public const RESPONSE_STATUS_CANCELLED = 'CANCELLED'; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* A chargeback was requested by the consumer on a transaction under dispute. The system will create a new |
23
|
|
|
* chargeback transaction. All funds will be returned to the consumer. |
24
|
|
|
* |
25
|
|
|
* @var string |
26
|
|
|
*/ |
27
|
|
|
public const RESPONSE_STATUS_CBACK = 'CBACK'; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* The transaction was successfully processed and was cleared by the payments system. Funds have not (yet) been |
31
|
|
|
* received by ICEPAY. It's the customers own risk to deliver products and/or services based on this status. |
32
|
|
|
* |
33
|
|
|
* @var string |
34
|
|
|
*/ |
35
|
|
|
public const RESPONSE_STATUS_COMPLETED = 'COMPLETED'; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* The consumer did not complete the transaction in due time. |
39
|
|
|
* |
40
|
|
|
* @var string |
41
|
|
|
*/ |
42
|
|
|
public const RESPONSE_STATUS_EXPIRED = 'EXPIRED'; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* The transaction failed due to technical reasons. |
46
|
|
|
* |
47
|
|
|
* @var string |
48
|
|
|
*/ |
49
|
|
|
public const RESPONSE_STATUS_FAILED = 'FAILED'; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* A transaction was initiated by the consumer. |
53
|
|
|
* |
54
|
|
|
* @var string |
55
|
|
|
*/ |
56
|
|
|
public const RESPONSE_STATUS_PENDING = 'PENDING'; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* A refund was initiated by the merchant. The system will create a new refund transaction. All (or part of the) |
60
|
|
|
* funds will be returned to the consumer. |
61
|
|
|
* |
62
|
|
|
* @var string |
63
|
|
|
*/ |
64
|
|
|
public const RESPONSE_STATUS_REFUND = 'REFUND'; |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* The transaction failed due to functional reasons. |
68
|
|
|
* |
69
|
|
|
* @var string |
70
|
|
|
*/ |
71
|
|
|
public const RESPONSE_STATUS_REJECTED = 'REJECTED'; |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* The transaction was settled to ICEPAY, funds were received by ICEPAY and the transaction was fully reconciled in |
75
|
|
|
* the payments system. The transaction will be credited to the balance of the merchant and is available for payout. |
76
|
|
|
* |
77
|
|
|
* @var string |
78
|
|
|
*/ |
79
|
|
|
public const RESPONSE_STATUS_SETTLED = 'SETTLED'; |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* The payment process was started by the consumer after initiation of the transaction. |
83
|
|
|
* |
84
|
|
|
* @var string |
85
|
|
|
*/ |
86
|
|
|
public const RESPONSE_STATUS_STARTED = 'STARTED'; |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* {@inheritdoc} |
90
|
|
|
*/ |
91
|
2 |
|
public function isSuccessful(): bool |
92
|
|
|
{ |
93
|
2 |
|
return isset($this->data['contractId']) && isset($this->data['transactionId']); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* There is no real way to know if the user pressed cancelled when the status is delayed. |
98
|
|
|
* We can, however, check if we get an undocumented error message. |
99
|
|
|
* This should not happen, but it still does. |
100
|
|
|
* |
101
|
|
|
* {@inheritdoc} |
102
|
|
|
*/ |
103
|
2 |
|
public function isCancelled(): bool |
104
|
|
|
{ |
105
|
2 |
|
return (isset($this->data[0]['ErrorAt']) && isset($this->data[0]['Description'])); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* {@inheritdoc} |
110
|
|
|
*/ |
111
|
|
|
public function getTransactionReference(): ?string |
112
|
|
|
{ |
113
|
|
|
return $this->data['transactionId'] ?? null; |
114
|
|
|
} |
115
|
|
|
} |
116
|
|
|
|