1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Omnipay\CapitaPay360; |
4
|
|
|
|
5
|
|
|
use Omnipay\Common\Item as BaseItem; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Capita Pay360 sale line item |
9
|
|
|
*/ |
10
|
|
|
class Item extends BaseItem |
11
|
|
|
{ |
12
|
|
|
const CUSTOMER_INFO_KEYS = array( |
13
|
|
|
'customerString1', |
14
|
|
|
'customerString2', |
15
|
4 |
|
'customerString3', |
16
|
|
|
'customerString4', |
17
|
4 |
|
'customerString5', |
18
|
|
|
'customerNumber1', |
19
|
|
|
'customerNumber2', |
20
|
|
|
'customerNumber3', |
21
|
|
|
'customerNumber4', |
22
|
|
|
); |
23
|
3 |
|
|
24
|
|
|
/** |
25
|
3 |
|
* Get the item reference (acccount code) |
26
|
|
|
*/ |
27
|
|
|
public function getReference() |
28
|
|
|
{ |
29
|
|
|
return $this->getParameter('reference'); |
30
|
|
|
} |
31
|
4 |
|
|
32
|
|
|
/** |
33
|
4 |
|
* Set the item reference (acccount code) |
34
|
|
|
*/ |
35
|
|
|
public function setReference($value) |
36
|
|
|
{ |
37
|
|
|
return $this->setParameter('reference', substr($value, 0, 50)); |
38
|
|
|
} |
39
|
3 |
|
|
40
|
|
|
/** |
41
|
3 |
|
* Get the item additional reference |
42
|
|
|
*/ |
43
|
|
|
public function getAdditionalReference() |
44
|
|
|
{ |
45
|
|
|
return $this->getParameter('additionalReference'); |
46
|
|
|
} |
47
|
4 |
|
|
48
|
|
|
/** |
49
|
4 |
|
* Set the item additional reference |
50
|
|
|
*/ |
51
|
|
|
public function setAdditionalReference($value) |
52
|
|
|
{ |
53
|
|
|
return $this->setParameter('additionalReference', substr($value, 0, 50)); |
54
|
|
|
} |
55
|
3 |
|
|
56
|
|
|
/** |
57
|
3 |
|
* Get the item fund code |
58
|
|
|
*/ |
59
|
|
|
public function getFundCode() |
60
|
|
|
{ |
61
|
|
|
return $this->getParameter('fundCode'); |
62
|
|
|
} |
63
|
4 |
|
|
64
|
|
|
/** |
65
|
4 |
|
* Set the item fund code |
66
|
|
|
*/ |
67
|
|
|
public function setFundCode($value) |
68
|
|
|
{ |
69
|
|
|
return $this->setParameter('fundCode', substr($value, 0, 5)); |
70
|
|
|
} |
71
|
3 |
|
|
72
|
|
|
/** |
73
|
3 |
|
* Get the item narrative |
74
|
|
|
*/ |
75
|
|
|
public function getNarrative() |
76
|
|
|
{ |
77
|
|
|
return $this->getParameter('narrative'); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Set the item narrative |
82
|
|
|
*/ |
83
|
|
|
public function setNarrative($value) |
84
|
|
|
{ |
85
|
|
|
return $this->setParameter('narrative', substr($value, 0, 50)); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Get the customer-specific string 1 |
90
|
|
|
*/ |
91
|
|
|
public function getCustomerString1() |
92
|
|
|
{ |
93
|
|
|
return $this->getParameter('customerString1'); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Set the customer-specific string 1 |
98
|
|
|
*/ |
99
|
|
|
public function setCustomerString1($value) |
100
|
|
|
{ |
101
|
|
|
$this->setParameter('customerString1', substr($value, 0, 50)); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* Get the customer-specific string 2 |
106
|
|
|
*/ |
107
|
|
|
public function getCustomerString2() |
108
|
|
|
{ |
109
|
|
|
return $this->getParameter('customerString2'); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* Set the customer-specific string 2 |
114
|
|
|
*/ |
115
|
|
|
public function setCustomerString2($value) |
116
|
|
|
{ |
117
|
|
|
$this->setParameter('customerString2', substr($value, 0, 50)); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* Get the customer-specific string 3 |
122
|
|
|
*/ |
123
|
|
|
public function getCustomerString3() |
124
|
|
|
{ |
125
|
|
|
return $this->getParameter('customerString3'); |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* Set the customer-specific string 3 |
130
|
|
|
*/ |
131
|
|
|
public function setCustomerString3($value) |
132
|
|
|
{ |
133
|
|
|
$this->setParameter('customerString3', substr($value, 0, 50)); |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* Get the customer-specific string 4 |
138
|
|
|
*/ |
139
|
|
|
public function getCustomerString4() |
140
|
|
|
{ |
141
|
|
|
return $this->getParameter('customerString4'); |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* Set the customer-specific string 4 |
146
|
|
|
*/ |
147
|
|
|
public function setCustomerString4($value) |
148
|
|
|
{ |
149
|
|
|
$this->setParameter('customerString4', substr($value, 0, 50)); |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* Get the customer-specific string 5 |
154
|
|
|
*/ |
155
|
|
|
public function getCustomerString5() |
156
|
|
|
{ |
157
|
|
|
return $this->getParameter('customerString5'); |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* Set the customer-specific string 5 |
162
|
|
|
*/ |
163
|
|
|
public function setCustomerString5($value) |
164
|
|
|
{ |
165
|
|
|
$this->setParameter('customerString5', substr($value, 0, 50)); |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
/** |
169
|
|
|
* Get the customer-specific integer 1 |
170
|
|
|
*/ |
171
|
|
|
public function getCustomerNumber1() |
172
|
|
|
{ |
173
|
|
|
return $this->getParameter('customerNumber1'); |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
/** |
177
|
|
|
* Set the customer-specific integer 1 |
178
|
|
|
*/ |
179
|
|
|
public function setCustomerNumber1($value) |
180
|
|
|
{ |
181
|
|
|
$this->setParameter('customerNumber1', $value === null ? null : (int) $value); |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
/** |
185
|
|
|
* Get the customer-specific integer 2 |
186
|
|
|
*/ |
187
|
|
|
public function getCustomerNumber2() |
188
|
|
|
{ |
189
|
|
|
return $this->getParameter('customerNumber2'); |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
/** |
193
|
|
|
* Set the customer-specific integer 2 |
194
|
|
|
*/ |
195
|
|
|
public function setCustomerNumber2($value) |
196
|
|
|
{ |
197
|
|
|
$this->setParameter('customerNumber2', $value === null ? null : (int) $value); |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
/** |
201
|
|
|
* Get the customer-specific integer 3 |
202
|
|
|
*/ |
203
|
|
|
public function getCustomerNumber3() |
204
|
|
|
{ |
205
|
|
|
return $this->getParameter('customerNumber3'); |
206
|
|
|
} |
207
|
|
|
|
208
|
|
|
/** |
209
|
|
|
* Set the customer-specific integer 3 |
210
|
|
|
*/ |
211
|
|
|
public function setCustomerNumber3($value) |
212
|
|
|
{ |
213
|
|
|
$this->setParameter('customerNumber3', $value === null ? null : (int) $value); |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
/** |
217
|
|
|
* Get the customer-specific integer 4 |
218
|
|
|
*/ |
219
|
|
|
public function getCustomerNumber4() |
220
|
|
|
{ |
221
|
|
|
return $this->getParameter('customerNumber4'); |
222
|
|
|
} |
223
|
|
|
|
224
|
|
|
/** |
225
|
|
|
* Set the customer-specific integer 4 |
226
|
|
|
*/ |
227
|
|
|
public function setCustomerNumber4($value) |
228
|
|
|
{ |
229
|
|
|
$this->setParameter('customerNumber4', $value === null ? null : (int) $value); |
230
|
|
|
} |
231
|
|
|
|
232
|
|
|
/** |
233
|
|
|
* Get all the customer-specific fields (that have values) |
234
|
|
|
*/ |
235
|
|
|
public function getCustomerInfo() |
236
|
|
|
{ |
237
|
|
|
$info = array(); |
238
|
|
|
foreach (self::CUSTOMER_INFO_KEYS as $key) { |
239
|
|
|
$info[$key] = $this->{'get'.ucfirst($key)}(); |
240
|
|
|
} |
241
|
|
|
return array_filter( |
242
|
|
|
$info, |
243
|
|
|
function ($x) { |
244
|
|
|
return $x !== null; |
245
|
|
|
} |
246
|
|
|
); |
247
|
|
|
} |
248
|
|
|
|
249
|
|
|
/** |
250
|
|
|
* Set all the customer-specific fields |
251
|
|
|
*/ |
252
|
|
|
public function setCustomerInfo($value) |
253
|
|
|
{ |
254
|
|
|
if (!is_array($value)) { |
255
|
|
|
return; |
256
|
|
|
} |
257
|
|
|
foreach (self::CUSTOMER_INFO_KEYS as $key) { |
258
|
|
|
if (array_key_exists($key, $value)) { |
259
|
|
|
$this->{'set'.ucfirst($key)}($value[$key]); |
260
|
|
|
} |
261
|
|
|
} |
262
|
|
|
} |
263
|
|
|
} |
264
|
|
|
|