|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Classes for the various AuthorizeNet data types. |
|
4
|
|
|
* |
|
5
|
|
|
* @package AuthorizeNet |
|
6
|
|
|
* @subpackage AuthorizeNetCIM |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* A class that contains all fields for a CIM Customer Profile. |
|
12
|
|
|
* |
|
13
|
|
|
* @package AuthorizeNet |
|
14
|
|
|
* @subpackage AuthorizeNetCIM |
|
15
|
|
|
*/ |
|
16
|
|
|
class AuthorizeNetCustomer |
|
|
|
|
|
|
17
|
|
|
{ |
|
18
|
|
|
public $merchantCustomerId; |
|
19
|
|
|
public $description; |
|
20
|
|
|
public $email; |
|
21
|
|
|
public $paymentProfiles = array(); |
|
22
|
|
|
public $shipToList = array(); |
|
23
|
|
|
public $customerProfileId; |
|
24
|
|
|
|
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* A class that contains all fields for a CIM Address. |
|
29
|
|
|
* |
|
30
|
|
|
* @package AuthorizeNet |
|
31
|
|
|
* @subpackage AuthorizeNetCIM |
|
32
|
|
|
*/ |
|
33
|
|
|
class AuthorizeNetAddress |
|
|
|
|
|
|
34
|
|
|
{ |
|
35
|
|
|
public $firstName; |
|
36
|
|
|
public $lastName; |
|
37
|
|
|
public $company; |
|
38
|
|
|
public $address; |
|
39
|
|
|
public $city; |
|
40
|
|
|
public $state; |
|
41
|
|
|
public $zip; |
|
42
|
|
|
public $country; |
|
43
|
|
|
public $phoneNumber; |
|
44
|
|
|
public $faxNumber; |
|
45
|
|
|
public $customerAddressId; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* A class that contains all fields for a CIM Payment Profile. |
|
50
|
|
|
* |
|
51
|
|
|
* @package AuthorizeNet |
|
52
|
|
|
* @subpackage AuthorizeNetCIM |
|
53
|
|
|
*/ |
|
54
|
|
|
class AuthorizeNetPaymentProfile |
|
|
|
|
|
|
55
|
|
|
{ |
|
56
|
|
|
|
|
57
|
|
|
public $customerType; |
|
58
|
|
|
public $billTo; |
|
59
|
|
|
public $payment; |
|
60
|
|
|
public $customerPaymentProfileId; |
|
61
|
|
|
|
|
62
|
3 |
|
public function __construct() |
|
63
|
|
|
{ |
|
64
|
3 |
|
$this->billTo = new AuthorizeNetAddress; |
|
65
|
3 |
|
$this->payment = new AuthorizeNetPayment; |
|
66
|
3 |
|
} |
|
67
|
|
|
|
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* A class that contains all fields for a CIM Payment Type. |
|
72
|
|
|
* |
|
73
|
|
|
* @package AuthorizeNet |
|
74
|
|
|
* @subpackage AuthorizeNetCIM |
|
75
|
|
|
*/ |
|
76
|
|
|
class AuthorizeNetPayment |
|
|
|
|
|
|
77
|
|
|
{ |
|
78
|
|
|
public $creditCard; |
|
79
|
|
|
public $bankAccount; |
|
80
|
|
|
|
|
81
|
3 |
|
public function __construct() |
|
82
|
|
|
{ |
|
83
|
3 |
|
$this->creditCard = new AuthorizeNetCreditCard; |
|
84
|
3 |
|
$this->bankAccount = new AuthorizeNetBankAccount; |
|
85
|
3 |
|
} |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* A class that contains all fields for a CIM Transaction. |
|
90
|
|
|
* |
|
91
|
|
|
* @package AuthorizeNet |
|
92
|
|
|
* @subpackage AuthorizeNetCIM |
|
93
|
|
|
*/ |
|
94
|
|
|
class AuthorizeNetTransaction |
|
|
|
|
|
|
95
|
|
|
{ |
|
96
|
|
|
public $amount; |
|
97
|
|
|
public $tax; |
|
98
|
|
|
public $shipping; |
|
99
|
|
|
public $duty; |
|
100
|
|
|
public $lineItems = array(); |
|
101
|
|
|
public $customerProfileId; |
|
102
|
|
|
public $customerPaymentProfileId; |
|
103
|
|
|
public $customerShippingAddressId; |
|
104
|
|
|
public $creditCardNumberMasked; |
|
105
|
|
|
public $bankRoutingNumberMasked; |
|
106
|
|
|
public $bankAccountNumberMasked; |
|
107
|
|
|
public $order; |
|
108
|
|
|
public $taxExempt; |
|
109
|
|
|
public $recurringBilling; |
|
110
|
|
|
public $cardCode; |
|
111
|
|
|
public $splitTenderId; |
|
112
|
|
|
public $approvalCode; |
|
113
|
|
|
public $transId; |
|
114
|
|
|
|
|
115
|
1 |
|
public function __construct() |
|
116
|
|
|
{ |
|
117
|
1 |
|
$this->tax = (object)array(); |
|
118
|
1 |
|
$this->tax->amount = ""; |
|
119
|
1 |
|
$this->tax->name = ""; |
|
120
|
1 |
|
$this->tax->description = ""; |
|
121
|
|
|
|
|
122
|
1 |
|
$this->shipping = (object)array(); |
|
123
|
1 |
|
$this->shipping->amount = ""; |
|
124
|
1 |
|
$this->shipping->name = ""; |
|
125
|
1 |
|
$this->shipping->description = ""; |
|
126
|
|
|
|
|
127
|
1 |
|
$this->duty = (object)array(); |
|
128
|
1 |
|
$this->duty->amount = ""; |
|
129
|
1 |
|
$this->duty->name = ""; |
|
130
|
1 |
|
$this->duty->description = ""; |
|
131
|
|
|
|
|
132
|
|
|
// line items |
|
133
|
|
|
|
|
134
|
1 |
|
$this->order = (object)array(); |
|
135
|
1 |
|
$this->order->invoiceNumber = ""; |
|
136
|
1 |
|
$this->order->description = ""; |
|
137
|
1 |
|
$this->order->purchaseOrderNumber = ""; |
|
138
|
1 |
|
} |
|
139
|
|
|
|
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
/** |
|
143
|
|
|
* A class that contains all fields for a CIM Transaction Line Item. |
|
144
|
|
|
* |
|
145
|
|
|
* @package AuthorizeNet |
|
146
|
|
|
* @subpackage AuthorizeNetCIM |
|
147
|
|
|
*/ |
|
148
|
|
|
class AuthorizeNetLineItem |
|
|
|
|
|
|
149
|
|
|
{ |
|
150
|
|
|
public $itemId; |
|
151
|
|
|
public $name; |
|
152
|
|
|
public $description; |
|
153
|
|
|
public $quantity; |
|
154
|
|
|
public $unitPrice; |
|
155
|
|
|
public $taxable; |
|
156
|
|
|
|
|
157
|
|
|
} |
|
158
|
|
|
|
|
159
|
|
|
/** |
|
160
|
|
|
* A class that contains all fields for a CIM Credit Card. |
|
161
|
|
|
* |
|
162
|
|
|
* @package AuthorizeNet |
|
163
|
|
|
* @subpackage AuthorizeNetCIM |
|
164
|
|
|
*/ |
|
165
|
|
|
class AuthorizeNetCreditCard |
|
|
|
|
|
|
166
|
|
|
{ |
|
167
|
|
|
public $cardNumber; |
|
168
|
|
|
public $expirationDate; |
|
169
|
|
|
public $cardCode; |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
|
|
/** |
|
173
|
|
|
* A class that contains all fields for a CIM Bank Account. |
|
174
|
|
|
* |
|
175
|
|
|
* @package AuthorizeNet |
|
176
|
|
|
* @subpackage AuthorizeNetCIM |
|
177
|
|
|
*/ |
|
178
|
|
|
class AuthorizeNetBankAccount |
|
|
|
|
|
|
179
|
|
|
{ |
|
180
|
|
|
public $accountType; |
|
181
|
|
|
public $routingNumber; |
|
182
|
|
|
public $accountNumber; |
|
183
|
|
|
public $nameOnAccount; |
|
184
|
|
|
public $echeckType; |
|
185
|
|
|
public $bankName; |
|
186
|
|
|
} |
|
187
|
|
|
|
|
188
|
|
|
/** |
|
189
|
|
|
* A class that contains all fields for an AuthorizeNet ARB Subscription. |
|
190
|
|
|
* |
|
191
|
|
|
* @package AuthorizeNet |
|
192
|
|
|
* @subpackage AuthorizeNetARB |
|
193
|
|
|
*/ |
|
194
|
|
|
class AuthorizeNet_Subscription |
|
|
|
|
|
|
195
|
|
|
{ |
|
196
|
|
|
|
|
197
|
|
|
public $name; |
|
198
|
|
|
public $intervalLength; |
|
199
|
|
|
public $intervalUnit; |
|
200
|
|
|
public $startDate; |
|
201
|
|
|
public $totalOccurrences; |
|
202
|
|
|
public $trialOccurrences; |
|
203
|
|
|
public $amount; |
|
204
|
|
|
public $trialAmount; |
|
205
|
|
|
public $creditCardCardNumber; |
|
206
|
|
|
public $creditCardExpirationDate; |
|
207
|
|
|
public $creditCardCardCode; |
|
208
|
|
|
public $bankAccountAccountType; |
|
209
|
|
|
public $bankAccountRoutingNumber; |
|
210
|
|
|
public $bankAccountAccountNumber; |
|
211
|
|
|
public $bankAccountNameOnAccount; |
|
212
|
|
|
public $bankAccountEcheckType; |
|
213
|
|
|
public $bankAccountBankName; |
|
214
|
|
|
public $orderInvoiceNumber; |
|
215
|
|
|
public $orderDescription; |
|
216
|
|
|
public $customerId; |
|
217
|
|
|
public $customerEmail; |
|
218
|
|
|
public $customerPhoneNumber; |
|
219
|
|
|
public $customerFaxNumber; |
|
220
|
|
|
public $billToFirstName; |
|
221
|
|
|
public $billToLastName; |
|
222
|
|
|
public $billToCompany; |
|
223
|
|
|
public $billToAddress; |
|
224
|
|
|
public $billToCity; |
|
225
|
|
|
public $billToState; |
|
226
|
|
|
public $billToZip; |
|
227
|
|
|
public $billToCountry; |
|
228
|
|
|
public $shipToFirstName; |
|
229
|
|
|
public $shipToLastName; |
|
230
|
|
|
public $shipToCompany; |
|
231
|
|
|
public $shipToAddress; |
|
232
|
|
|
public $shipToCity; |
|
233
|
|
|
public $shipToState; |
|
234
|
|
|
public $shipToZip; |
|
235
|
|
|
public $shipToCountry; |
|
236
|
|
|
|
|
237
|
2 |
|
public function getXml() |
|
238
|
|
|
{ |
|
239
|
|
|
$xml = "<subscription> |
|
240
|
2 |
|
<name>{$this->name}</name> |
|
241
|
|
|
<paymentSchedule> |
|
242
|
|
|
<interval> |
|
243
|
2 |
|
<length>{$this->intervalLength}</length> |
|
244
|
2 |
|
<unit>{$this->intervalUnit}</unit> |
|
245
|
|
|
</interval> |
|
246
|
2 |
|
<startDate>{$this->startDate}</startDate> |
|
247
|
2 |
|
<totalOccurrences>{$this->totalOccurrences}</totalOccurrences> |
|
248
|
2 |
|
<trialOccurrences>{$this->trialOccurrences}</trialOccurrences> |
|
249
|
|
|
</paymentSchedule> |
|
250
|
2 |
|
<amount>{$this->amount}</amount> |
|
251
|
2 |
|
<trialAmount>{$this->trialAmount}</trialAmount> |
|
252
|
|
|
<payment> |
|
253
|
|
|
<creditCard> |
|
254
|
2 |
|
<cardNumber>{$this->creditCardCardNumber}</cardNumber> |
|
255
|
2 |
|
<expirationDate>{$this->creditCardExpirationDate}</expirationDate> |
|
256
|
2 |
|
<cardCode>{$this->creditCardCardCode}</cardCode> |
|
257
|
|
|
</creditCard> |
|
258
|
|
|
<bankAccount> |
|
259
|
2 |
|
<accountType>{$this->bankAccountAccountType}</accountType> |
|
260
|
2 |
|
<routingNumber>{$this->bankAccountRoutingNumber}</routingNumber> |
|
261
|
2 |
|
<accountNumber>{$this->bankAccountAccountNumber}</accountNumber> |
|
262
|
2 |
|
<nameOnAccount>{$this->bankAccountNameOnAccount}</nameOnAccount> |
|
263
|
2 |
|
<echeckType>{$this->bankAccountEcheckType}</echeckType> |
|
264
|
2 |
|
<bankName>{$this->bankAccountBankName}</bankName> |
|
265
|
|
|
</bankAccount> |
|
266
|
|
|
</payment> |
|
267
|
|
|
<order> |
|
268
|
2 |
|
<invoiceNumber>{$this->orderInvoiceNumber}</invoiceNumber> |
|
269
|
2 |
|
<description>{$this->orderDescription}</description> |
|
270
|
|
|
</order> |
|
271
|
|
|
<customer> |
|
272
|
2 |
|
<id>{$this->customerId}</id> |
|
273
|
2 |
|
<email>{$this->customerEmail}</email> |
|
274
|
2 |
|
<phoneNumber>{$this->customerPhoneNumber}</phoneNumber> |
|
275
|
2 |
|
<faxNumber>{$this->customerFaxNumber}</faxNumber> |
|
276
|
|
|
</customer> |
|
277
|
|
|
<billTo> |
|
278
|
2 |
|
<firstName>{$this->billToFirstName}</firstName> |
|
279
|
2 |
|
<lastName>{$this->billToLastName}</lastName> |
|
280
|
2 |
|
<company>{$this->billToCompany}</company> |
|
281
|
2 |
|
<address>{$this->billToAddress}</address> |
|
282
|
2 |
|
<city>{$this->billToCity}</city> |
|
283
|
2 |
|
<state>{$this->billToState}</state> |
|
284
|
2 |
|
<zip>{$this->billToZip}</zip> |
|
285
|
2 |
|
<country>{$this->billToCountry}</country> |
|
286
|
|
|
</billTo> |
|
287
|
|
|
<shipTo> |
|
288
|
2 |
|
<firstName>{$this->shipToFirstName}</firstName> |
|
289
|
2 |
|
<lastName>{$this->shipToLastName}</lastName> |
|
290
|
2 |
|
<company>{$this->shipToCompany}</company> |
|
291
|
2 |
|
<address>{$this->shipToAddress}</address> |
|
292
|
2 |
|
<city>{$this->shipToCity}</city> |
|
293
|
2 |
|
<state>{$this->shipToState}</state> |
|
294
|
2 |
|
<zip>{$this->shipToZip}</zip> |
|
295
|
2 |
|
<country>{$this->shipToCountry}</country> |
|
296
|
|
|
</shipTo> |
|
297
|
2 |
|
</subscription>"; |
|
298
|
|
|
|
|
299
|
2 |
|
$xml_clean = ""; |
|
300
|
|
|
// Remove any blank child elements |
|
301
|
2 |
|
foreach (preg_split("/(\r?\n)/", $xml) as $key => $line) { |
|
302
|
2 |
|
if (!preg_match('/><\//', $line)) { |
|
303
|
2 |
|
$xml_clean .= $line . "\n"; |
|
304
|
|
|
} |
|
305
|
|
|
} |
|
306
|
|
|
|
|
307
|
|
|
// Remove any blank parent elements |
|
308
|
2 |
|
$element_removed = 1; |
|
309
|
|
|
// Recursively repeat if a change is made |
|
310
|
2 |
|
while ($element_removed) { |
|
311
|
2 |
|
$element_removed = 0; |
|
312
|
2 |
|
if (preg_match('/<[a-z]+>[\r?\n]+\s*<\/[a-z]+>/i', $xml_clean)) { |
|
313
|
2 |
|
$xml_clean = preg_replace('/<[a-z]+>[\r?\n]+\s*<\/[a-z]+>/i', '', $xml_clean); |
|
314
|
2 |
|
$element_removed = 1; |
|
315
|
|
|
} |
|
316
|
|
|
} |
|
317
|
|
|
|
|
318
|
|
|
// Remove any blank lines |
|
319
|
|
|
// $xml_clean = preg_replace('/\r\n[\s]+\r\n/','',$xml_clean); |
|
|
|
|
|
|
320
|
2 |
|
return $xml_clean; |
|
321
|
|
|
} |
|
322
|
|
|
} |
|
323
|
|
|
|
|
324
|
|
|
/** |
|
325
|
|
|
* A class that contains all fields for an AuthorizeNet ARB SubscriptionList. |
|
326
|
|
|
* |
|
327
|
|
|
* @package AuthorizeNet |
|
328
|
|
|
* @subpackage AuthorizeNetARB |
|
329
|
|
|
*/ |
|
330
|
|
|
class AuthorizeNetGetSubscriptionList |
|
|
|
|
|
|
331
|
|
|
{ |
|
332
|
|
|
public $searchType; |
|
333
|
|
|
public $sorting; |
|
334
|
|
|
public $paging; |
|
335
|
|
|
|
|
336
|
1 |
|
public function getXml() |
|
337
|
|
|
{ |
|
338
|
1 |
|
$emptyString = ""; |
|
339
|
1 |
|
$sortingXml = (is_null($this->sorting)) ? $emptyString : $this->sorting->getXml(); |
|
340
|
1 |
|
$pagingXml = (is_null($this->paging)) ? $emptyString : $this->paging->getXml(); |
|
341
|
|
|
|
|
342
|
|
|
$xml = " |
|
343
|
1 |
|
<searchType>{$this->searchType}</searchType>" |
|
344
|
1 |
|
.$sortingXml |
|
345
|
1 |
|
.$pagingXml |
|
346
|
|
|
; |
|
347
|
|
|
|
|
348
|
1 |
|
$xml_clean = ""; |
|
349
|
|
|
// Remove any blank child elements |
|
350
|
1 |
|
foreach (preg_split("/(\r?\n)/", $xml) as $key => $line) { |
|
351
|
1 |
|
if (!preg_match('/><\//', $line)) { |
|
352
|
1 |
|
$xml_clean .= $line . "\n"; |
|
353
|
|
|
} |
|
354
|
|
|
} |
|
355
|
|
|
|
|
356
|
|
|
// Remove any blank parent elements |
|
357
|
1 |
|
$element_removed = 1; |
|
358
|
|
|
// Recursively repeat if a change is made |
|
359
|
1 |
|
while ($element_removed) { |
|
360
|
1 |
|
$element_removed = 0; |
|
361
|
1 |
|
if (preg_match('/<[a-z]+>[\r?\n]+\s*<\/[a-z]+>/i', $xml_clean)) { |
|
362
|
|
|
$xml_clean = preg_replace('/<[a-z]+>[\r?\n]+\s*<\/[a-z]+>/i', '', $xml_clean); |
|
363
|
|
|
$element_removed = 1; |
|
364
|
|
|
} |
|
365
|
|
|
} |
|
366
|
|
|
|
|
367
|
|
|
// Remove any blank lines |
|
368
|
|
|
// $xml_clean = preg_replace('/\r\n[\s]+\r\n/','',$xml_clean); |
|
|
|
|
|
|
369
|
1 |
|
return $xml_clean; |
|
370
|
|
|
} |
|
371
|
|
|
} |
|
372
|
|
|
|
|
373
|
|
|
class AuthorizeNetSubscriptionListPaging |
|
|
|
|
|
|
374
|
|
|
{ |
|
375
|
|
|
public $limit; |
|
376
|
|
|
public $offset; |
|
377
|
|
|
|
|
378
|
1 |
|
public function getXml() |
|
379
|
|
|
{ |
|
380
|
|
|
$xml = "<paging> |
|
381
|
1 |
|
<limit>{$this->limit}</limit> |
|
382
|
1 |
|
<offset>{$this->offset}</offset> |
|
383
|
1 |
|
</paging>"; |
|
384
|
|
|
|
|
385
|
1 |
|
return $xml; |
|
386
|
|
|
} |
|
387
|
|
|
} |
|
388
|
|
|
|
|
389
|
|
|
class AuthorizeNetSubscriptionListSorting |
|
|
|
|
|
|
390
|
|
|
{ |
|
391
|
|
|
public $orderBy; |
|
392
|
|
|
public $orderDescending; |
|
393
|
|
|
|
|
394
|
1 |
|
public function getXml() |
|
395
|
|
|
{ |
|
396
|
|
|
$xml = " |
|
397
|
|
|
<sorting> |
|
398
|
1 |
|
<orderBy>{$this->orderBy}</orderBy> |
|
399
|
1 |
|
<orderDescending>{$this->orderDescending}</orderDescending> |
|
400
|
1 |
|
</sorting>"; |
|
401
|
|
|
|
|
402
|
1 |
|
return $xml; |
|
403
|
|
|
} |
|
404
|
|
|
} |
|
405
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.