This repository was archived by the owner on Jan 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAuthorizeNetSubscription.php
More file actions
139 lines (132 loc) · 4.65 KB
/
AuthorizeNetSubscription.php
File metadata and controls
139 lines (132 loc) · 4.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?php
namespace Problematic\AuthNetBundle\AuthorizeNet\API\ARB;
/**
* A class that contains all fields for an AuthorizeNet ARB Subscription.
*
* @package AuthorizeNet
* @subpackage AuthorizeNetARB
*/
class AuthorizeNetSubscription
{
public $name;
public $intervalLength;
public $intervalUnit;
public $startDate;
public $totalOccurrences;
public $trialOccurrences;
public $amount;
public $trialAmount;
public $creditCardCardNumber;
public $creditCardExpirationDate;
public $creditCardCardCode;
public $bankAccountAccountType;
public $bankAccountRoutingNumber;
public $bankAccountAccountNumber;
public $bankAccountNameOnAccount;
public $bankAccountEcheckType;
public $bankAccountBankName;
public $orderInvoiceNumber;
public $orderDescription;
public $customerId;
public $customerEmail;
public $customerPhoneNumber;
public $customerFaxNumber;
public $billToFirstName;
public $billToLastName;
public $billToCompany;
public $billToAddress;
public $billToCity;
public $billToState;
public $billToZip;
public $billToCountry;
public $shipToFirstName;
public $shipToLastName;
public $shipToCompany;
public $shipToAddress;
public $shipToCity;
public $shipToState;
public $shipToZip;
public $shipToCountry;
public function getXml()
{
$xml = "<subscription>
<name>{$this->name}</name>
<paymentSchedule>
<interval>
<length>{$this->intervalLength}</length>
<unit>{$this->intervalUnit}</unit>
</interval>
<startDate>{$this->startDate}</startDate>
<totalOccurrences>{$this->totalOccurrences}</totalOccurrences>
<trialOccurrences>{$this->trialOccurrences}</trialOccurrences>
</paymentSchedule>
<amount>{$this->amount}</amount>
<trialAmount>{$this->trialAmount}</trialAmount>
<payment>
<creditCard>
<cardNumber>{$this->creditCardCardNumber}</cardNumber>
<expirationDate>{$this->creditCardExpirationDate}</expirationDate>
<cardCode>{$this->creditCardCardCode}</cardCode>
</creditCard>
<bankAccount>
<accountType>{$this->bankAccountAccountType}</accountType>
<routingNumber>{$this->bankAccountRoutingNumber}</routingNumber>
<accountNumber>{$this->bankAccountAccountNumber}</accountNumber>
<nameOnAccount>{$this->bankAccountNameOnAccount}</nameOnAccount>
<echeckType>{$this->bankAccountEcheckType}</echeckType>
<bankName>{$this->bankAccountBankName}</bankName>
</bankAccount>
</payment>
<order>
<invoiceNumber>{$this->orderInvoiceNumber}</invoiceNumber>
<description>{$this->orderDescription}</description>
</order>
<customer>
<id>{$this->customerId}</id>
<email>{$this->customerEmail}</email>
<phoneNumber>{$this->customerPhoneNumber}</phoneNumber>
<faxNumber>{$this->customerFaxNumber}</faxNumber>
</customer>
<billTo>
<firstName>{$this->billToFirstName}</firstName>
<lastName>{$this->billToLastName}</lastName>
<company>{$this->billToCompany}</company>
<address>{$this->billToAddress}</address>
<city>{$this->billToCity}</city>
<state>{$this->billToState}</state>
<zip>{$this->billToZip}</zip>
<country>{$this->billToCountry}</country>
</billTo>
<shipTo>
<firstName>{$this->shipToFirstName}</firstName>
<lastName>{$this->shipToLastName}</lastName>
<company>{$this->shipToCompany}</company>
<address>{$this->shipToAddress}</address>
<city>{$this->shipToCity}</city>
<state>{$this->shipToState}</state>
<zip>{$this->shipToZip}</zip>
<country>{$this->shipToCountry}</country>
</shipTo>
</subscription>";
$xml_clean = "";
// Remove any blank child elements
foreach (preg_split("/(\r?\n)/", $xml) as $key => $line) {
if (!preg_match('/><\//', $line)) {
$xml_clean .= $line . "\n";
}
}
// Remove any blank parent elements
$element_removed = 1;
// Recursively repeat if a change is made
while ($element_removed) {
$element_removed = 0;
if (preg_match('/<[a-z]+>[\r?\n]+\s*<\/[a-z]+>/i', $xml_clean)) {
$xml_clean = preg_replace('/<[a-z]+>[\r?\n]+\s*<\/[a-z]+>/i', '', $xml_clean);
$element_removed = 1;
}
}
// Remove any blank lines
// $xml_clean = preg_replace('/\r\n[\s]+\r\n/','',$xml_clean);
return $xml_clean;
}
}