|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Kerox\Messenger\Model\Callback\Payment; |
|
6
|
|
|
|
|
7
|
|
|
use Kerox\Messenger\Model\Common\Address; |
|
8
|
|
|
|
|
9
|
|
|
class RequestedUserInfo |
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* @var \Kerox\Messenger\Model\Common\Address |
|
13
|
|
|
*/ |
|
14
|
|
|
protected $shippingAddress; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @var string |
|
18
|
|
|
*/ |
|
19
|
|
|
protected $contactName; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @var null|string |
|
23
|
|
|
*/ |
|
24
|
|
|
protected $contactEmail; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @var null|string |
|
28
|
|
|
*/ |
|
29
|
|
|
protected $contactPhone; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* RequestedUserInfo constructor. |
|
33
|
|
|
* |
|
34
|
|
|
* @param \Kerox\Messenger\Model\Common\Address $shippingAddress |
|
35
|
|
|
* @param string $contactName |
|
36
|
|
|
* @param null|string $contactEmail |
|
37
|
|
|
* @param null|string $contactPhone |
|
38
|
|
|
*/ |
|
39
|
9 |
|
public function __construct( |
|
40
|
|
|
Address $shippingAddress, |
|
41
|
|
|
string $contactName, |
|
42
|
|
|
?string $contactEmail = null, |
|
43
|
|
|
?string $contactPhone = null |
|
44
|
|
|
) { |
|
45
|
9 |
|
$this->shippingAddress = $shippingAddress; |
|
46
|
9 |
|
$this->contactName = $contactName; |
|
47
|
9 |
|
$this->contactEmail = $contactEmail; |
|
48
|
9 |
|
$this->contactPhone = $contactPhone; |
|
49
|
9 |
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @return \Kerox\Messenger\Model\Common\Address |
|
53
|
|
|
*/ |
|
54
|
4 |
|
public function getShippingAddress(): Address |
|
55
|
|
|
{ |
|
56
|
4 |
|
return $this->shippingAddress; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @return string |
|
61
|
|
|
*/ |
|
62
|
2 |
|
public function getContactName(): string |
|
63
|
|
|
{ |
|
64
|
2 |
|
return $this->contactName; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @return null|string |
|
69
|
|
|
*/ |
|
70
|
1 |
|
public function getContactEmail(): ?string |
|
71
|
|
|
{ |
|
72
|
1 |
|
return $this->contactEmail; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @return null|string |
|
77
|
|
|
*/ |
|
78
|
1 |
|
public function getContactPhone(): ?string |
|
79
|
|
|
{ |
|
80
|
1 |
|
return $this->contactPhone; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @param array $callbackData |
|
85
|
|
|
* |
|
86
|
|
|
* @return \Kerox\Messenger\Model\Callback\Payment\RequestedUserInfo |
|
87
|
|
|
*/ |
|
88
|
9 |
|
public static function create(array $callbackData): self |
|
89
|
|
|
{ |
|
90
|
9 |
|
$shippingAddress = Address::fromPayload($callbackData['shipping_address']); |
|
91
|
|
|
|
|
92
|
9 |
|
$contactEmail = $callbackData['contact_email'] ?? null; |
|
93
|
9 |
|
$contactPhone = $callbackData['contact_phone'] ?? null; |
|
94
|
|
|
|
|
95
|
9 |
|
return new self($shippingAddress, $callbackData['contact_name'], $contactEmail, $contactPhone); |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
|