4 +--------------------------------------------------------------------+
6 +--------------------------------------------------------------------+
7 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
28 * Licensed to CiviCRM under the Academic Free License version 3.0
29 * Written & Contributed by Dolphin Software P/L - March 2008
31 * 'eWAY_GatewayRequest.php' - Based on the standard supplied eWay sample code 'GatewayResponse.php'
33 * The only significant change from the original is that the 'CVN' field is uncommented,
34 * unlike the distributed sample code.
36 * ALSO: Added a 'GetTransactionNumber' function.
39 use CRM_Ewaysingle_ExtensionUtil
as E
;
41 class GatewayRequest
{
42 public $txCustomerID = "";
46 public $txCardholderName = "";
48 public $txCardNumber = "";
50 public $txCardExpiryMonth = "01";
52 public $txCardExpiryYear = "00";
54 public $txTransactionNumber = "";
56 public $txCardholderFirstName = "";
58 public $txCardholderLastName = "";
60 public $txCardholderEmailAddress = "";
62 public $txCardholderAddress = "";
64 public $txCardholderPostalCode = "";
66 public $txInvoiceReference = "";
68 public $txInvoiceDescription = "";
72 public $txOption1 = "";
74 public $txOption2 = "";
76 public $txOption3 = "";
78 public $txCustomerBillingCountry = "";
80 public $txCustomerIPAddress = "";
82 public function __construct() {
86 public function GetTransactionNumber() {
87 return $this->txTransactionNumber
;
90 public function EwayCustomerID($value) {
91 $this->txCustomerID
= $value;
94 public function InvoiceAmount($value) {
95 $this->txAmount
= $value;
98 public function CardHolderName($value) {
99 $this->txCardholderName
= $value;
102 public function CardExpiryMonth($value) {
103 $this->txCardExpiryMonth
= $value;
106 public function CardExpiryYear($value) {
107 $this->txCardExpiryYear
= $value;
110 public function TransactionNumber($value) {
111 $this->txTransactionNumber
= $value;
114 public function PurchaserFirstName($value) {
115 $this->txCardholderFirstName
= $value;
118 public function PurchaserLastName($value) {
119 $this->txCardholderLastName
= $value;
122 public function CardNumber($value) {
123 $this->txCardNumber
= $value;
126 public function PurchaserAddress($value) {
127 $this->txCardholderAddress
= $value;
130 public function PurchaserPostalCode($value) {
131 $this->txCardholderPostalCode
= $value;
134 public function PurchaserEmailAddress($value) {
135 $this->txCardholderEmailAddress
= $value;
138 public function InvoiceReference($value) {
139 $this->txInvoiceReference
= $value;
142 public function InvoiceDescription($value) {
143 $this->txInvoiceDescription
= $value;
146 public function CVN($value) {
147 $this->txCVN
= $value;
150 public function EwayOption1($value) {
151 $this->txOption1
= $value;
154 public function EwayOption2($value) {
155 $this->txOption2
= $value;
158 public function EwayOption3($value) {
159 $this->txOption3
= $value;
162 public function CustomerBillingCountry($value) {
163 $this->txCustomerBillingCountry
= $value;
166 public function CustomerIPAddress($value) {
167 $this->txCustomerIPAddress
= $value;
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.
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>";
201 * Builds a simple XML Node
203 * 'NodeName' is the anem of the node being created.
204 * 'NodeValue' is its value
207 public function CreateNode($NodeName, $NodeValue) {
208 require_once E
::path('lib/XML/Util.php');
210 $xml = new XML_Util();
211 $node = "<" . $NodeName . ">" . $xml->replaceEntities($NodeValue) . "</" . $NodeName . ">";