1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Tgallice\FBMessenger\Attachment\Structured; |
4
|
|
|
|
5
|
|
|
use Tgallice\FBMessenger\Attachment\Structured; |
6
|
|
|
use Tgallice\FBMessenger\Model\Address; |
7
|
|
|
use Tgallice\FBMessenger\Model\Adjustment; |
8
|
|
|
use Tgallice\FBMessenger\Model\Receipt\Element; |
9
|
|
|
use Tgallice\FBMessenger\Model\Summary; |
10
|
|
|
|
11
|
|
|
class Receipt extends Structured |
12
|
|
|
{ |
13
|
|
|
const TEMPLATE_TYPE = 'receipt'; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @param string $recipientName |
17
|
|
|
* @param string $orderNumber |
18
|
|
|
* @param string $currency |
19
|
|
|
* @param string $paymentMethod |
20
|
|
|
* @param Element[] $elements |
21
|
|
|
* @param Summary $summary |
22
|
|
|
*/ |
23
|
19 |
|
public function __construct($recipientName, $orderNumber, $currency, $paymentMethod, array $elements, Summary $summary) |
24
|
|
|
{ |
25
|
19 |
|
$this->payload = [ |
26
|
19 |
|
'template_type' => self::TEMPLATE_TYPE, |
27
|
19 |
|
'recipient_name' => $recipientName, |
28
|
19 |
|
'order_number' => $orderNumber, |
29
|
19 |
|
'currency' => $currency, |
30
|
19 |
|
'payment_method' => $paymentMethod, |
31
|
19 |
|
'timestamp' => null, |
32
|
19 |
|
'order_url' => null, |
33
|
19 |
|
'elements' => $elements, |
34
|
19 |
|
'address' => null, |
35
|
19 |
|
'summary' => $summary, |
36
|
19 |
|
'adjustments' => [], |
37
|
|
|
]; |
38
|
19 |
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @return null|Address |
42
|
|
|
*/ |
43
|
2 |
|
public function getAddress() |
44
|
|
|
{ |
45
|
2 |
|
return $this->payload['address']; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @return Adjustment[] |
50
|
|
|
*/ |
51
|
2 |
|
public function getAdjustments() |
52
|
|
|
{ |
53
|
2 |
|
return $this->payload['adjustments']; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @return Element[] |
58
|
|
|
*/ |
59
|
1 |
|
public function getElements() |
60
|
|
|
{ |
61
|
1 |
|
return $this->payload['elements']; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @return string |
66
|
|
|
*/ |
67
|
1 |
|
public function getCurrency() |
68
|
|
|
{ |
69
|
1 |
|
return $this->payload['currency']; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @return string |
74
|
|
|
*/ |
75
|
1 |
|
public function getOrderNumber() |
76
|
|
|
{ |
77
|
1 |
|
return $this->payload['order_number']; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @return null|string |
82
|
|
|
*/ |
83
|
2 |
|
public function getOrderUrl() |
84
|
|
|
{ |
85
|
2 |
|
return $this->payload['order_url']; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @return string |
90
|
|
|
*/ |
91
|
1 |
|
public function getPaymentMethod() |
92
|
|
|
{ |
93
|
1 |
|
return $this->payload['payment_method']; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @return string |
98
|
|
|
*/ |
99
|
1 |
|
public function getRecipientName() |
100
|
|
|
{ |
101
|
1 |
|
return $this->payload['recipient_name']; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @return Summary |
106
|
|
|
*/ |
107
|
1 |
|
public function getSummary() |
108
|
|
|
{ |
109
|
1 |
|
return $this->payload['summary']; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @return null|string |
114
|
|
|
*/ |
115
|
2 |
|
public function getTimestamp() |
116
|
|
|
{ |
117
|
2 |
|
return $this->payload['timestamp']; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* @param Address $address |
122
|
|
|
*/ |
123
|
2 |
|
public function setAddress(Address $address) |
124
|
|
|
{ |
125
|
2 |
|
$this->payload['address'] = $address; |
126
|
2 |
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* @param Adjustment[] $adjustments |
130
|
|
|
*/ |
131
|
2 |
|
public function setAdjustments(array $adjustments) |
132
|
|
|
{ |
133
|
2 |
|
$this->payload['adjustments'] = $adjustments; |
134
|
2 |
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* @param string $orderUrl |
138
|
|
|
*/ |
139
|
2 |
|
public function setOrderUrl($orderUrl) |
140
|
|
|
{ |
141
|
2 |
|
$this->payload['order_url'] = $orderUrl; |
142
|
2 |
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* @param string $timestamp |
146
|
|
|
*/ |
147
|
2 |
|
public function setTimestamp($timestamp) |
148
|
|
|
{ |
149
|
2 |
|
$this->payload['timestamp'] = $timestamp; |
150
|
2 |
|
} |
151
|
|
|
} |
152
|
|
|
|