|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Generalization over Omnipay and Payum |
|
4
|
|
|
* |
|
5
|
|
|
* @link https://github.com/hiqdev/php-merchant |
|
6
|
|
|
* @package php-merchant |
|
7
|
|
|
* @license BSD-3-Clause |
|
8
|
|
|
* @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/) |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace hiqdev\php\merchant\response; |
|
12
|
|
|
|
|
13
|
|
|
use Money\Currency; |
|
14
|
|
|
use Money\Money; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Class CompletePurchaseResponse. |
|
18
|
|
|
* |
|
19
|
|
|
* @author Dmytro Naumenko <[email protected]> |
|
20
|
|
|
*/ |
|
21
|
|
|
class CompletePurchaseResponse |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* @var bool |
|
25
|
|
|
*/ |
|
26
|
|
|
protected $isSuccessful; |
|
27
|
|
|
/** |
|
28
|
|
|
* @var Currency |
|
29
|
|
|
*/ |
|
30
|
|
|
protected $currency; |
|
31
|
|
|
/** |
|
32
|
|
|
* @var Money |
|
33
|
|
|
*/ |
|
34
|
|
|
protected $amount; |
|
35
|
|
|
/** |
|
36
|
|
|
* @var Money |
|
37
|
|
|
*/ |
|
38
|
|
|
protected $fee; |
|
39
|
|
|
/** |
|
40
|
|
|
* @var \DateTime |
|
41
|
|
|
*/ |
|
42
|
|
|
protected $time; |
|
43
|
|
|
/** |
|
44
|
|
|
* @var string |
|
45
|
|
|
*/ |
|
46
|
|
|
protected $transactionReference; |
|
47
|
|
|
/** |
|
48
|
|
|
* @var string |
|
49
|
|
|
*/ |
|
50
|
|
|
protected $transactionId; |
|
51
|
|
|
/** |
|
52
|
|
|
* @var string |
|
53
|
|
|
*/ |
|
54
|
|
|
protected $payer; |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @return string |
|
58
|
|
|
*/ |
|
59
|
10 |
|
public function getTransactionId() |
|
60
|
|
|
{ |
|
61
|
10 |
|
return $this->transactionId; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @param string $transactionId |
|
66
|
|
|
* @return CompletePurchaseResponse |
|
67
|
|
|
*/ |
|
68
|
10 |
|
public function setTransactionId($transactionId) |
|
69
|
|
|
{ |
|
70
|
10 |
|
$this->transactionId = $transactionId; |
|
71
|
|
|
|
|
72
|
10 |
|
return $this; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @return Currency |
|
77
|
|
|
*/ |
|
78
|
10 |
|
public function getCurrency() |
|
79
|
|
|
{ |
|
80
|
10 |
|
return $this->currency; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @return Money |
|
85
|
|
|
*/ |
|
86
|
10 |
|
public function getAmount(): Money |
|
87
|
|
|
{ |
|
88
|
10 |
|
return $this->amount; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* @param Money $amount |
|
93
|
|
|
* @return CompletePurchaseResponse |
|
94
|
|
|
*/ |
|
95
|
10 |
|
public function setAmount(Money $amount) |
|
96
|
|
|
{ |
|
97
|
10 |
|
$this->amount = $amount; |
|
98
|
10 |
|
$this->currency = $amount->getCurrency(); |
|
99
|
|
|
|
|
100
|
10 |
|
return $this; |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* @return Money |
|
105
|
|
|
*/ |
|
106
|
10 |
|
public function getFee() |
|
107
|
|
|
{ |
|
108
|
10 |
|
if ($this->fee !== null) { |
|
109
|
4 |
|
return $this->fee; |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
6 |
|
return new Money(0, $this->getCurrency()); |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* @param Money $fee |
|
117
|
|
|
* @return CompletePurchaseResponse |
|
118
|
|
|
*/ |
|
119
|
4 |
|
public function setFee($fee) |
|
120
|
|
|
{ |
|
121
|
4 |
|
$this->fee = $fee; |
|
122
|
|
|
|
|
123
|
4 |
|
return $this; |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
/** |
|
127
|
|
|
* @return \DateTime of purchase in UTC |
|
128
|
|
|
*/ |
|
129
|
10 |
|
public function getTime() |
|
130
|
|
|
{ |
|
131
|
10 |
|
return $this->time; |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
/** |
|
135
|
|
|
* @param \DateTime $time In UTC |
|
136
|
|
|
* @return CompletePurchaseResponse |
|
137
|
|
|
*/ |
|
138
|
10 |
|
public function setTime(\DateTime $time) |
|
139
|
|
|
{ |
|
140
|
10 |
|
$this->time = $time; |
|
141
|
|
|
|
|
142
|
10 |
|
return $this; |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
/** |
|
146
|
|
|
* @return string |
|
147
|
|
|
*/ |
|
148
|
10 |
|
public function getTransactionReference() |
|
149
|
|
|
{ |
|
150
|
10 |
|
return $this->transactionReference; |
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
|
|
/** |
|
154
|
|
|
* @param string $transactionReference |
|
155
|
|
|
* @return CompletePurchaseResponse |
|
156
|
|
|
*/ |
|
157
|
10 |
|
public function setTransactionReference($transactionReference) |
|
158
|
|
|
{ |
|
159
|
10 |
|
$this->transactionReference = $transactionReference; |
|
160
|
|
|
|
|
161
|
10 |
|
return $this; |
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
/** |
|
165
|
|
|
* @return string |
|
166
|
|
|
*/ |
|
167
|
4 |
|
public function getPayer() |
|
168
|
|
|
{ |
|
169
|
4 |
|
return $this->payer; |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
|
|
/** |
|
173
|
|
|
* @param string $payer |
|
174
|
|
|
* @return CompletePurchaseResponse |
|
175
|
|
|
*/ |
|
176
|
10 |
|
public function setPayer($payer) |
|
177
|
|
|
{ |
|
178
|
10 |
|
$this->payer = $payer; |
|
179
|
|
|
|
|
180
|
10 |
|
return $this; |
|
181
|
|
|
} |
|
182
|
|
|
|
|
183
|
|
|
/** |
|
184
|
|
|
* @param string $isSuccessful |
|
185
|
|
|
* @return CompletePurchaseResponse |
|
186
|
|
|
*/ |
|
187
|
10 |
|
public function setIsSuccessful($isSuccessful) |
|
188
|
|
|
{ |
|
189
|
10 |
|
$this->isSuccessful = $isSuccessful; |
|
|
|
|
|
|
190
|
|
|
|
|
191
|
10 |
|
return $this; |
|
192
|
|
|
} |
|
193
|
|
|
|
|
194
|
|
|
/** |
|
195
|
|
|
* @return string |
|
196
|
|
|
*/ |
|
197
|
10 |
|
public function getIsSuccessful() |
|
198
|
|
|
{ |
|
199
|
10 |
|
return $this->isSuccessful; |
|
200
|
|
|
} |
|
201
|
|
|
} |
|
202
|
|
|
|
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.