Merge pull request #18351 from eileenmcnaughton/line
[civicrm-core.git] / ext / ewaysingle / lib / eWAY / eWAY_GatewayRequest.php
1 <?php
2
3 /*
4 +--------------------------------------------------------------------+
5 | CiviCRM version 5 |
6 +--------------------------------------------------------------------+
7 | This file is a part of CiviCRM. |
8 | |
9 | CiviCRM is free software; you can copy, modify, and distribute it |
10 | under the terms of the GNU Affero General Public License |
11 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
12 | |
13 | CiviCRM is distributed in the hope that it will be useful, but |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
16 | See the GNU Affero General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU Affero General Public |
19 | License and the CiviCRM Licensing Exception along |
20 | with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
25 */
26
27 /**
28 * Licensed to CiviCRM under the Academic Free License version 3.0
29 * Written & Contributed by Dolphin Software P/L - March 2008
30 *
31 * 'eWAY_GatewayRequest.php' - Based on the standard supplied eWay sample code 'GatewayResponse.php'
32 *
33 * The only significant change from the original is that the 'CVN' field is uncommented,
34 * unlike the distributed sample code.
35 *
36 * ALSO: Added a 'GetTransactionNumber' function.
37 *
38 */
39 use CRM_Ewaysingle_ExtensionUtil as E;
40
41 class GatewayRequest {
42 public $txCustomerID = "";
43
44 public $txAmount = 0;
45
46 public $txCardholderName = "";
47
48 public $txCardNumber = "";
49
50 public $txCardExpiryMonth = "01";
51
52 public $txCardExpiryYear = "00";
53
54 public $txTransactionNumber = "";
55
56 public $txCardholderFirstName = "";
57
58 public $txCardholderLastName = "";
59
60 public $txCardholderEmailAddress = "";
61
62 public $txCardholderAddress = "";
63
64 public $txCardholderPostalCode = "";
65
66 public $txInvoiceReference = "";
67
68 public $txInvoiceDescription = "";
69
70 public $txCVN = "";
71
72 public $txOption1 = "";
73
74 public $txOption2 = "";
75
76 public $txOption3 = "";
77
78 public $txCustomerBillingCountry = "";
79
80 public $txCustomerIPAddress = "";
81
82 public function __construct() {
83 // Empty Constructor
84 }
85
86 public function GetTransactionNumber() {
87 return $this->txTransactionNumber;
88 }
89
90 public function EwayCustomerID($value) {
91 $this->txCustomerID = $value;
92 }
93
94 public function InvoiceAmount($value) {
95 $this->txAmount = $value;
96 }
97
98 public function CardHolderName($value) {
99 $this->txCardholderName = $value;
100 }
101
102 public function CardExpiryMonth($value) {
103 $this->txCardExpiryMonth = $value;
104 }
105
106 public function CardExpiryYear($value) {
107 $this->txCardExpiryYear = $value;
108 }
109
110 public function TransactionNumber($value) {
111 $this->txTransactionNumber = $value;
112 }
113
114 public function PurchaserFirstName($value) {
115 $this->txCardholderFirstName = $value;
116 }
117
118 public function PurchaserLastName($value) {
119 $this->txCardholderLastName = $value;
120 }
121
122 public function CardNumber($value) {
123 $this->txCardNumber = $value;
124 }
125
126 public function PurchaserAddress($value) {
127 $this->txCardholderAddress = $value;
128 }
129
130 public function PurchaserPostalCode($value) {
131 $this->txCardholderPostalCode = $value;
132 }
133
134 public function PurchaserEmailAddress($value) {
135 $this->txCardholderEmailAddress = $value;
136 }
137
138 public function InvoiceReference($value) {
139 $this->txInvoiceReference = $value;
140 }
141
142 public function InvoiceDescription($value) {
143 $this->txInvoiceDescription = $value;
144 }
145
146 public function CVN($value) {
147 $this->txCVN = $value;
148 }
149
150 public function EwayOption1($value) {
151 $this->txOption1 = $value;
152 }
153
154 public function EwayOption2($value) {
155 $this->txOption2 = $value;
156 }
157
158 public function EwayOption3($value) {
159 $this->txOption3 = $value;
160 }
161
162 public function CustomerBillingCountry($value) {
163 $this->txCustomerBillingCountry = $value;
164 }
165
166 public function CustomerIPAddress($value) {
167 $this->txCustomerIPAddress = $value;
168 }
169
170 public function ToXml() {
171 // We don't really need the overhead of creating an XML DOM object
172 // to really just concatenate a string together.
173
174 $xml = "<ewaygateway>";
175 $xml .= $this->CreateNode("ewayCustomerID", $this->txCustomerID);
176 $xml .= $this->CreateNode("ewayTotalAmount", $this->txAmount);
177 $xml .= $this->CreateNode("ewayCardHoldersName", $this->txCardholderName);
178 $xml .= $this->CreateNode("ewayCardNumber", $this->txCardNumber);
179 $xml .= $this->CreateNode("ewayCardExpiryMonth", $this->txCardExpiryMonth);
180 $xml .= $this->CreateNode("ewayCardExpiryYear", $this->txCardExpiryYear);
181 $xml .= $this->CreateNode("ewayTrxnNumber", $this->txTransactionNumber);
182 $xml .= $this->CreateNode("ewayCustomerInvoiceDescription", $this->txInvoiceDescription);
183 $xml .= $this->CreateNode("ewayCustomerFirstName", $this->txCardholderFirstName);
184 $xml .= $this->CreateNode("ewayCustomerLastName", $this->txCardholderLastName);
185 $xml .= $this->CreateNode("ewayCustomerEmail", $this->txCardholderEmailAddress);
186 $xml .= $this->CreateNode("ewayCustomerAddress", $this->txCardholderAddress);
187 $xml .= $this->CreateNode("ewayCustomerPostcode", $this->txCardholderPostalCode);
188 $xml .= $this->CreateNode("ewayCustomerInvoiceRef", $this->txInvoiceReference);
189 $xml .= $this->CreateNode("ewayCVN", $this->txCVN);
190 $xml .= $this->CreateNode("ewayOption1", $this->txOption1);
191 $xml .= $this->CreateNode("ewayOption2", $this->txOption2);
192 $xml .= $this->CreateNode("ewayOption3", $this->txOption3);
193 $xml .= $this->CreateNode("ewayCustomerIPAddress", $this->txCustomerIPAddress);
194 $xml .= $this->CreateNode("ewayCustomerBillingCountry", $this->txCustomerBillingCountry);
195 $xml .= "</ewaygateway>";
196
197 return $xml;
198 }
199
200 /**
201 * Builds a simple XML Node
202 *
203 * 'NodeName' is the anem of the node being created.
204 * 'NodeValue' is its value
205 *
206 */
207 public function CreateNode($NodeName, $NodeValue) {
208 require_once E::path('lib/XML/Util.php');
209
210 $xml = new XML_Util();
211 $node = "<" . $NodeName . ">" . $xml->replaceEntities($NodeValue) . "</" . $NodeName . ">";
212 return $node;
213 }
214
215 }