|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* PHP version 5.4 and 7 |
|
4
|
|
|
* |
|
5
|
|
|
* @category RequestEntity |
|
6
|
|
|
* @package Payever\Payments |
|
7
|
|
|
* @author Hennadii Shymanskyi <[email protected]> |
|
8
|
|
|
* @copyright 2017-2019 payever GmbH |
|
9
|
|
|
* @license MIT <https://opensource.org/licenses/MIT> |
|
10
|
|
|
* @link https://getpayever.com/shopsystem/ |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace Payever\ExternalIntegration\Payments\Http\RequestEntity; |
|
14
|
|
|
|
|
15
|
|
|
use Payever\ExternalIntegration\Core\Http\RequestEntity; |
|
16
|
|
|
use Payever\ExternalIntegration\Payments\Http\MessageEntity\RetrievePaymentResultEntity; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Class NotificationRequestEntity |
|
20
|
|
|
* |
|
21
|
|
|
* @package Payever\ExternalIntegration\Payments\Http\RequestEntity |
|
22
|
|
|
* |
|
23
|
|
|
* @method string getNotificationType() |
|
24
|
|
|
* @method array getNotificationTypesAvailable() |
|
25
|
|
|
* @method \DateTime|false getCreatedAt() |
|
26
|
|
|
* @method RetrievePaymentResultEntity getPayment() |
|
27
|
|
|
*/ |
|
28
|
|
|
class NotificationRequestEntity extends RequestEntity |
|
29
|
|
|
{ |
|
30
|
|
|
/** @var string */ |
|
31
|
|
|
protected $notificationType; |
|
32
|
|
|
|
|
33
|
|
|
/** @var array */ |
|
34
|
|
|
protected $notificationTypesAvailable; |
|
35
|
|
|
|
|
36
|
|
|
/** @var \DateTime|bool */ |
|
37
|
|
|
protected $createdAt; |
|
38
|
|
|
|
|
39
|
|
|
/** @var RetrievePaymentResultEntity */ |
|
40
|
|
|
protected $payment; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @param string $createdAt |
|
44
|
|
|
* @return static |
|
45
|
|
|
*/ |
|
46
|
|
|
public function setCreatedAt($createdAt) |
|
47
|
|
|
{ |
|
48
|
|
|
$this->createdAt = date_create($createdAt); |
|
49
|
|
|
|
|
50
|
|
|
return $this; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @return bool |
|
55
|
|
|
*/ |
|
56
|
|
|
public function isValid() |
|
57
|
|
|
{ |
|
58
|
|
|
$types = $this->getNotificationTypesAvailable(); |
|
59
|
|
|
|
|
60
|
|
|
return is_array($types) |
|
61
|
|
|
&& in_array($this->getNotificationType(), $types) |
|
62
|
|
|
; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @param array $data |
|
67
|
|
|
* |
|
68
|
|
|
* @return static |
|
69
|
|
|
*/ |
|
70
|
|
|
public function setData(array $data) |
|
71
|
|
|
{ |
|
72
|
|
|
$this->payment = new RetrievePaymentResultEntity($data['payment']); |
|
73
|
|
|
|
|
74
|
|
|
return $this; |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|