|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Cardinity\Method\Payment; |
|
4
|
|
|
|
|
5
|
|
|
use Cardinity\Method\ResultObject; |
|
6
|
|
|
|
|
7
|
|
|
class Payment extends ResultObject |
|
8
|
|
|
{ |
|
9
|
|
|
/** @type string ID of the payment. |
|
10
|
|
|
Value assigned by Cardinity. */ |
|
11
|
|
|
private $id; |
|
12
|
|
|
|
|
13
|
|
|
/** @type float Amount charged shown in #0.00 format. */ |
|
14
|
|
|
private $amount; |
|
15
|
|
|
|
|
16
|
|
|
/** @type string Three-letter ISO currency code representing the currency in |
|
17
|
|
|
which the charge was made. |
|
18
|
|
|
Supported currencies: EUR, USD. */ |
|
19
|
|
|
private $currency; |
|
20
|
|
|
|
|
21
|
|
|
/** @type string Payment creation time as defined in RFC 3339 Section 5.6. |
|
22
|
|
|
UTC timezone. |
|
23
|
|
|
Value assigned by Cardinity. */ |
|
24
|
|
|
private $created; |
|
25
|
|
|
|
|
26
|
|
|
/** @type string Payment type. |
|
27
|
|
|
Can be one of the following: authorization, purchase. |
|
28
|
|
|
Value assigned by Cardinity. */ |
|
29
|
|
|
private $type; |
|
30
|
|
|
|
|
31
|
|
|
/** @type boolean Indicates whether a payment was made in live or testing |
|
32
|
|
|
mode. |
|
33
|
|
|
Value assigned by Cardinity. */ |
|
34
|
|
|
private $live; |
|
35
|
|
|
|
|
36
|
|
|
/** @type boolean Optional. Default: true. |
|
37
|
|
|
Used to indicate a transaction type while creating a payment: true - |
|
38
|
|
|
purchase, false - authorization. */ |
|
39
|
|
|
private $settle; |
|
40
|
|
|
|
|
41
|
|
|
/** @type string Payment status. |
|
42
|
|
|
Can be one of the following: pending, approved, declined. |
|
43
|
|
|
Value assigned by Cardinity. */ |
|
44
|
|
|
private $status; |
|
45
|
|
|
|
|
46
|
|
|
/** @type string Error message. |
|
47
|
|
|
Returned only if status is declined. |
|
48
|
|
|
Provides human readable information why the payment failed. |
|
49
|
|
|
Value assigned by Cardinity. */ |
|
50
|
|
|
private $error; |
|
51
|
|
|
|
|
52
|
|
|
/** @type string Optional. Order ID provided by a merchant. |
|
53
|
|
|
Must be between 2 and 50 characters [A-Za-z0-9'.-]. */ |
|
54
|
|
|
private $orderId; |
|
55
|
|
|
|
|
56
|
|
|
/** @type string Payment description provided by a merchant. |
|
57
|
|
|
Maximum length 255 characters. */ |
|
58
|
|
|
private $description; |
|
59
|
|
|
|
|
60
|
|
|
/** @type string Country of a customer provided by a merchant. |
|
61
|
|
|
ISO 3166-1 alpha-2 country code. */ |
|
62
|
|
|
private $country; |
|
63
|
|
|
|
|
64
|
|
|
/** @type string Can be one the following: card, recurring. */ |
|
65
|
|
|
private $paymentMethod; |
|
66
|
|
|
|
|
67
|
|
|
/** @type PaymentInstrumentInterface Payment instrument representing earlier described |
|
68
|
|
|
payment_method. |
|
69
|
|
|
Can be one of the following: card or recurring. |
|
70
|
|
|
*/ |
|
71
|
|
|
private $paymentInstrument; |
|
72
|
|
|
|
|
73
|
|
|
/** @type string Used to provide additional information (PATCH verb) once |
|
74
|
|
|
customer completes authorization process. */ |
|
75
|
|
|
private $authorizeData; |
|
76
|
|
|
|
|
77
|
|
|
/** @type AuthorizationInformation Specific authorization object returned in case additional |
|
78
|
|
|
payment authorization is needed (i.e. payment status is pending). |
|
79
|
|
|
Value assigned by Cardinity. */ |
|
80
|
|
|
private $authorizationInformation; |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* Gets the value of id. |
|
84
|
|
|
* @return mixed |
|
85
|
|
|
*/ |
|
86
|
|
|
public function getId() |
|
87
|
|
|
{ |
|
88
|
|
|
return $this->id; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* Sets the value of id. |
|
93
|
|
|
* @param mixed $id the id |
|
94
|
|
|
* @return void |
|
95
|
|
|
*/ |
|
96
|
|
|
public function setId($id) |
|
97
|
|
|
{ |
|
98
|
|
|
$this->id = $id; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* Gets the value of amount. |
|
103
|
|
|
* @return mixed |
|
104
|
|
|
*/ |
|
105
|
|
|
public function getAmount() |
|
106
|
|
|
{ |
|
107
|
|
|
return $this->amount; |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* Sets the value of amount. |
|
112
|
|
|
* @param mixed $amount the amount |
|
113
|
|
|
* @return void |
|
114
|
|
|
*/ |
|
115
|
|
|
public function setAmount($amount) |
|
116
|
|
|
{ |
|
117
|
|
|
$this->amount = $amount; |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
/** |
|
121
|
|
|
* Gets the value of currency. |
|
122
|
|
|
* @return mixed |
|
123
|
|
|
*/ |
|
124
|
|
|
public function getCurrency() |
|
125
|
|
|
{ |
|
126
|
|
|
return $this->currency; |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
/** |
|
130
|
|
|
* Sets the value of currency. |
|
131
|
|
|
* @param mixed $currency the currency |
|
132
|
|
|
* @return void |
|
133
|
|
|
*/ |
|
134
|
|
|
public function setCurrency($currency) |
|
135
|
|
|
{ |
|
136
|
|
|
$this->currency = $currency; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
/** |
|
140
|
|
|
* Gets the value of created. |
|
141
|
|
|
* @return mixed |
|
142
|
|
|
*/ |
|
143
|
|
|
public function getCreated() |
|
144
|
|
|
{ |
|
145
|
|
|
return $this->created; |
|
146
|
|
|
} |
|
147
|
|
|
|
|
148
|
|
|
/** |
|
149
|
|
|
* Sets the value of created. |
|
150
|
|
|
* @param mixed $created the created |
|
151
|
|
|
* @return void |
|
152
|
|
|
*/ |
|
153
|
|
|
public function setCreated($created) |
|
154
|
|
|
{ |
|
155
|
|
|
$this->created = $created; |
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
|
|
/** |
|
159
|
|
|
* Gets the value of type. |
|
160
|
|
|
* @return mixed |
|
161
|
|
|
*/ |
|
162
|
|
|
public function getType() |
|
163
|
|
|
{ |
|
164
|
|
|
return $this->type; |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
/** |
|
168
|
|
|
* Sets the value of type. |
|
169
|
|
|
* @param mixed $type the type |
|
170
|
|
|
* @return void |
|
171
|
|
|
*/ |
|
172
|
|
|
public function setType($type) |
|
173
|
|
|
{ |
|
174
|
|
|
$this->type = $type; |
|
175
|
|
|
} |
|
176
|
|
|
|
|
177
|
|
|
/** |
|
178
|
|
|
* Gets the value of live. |
|
179
|
|
|
* @return mixed |
|
180
|
|
|
*/ |
|
181
|
|
|
public function getLive() |
|
182
|
|
|
{ |
|
183
|
|
|
return $this->live; |
|
184
|
|
|
} |
|
185
|
|
|
|
|
186
|
|
|
/** |
|
187
|
|
|
* Sets the value of live. |
|
188
|
|
|
* @param mixed $live the live |
|
189
|
|
|
* @return void |
|
190
|
|
|
*/ |
|
191
|
|
|
public function setLive($live) |
|
192
|
|
|
{ |
|
193
|
|
|
$this->live = $live; |
|
194
|
|
|
} |
|
195
|
|
|
|
|
196
|
|
|
/** |
|
197
|
|
|
* Gets the value of settle. |
|
198
|
|
|
* @return mixed |
|
199
|
|
|
*/ |
|
200
|
|
|
public function getSettle() |
|
201
|
|
|
{ |
|
202
|
|
|
return $this->settle; |
|
203
|
|
|
} |
|
204
|
|
|
|
|
205
|
|
|
/** |
|
206
|
|
|
* Sets the value of settle. |
|
207
|
|
|
* @param mixed $settle the settle |
|
208
|
|
|
* @return void |
|
209
|
|
|
*/ |
|
210
|
|
|
public function setSettle($settle) |
|
211
|
|
|
{ |
|
212
|
|
|
$this->settle = $settle; |
|
213
|
|
|
} |
|
214
|
|
|
|
|
215
|
|
|
/** |
|
216
|
|
|
* Gets the value of status. |
|
217
|
|
|
* @return mixed |
|
218
|
|
|
*/ |
|
219
|
|
|
public function getStatus() |
|
220
|
|
|
{ |
|
221
|
|
|
return $this->status; |
|
222
|
|
|
} |
|
223
|
|
|
|
|
224
|
|
|
/** |
|
225
|
|
|
* Sets the value of status. |
|
226
|
|
|
* @param mixed $status the status |
|
227
|
|
|
* @return void |
|
228
|
|
|
*/ |
|
229
|
|
|
public function setStatus($status) |
|
230
|
|
|
{ |
|
231
|
|
|
$this->status = $status; |
|
232
|
|
|
} |
|
233
|
|
|
|
|
234
|
|
|
/** |
|
235
|
|
|
* Gets the value of error. |
|
236
|
|
|
* @return mixed |
|
237
|
|
|
*/ |
|
238
|
|
|
public function getError() |
|
239
|
|
|
{ |
|
240
|
|
|
return $this->error; |
|
241
|
|
|
} |
|
242
|
|
|
|
|
243
|
|
|
/** |
|
244
|
|
|
* Sets the value of error. |
|
245
|
|
|
* @param mixed $error the error |
|
246
|
|
|
* @return void |
|
247
|
|
|
*/ |
|
248
|
|
|
public function setError($error) |
|
249
|
|
|
{ |
|
250
|
|
|
$this->error = $error; |
|
251
|
|
|
} |
|
252
|
|
|
|
|
253
|
|
|
/** |
|
254
|
|
|
* Gets the value of orderId. |
|
255
|
|
|
* @return mixed |
|
256
|
|
|
*/ |
|
257
|
|
|
public function getOrderId() |
|
258
|
|
|
{ |
|
259
|
|
|
return $this->orderId; |
|
260
|
|
|
} |
|
261
|
|
|
|
|
262
|
|
|
/** |
|
263
|
|
|
* Sets the value of orderId. |
|
264
|
|
|
* @param mixed $orderId the order id |
|
265
|
|
|
* @return void |
|
266
|
|
|
*/ |
|
267
|
|
|
public function setOrderId($orderId) |
|
268
|
|
|
{ |
|
269
|
|
|
$this->orderId = $orderId; |
|
270
|
|
|
} |
|
271
|
|
|
|
|
272
|
|
|
/** |
|
273
|
|
|
* Gets the value of description. |
|
274
|
|
|
* @return mixed |
|
275
|
|
|
*/ |
|
276
|
|
|
public function getDescription() |
|
277
|
|
|
{ |
|
278
|
|
|
return $this->description; |
|
279
|
|
|
} |
|
280
|
|
|
|
|
281
|
|
|
/** |
|
282
|
|
|
* Sets the value of description. |
|
283
|
|
|
* @param mixed $description the description |
|
284
|
|
|
* @return void |
|
285
|
|
|
*/ |
|
286
|
|
|
public function setDescription($description) |
|
287
|
|
|
{ |
|
288
|
|
|
$this->description = $description; |
|
289
|
|
|
} |
|
290
|
|
|
|
|
291
|
|
|
/** |
|
292
|
|
|
* Gets the value of country. |
|
293
|
|
|
* @return mixed |
|
294
|
|
|
*/ |
|
295
|
|
|
public function getCountry() |
|
296
|
|
|
{ |
|
297
|
|
|
return $this->country; |
|
298
|
|
|
} |
|
299
|
|
|
|
|
300
|
|
|
/** |
|
301
|
|
|
* Sets the value of country. |
|
302
|
|
|
* @param mixed $country the country |
|
303
|
|
|
* @return void |
|
304
|
|
|
*/ |
|
305
|
|
|
public function setCountry($country) |
|
306
|
|
|
{ |
|
307
|
|
|
$this->country = $country; |
|
308
|
|
|
} |
|
309
|
|
|
|
|
310
|
|
|
/** |
|
311
|
|
|
* Gets the value of paymentMethod. |
|
312
|
|
|
* @return mixed |
|
313
|
|
|
*/ |
|
314
|
|
|
public function getPaymentMethod() |
|
315
|
|
|
{ |
|
316
|
|
|
return $this->paymentMethod; |
|
317
|
|
|
} |
|
318
|
|
|
|
|
319
|
|
|
/** |
|
320
|
|
|
* Sets the value of paymentMethod. |
|
321
|
|
|
* @param mixed $paymentMethod the payment method |
|
322
|
|
|
* @return void |
|
323
|
|
|
*/ |
|
324
|
|
|
public function setPaymentMethod($paymentMethod) |
|
325
|
|
|
{ |
|
326
|
|
|
$this->paymentMethod = $paymentMethod; |
|
327
|
|
|
} |
|
328
|
|
|
|
|
329
|
|
|
/** |
|
330
|
|
|
* Gets the value of paymentInstrument. |
|
331
|
|
|
* @return PaymentInstrumentInterface |
|
332
|
|
|
*/ |
|
333
|
|
|
public function getPaymentInstrument() |
|
334
|
|
|
{ |
|
335
|
|
|
return $this->paymentInstrument; |
|
336
|
|
|
} |
|
337
|
|
|
|
|
338
|
|
|
/** |
|
339
|
|
|
* Sets the value of paymentInstrument. |
|
340
|
|
|
* @param PaymentInstrumentInterface $paymentInstrument the payment instrument |
|
341
|
|
|
* @return void |
|
342
|
|
|
*/ |
|
343
|
|
|
public function setPaymentInstrument(PaymentInstrumentInterface $paymentInstrument) |
|
344
|
|
|
{ |
|
345
|
|
|
$this->paymentInstrument = $paymentInstrument; |
|
346
|
|
|
} |
|
347
|
|
|
|
|
348
|
|
|
/** |
|
349
|
|
|
* Gets the value of authorizeData. |
|
350
|
|
|
* @return mixed |
|
351
|
|
|
*/ |
|
352
|
|
|
public function getAuthorizeData() |
|
353
|
|
|
{ |
|
354
|
|
|
return $this->authorizeData; |
|
355
|
|
|
} |
|
356
|
|
|
|
|
357
|
|
|
/** |
|
358
|
|
|
* Sets the value of authorizeData. |
|
359
|
|
|
* @param mixed $authorizeData the authorize data |
|
360
|
|
|
* @return void |
|
361
|
|
|
*/ |
|
362
|
|
|
public function setAuthorizeData($authorizeData) |
|
363
|
|
|
{ |
|
364
|
|
|
$this->authorizeData = $authorizeData; |
|
365
|
|
|
} |
|
366
|
|
|
|
|
367
|
|
|
/** |
|
368
|
|
|
* Gets the value of authorizationInformation. |
|
369
|
|
|
* @return AuthorizationInformation |
|
370
|
|
|
*/ |
|
371
|
|
|
public function getAuthorizationInformation() |
|
372
|
|
|
{ |
|
373
|
|
|
return $this->authorizationInformation; |
|
374
|
|
|
} |
|
375
|
|
|
|
|
376
|
|
|
/** |
|
377
|
|
|
* Sets the value of authorizationInformation. |
|
378
|
|
|
* @param AuthorizationInformation $authorizationInformation the authorization information |
|
379
|
|
|
* @return void |
|
380
|
|
|
*/ |
|
381
|
|
|
public function setAuthorizationInformation(AuthorizationInformation $authorizationInformation) |
|
382
|
|
|
{ |
|
383
|
|
|
$this->authorizationInformation = $authorizationInformation; |
|
384
|
|
|
} |
|
385
|
|
|
|
|
386
|
|
|
/** |
|
387
|
|
|
* Check if payment is pending |
|
388
|
|
|
* @return boolean |
|
389
|
|
|
*/ |
|
390
|
|
|
public function isPending() |
|
391
|
|
|
{ |
|
392
|
|
|
return $this->getStatus() === 'pending'; |
|
393
|
|
|
} |
|
394
|
|
|
|
|
395
|
|
|
/** |
|
396
|
|
|
* Check if payment is approved |
|
397
|
|
|
* @return boolean |
|
398
|
|
|
*/ |
|
399
|
|
|
public function isApproved() |
|
400
|
|
|
{ |
|
401
|
|
|
return $this->getStatus() === 'approved'; |
|
402
|
|
|
} |
|
403
|
|
|
|
|
404
|
|
|
/** |
|
405
|
|
|
* Check if payment is declined |
|
406
|
|
|
* @return boolean |
|
407
|
|
|
*/ |
|
408
|
|
|
public function isDeclined() |
|
409
|
|
|
{ |
|
410
|
|
|
return $this->getStatus() === 'declined'; |
|
411
|
|
|
} |
|
412
|
|
|
} |
|
413
|
|
|
|