Iridiumcorp_Tpg - Version 1.3

Version Notes

3D Secure transactions redirected to an outer ACS page rather than using iframe. System log file contains transaction specific result details.

Download this release

Release Info

Developer Magento Core Team
Extension Iridiumcorp_Tpg
Version 1.3
Comparing to
See all releases


Version 1.3

Files changed (30) hide show
  1. app/code/local/Iridiumcorp/Checkout/Model/Type/Onepage.php +332 -0
  2. app/code/local/Iridiumcorp/Checkout/etc/config.xml +17 -0
  3. app/code/local/Iridiumcorp/Tpg/Block/Error.php +6 -0
  4. app/code/local/Iridiumcorp/Tpg/Block/Form.php +127 -0
  5. app/code/local/Iridiumcorp/Tpg/Block/Info.php +36 -0
  6. app/code/local/Iridiumcorp/Tpg/Block/Redirect.php +235 -0
  7. app/code/local/Iridiumcorp/Tpg/Block/Threedsecure.php +38 -0
  8. app/code/local/Iridiumcorp/Tpg/Helper/Data.php +6 -0
  9. app/code/local/Iridiumcorp/Tpg/Model/Direct.php +768 -0
  10. app/code/local/Iridiumcorp/Tpg/Model/Request.php +22 -0
  11. app/code/local/Iridiumcorp/Tpg/Model/Source/HashMethod.php +33 -0
  12. app/code/local/Iridiumcorp/Tpg/Model/Source/PaymentAction.php +15 -0
  13. app/code/local/Iridiumcorp/Tpg/Model/Source/PaymentMode.php +28 -0
  14. app/code/local/Iridiumcorp/Tpg/Model/Source/ResultDeliveryMethod.php +23 -0
  15. app/code/local/Iridiumcorp/Tpg/Model/Tpg/GlobalErrors.php +20 -0
  16. app/code/local/Iridiumcorp/Tpg/Model/Tpg/ISOCountries.php +265 -0
  17. app/code/local/Iridiumcorp/Tpg/Model/Tpg/ISOCurrencies.php +199 -0
  18. app/code/local/Iridiumcorp/Tpg/Model/Tpg/PaymentFormHelper.php +444 -0
  19. app/code/local/Iridiumcorp/Tpg/Model/Tpg/ThePaymentGateway/PaymentSystem.php +2398 -0
  20. app/code/local/Iridiumcorp/Tpg/Model/Tpg/ThePaymentGateway/SOAP.php +968 -0
  21. app/code/local/Iridiumcorp/Tpg/Model/Tpg/ThePaymentGateway/TPG_Common.php +882 -0
  22. app/code/local/Iridiumcorp/Tpg/controllers/PaymentController.php +411 -0
  23. app/code/local/Iridiumcorp/Tpg/etc/config.xml +105 -0
  24. app/code/local/Iridiumcorp/Tpg/etc/system.xml +249 -0
  25. app/design/adminhtml/default/default/template/tpg/form.phtml +86 -0
  26. app/design/adminhtml/default/default/template/tpg/info.phtml +18 -0
  27. app/design/frontend/default/default/template/tpg/form.phtml +86 -0
  28. app/design/frontend/default/default/template/tpg/info.phtml +17 -0
  29. app/etc/modules/Iridiumcorp_All.xml +15 -0
  30. package.xml +18 -0
app/code/local/Iridiumcorp/Checkout/Model/Type/Onepage.php ADDED
@@ -0,0 +1,332 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Iridiumcorp_Checkout_Model_Type_Onepage extends Mage_Checkout_Model_Type_Onepage
4
+ {
5
+ /**
6
+ * Create order based on checkout type. Create customer if necessary. Overrided for necessary redirection
7
+ *
8
+ * @return Mage_Checkout_Model_Type_Onepage
9
+ */
10
+ public function saveOrder()
11
+ {
12
+ $this->validate();
13
+ $isNewCustomer = false;
14
+
15
+ switch ($this->getCheckoutMehod())
16
+ {
17
+ case self::METHOD_GUEST:
18
+ $this->_prepareGuestQuote();
19
+ break;
20
+ case self::METHOD_REGISTER:
21
+ $this->_prepareNewCustomerQuote();
22
+ $isNewCustomer = true;
23
+ break;
24
+ default:
25
+ $this->_prepareCustomerQuote();
26
+ break;
27
+ }
28
+
29
+ $service = Mage::getModel('sales/service_quote', $this->getQuote());
30
+ $order = $service->submit();
31
+
32
+ if ($isNewCustomer)
33
+ {
34
+ try
35
+ {
36
+ $this->_involveNewCustomer();
37
+ }
38
+ catch (Exception $e)
39
+ {
40
+ Mage::logException($e);
41
+ }
42
+ }
43
+ Mage::dispatchEvent('checkout_type_onepage_save_order_after', array('order'=>$order, 'quote'=>$this->getQuote()));
44
+
45
+ /**
46
+ * a flag to set for redirecting to a third party URL (ie: for 3D Secure authorization)
47
+ *
48
+ */
49
+ $redirectUrl = $this->getQuote()->getPayment()->getOrderPlaceRedirectUrl();
50
+
51
+ /**
52
+ * we only want to send email to customer about new order when there is no redirect to third party
53
+ */
54
+ if(!$redirectUrl)
55
+ {
56
+ try
57
+ {
58
+ $order->sendNewOrderEmail();
59
+ }
60
+ catch (Exception $exc)
61
+ {
62
+ Mage::logException($exc);
63
+ }
64
+ }
65
+
66
+ $this->getCheckout()->setLastQuoteId($this->getQuote()->getId())
67
+ ->setLastOrderId($order->getId())
68
+ ->setLastRealOrderId($order->getIncrementId())
69
+ ->setRedirectUrl($redirectUrl)
70
+ ->setLastSuccessQuoteId($this->getQuote()->getId());
71
+
72
+ return $this;
73
+ }
74
+
75
+ /**
76
+ * Finalising a 3D Secure transaction payment
77
+ *
78
+ * @param string $PaRes
79
+ * @param string $MD
80
+ * @return unknown
81
+ */
82
+ public function saveOrderAfter3DSecure($PaRes, $MD)
83
+ {
84
+ $this->validateOrder();
85
+ $billing = $this->getQuote()->getBillingAddress();
86
+
87
+ if (!$this->getQuote()->isVirtual())
88
+ {
89
+ $shipping = $this->getQuote()->getShippingAddress();
90
+ }
91
+
92
+ switch ($this->getQuote()->getCheckoutMethod())
93
+ {
94
+ case 'guest':
95
+ $this->getQuote()->setCustomerEmail($billing->getEmail())
96
+ ->setCustomerIsGuest(true)
97
+ ->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
98
+ break;
99
+ default:
100
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
101
+
102
+ if (!$billing->getCustomerId() ||
103
+ $billing->getSaveInAddressBook())
104
+ {
105
+ $customerBilling = $billing->exportCustomerAddress();
106
+ $customer->addAddress($customerBilling);
107
+ }
108
+ if (!$this->getQuote()->isVirtual() &&
109
+ ((!$shipping->getCustomerId() && !$shipping->getSameAsBilling()) ||
110
+ (!$shipping->getSameAsBilling() && $shipping->getSaveInAddressBook())))
111
+ {
112
+ $customerShipping = $shipping->exportCustomerAddress();
113
+ $customer->addAddress($customerShipping);
114
+ }
115
+
116
+ $customer->setSavedFromQuote(true);
117
+ $customer->save();
118
+
119
+ $changed = false;
120
+ if (isset($customerBilling) &&
121
+ !$customer->getDefaultBilling())
122
+ {
123
+ $customer->setDefaultBilling($customerBilling->getId());
124
+ $changed = true;
125
+ }
126
+
127
+ if (!$this->getQuote()->isVirtual() &&
128
+ isset($customerBilling) &&
129
+ !$customer->getDefaultShipping() &&
130
+ $shipping->getSameAsBilling())
131
+ {
132
+ $customer->setDefaultShipping($customerBilling->getId());
133
+ $changed = true;
134
+ }
135
+ elseif (!$this->getQuote()->isVirtual() &&
136
+ isset($customerShipping) &&
137
+ !$customer->getDefaultShipping())
138
+ {
139
+ $customer->setDefaultShipping($customerShipping->getId());
140
+ $changed = true;
141
+ }
142
+
143
+ if ($changed)
144
+ {
145
+ $customer->save();
146
+ }
147
+ }
148
+
149
+ // make sure that the order id is not incremented for the second phase of a 3D Secure transaction
150
+ //$this->getQuote()->reserveOrderId();
151
+
152
+ $convertQuote = Mage::getModel('sales/convert_quote');
153
+ if ($this->getQuote()->isVirtual())
154
+ {
155
+ $order = $convertQuote->addressToOrder($billing);
156
+ }
157
+ else
158
+ {
159
+ $order = $convertQuote->addressToOrder($shipping);
160
+ }
161
+
162
+ $order->setBillingAddress($convertQuote->addressToOrderAddress($billing));
163
+
164
+ if (!$this->getQuote()->isVirtual())
165
+ {
166
+ $order->setShippingAddress($convertQuote->addressToOrderAddress($shipping));
167
+ }
168
+
169
+ $order->setPayment($convertQuote->paymentToOrderPayment($this->getQuote()->getPayment()));
170
+
171
+ foreach ($this->getQuote()->getAllItems() as $item)
172
+ {
173
+ $order->addItem($convertQuote->itemToOrderItem($item));
174
+ }
175
+
176
+ /**
177
+ * We can use configuration data for declare new order status
178
+ */
179
+ Mage::dispatchEvent('checkout_type_onepage_save_order', array('order'=>$order, 'quote'=>$this->getQuote()));
180
+
181
+ Mage::getSingleton('checkout/session')->setSecure3d(true);
182
+ Mage::getSingleton('checkout/session')->setMd($MD);
183
+ Mage::getSingleton('checkout/session')->setPares($PaRes);
184
+
185
+ $order->place();
186
+
187
+ if ($order->getPayment()->getMethodInstance()->getCode()=="tpg" &&
188
+ $order->getStatus() != 'pending' )
189
+ {
190
+ #set it as pending
191
+ #get the xml configuration ($this)
192
+ #$order_status = 'pending';
193
+
194
+ $order_status = Mage::getStoreConfig('payment/tpg/order_status', Mage::app()->getStore()->getId());
195
+
196
+ $order->addStatusToHistory($order_status);
197
+ $order->setStatus($order_status);
198
+ }
199
+
200
+ $order->save();
201
+
202
+ Mage::dispatchEvent('checkout_type_onepage_save_order_after', array('order'=>$order, 'quote'=>$this->getQuote()));
203
+
204
+ $this->getQuote()->setIsActive(false);
205
+ $this->getQuote()->save();
206
+
207
+ $orderId = $order->getIncrementId();
208
+ $this->getCheckout()->setLastQuoteId($this->getQuote()->getId());
209
+ $this->getCheckout()->setLastOrderId($order->getId());
210
+ $this->getCheckout()->setLastRealOrderId($order->getIncrementId());
211
+
212
+ if ($this->getQuote()->getCheckoutMethod()=='register')
213
+ {
214
+ Mage::getSingleton('customer/session')->loginById($customer->getId());
215
+ }
216
+
217
+ return $this;
218
+ }
219
+
220
+ /**
221
+ * Completing the order on the Mage system after a Hosted Payment (save the updated order)
222
+ *
223
+ */
224
+ public function saveOrderAfterHostedPayment()
225
+ {
226
+ $this->validateOrder();
227
+
228
+ // get the order from the billing or the shipping details
229
+ $billing = $this->getQuote()->getBillingAddress();
230
+ if (!$this->getQuote()->isVirtual())
231
+ {
232
+ $shipping = $this->getQuote()->getShippingAddress();
233
+ }
234
+
235
+ switch ($this->getQuote()->getCheckoutMethod())
236
+ {
237
+ case 'guest':
238
+ $this->getQuote()->setCustomerEmail($billing->getEmail())
239
+ ->setCustomerIsGuest(true)
240
+ ->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
241
+ break;
242
+ default:
243
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
244
+
245
+ if (!$billing->getCustomerId() ||
246
+ $billing->getSaveInAddressBook())
247
+ {
248
+ $customerBilling = $billing->exportCustomerAddress();
249
+ $customer->addAddress($customerBilling);
250
+ }
251
+ if (!$this->getQuote()->isVirtual() &&
252
+ ((!$shipping->getCustomerId() && !$shipping->getSameAsBilling()) || (!$shipping->getSameAsBilling() && $shipping->getSaveInAddressBook())))
253
+ {
254
+ $customerShipping = $shipping->exportCustomerAddress();
255
+ $customer->addAddress($customerShipping);
256
+ }
257
+
258
+ $customer->setSavedFromQuote(true);
259
+ $customer->save();
260
+
261
+ $changed = false;
262
+ if (isset($customerBilling) &&
263
+ !$customer->getDefaultBilling())
264
+ {
265
+ $customer->setDefaultBilling($customerBilling->getId());
266
+ $changed = true;
267
+ }
268
+
269
+ if (!$this->getQuote()->isVirtual() &&
270
+ isset($customerBilling) &&
271
+ !$customer->getDefaultShipping() &&
272
+ $shipping->getSameAsBilling())
273
+ {
274
+ $customer->setDefaultShipping($customerBilling->getId());
275
+ $changed = true;
276
+ }
277
+ elseif (!$this->getQuote()->isVirtual() &&
278
+ isset($customerShipping) &&
279
+ !$customer->getDefaultShipping())
280
+ {
281
+ $customer->setDefaultShipping($customerShipping->getId());
282
+ $changed = true;
283
+ }
284
+
285
+ if ($changed)
286
+ {
287
+ $customer->save();
288
+ }
289
+ }
290
+
291
+ $convertQuote = Mage::getModel('sales/convert_quote');
292
+ if ($this->getQuote()->isVirtual())
293
+ {
294
+ $order = $convertQuote->addressToOrder($billing);
295
+ }
296
+ else
297
+ {
298
+ $order = $convertQuote->addressToOrder($shipping);
299
+ }
300
+
301
+ $order->setBillingAddress($convertQuote->addressToOrderAddress($billing));
302
+
303
+ if (!$this->getQuote()->isVirtual())
304
+ {
305
+ $order->setShippingAddress($convertQuote->addressToOrderAddress($shipping));
306
+ }
307
+
308
+ $order->setPayment($convertQuote->paymentToOrderPayment($this->getQuote()->getPayment()));
309
+
310
+ foreach ($this->getQuote()->getAllItems() as $item)
311
+ {
312
+ $order->addItem($convertQuote->itemToOrderItem($item));
313
+ }
314
+
315
+ /**
316
+ * We can use configuration data for declare new order status
317
+ */
318
+ Mage::dispatchEvent('checkout_type_onepage_save_order', array('order'=>$order, 'quote'=>$this->getQuote()));
319
+
320
+ $order->save();
321
+ Mage::dispatchEvent('checkout_type_onepage_save_order_after', array('order'=>$order, 'quote'=>$this->getQuote()));
322
+
323
+ $this->getQuote()->setIsActive(false);
324
+ $this->getQuote()->save();
325
+
326
+ $this->getCheckout()->setLastQuoteId($this->getQuote()->getId())
327
+ ->setLastOrderId($order->getId())
328
+ ->setLastRealOrderId($order->getIncrementId());
329
+
330
+ return $this;
331
+ }
332
+ }
app/code/local/Iridiumcorp/Checkout/etc/config.xml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Iridiumcorp_Checkout>
5
+ <version>0.0.1</version>
6
+ </Iridiumcorp_Checkout>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <checkout>
11
+ <rewrite>
12
+ <type_onepage>Iridiumcorp_Checkout_Model_Type_Onepage</type_onepage>
13
+ </rewrite>
14
+ </checkout>
15
+ </models>
16
+ </global>
17
+ </config>
app/code/local/Iridiumcorp/Tpg/Block/Error.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Iridiumcorp_Tpg_Block_Error extends Mage_Core_Block_Template
4
+ {
5
+
6
+ }
app/code/local/Iridiumcorp/Tpg/Block/Form.php ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Iridiumcorp_Tpg_Block_Form extends Mage_Payment_Block_Form
3
+ {
4
+ protected function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->setTemplate('tpg/form.phtml');
8
+ }
9
+
10
+ protected function _getConfig()
11
+ {
12
+ return Mage::getSingleton('payment/config');
13
+ }
14
+
15
+ /**
16
+ * Returns an array of credit card expiry months
17
+ *
18
+ * @return unknown
19
+ */
20
+ public function getCcMonths()
21
+ {
22
+ $months = $this->getData('cc_months');
23
+
24
+ if (is_null($months))
25
+ {
26
+ $months = array();
27
+ $monthList = $this->_getConfig()->getMonths();
28
+
29
+ $months[0] = $this->__('Month');
30
+ for ($nCount = 1; $nCount <= sizeof($monthList); $nCount++)
31
+ {
32
+ $value = $nCount;
33
+ if($value < 10)
34
+ {
35
+ $value = '0'.$value;
36
+ }
37
+ $months[$value] = $monthList[$nCount];
38
+ }
39
+
40
+ $this->setData('cc_months', $months);
41
+ }
42
+
43
+ return $months;
44
+ }
45
+
46
+ /**
47
+ * Returns an array of credit card expiry years
48
+ *
49
+ * @return unknown
50
+ */
51
+ public function getCcYears()
52
+ {
53
+ $years = $this->getData('cc_years');
54
+
55
+ if (is_null($years))
56
+ {
57
+ $years = array();
58
+ $first = date("Y");
59
+
60
+ $years = array($this->__('Year'));
61
+ for ($index = 0; $index < 10; $index++)
62
+ {
63
+ $year = $first + $index;
64
+ $yearPartial = substr($year, 2);
65
+ $years[$yearPartial] = $year;
66
+ }
67
+ $this->setData('cc_years', $years);
68
+ }
69
+
70
+ return $years;
71
+ }
72
+
73
+ /**
74
+ * Returns an array credit card start months
75
+ *
76
+ * @return unknown
77
+ */
78
+ public function getCcStartMonths()
79
+ {
80
+ $months = $this->getData('cc_ss_start_month');
81
+
82
+ if (is_null($months))
83
+ {
84
+ $months = array();
85
+ $monthList = $this->_getConfig()->getMonths();
86
+
87
+ for ($nCount = 1; $nCount <= sizeof($monthList); $nCount++)
88
+ {
89
+ $value = $nCount;
90
+ if($value < 10)
91
+ {
92
+ $value = '0'.$value;
93
+ }
94
+ $months[$value] = $monthList[$nCount];
95
+ }
96
+ $this->setData('cc_ss_start_month', $months);
97
+ }
98
+
99
+ return $months;
100
+ }
101
+
102
+ /**
103
+ * Returns an array of credit card start years
104
+ *
105
+ * @return unknown
106
+ */
107
+ public function getCcStartYears()
108
+ {
109
+ $years = $this->getData('cc_start_years');
110
+
111
+ if(is_null($years))
112
+ {
113
+ $years = array();
114
+ $first = date("Y");
115
+
116
+ for ($index = 0; $index < 10; $index++)
117
+ {
118
+ $year = $first - $index;
119
+ $yearPartial = substr($year, 2);
120
+ $years[$yearPartial] = $year;
121
+ }
122
+ $this->setData('cc_start_years', $years);
123
+ }
124
+
125
+ return $years;
126
+ }
127
+ }
app/code/local/Iridiumcorp/Tpg/Block/Info.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Iridiumcorp_Tpg_Block_Info extends Mage_Payment_Block_Info
4
+ {
5
+ /**
6
+ * Init default template for block
7
+ */
8
+ protected function _construct()
9
+ {
10
+ parent::_construct();
11
+ $this->setTemplate('tpg/info.phtml');
12
+ }
13
+
14
+ public function getCcNumber()
15
+ {
16
+ return $this->getInfo()->decrypt($this->getInfo()->getCcNumberEnc());
17
+ }
18
+
19
+ public function getCcCid()
20
+ {
21
+ return $this->getInfo()->decrypt($this->getInfo()->getCcCidEnc());
22
+ }
23
+
24
+ /**
25
+ * Retrieve CC expiration date
26
+ *
27
+ * @return Zend_Date
28
+ */
29
+ public function getCcExpDate()
30
+ {
31
+ $date = Mage::app()->getLocale()->date(0);
32
+ $date->setYear($this->getInfo()->getCcExpYear());
33
+ $date->setMonth($this->getInfo()->getCcExpMonth());
34
+ return $date;
35
+ }
36
+ }
app/code/local/Iridiumcorp/Tpg/Block/Redirect.php ADDED
@@ -0,0 +1,235 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Iridiumcorp_Tpg_Block_Redirect extends Mage_Core_Block_Abstract
4
+ {
5
+ /**
6
+ * Build the redirect form to be submitted to the hosted payment form or the transparent redirect page
7
+ *
8
+ */
9
+ protected function _toHtml()
10
+ {
11
+ $model = Mage::getModel('tpg/direct');
12
+ $pmPaymentMode = $model->getConfigData('mode');
13
+
14
+ switch ($pmPaymentMode)
15
+ {
16
+ case Iridiumcorp_Tpg_Model_Source_PaymentMode::PAYMENT_MODE_HOSTED_PAYMENT_FORM:
17
+ $html = self::_redirectToHostedPaymentForm();
18
+ break;
19
+ case Iridiumcorp_Tpg_Model_Source_PaymentMode::PAYMENT_MODE_TRANSPARENT_REDIRECT:
20
+ $html = self::_redirectToTransparentRedirect();
21
+ break;
22
+ }
23
+
24
+ return $html;
25
+ }
26
+
27
+ private function _redirectToHostedPaymentForm()
28
+ {
29
+ $html = '';
30
+ $model = Mage::getModel('tpg/direct');
31
+ $szActionURL = $model->getConfigData('hostedpaymentactionurl');
32
+
33
+ // create a Magento form
34
+ $form = new Varien_Data_Form();
35
+ $form->setAction($szActionURL)
36
+ ->setId('HostedPaymentForm')
37
+ ->setName('HostedPaymentForm')
38
+ ->setMethod('POST')
39
+ ->setUseContainer(true);
40
+
41
+ $form->addField("HashDigest", 'hidden', array('name'=>"HashDigest", 'value'=>Mage::getSingleton('checkout/session')->getHashdigest()));
42
+ $form->addField("MerchantID", 'hidden', array('name'=>"MerchantID", 'value'=>Mage::getSingleton('checkout/session')->getMerchantid()));
43
+ $form->addField("Amount", 'hidden', array('name'=>"Amount", 'value'=>Mage::getSingleton('checkout/session')->getAmount()));
44
+ $form->addField("CurrencyCode", 'hidden', array('name'=>"CurrencyCode", 'value'=>Mage::getSingleton('checkout/session')->getCurrencycode()));
45
+ $form->addField("OrderID", 'hidden', array('name'=>"OrderID", 'value'=>Mage::getSingleton('checkout/session')->getOrderid()));
46
+ $form->addField("TransactionType", 'hidden', array('name'=>"TransactionType", 'value'=>Mage::getSingleton('checkout/session')->getTransactiontype()));
47
+ $form->addField("TransactionDateTime", 'hidden', array('name'=>"TransactionDateTime", 'value'=>Mage::getSingleton('checkout/session')->getTransactiondatetime()));
48
+ $form->addField("CallbackURL", 'hidden', array('name'=>"CallbackURL", 'value'=>Mage::getSingleton('checkout/session')->getCallbackurl()));
49
+ $form->addField("OrderDescription", 'hidden', array('name'=>"OrderDescription", 'value'=>Mage::getSingleton('checkout/session')->getOrderdescription()));
50
+ $form->addField("CustomerName", 'hidden', array('name'=>"CustomerName", 'value'=>Mage::getSingleton('checkout/session')->getCustomername()));
51
+ $form->addField("Address1", 'hidden', array('name'=>"Address1", 'value'=>Mage::getSingleton('checkout/session')->getAddress1()));
52
+ $form->addField("Address2", 'hidden', array('name'=>"Address2", 'value'=>Mage::getSingleton('checkout/session')->getAddress2()));
53
+ $form->addField("Address3", 'hidden', array('name'=>"Address3", 'value'=>Mage::getSingleton('checkout/session')->getAddress3()));
54
+ $form->addField("Address4", 'hidden', array('name'=>"Address4", 'value'=>Mage::getSingleton('checkout/session')->getAddress4()));
55
+ $form->addField("City", 'hidden', array('name'=>"City", 'value'=>Mage::getSingleton('checkout/session')->getCity()));
56
+ $form->addField("State", 'hidden', array('name'=>"State", 'value'=>Mage::getSingleton('checkout/session')->getState()));
57
+ $form->addField("PostCode", 'hidden', array('name'=>"PostCode", 'value'=>Mage::getSingleton('checkout/session')->getPostcode()));
58
+ $form->addField("CountryCode", 'hidden', array('name'=>"CountryCode", 'value'=>Mage::getSingleton('checkout/session')->getCountrycode()));
59
+ $form->addField("CV2Mandatory", 'hidden', array('name'=>"CV2Mandatory", 'value'=>Mage::getSingleton('checkout/session')->getCv2mandatory()));
60
+ $form->addField("Address1Mandatory", 'hidden', array('name'=>"Address1Mandatory", 'value'=>Mage::getSingleton('checkout/session')->getAddress1mandatory()));
61
+ $form->addField("CityMandatory", 'hidden', array('name'=>"CityMandatory", 'value'=>Mage::getSingleton('checkout/session')->getCitymandatory()));
62
+ $form->addField("PostCodeMandatory", 'hidden', array('name'=>"PostCodeMandatory", 'value'=>Mage::getSingleton('checkout/session')->getPostcodemandatory()));
63
+ $form->addField("StateMandatory", 'hidden', array('name'=>"StateMandatory", 'value'=>Mage::getSingleton('checkout/session')->getStatemandatory()));
64
+ $form->addField("CountryMandatory", 'hidden', array('name'=>"CountryMandatory", 'value'=>Mage::getSingleton('checkout/session')->getCountrymandatory()));
65
+ $form->addField("ResultDeliveryMethod", 'hidden', array('name'=>"ResultDeliveryMethod", 'value'=>Mage::getSingleton('checkout/session')->getResultdeliverymethod()));
66
+ $form->addField("ServerResultURL", 'hidden', array('name'=>"ServerResultURL", 'value'=>Mage::getSingleton('checkout/session')->getServerresulturl()));
67
+ $form->addField("PaymentFormDisplaysResult", 'hidden', array('name'=>"PaymentFormDisplaysResult", 'value'=>Mage::getSingleton('checkout/session')->getPaymentformdisplaysresult()));
68
+
69
+ // reset the session items
70
+ Mage::getSingleton('checkout/session')->setHashdigest(null)
71
+ ->setMerchantid(null)
72
+ ->setAmount(null)
73
+ ->setCurrencycode(null)
74
+ ->setOrderid(null)
75
+ ->setTransactiontype(null)
76
+ ->setTransactiondatetime(null)
77
+ ->setCallbackurl(null)
78
+ ->setOrderdescription(null)
79
+ ->setCustomername(null)
80
+ ->setAddress1(null)
81
+ ->setAddress2(null)
82
+ ->setAddress3(null)
83
+ ->setAddress4(null)
84
+ ->setCity(null)
85
+ ->setState(null)
86
+ ->setPostcode(null)
87
+ ->setCountrycode(null)
88
+ ->setCv2mandatory(null)
89
+ ->setAddress1mandatory(null)
90
+ ->setCitymandatory(null)
91
+ ->setPostcodemandatory(null)
92
+ ->setStatemandatory(null)
93
+ ->setCountrymandatory(null)
94
+ ->setResultdeliverymethod(null)
95
+ ->setServerresulturl(null)
96
+ ->setPaymentformdisplaysresult(null);
97
+
98
+ $html = '<html><body>';
99
+ $html.= $this->__('You will be redirected to a secure payment page in a few seconds.');
100
+ $html.= $form->toHtml();
101
+ $html.= '<script type="text/javascript">document.getElementById("HostedPaymentForm").submit();</script>';
102
+ $html.= '</body></html>';
103
+
104
+ return $html;
105
+ }
106
+
107
+ private function _redirectToTransparentRedirect()
108
+ {
109
+ $html;
110
+ $model = Mage::getModel('tpg/direct');
111
+ $szActionURL = $model->getConfigData('transparentredirectactionurl');
112
+ $szPaRes = Mage::getSingleton('checkout/session')->getPares();
113
+
114
+ if(isset($szPaRes))
115
+ {
116
+ $html = self::_submitPaRes($szActionURL);
117
+ }
118
+ else
119
+ {
120
+ $html = self::_submitTransaction($szActionURL);
121
+ }
122
+
123
+ return $html;
124
+ }
125
+
126
+ private function _submitTransaction($szActionURL)
127
+ {
128
+ $html = '';
129
+
130
+ // create a Magento form
131
+ $form = new Varien_Data_Form();
132
+ $form->setAction($szActionURL)
133
+ ->setId('TransparentRedirectForm')
134
+ ->setName('TransparentRedirectForm')
135
+ ->setMethod('POST')
136
+ ->setUseContainer(true);
137
+
138
+ $form->addField("HashDigest", 'hidden', array('name'=>"HashDigest", 'value'=>Mage::getSingleton('checkout/session')->getHashdigest()));
139
+ $form->addField("MerchantID", 'hidden', array('name'=>"MerchantID", 'value'=>Mage::getSingleton('checkout/session')->getMerchantid()));
140
+ $form->addField("Amount", 'hidden', array('name'=>"Amount", 'value'=>Mage::getSingleton('checkout/session')->getAmount()));
141
+ $form->addField("CurrencyCode", 'hidden', array('name'=>"CurrencyCode", 'value'=>Mage::getSingleton('checkout/session')->getCurrencycode()));
142
+ $form->addField("OrderID", 'hidden', array('name'=>"OrderID", 'value'=>Mage::getSingleton('checkout/session')->getOrderid()));
143
+ $form->addField("TransactionType", 'hidden', array('name'=>"TransactionType", 'value'=>Mage::getSingleton('checkout/session')->getTransactiontype()));
144
+ $form->addField("TransactionDateTime", 'hidden', array('name'=>"TransactionDateTime", 'value'=>Mage::getSingleton('checkout/session')->getTransactiondatetime()));
145
+ $form->addField("CallbackURL", 'hidden', array('name'=>"CallbackURL", 'value'=>Mage::getSingleton('checkout/session')->getCallbackurl()));
146
+ $form->addField("OrderDescription", 'hidden', array('name'=>"OrderDescription", 'value'=>Mage::getSingleton('checkout/session')->getOrderdescription()));
147
+ $form->addField("Address1", 'hidden', array('name'=>"Address1", 'value'=>Mage::getSingleton('checkout/session')->getAddress1()));
148
+ $form->addField("Address2", 'hidden', array('name'=>"Address2", 'value'=>Mage::getSingleton('checkout/session')->getAddress2()));
149
+ $form->addField("Address3", 'hidden', array('name'=>"Address3", 'value'=>Mage::getSingleton('checkout/session')->getAddress3()));
150
+ $form->addField("Address4", 'hidden', array('name'=>"Address4", 'value'=>Mage::getSingleton('checkout/session')->getAddress4()));
151
+ $form->addField("City", 'hidden', array('name'=>"City", 'value'=>Mage::getSingleton('checkout/session')->getCity()));
152
+ $form->addField("State", 'hidden', array('name'=>"State", 'value'=>Mage::getSingleton('checkout/session')->getState()));
153
+ $form->addField("PostCode", 'hidden', array('name'=>"PostCode", 'value'=>Mage::getSingleton('checkout/session')->getPostcode()));
154
+ $form->addField("CountryCode", 'hidden', array('name'=>"CountryCode", 'value'=>Mage::getSingleton('checkout/session')->getCountrycode()));
155
+ $form->addField("CardName", 'hidden', array('name'=>"CardName", 'value'=>Mage::getSingleton('checkout/session')->getCardname()));
156
+ $form->addField("CardNumber", 'hidden', array('name'=>"CardNumber", 'value'=>Mage::getSingleton('checkout/session')->getCardnumber()));
157
+ $form->addField("ExpiryDateMonth", 'hidden', array('name'=>"ExpiryDateMonth", 'value'=>Mage::getSingleton('checkout/session')->getExpirydatemonth()));
158
+ $form->addField("ExpiryDateYear", 'hidden', array('name'=>"ExpiryDateYear", 'value'=>Mage::getSingleton('checkout/session')->getExpirydateyear()));
159
+ $form->addField("StartDateMonth", 'hidden', array('name'=>"StartDateMonth", 'value'=>Mage::getSingleton('checkout/session')->getStartdatemonth()));
160
+ $form->addField("StartDateYear", 'hidden', array('name'=>"StartDateYear", 'value'=>Mage::getSingleton('checkout/session')->getStartdateyear()));
161
+ $form->addField("IssueNumber", 'hidden', array('name'=>"IssueNumber", 'value'=>Mage::getSingleton('checkout/session')->getIssuenumber()));
162
+ $form->addField("CV2", 'hidden', array('name'=>"CV2", 'value'=>Mage::getSingleton('checkout/session')->getCv2()));
163
+
164
+ // reset the session items
165
+ Mage::getSingleton('checkout/session')->setHashdigest(null)
166
+ ->setMerchantid(null)
167
+ ->setAmount(null)
168
+ ->setCurrencycode(null)
169
+ ->setOrderid(null)
170
+ ->setTransactiontype(null)
171
+ ->setTransactiondatetime(null)
172
+ ->setCallbackurl(null)
173
+ ->setOrderdescription(null)
174
+ ->setAddress1(null)
175
+ ->setAddress2(null)
176
+ ->setAddress3(null)
177
+ ->setAddress4(null)
178
+ ->setCity(null)
179
+ ->setState(null)
180
+ ->setPostcode(null)
181
+ ->setCountrycode(null)
182
+ ->setCardname(null)
183
+ ->setCardnumber(null)
184
+ ->setExpirydatemonth(null)
185
+ ->setExpirydateyear(null)
186
+ ->setStartdatemonth(null)
187
+ ->setStartdateyear(null)
188
+ ->setIssuenumber(null)
189
+ ->setCv2(null);
190
+
191
+
192
+ $html = '<html><body>';
193
+ $html.= $form->toHtml();
194
+ $html.= '<script type="text/javascript">document.getElementById("TransparentRedirectForm").submit();</script>';
195
+ $html.= '</body></html>';
196
+
197
+ return $html;
198
+ }
199
+
200
+ private function _submitPaRes($szActionURL)
201
+ {
202
+ $html = '';
203
+
204
+ // create a Magento form
205
+ $form = new Varien_Data_Form();
206
+ $form->setAction($szActionURL)
207
+ ->setId('SubmitPaResForm')
208
+ ->setName('SubmitPaResForm')
209
+ ->setMethod('POST')
210
+ ->setUseContainer(true);
211
+
212
+ $form->addField("HashDigest", 'hidden', array('name'=>"HashDigest", 'value'=>Mage::getSingleton('checkout/session')->getHashdigest()));
213
+ $form->addField("MerchantID", 'hidden', array('name'=>"MerchantID", 'value'=>Mage::getSingleton('checkout/session')->getMerchantid()));
214
+ $form->addField("CrossReference", 'hidden', array('name'=>"CrossReference", 'value'=>Mage::getSingleton('checkout/session')->getCrossreference()));
215
+ $form->addField("TransactionDateTime", 'hidden', array('name'=>"TransactionDateTime", 'value'=>Mage::getSingleton('checkout/session')->getTransactiondatetime()));
216
+ $form->addField("CallbackURL", 'hidden', array('name'=>"CallbackURL", 'value'=>Mage::getSingleton('checkout/session')->getCallbackurl()));
217
+ $form->addField("PaRES", 'hidden', array('name'=>"PaRES", 'value'=>Mage::getSingleton('checkout/session')->getPares()));
218
+
219
+ // reset the session items
220
+ Mage::getSingleton('checkout/session')->setHashdigest(null)
221
+ ->setMerchantid(null)
222
+ ->setCrossreference(null)
223
+ ->setTransactiondatetime(null)
224
+ ->setCallbackurl(null)
225
+ ->setPares(null);
226
+
227
+
228
+ $html = '<html><body>';
229
+ $html.= $form->toHtml();
230
+ $html.= '<script type="text/javascript">document.getElementById("SubmitPaResForm").submit();</script>';
231
+ $html.= '</body></html>';
232
+
233
+ return $html;
234
+ }
235
+ }
app/code/local/Iridiumcorp/Tpg/Block/Threedsecure.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Iridiumcorp_Tpg_Block_Threedsecure extends Mage_Core_Block_Abstract
4
+ {
5
+ /**
6
+ * Build the 3D Secure form to be submitted to the redirect 3D Secure authorization page
7
+ *
8
+ */
9
+ protected function _toHtml()
10
+ {
11
+ $szTermURL = Mage::getSingleton('checkout/session')->getTermurl();
12
+
13
+ $form = new Varien_Data_Form();
14
+ $form->setAction(Mage::getSingleton('checkout/session')->getAcsurl())
15
+ ->setId('ThreeDSecureForm')
16
+ ->setName('ThreeDSecureForm')
17
+ ->setMethod('POST')
18
+ ->setUseContainer(true);
19
+
20
+ $form->addField("PaReq", 'hidden', array('name'=>"PaReq", 'value'=>Mage::getSingleton('checkout/session')->getPareq()));
21
+ $form->addField("MD", 'hidden', array('name'=>"MD", 'value'=>Mage::getSingleton('checkout/session')->getMd()));
22
+ $form->addField("TermUrl", 'hidden', array('name'=>"TermUrl", 'value'=>Mage::getUrl($szTermURL)));
23
+
24
+ $html = '<html><body>';
25
+ $html.= $this->__('You will be redirected to a 3D secure form in a few seconds.');
26
+ $html.= $form->toHtml();
27
+ $html.= '<script type="text/javascript">document.getElementById("ThreeDSecureForm").submit();</script>';
28
+ $html.= '</body></html>';
29
+
30
+ // reset the 3DS session values
31
+ Mage::getSingleton('checkout/session')->setMd(null)
32
+ ->setAcsurl(null)
33
+ ->setPareq(null)
34
+ ->setTermurl(null);
35
+
36
+ return $html;
37
+ }
38
+ }
app/code/local/Iridiumcorp/Tpg/Helper/Data.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Iridiumcorp_Tpg_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ }
app/code/local/Iridiumcorp/Tpg/Model/Direct.php ADDED
@@ -0,0 +1,768 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ include ("Tpg/ThePaymentGateway/PaymentSystem.php");
4
+ include_once ("Tpg/PaymentFormHelper.php");
5
+ include ("Tpg/ISOCurrencies.php");
6
+ include ("Tpg/ISOCountries.php");
7
+
8
+ // GLOBAL 3D Secure authorization result variables:
9
+ $m_sz3DSecureMessage;
10
+ $m_bo3DSecureError;
11
+
12
+ class Iridiumcorp_Tpg_Model_Direct extends Mage_Payment_Model_Method_Abstract
13
+ {
14
+ /**
15
+ * unique internal payment method identifier
16
+ *
17
+ * @var string [a-z0-9_]
18
+ */
19
+ protected $_code = 'tpg';
20
+ protected $_formBlockType = 'tpg/form';
21
+ protected $_infoBlockType = 'tpg/info';
22
+
23
+ protected $_isGateway = true;
24
+ protected $_canAuthorize = false;
25
+ protected $_canCapture = true;
26
+ protected $_canCapturePartial = true;
27
+ protected $_canRefund = false;
28
+ protected $_canVoid = false;
29
+ protected $_canUseInternal = true;
30
+ protected $_canUseCheckout = true;
31
+ protected $_canUseForMultishipping = true;
32
+ protected $_canSaveCc = false;
33
+
34
+ /**
35
+ * Assign data to info model instance
36
+ *
37
+ * @param mixed $data
38
+ * @return Mage_Payment_Model_Info
39
+ */
40
+ public function assignData($data)
41
+ {
42
+ if (!($data instanceof Varien_Object))
43
+ {
44
+ $data = new Varien_Object($data);
45
+ }
46
+
47
+ $info = $this->getInfoInstance();
48
+
49
+ $info->setCcOwner($data->getCcOwner())
50
+ ->setCcLast4(substr($data->getCcNumber(), -4))
51
+ ->setCcNumber($data->getCcNumber())
52
+ ->setCcCid($data->getCcCid())
53
+ ->setCcExpMonth($data->getCcExpMonth())
54
+ ->setCcExpYear($data->getCcExpYear())
55
+ ->setCcSsStartMonth($data->getCcSsStartMonth())
56
+ ->setCcSsStartYear($data->getCcSsStartYear())
57
+ ->setCcSsIssue($data->getCcSsIssue());
58
+
59
+ return $this;
60
+ }
61
+
62
+ /**
63
+ * Validate payment method information object
64
+ *
65
+ * @param Mage_Payment_Model_Info $info
66
+ * @return Mage_Payment_Model_Abstract
67
+ */
68
+ public function validate()
69
+ {
70
+ // NOTE : cancel out the core Magento validator functionality, the payment gateway will overtake this task
71
+
72
+ return $this;
73
+ }
74
+
75
+ /**
76
+ * Authorize - core Mage pre-authorization functionality
77
+ *
78
+ * @param Varien_Object $orderPayment
79
+ * @return Mage_Payment_Model_Abstract
80
+ */
81
+ public function authorize(Varien_Object $payment, $amount)
82
+ {
83
+ $error = false;
84
+
85
+ Mage::throwException('This payment module only allow capture payments.');
86
+
87
+ return $this;
88
+ }
89
+
90
+ /**
91
+ * Capture payment - immediate settlement payments
92
+ *
93
+ * @param Varien_Object $payment
94
+ * @return Mage_Payment_Model_Abstract
95
+ */
96
+ public function capture(Varien_Object $payment, $amount)
97
+ {
98
+ $error = false;
99
+
100
+ // reset the global 3D Secure variables
101
+ $GLOBALS['m_bo3DSecureError'] = true;
102
+ $GLOBALS['m_sz3DSecureMessage'] = false;
103
+
104
+ if($amount <= 0)
105
+ {
106
+ Mage::throwException(Mage::helper('paygate')->__('Invalid amount for authorization.'));
107
+ }
108
+ else
109
+ {
110
+ // TODO : wrap this content with try/catch and log any exception
111
+ // check if the payment is a 3D Secure
112
+ if(Mage::getSingleton('checkout/session')->getSecure3d())
113
+ {
114
+ // this is a 3D Secure payment
115
+ $this->_run3DSecureTransaction($payment, $amount, Mage::getSingleton('checkout/session')->getPares(), Mage::getSingleton('checkout/session')->getMd());
116
+
117
+ // reset the property to default non 3DS
118
+ Mage::getSingleton('checkout/session')->setSecure3d(false);
119
+ }
120
+ else
121
+ {
122
+ // reset the 3DS properties for a fresh payment request
123
+ Mage::getSingleton('checkout/session')
124
+ ->setMd(null)
125
+ ->setAcsurl(null)
126
+ ->setPareq(null)
127
+ ->setTermurl(null);
128
+
129
+ // run a fresh payment request
130
+ switch ($this->getConfigData('mode'))
131
+ {
132
+ case Iridiumcorp_Tpg_Model_Source_PaymentMode::PAYMENT_MODE_DIRECT_API:
133
+ $this->_runTransaction($payment, $amount);
134
+ break;
135
+ case Iridiumcorp_Tpg_Model_Source_PaymentMode::PAYMENT_MODE_HOSTED_PAYMENT_FORM:
136
+ $this->_redirectTransaction($payment, $amount);
137
+ break;
138
+ case Iridiumcorp_Tpg_Model_Source_PaymentMode::PAYMENT_MODE_TRANSPARENT_REDIRECT:
139
+ $this->_transparentRedirectTransaction($payment, $amount);
140
+ break;
141
+ default:
142
+ Mage::throwException('Invalid payment type: '.$this->getConfigData('mode'));
143
+ break;
144
+ }
145
+ }
146
+ }
147
+
148
+ return $this;
149
+ }
150
+
151
+ /**
152
+ * Processing the transaction using the direct integration
153
+ *
154
+ * @param Varien_Object $orderPayment
155
+ * @param $amount
156
+ * @return void
157
+ */
158
+ public function _runTransaction(Varien_Object $payment, $amount)
159
+ {
160
+ $MerchantID = $this->getConfigData('merchantid');
161
+ $Password = $this->getConfigData('password');
162
+ $SecretKey = $this->getConfigData('secretkey');
163
+ // assign payment form field values to variables
164
+ $order = $payment->getOrder();
165
+ $szOrderID = $payment->getOrder()->increment_id;
166
+ $szOrderDescription = '';
167
+ $szCardName = $payment->getCcOwner();
168
+ $szCardNumber = $payment->getCcNumber();
169
+ $szIssueNumber = $payment->getCcSsIssue();
170
+ $szCV2 = $payment->getCcCid();
171
+ $nCurrencyCode;
172
+ $szCurrencyShort = $order->getOrderCurrency()->getCurrencyCode();
173
+ // address details
174
+ $billingAddress = $order->getBillingAddress();
175
+ $szAddress1 = $billingAddress->getStreet1();
176
+ $szAddress2 = $billingAddress->getStreet2();
177
+ $szAddress3 = $billingAddress->getStreet3();
178
+ $szAddress4 = $billingAddress->getStreet4();
179
+ $szCity = $billingAddress->getCity();
180
+ $szState = $billingAddress->getRegion();
181
+ $szPostCode = $billingAddress->getPostcode();
182
+ $szISO2CountryCode = $billingAddress->getCountry();
183
+ $nCountryCode;
184
+ $szEmailAddress = $billingAddress->getCustomerEmail();
185
+ $szPhoneNumber = $billingAddress->getTelephone();
186
+ $nDecimalAmount;
187
+
188
+ $PaymentProcessorFullDomain = $this->_getPaymentProcessorFullDomain();
189
+
190
+ $rgeplRequestGatewayEntryPointList = new IRC_RequestGatewayEntryPointList();
191
+
192
+ $rgeplRequestGatewayEntryPointList->add("https://gw1.".$PaymentProcessorFullDomain, 100, 2);
193
+ $rgeplRequestGatewayEntryPointList->add("https://gw2.".$PaymentProcessorFullDomain, 200, 2);
194
+ $rgeplRequestGatewayEntryPointList->add("https://gw3.".$PaymentProcessorFullDomain, 300, 2);
195
+
196
+ $maMerchantAuthentication = new IRC_MerchantAuthentication($MerchantID, $Password);
197
+
198
+ $mdMessageDetails = new IRC_MessageDetails("SALE");
199
+
200
+ $boEchoCardType = new IRC_NullableBool(true);
201
+ $boEchoAmountReceived = new IRC_NullableBool(true);
202
+ $boEchoAVSCheckResult = new IRC_NullableBool(true);
203
+ $boEchoCV2CheckResult = new IRC_NullableBool(true);
204
+ $boThreeDSecureOverridePolicy = new IRC_NullableBool(true);
205
+ $nDuplicateDelay = new IRC_NullableInt(60);
206
+ $tcTransactionControl = new IRC_TransactionControl($boEchoCardType, $boEchoAVSCheckResult, $boEchoCV2CheckResult, $boEchoAmountReceived, $nDuplicateDelay, "", "", $boThreeDSecureOverridePolicy, "", null, null);
207
+
208
+ $iclISOCurrencyList = IRC_ISOCurrencies::getISOCurrencyList();
209
+
210
+ if ($szCurrencyShort != '' &&
211
+ $iclISOCurrencyList->getISOCurrency($szCurrencyShort, $icISOCurrency))
212
+ {
213
+ $nCurrencyCode = new IRC_NullableInt($icISOCurrency->getISOCode());
214
+ }
215
+
216
+ $power = pow(10, $icISOCurrency->getExponent());
217
+ $nDecimalAmount = $amount * $power;
218
+ $nAmount = new IRC_NullableInt($nDecimalAmount);
219
+
220
+ $nDeviceCategory = new IRC_NullableInt(0);
221
+ $tdsbdThreeDSecureBrowserDetails = new IRC_ThreeDSecureBrowserDetails($nDeviceCategory, "*/*", $_SERVER["HTTP_USER_AGENT"]);;
222
+ $tdTransactionDetails = new IRC_TransactionDetails($mdMessageDetails, $nAmount, $nCurrencyCode, $szOrderID, $szOrderDescription, $tcTransactionControl, $tdsbdThreeDSecureBrowserDetails);
223
+
224
+ $nExpiryDateMonth = null;
225
+ if($payment->getCcExpMonth() != '')
226
+ {
227
+ $nExpiryDateMonth = new IRC_NullableInt($payment->getCcExpMonth());
228
+ }
229
+
230
+ $nExpiryDateYear = null;
231
+ if($payment->getCcExpYear() != '')
232
+ {
233
+ $nExpiryDateYear = new IRC_NullableInt($payment->getCcExpYear());
234
+ }
235
+
236
+ $nStartDateMonth = null;
237
+ if($payment->getCcSsStartMonth() != '')
238
+ {
239
+ $nStartDateMonth = new IRC_NullableInt($payment->getCcSsStartMonth());
240
+ }
241
+
242
+ $nStartDateYear = null;
243
+ if($payment->getCcSsStartYear() != '')
244
+ {
245
+ $nStartDateYear = new IRC_NullableInt($payment->getCcSsStartYear());
246
+ }
247
+
248
+ $edExpiryDate = new IRC_ExpiryDate($nExpiryDateMonth, $nExpiryDateYear);
249
+ $sdStartDate = new IRC_StartDate($nStartDateMonth, $nStartDateYear);
250
+ $cdCardDetails = new IRC_CardDetails($szCardName, $szCardNumber, $edExpiryDate, $sdStartDate, $szIssueNumber, $szCV2);
251
+
252
+ $nCountryCode = null;
253
+ $iclISOCountryList = IRC_ISOCountries::getISOCountryList();
254
+ $szCountryShort = $this->_getISO3Code($szISO2CountryCode);
255
+ if($iclISOCountryList->getISOCountry($szCountryShort, $icISOCountry))
256
+ {
257
+ $nCountryCode = new IRC_NullableInt($icISOCountry->getISOCode());
258
+ }
259
+
260
+ if($szAddress1 == null)
261
+ {
262
+ $szAddress1 = '';
263
+ }
264
+ if($szAddress2 == null)
265
+ {
266
+ $szAddress2 = '';
267
+ }
268
+ if($szAddress2 == null)
269
+ {
270
+ $szAddress2 = '';
271
+ }
272
+ if($szAddress2 == null)
273
+ {
274
+ $szAddress2 = '';
275
+ }
276
+
277
+ $adBillingAddress = new IRC_AddressDetails($szAddress1, $szAddress2, $szAddress3, $szAddress4, $szCity, $szState, $szPostCode, $nCountryCode);
278
+ $cdCustomerDetails = new IRC_CustomerDetails($adBillingAddress, $szEmailAddress, $szPhoneNumber, $_SERVER["REMOTE_ADDR"]);
279
+ $cdtCardDetailsTransaction = new IRC_CardDetailsTransaction($rgeplRequestGatewayEntryPointList, 1, null, $maMerchantAuthentication, $tdTransactionDetails, $cdCardDetails, $cdCustomerDetails, "Some data to be passed out");
280
+ $boTransactionProcessed = $cdtCardDetailsTransaction->processTransaction($cdtrCardDetailsTransactionResult, $todTransactionOutputData);
281
+
282
+ if ($boTransactionProcessed == false)
283
+ {
284
+ // could not communicate with the payment gateway
285
+ $szLogMessage = "Couldn't complete transaction. Details: ".print_r($cdtrCardDetailsTransactionResult, 1)." ".print_r($todTransactionOutputData, 1); //"Couldn't communicate with payment gateway.";
286
+ Mage::log($szLogMessage);
287
+ Mage::throwException(Iridiumcorp_Tpg_Model_Tpg_GlobalErrors::ERROR_261);
288
+ }
289
+ else
290
+ {
291
+ $boError = true;
292
+ $szLogMessage = "Transaction could not be completed for OrderID: ".$szOrderID.". Result details: ";
293
+ $szNotificationMessage = 'Payment Processor Response: '.$cdtrCardDetailsTransactionResult->getMessage();
294
+
295
+ switch ($cdtrCardDetailsTransactionResult->getStatusCode())
296
+ {
297
+ case 0:
298
+ // status code of 0 - means transaction successful
299
+ $boError = false;
300
+ $szLogMessage = "Transaction successfully completed for OrderID: ".$szOrderID.". Result object details: ";
301
+ Mage::getSingleton('core/session')->addSuccess($szNotificationMessage);
302
+ break;
303
+ case 3:
304
+ // status code of 3 - means 3D Secure authentication required
305
+ $boError = false;
306
+ $szLogMessage = "3D Secure Authentication required for OrderID: ".$szOrderID.". Result object details: ";
307
+
308
+ $szPaReq = $todTransactionOutputData->getThreeDSecureOutputData()->getPaREQ();
309
+ $szCrossReference = $todTransactionOutputData->getCrossReference();
310
+ $szACSURL = $todTransactionOutputData->getThreeDSecureOutputData()->getACSURL();
311
+
312
+ Mage::getSingleton('checkout/session')->setMd($szCrossReference)
313
+ ->setAcsurl($szACSURL)
314
+ ->setPareq($szPaReq)
315
+ ->setTermurl('tpg/payment/callback3d');
316
+ break;
317
+ case 5:
318
+ // status code of 5 - means transaction declined
319
+ break;
320
+ case 20:
321
+ // status code of 20 - means duplicate transaction
322
+ $szPreviousTransactionMessage = $cdtrCardDetailsTransactionResult->getPreviousTransactionResult()->getMessage();
323
+ $szLogMessage = "Duplicate transaction for OrderID: ".$szOrderID.". A duplicate transaction means that a transaction with these details has already been processed by the payment provider. The details of the original transaction: ".$szPreviousTransactionMessage.". Result object details: ";
324
+ $szNotificationMessage = $szNotificationMessage.". A duplicate transaction means that a transaction with these details has already been processed by the payment provider. The details of the original transaction - Previous Transaction Response: ".$szPreviousTransactionMessage;
325
+
326
+ if ($cdtrCardDetailsTransactionResult->getPreviousTransactionResult()->getStatusCode()->getValue() == 0)
327
+ {
328
+ $boError = false;
329
+ Mage::getSingleton('core/session')->addSuccess($szNotificationMessage);
330
+ }
331
+ break;
332
+ case 30:
333
+ // status code of 30 - means an error occurred
334
+ $szLogMessage = "Transaction could not be completed for OrderID: ".$szOrderID.". Error message: ".$cdtrCardDetailsTransactionResult->getMessage();
335
+ if ($cdtrCardDetailsTransactionResult->getErrorMessages()->getCount() > 0)
336
+ {
337
+ $szLogMessage = $szLogMessage.".";
338
+
339
+ for ($LoopIndex = 0; $LoopIndex < $cdtrCardDetailsTransactionResult->getErrorMessages()->getCount(); $LoopIndex++)
340
+ {
341
+ $szLogMessage = $szLogMessage.$cdtrCardDetailsTransactionResult->getErrorMessages()->getAt($LoopIndex).";";
342
+ }
343
+ $szLogMessage = $szLogMessage." ";
344
+ }
345
+ $szLogMessage = $szLogMessage.' Result object details: ';
346
+ break;
347
+ default:
348
+ // unhandled status code
349
+ break;
350
+ }
351
+
352
+ $szLogMessage = $szLogMessage.print_r($cdtrCardDetailsTransactionResult, 1);
353
+ Mage::log($szLogMessage);
354
+
355
+ // if the payment was not sucessful notify the customer with a message
356
+ if($boError == true)
357
+ {
358
+ Mage::throwException($szNotificationMessage);
359
+ }
360
+ }
361
+ }
362
+
363
+ /**
364
+ * Processing the transaction using the hosted payment form integration
365
+ *
366
+ * @param Varien_Object $payment
367
+ * @param unknown_type $amount
368
+ */
369
+ public function _redirectTransaction(Varien_Object $payment, $amount)
370
+ {
371
+ $szMerchantID = $this->getConfigData('merchantid');
372
+ $szPassword = $this->getConfigData('password');
373
+ $szCallbackURL = Mage::getUrl('tpg/payment/callbackhostedpayment');
374
+ $szPreSharedKey = $this->getConfigData('presharedkey');
375
+ $hmHashMethod = $this->getConfigData('hashmethod');
376
+ $boCV2Mandatory = 'false';
377
+ $boAddress1Mandatory = 'false';
378
+ $boCityMandatory = 'false';
379
+ $boPostCodeMandatory = 'false';
380
+ $boStateMandatory = 'false';
381
+ $boCountryMandatory = 'false';
382
+ $rdmResultdeliveryMethod = $this->getConfigData('resultdeliverymethod');
383
+ $szServerResultURL = $this->getConfigData('serverresulturl');
384
+ $boPaymentFormDisplaysResult = 'false';
385
+
386
+ $order = $payment->getOrder();
387
+ $billingAddress = $order->getBillingAddress();
388
+ $iclISOCurrencyList = IRC_ISOCurrencies::getISOCurrencyList();
389
+ $iclISOCountryList = IRC_ISOCountries::getISOCountryList();
390
+
391
+ $szCurrencyShort = $order->getOrderCurrency()->getCurrencyCode();
392
+ if ($szCurrencyShort != '' &&
393
+ $iclISOCurrencyList->getISOCurrency($szCurrencyShort, $icISOCurrency))
394
+ {
395
+ $nCurrencyCode = $icISOCurrency->getISOCode();
396
+ }
397
+
398
+ $power = pow(10, $icISOCurrency->getExponent());
399
+ $nAmount = $amount * $power;
400
+
401
+ $szISO2CountryCode = $billingAddress->getCountry();
402
+ $szCountryShort = $this->_getISO3Code($szISO2CountryCode);
403
+ if($iclISOCountryList->getISOCountry($szCountryShort, $icISOCountry))
404
+ {
405
+ $nCountryCode = $icISOCountry->getISOCode();
406
+ }
407
+
408
+ $szOrderID = $payment->getOrder()->increment_id;
409
+ $szTransactionType = 'SALE';
410
+ //date time with 2008-12-01 14:12:00 +01:00 format
411
+ $szTransactionDateTime = date('Y-m-d H:i:s P');
412
+ $szOrderDescription = '';
413
+
414
+ $szCustomerName = $billingAddress->getfirstname();
415
+ if($billingAddress->getfirstname())
416
+ {
417
+ $szCustomerName = $szCustomerName.' '.$billingAddress->getlastname();
418
+ }
419
+ $szAddress1 = $billingAddress->getStreet1();
420
+ $szAddress2 = $billingAddress->getStreet2();
421
+ $szAddress3 = $billingAddress->getStreet3();
422
+ $szAddress4 = $billingAddress->getStreet4();
423
+ $szCity = $billingAddress->getCity();
424
+ $szState = $billingAddress->getRegion();
425
+ $szPostCode = $billingAddress->getPostcode();
426
+
427
+ if($this->getConfigData('cv2mandatory'))
428
+ {
429
+ $boCV2Mandatory = 'true';
430
+ }
431
+ if($this->getConfigData('address1mandatory'))
432
+ {
433
+ $boAddress1Mandatory = 'true';
434
+ }
435
+ if($this->getConfigData('citymandatory'))
436
+ {
437
+ $boCityMandatory = 'true';
438
+ }
439
+ if($this->getConfigData('postcodemandatory'))
440
+ {
441
+ $boPostCodeMandatory = 'true';
442
+ }
443
+ if($this->getConfigData('statemandatory'))
444
+ {
445
+ $boStateMandatory = 'true';
446
+ }
447
+ if($this->getConfigData('countrymandatory'))
448
+ {
449
+ $boCountryMandatory = 'true';
450
+ }
451
+ if($this->getConfigData('paymentformdisplaysresult'))
452
+ {
453
+ $boPaymentFormDisplaysResult = 'true';
454
+ }
455
+
456
+ $szHashDigest = IRC_PaymentFormHelper::calculateHashDigest($szMerchantID, $szPassword, $hmHashMethod, $szPreSharedKey, $nAmount, $nCurrencyCode, $szOrderID, $szTransactionType, $szTransactionDateTime, $szCallbackURL, $szOrderDescription, $szCustomerName, $szAddress1, $szAddress2, $szAddress3, $szAddress4, $szCity, $szState, $szPostCode, $nCountryCode, $boCV2Mandatory, $boAddress1Mandatory, $boCityMandatory, $boPostCodeMandatory, $boStateMandatory, $boCountryMandatory, $rdmResultdeliveryMethod, $szServerResultURL, $boPaymentFormDisplaysResult);
457
+
458
+ Mage::getSingleton('checkout/session')->setHashdigest($szHashDigest)
459
+ ->setMerchantid($szMerchantID)
460
+ ->setAmount($nAmount)
461
+ ->setCurrencycode($nCurrencyCode)
462
+ ->setOrderid($szOrderID)
463
+ ->setTransactiontype($szTransactionType)
464
+ ->setTransactiondatetime($szTransactionDateTime)
465
+ ->setCallbackurl($szCallbackURL)
466
+ ->setOrderdescription($szOrderDescription)
467
+ ->setCustomername($szCustomerName)
468
+ ->setAddress1($szAddress1)
469
+ ->setAddress2($szAddress2)
470
+ ->setAddress3($szAddress3)
471
+ ->setAddress4($szAddress4)
472
+ ->setCity($szCity)
473
+ ->setState($szState)
474
+ ->setPostcode($szPostCode)
475
+ ->setCountrycode($nCountryCode)
476
+ ->setCv2mandatory($boCV2Mandatory)
477
+ ->setAddress1mandatory($boAddress1Mandatory)
478
+ ->setCitymandatory($boCityMandatory)
479
+ ->setPostcodemandatory($boPostCodeMandatory)
480
+ ->setStatemandatory($boStateMandatory)
481
+ ->setCountrymandatory($boCountryMandatory)
482
+ ->setResultdeliverymethod($rdmResultdeliveryMethod)
483
+ ->setServerresulturl($szServerResultURL)
484
+ ->setPaymentformdisplaysresult($boPaymentFormDisplaysResult);
485
+ }
486
+
487
+ /**
488
+ * Processing the transaction using the transparent redirect integration
489
+ *
490
+ * @param Varien_Object $payment
491
+ * @param unknown_type $amount
492
+ */
493
+ public function _transparentRedirectTransaction(Varien_Object $payment, $amount)
494
+ {
495
+ $szMerchantID = $this->getConfigData('merchantid');
496
+ $szPassword = $this->getConfigData('password');
497
+ $szPreSharedKey = $this->getConfigData('presharedkey');
498
+ $hmHashMethod = $this->getConfigData('hashmethod');
499
+ $szCallbackURL = Mage::getUrl('tpg/payment/callbacktransparentredirect');
500
+ $order = $payment->getOrder();
501
+ $billingAddress = $order->getBillingAddress();
502
+ $iclISOCurrencyList = IRC_ISOCurrencies::getISOCurrencyList();
503
+ $iclISOCountryList = IRC_ISOCountries::getISOCountryList();
504
+ $szStartDateMonth = '';
505
+ $szStartDateYear = '';
506
+
507
+ $szCurrencyShort = $order->getOrderCurrency()->getCurrencyCode();
508
+ if ($szCurrencyShort != '' &&
509
+ $iclISOCurrencyList->getISOCurrency($szCurrencyShort, $icISOCurrency))
510
+ {
511
+ $nCurrencyCode = $icISOCurrency->getISOCode();
512
+ }
513
+
514
+ $power = pow(10, $icISOCurrency->getExponent());
515
+ $nAmount = $amount * $power;
516
+
517
+ $szOrderID = $payment->getOrder()->increment_id;
518
+ $szTransactionType = 'SALE';
519
+ //date time with 2008-12-01 14:12:00 +01:00 format
520
+ $szTransactionDateTime = date('Y-m-d H:i:s P');
521
+ $szOrderDescription = '';
522
+
523
+ $szAddress1 = $billingAddress->getStreet1();
524
+ $szAddress2 = $billingAddress->getStreet2();
525
+ $szAddress3 = $billingAddress->getStreet3();
526
+ $szAddress4 = $billingAddress->getStreet4();
527
+ $szCity = $billingAddress->getCity();
528
+ $szState = $billingAddress->getRegion();
529
+ $szPostCode = $billingAddress->getPostcode();
530
+ $szISO2CountryCode = $billingAddress->getCountry();
531
+ $szCountryShort = $this->_getISO3Code($szISO2CountryCode);
532
+ if($iclISOCountryList->getISOCountry($szCountryShort, $icISOCountry))
533
+ {
534
+ $nCountryCode = $icISOCountry->getISOCode();
535
+ }
536
+
537
+ $szCardName = $payment->getCcOwner();
538
+ $szCardNumber = $payment->getCcNumber();
539
+ $szExpiryDateMonth = $payment->getCcExpMonth();
540
+ $szExpiryDateYear = $payment->getCcExpYear();
541
+ if($payment->getCcSsStartMonth() != '')
542
+ {
543
+ $szStartDateMonth = $payment->getCcSsStartMonth();
544
+ }
545
+ if($payment->getCcSsStartYear() != '')
546
+ {
547
+ $szStartDateYear = $payment->getCcSsStartYear();
548
+ }
549
+ $szIssueNumber = $payment->getCcSsIssue();
550
+ $szCV2 = $payment->getCcCid();
551
+
552
+ $szHashDigest = IRC_PaymentFormHelper::calculateTransparentRedirectHashDigest($szMerchantID, $szPassword, $hmHashMethod, $szPreSharedKey, $nAmount, $nCurrencyCode, $szOrderID, $szTransactionType, $szTransactionDateTime, $szCallbackURL, $szOrderDescription);
553
+
554
+ Mage::getSingleton('checkout/session')->setHashdigest($szHashDigest)
555
+ ->setMerchantid($szMerchantID)
556
+ ->setAmount($nAmount)
557
+ ->setCurrencycode($nCurrencyCode)
558
+ ->setOrderid($szOrderID)
559
+ ->setTransactiontype($szTransactionType)
560
+ ->setTransactiondatetime($szTransactionDateTime)
561
+ ->setCallbackurl($szCallbackURL)
562
+ ->setOrderdescription($szOrderDescription)
563
+ ->setAddress1($szAddress1)
564
+ ->setAddress2($szAddress2)
565
+ ->setAddress3($szAddress3)
566
+ ->setAddress4($szAddress4)
567
+ ->setCity($szCity)
568
+ ->setState($szState)
569
+ ->setPostcode($szPostCode)
570
+ ->setCountrycode($nCountryCode)
571
+ ->setCardname($szCardName)
572
+ ->setCardnumber($szCardNumber)
573
+ ->setExpirydatemonth($szExpiryDateMonth)
574
+ ->setExpirydateyear($szExpiryDateYear)
575
+ ->setStartdatemonth($szStartDateMonth)
576
+ ->setStartdateyear($szStartDateYear)
577
+ ->setIssuenumber($szIssueNumber)
578
+ ->setCv2($szCV2);
579
+ }
580
+
581
+ /**
582
+ * Processing the 3D Secure transaction
583
+ *
584
+ * @param Varien_Object $payment
585
+ * @param int $amount
586
+ * @param string $szPaRes
587
+ * @param string $szMD
588
+ */
589
+ public function _run3DSecureTransaction(Varien_Object $payment, $amount, $szPaRes, $szMD)
590
+ {
591
+ $szOrderID = Mage::getSingleton('checkout/session')->getLastRealOrderId();
592
+
593
+ $MerchantID = $this->getConfigData('merchantid');
594
+ $Password = $this->getConfigData('password');
595
+ $SecretKey = $this->getConfigData('secretkey');
596
+
597
+ $PaymentProcessorFullDomain = $this->_getPaymentProcessorFullDomain();
598
+ $rgeplRequestGatewayEntryPointList = new IRC_RequestGatewayEntryPointList();
599
+ $rgeplRequestGatewayEntryPointList->add("https://gw1.".$PaymentProcessorFullDomain, 100, 2);
600
+ $rgeplRequestGatewayEntryPointList->add("https://gw2.".$PaymentProcessorFullDomain, 200, 2);
601
+ $rgeplRequestGatewayEntryPointList->add("https://gw3.".$PaymentProcessorFullDomain, 300, 2);
602
+
603
+ $maMerchantAuthentication = new IRC_MerchantAuthentication($MerchantID, $Password);
604
+ $tdsidThreeDSecureInputData = new IRC_ThreeDSecureInputData($szMD, $szPaRes);
605
+
606
+ $tdsaThreeDSecureAuthentication = new IRC_ThreeDSecureAuthentication($rgeplRequestGatewayEntryPointList, 1, null, $maMerchantAuthentication, $tdsidThreeDSecureInputData, "Some data to be passed out");
607
+ $boTransactionProcessed = $tdsaThreeDSecureAuthentication->processTransaction($tdsarThreeDSecureAuthenticationResult, $todTransactionOutputData);
608
+
609
+ if ($boTransactionProcessed == false)
610
+ {
611
+ // could not communicate with the payment gateway
612
+ //PaymentFormHelper::reportTransactionResults($CrossReference, 30, $Message, null);
613
+ $szLogMessage = Iridiumcorp_Tpg_Model_Tpg_GlobalErrors::ERROR_431;
614
+ Mage::log($szLogMessage);
615
+
616
+ $GLOBALS['m_bo3DSecureError'] = true;
617
+ $GLOBALS['m_sz3DSecureMessage'] = Iridiumcorp_Tpg_Model_Tpg_GlobalErrors::ERROR_431;
618
+ }
619
+ else
620
+ {
621
+ $szLogMessage = "3D Secure transaction could not be completed for OrderID: ".$szOrderID.". Result object details: ";
622
+ $GLOBALS['m_bo3DSecureError'] = true;
623
+ $GLOBALS['m_sz3DSecureMessage'] = "Payment Processor Response: ".$tdsarThreeDSecureAuthenticationResult->getMessage();
624
+
625
+ switch ($tdsarThreeDSecureAuthenticationResult->getStatusCode())
626
+ {
627
+ case 0:
628
+ // status code of 0 - means transaction successful
629
+ //PaymentFormHelper::reportTransactionResults($CrossReference, $tdsarThreeDSecureAuthenticationResult->getStatusCode(), $tdsarThreeDSecureAuthenticationResult->getMessage(), $todTransactionOutputData->getCrossReference());
630
+ $GLOBALS['m_bo3DSecureError'] = false;
631
+ $szLogMessage = "3D Secure transaction successfully completed for OrderID: ".$szOrderID.". Result object details: ";
632
+ break;
633
+ case 5:
634
+ // status code of 5 - means transaction declined
635
+ break;
636
+ case 20:
637
+ // status code of 20 - means duplicate transaction
638
+ $szPreviousTransactionMessage = $tdsarThreeDSecureAuthenticationResult->getPreviousTransactionResult()->getMessage();
639
+ $szLogMessage = "Duplicate transaction for OrderID: ".$szOrderID.". A duplicate transaction means that a transaction with these details has already been processed by the payment provider. The details of the original transaction: ".$szPreviousTransactionMessage.". Result object details: ";
640
+
641
+ if ($tdsarThreeDSecureAuthenticationResult->getPreviousTransactionResult()->getStatusCode()->getValue() == 0)
642
+ {
643
+ $GLOBALS['m_bo3DSecureError'] = false;
644
+ $GLOBALS['m_sz3DSecureMessage'] = $GLOBALS['m_sz3DSecureMessage'].". A duplicate transaction means that a transaction with these details has already been processed by the payment provider. The details of the original transaction are - ".$szPreviousTransactionMessage;
645
+ }
646
+ break;
647
+ case 30:
648
+ // status code of 30 - means an error occurred
649
+ $szLogMessage = "3D Secure transaction could not be completed for OrderID: ".$szOrderID.". Error message: ".$tdsarThreeDSecureAuthenticationResult->getMessage();
650
+ if ($tdsarThreeDSecureAuthenticationResult->getErrorMessages()->getCount() > 0)
651
+ {
652
+ $szLogMessage = $szLogMessage.".";
653
+
654
+ for ($LoopIndex = 0; $LoopIndex < $tdsarThreeDSecureAuthenticationResult->getErrorMessages()->getCount(); $LoopIndex++)
655
+ {
656
+ $szLogMessage = $szLogMessage.$tdsarThreeDSecureAuthenticationResult->getErrorMessages()->getAt($LoopIndex).";";
657
+ }
658
+ $szLogMessage = $szLogMessage." ";
659
+ }
660
+ break;
661
+ default:
662
+ // unhandled status code
663
+ break;
664
+ }
665
+
666
+ // log 3DS payment result
667
+ $szLogMessage = $szLogMessage.print_r($tdsarThreeDSecureAuthenticationResult, 1);
668
+ Mage::log($szLogMessage);
669
+ }
670
+ }
671
+
672
+ /**
673
+ * Building the request object for 3D Secure payment
674
+ *
675
+ * @param string $PaRes
676
+ * @param string $MD
677
+ * @return Iridiumcorp_Tpg_Model_Request
678
+ */
679
+ public function _build3DSecureRequest($PaRes, $MD)
680
+ {
681
+ $request = Mage::getModel('tpg/request')
682
+ ->setPares($PaRes)
683
+ ->setMd($MD);
684
+
685
+ return $request;
686
+ }
687
+
688
+ /**
689
+ * Override the core Mage function to get the URL to be redirected from the Onepage
690
+ *
691
+ * @return string
692
+ */
693
+ public function getOrderPlaceRedirectUrl()
694
+ {
695
+ $result = false;
696
+ $session = Mage::getSingleton('checkout/session');
697
+
698
+ // get the correct url for redirection
699
+ if ($session->getAcsurl() &&
700
+ $session->getMd() &&
701
+ $session->getPareq())
702
+ {
703
+ $result = Mage::getUrl('tpg/payment/threedsecure');
704
+ }
705
+ else if ($session->getHashdigest())
706
+ {
707
+ $result = Mage::getUrl('tpg/payment/redirect');
708
+ }
709
+
710
+ return $result;
711
+ }
712
+
713
+ /**
714
+ * Get the correct payment processor domain
715
+ *
716
+ * @return string
717
+ */
718
+ private function _getPaymentProcessorFullDomain()
719
+ {
720
+ $szPaymentProcessorFullDomain;
721
+
722
+ // get the stored config setting
723
+ $szPaymentProcessorDomain = $this->getConfigData('paymentprocessordomain');
724
+ $szPaymentProcessorPort = $this->getConfigData('paymentprocessorport');
725
+
726
+ if ($szPaymentProcessorPort == '443')
727
+ {
728
+ $szPaymentProcessorFullDomain = $szPaymentProcessorDomain."/";
729
+ }
730
+ else
731
+ {
732
+ $szPaymentProcessorFullDomain = $szPaymentProcessorDomain.":".$szPaymentProcessorPort."/";
733
+ }
734
+
735
+ return $szPaymentProcessorFullDomain;
736
+ }
737
+
738
+ /**
739
+ * Get the country ISO3 code from the ISO2 code
740
+ *
741
+ * @param ISO2Code
742
+ * @return string
743
+ */
744
+ private function _getISO3Code($szISO2Code)
745
+ {
746
+ $szISO3Code;
747
+ $collection;
748
+ $boFound = false;
749
+ $nCount = 1;
750
+ $item;
751
+
752
+ $collection = Mage::getModel('directory/country_api')->items();
753
+
754
+ while ($boFound == false &&
755
+ $nCount < count($collection))
756
+ {
757
+ $item = $collection[$nCount];
758
+ if($item['iso2_code'] == $szISO2Code)
759
+ {
760
+ $boFound = true;
761
+ $szISO3Code = $item['iso3_code'];
762
+ }
763
+ $nCount++;
764
+ }
765
+
766
+ return $szISO3Code;
767
+ }
768
+ }
app/code/local/Iridiumcorp/Tpg/Model/Request.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Iridiumcorp_Tpg_Model_Request extends Varien_Object
4
+ {
5
+ public function __call($method, $args)
6
+ {
7
+ switch (substr($method, 0, 3))
8
+ {
9
+ case 'get' :
10
+ $key = substr($method,3);
11
+ $data = $this->getData($key, isset($args[0]) ? $args[0] : null);
12
+ return $data;
13
+ case 'set' :
14
+ $key = substr($method,3);
15
+ $result = $this->setData($key, isset($args[0]) ? $args[0] : null);
16
+ return $result;
17
+ default:
18
+ return parent::__call($method, $args);
19
+ }
20
+ throw new Varien_Exception("Invalid method ".get_class($this)."::".$method."(".print_r($args,1).")");
21
+ }
22
+ }
app/code/local/Iridiumcorp/Tpg/Model/Source/HashMethod.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Iridiumcorp_Tpg_Model_Source_HashMethod
4
+ {
5
+ // public enum for the payment types
6
+ const HASH_METHOD_MD5 = 'md5';
7
+ const HASH_METHOD_SHA1 = 'sha1';
8
+ const HASH_METHOD_HMACMD5 = 'hmacmd5';
9
+ const HASH_METHOD_HMACSHA1 = 'hmacsha1';
10
+
11
+ public function toOptionArray()
12
+ {
13
+ return array
14
+ (
15
+ array(
16
+ 'value' => self::HASH_METHOD_MD5,
17
+ 'label' => Mage::helper('tpg')->__('MD5')
18
+ ),
19
+ array(
20
+ 'value' => self::HASH_METHOD_SHA1,
21
+ 'label' => Mage::helper('tpg')->__('SHA1')
22
+ ),
23
+ array(
24
+ 'value' => self::HASH_METHOD_HMACMD5,
25
+ 'label' => Mage::helper('tpg')->__('HMACMD5')
26
+ ),
27
+ array(
28
+ 'value' => self::HASH_METHOD_HMACSHA1,
29
+ 'label' => Mage::helper('tpg')->__('HMACSHA1')
30
+ )
31
+ );
32
+ }
33
+ }
app/code/local/Iridiumcorp/Tpg/Model/Source/PaymentAction.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Iridiumcorp_Tpg_Model_Source_PaymentAction extends Mage_Paygate_Model_Authorizenet_Source_PaymentAction
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ return array(
8
+ // override the core class to ONLy allow capture transactions (immediate settlement)
9
+ array(
10
+ 'value' => Mage_Paygate_Model_Authorizenet::ACTION_AUTHORIZE_CAPTURE,
11
+ 'label' => Mage::helper('paygate')->__('Authorize and Capture')
12
+ ),
13
+ );
14
+ }
15
+ }
app/code/local/Iridiumcorp/Tpg/Model/Source/PaymentMode.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Iridiumcorp_Tpg_Model_Source_PaymentMode
4
+ {
5
+ // public enum for the payment types
6
+ const PAYMENT_MODE_DIRECT_API = 'direct';
7
+ const PAYMENT_MODE_HOSTED_PAYMENT_FORM = 'hosted';
8
+ const PAYMENT_MODE_TRANSPARENT_REDIRECT = 'transparent';
9
+
10
+ public function toOptionArray()
11
+ {
12
+ return array
13
+ (
14
+ array(
15
+ 'value' => self::PAYMENT_MODE_DIRECT_API,
16
+ 'label' => Mage::helper('tpg')->__('Direct (API)')
17
+ ),
18
+ array(
19
+ 'value' => self::PAYMENT_MODE_HOSTED_PAYMENT_FORM,
20
+ 'label' => Mage::helper('tpg')->__('Hosted Payment Form')
21
+ ),
22
+ array(
23
+ 'value' => self::PAYMENT_MODE_TRANSPARENT_REDIRECT,
24
+ 'label' => Mage::helper('tpg')->__('Transparent Redirect')
25
+ ),
26
+ );
27
+ }
28
+ }
app/code/local/Iridiumcorp/Tpg/Model/Source/ResultDeliveryMethod.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Iridiumcorp_Tpg_Model_Source_ResultDeliveryMethod
4
+ {
5
+ // public enum for the payment types
6
+ const RESULT_DELIVERY_METHOD_POST = 'POST';
7
+ const RESULT_DELIVERY_METHOD_SERVER = 'SERVER';
8
+
9
+ public function toOptionArray()
10
+ {
11
+ return array
12
+ (
13
+ array(
14
+ 'value' => self::RESULT_DELIVERY_METHOD_POST,
15
+ 'label' => Mage::helper('tpg')->__('Post')
16
+ ),
17
+ array(
18
+ 'value' => self::RESULT_DELIVERY_METHOD_SERVER,
19
+ 'label' => Mage::helper('tpg')->__('Server')
20
+ ),
21
+ );
22
+ }
23
+ }
app/code/local/Iridiumcorp/Tpg/Model/Tpg/GlobalErrors.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Iridiumcorp_Tpg_Model_Tpg_GlobalErrors
4
+ {
5
+ // error occurred in the processing of the callback from the hosted payment form
6
+ const ERROR_183 = "ERROR 183: The payment result couldn't be verified.";
7
+
8
+ // error occurred during the processing of the callback from the transparent redirect page
9
+ const ERROR_260 = "ERROR 260: The payment result couldn't be verified.";
10
+
11
+ // direct integration transaction cannot be completed - problem in the communication with the payment gateway
12
+ const ERROR_261 = "ERROR 261: Couldn't communicate with payment gateway.";
13
+
14
+ // direct integration 3D Secure transaction couldn't be processed - problem in the communication with the paymwent gateway
15
+ const ERROR_431 = "ERROR 431: Couldn't communicate with payment gateway for 3D Secure transaction.";
16
+
17
+ // error occurred during the processing of the data in the callback from the 3D Secure Authentication page
18
+ const ERROR_7655 = "ERROR 7655: 3D Secure Validation was not successfull and checkout was cancelled.<br/>Please check your credit card details and try again.";
19
+ }
20
+ ?>
app/code/local/Iridiumcorp/Tpg/Model/Tpg/ISOCountries.php ADDED
@@ -0,0 +1,265 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ include_once ("ThePaymentGateway/TPG_Common.php");
4
+
5
+ class IRC_ISOCountries
6
+ {
7
+ /**
8
+ * Get the list of ISO Countries
9
+ *
10
+ * @return ISOCountryList
11
+ */
12
+ public static function getISOCountryList()
13
+ {
14
+ $iclISOCountryList = new IRC_ISOCountryList();
15
+
16
+ $iclISOCountryList->add(826,"United Kingdom","GBR",3);
17
+ $iclISOCountryList->add(840,"United States","USA",2);
18
+ $iclISOCountryList->add(36,"Australia","AUS",1);
19
+ $iclISOCountryList->add(124,"Canada","CAN",1);
20
+ $iclISOCountryList->add(250,"France","FRA",1);
21
+ $iclISOCountryList->add(276,"Germany","DEU",1);
22
+ $iclISOCountryList->add(4,"Afghanistan","AFG",0);
23
+ $iclISOCountryList->add(248,"�land Islands","ALA",0);
24
+ $iclISOCountryList->add(8,"Albania","ALB",0);
25
+ $iclISOCountryList->add(12,"Algeria","DZA",0);
26
+ $iclISOCountryList->add(16,"American Samoa","ASM",0);
27
+ $iclISOCountryList->add(20,"Andorra","AND",0);
28
+ $iclISOCountryList->add(24,"Angola","AGO",0);
29
+ $iclISOCountryList->add(660,"Anguilla","AIA",0);
30
+ $iclISOCountryList->add(10,"Antarctica","ATA",0);
31
+ $iclISOCountryList->add(28,"Antigua and Barbuda","ATG",0);
32
+ $iclISOCountryList->add(32,"Argentina","ARG",0);
33
+ $iclISOCountryList->add(51,"Armenia","ARM",0);
34
+ $iclISOCountryList->add(533,"Aruba","ABW",0);
35
+ $iclISOCountryList->add(40,"Austria","AUT",0);
36
+ $iclISOCountryList->add(31,"Azerbaijan","AZE",0);
37
+ $iclISOCountryList->add(44,"Bahamas","BHS",0);
38
+ $iclISOCountryList->add(48,"Bahrain","BHR",0);
39
+ $iclISOCountryList->add(50,"Bangladesh","BGD",0);
40
+ $iclISOCountryList->add(52,"Barbados","BRB",0);
41
+ $iclISOCountryList->add(112,"Belarus","BLR",0);
42
+ $iclISOCountryList->add(56,"Belgium","BEL",0);
43
+ $iclISOCountryList->add(84,"Belize","BLZ",0);
44
+ $iclISOCountryList->add(204,"Benin","BEN",0);
45
+ $iclISOCountryList->add(60,"Bermuda","BMU",0);
46
+ $iclISOCountryList->add(64,"Bhutan","BTN",0);
47
+ $iclISOCountryList->add(68,"Bolivia","BOL",0);
48
+ $iclISOCountryList->add(70,"Bosnia and Herzegovina","BIH",0);
49
+ $iclISOCountryList->add(72,"Botswana","BWA",0);
50
+ $iclISOCountryList->add(74,"Bouvet Island","BVT",0);
51
+ $iclISOCountryList->add(76,"Brazil Federative","BRA",0);
52
+ $iclISOCountryList->add(86,"British Indian Ocean Territory","IOT",0);
53
+ $iclISOCountryList->add(96,"Brunei","BRN",0);
54
+ $iclISOCountryList->add(100,"Bulgaria","BGR",0);
55
+ $iclISOCountryList->add(854,"Burkina Faso","BFA",0);
56
+ $iclISOCountryList->add(108,"Burundi","BDI",0);
57
+ $iclISOCountryList->add(116,"Cambodia","KHM",0);
58
+ $iclISOCountryList->add(120,"Cameroon","CMR",0);
59
+ $iclISOCountryList->add(132,"Cape Verde","CPV",0);
60
+ $iclISOCountryList->add(136,"Cayman Islands","CYM",0);
61
+ $iclISOCountryList->add(140,"Central African Republic","CAF",0);
62
+ $iclISOCountryList->add(148,"Chad","TCD",0);
63
+ $iclISOCountryList->add(152,"Chile","CHL",0);
64
+ $iclISOCountryList->add(156,"China","CHN",0);
65
+ $iclISOCountryList->add(162,"Christmas Island","CXR",0);
66
+ $iclISOCountryList->add(166,"Cocos (Keeling) Islands","CCK",0);
67
+ $iclISOCountryList->add(170,"Colombia","COL",0);
68
+ $iclISOCountryList->add(174,"Comoros","COM",0);
69
+ $iclISOCountryList->add(180,"Congo","COD",0);
70
+ $iclISOCountryList->add(178,"Congo","COG",0);
71
+ $iclISOCountryList->add(184,"Cook Islands","COK",0);
72
+ $iclISOCountryList->add(188,"Costa Rica","CRI",0);
73
+ $iclISOCountryList->add(384,"C�te d'Ivoire","CIV",0);
74
+ $iclISOCountryList->add(191,"Croatia","HRV",0);
75
+ $iclISOCountryList->add(192,"Cuba","CUB",0);
76
+ $iclISOCountryList->add(196,"Cyprus","CYP",0);
77
+ $iclISOCountryList->add(203,"Czech Republic","CZE",0);
78
+ $iclISOCountryList->add(208,"Denmark","DNK",0);
79
+ $iclISOCountryList->add(262,"Djibouti","DJI",0);
80
+ $iclISOCountryList->add(212,"Dominica","DMA",0);
81
+ $iclISOCountryList->add(214,"Dominican Republic","DOM",0);
82
+ $iclISOCountryList->add(626,"East Timor","TMP",0);
83
+ $iclISOCountryList->add(218,"Ecuador","ECU",0);
84
+ $iclISOCountryList->add(818,"Egypt","EGY",0);
85
+ $iclISOCountryList->add(222,"El Salvador","SLV",0);
86
+ $iclISOCountryList->add(226,"Equatorial Guinea","GNQ",0);
87
+ $iclISOCountryList->add(232,"Eritrea","ERI",0);
88
+ $iclISOCountryList->add(233,"Estonia","EST",0);
89
+ $iclISOCountryList->add(231,"Ethiopia","ETH",0);
90
+ $iclISOCountryList->add(238,"Falkland Islands (Malvinas)","FLK",0);
91
+ $iclISOCountryList->add(234,"Faroe Islands","FRO",0);
92
+ $iclISOCountryList->add(242,"Fiji","FJI",0);
93
+ $iclISOCountryList->add(246,"Finland","FIN",0);
94
+ $iclISOCountryList->add(254,"French Guiana","GUF",0);
95
+ $iclISOCountryList->add(258,"French Polynesia","PYF",0);
96
+ $iclISOCountryList->add(260,"French Southern Territories","ATF",0);
97
+ $iclISOCountryList->add(266,"Gabon","GAB",0);
98
+ $iclISOCountryList->add(270,"Gambia","GMB",0);
99
+ $iclISOCountryList->add(268,"Georgia","GEO",0);
100
+ $iclISOCountryList->add(288,"Ghana","GHA",0);
101
+ $iclISOCountryList->add(292,"Gibraltar","GIB",0);
102
+ $iclISOCountryList->add(300,"Greece","GRC",0);
103
+ $iclISOCountryList->add(304,"Greenland","GRL",0);
104
+ $iclISOCountryList->add(308,"Grenada","GRD",0);
105
+ $iclISOCountryList->add(312,"Guadaloupe","GLP",0);
106
+ $iclISOCountryList->add(316,"Guam","GUM",0);
107
+ $iclISOCountryList->add(320,"Guatemala","GTM",0);
108
+ $iclISOCountryList->add(831,"Guernsey","GGY",0);
109
+ $iclISOCountryList->add(324,"Guinea","GIN",0);
110
+ $iclISOCountryList->add(624,"Guinea-Bissau","GNB",0);
111
+ $iclISOCountryList->add(328,"Guyana","GUY",0);
112
+ $iclISOCountryList->add(332,"Haiti","HTI",0);
113
+ $iclISOCountryList->add(334,"Heard Island and McDonald Islands","HMD",0);
114
+ $iclISOCountryList->add(340,"Honduras","HND",0);
115
+ $iclISOCountryList->add(344,"Hong Kong","HKG",0);
116
+ $iclISOCountryList->add(348,"Hungary","HUN",0);
117
+ $iclISOCountryList->add(352,"Iceland","ISL",0);
118
+ $iclISOCountryList->add(356,"India","IND",0);
119
+ $iclISOCountryList->add(360,"Indonesia","IDN",0);
120
+ $iclISOCountryList->add(364,"Iran","IRN",0);
121
+ $iclISOCountryList->add(368,"Iraq","IRQ",0);
122
+ $iclISOCountryList->add(372,"Ireland","IRL",0);
123
+ $iclISOCountryList->add(833,"Isle of Man","IMN",0);
124
+ $iclISOCountryList->add(376,"Israel","ISR",0);
125
+ $iclISOCountryList->add(380,"Italy","ITA",0);
126
+ $iclISOCountryList->add(388,"Jamaica","JAM",0);
127
+ $iclISOCountryList->add(392,"Japan","JPN",0);
128
+ $iclISOCountryList->add(832,"Jersey","JEY",0);
129
+ $iclISOCountryList->add(400,"Jordan","JOR",0);
130
+ $iclISOCountryList->add(398,"Kazakhstan","KAZ",0);
131
+ $iclISOCountryList->add(404,"Kenya","KEN",0);
132
+ $iclISOCountryList->add(296,"Kiribati","KIR",0);
133
+ $iclISOCountryList->add(410,"Korea","KOR",0);
134
+ $iclISOCountryList->add(408,"Korea","PRK",0);
135
+ $iclISOCountryList->add(414,"Kuwait","KWT",0);
136
+ $iclISOCountryList->add(417,"Kyrgyzstan","KGZ",0);
137
+ $iclISOCountryList->add(418,"Lao","LAO",0);
138
+ $iclISOCountryList->add(428,"Latvia","LVA",0);
139
+ $iclISOCountryList->add(422,"Lebanon","LBN",0);
140
+ $iclISOCountryList->add(426,"Lesotho","LSO",0);
141
+ $iclISOCountryList->add(430,"Liberia","LBR",0);
142
+ $iclISOCountryList->add(434,"Libyan Arab Jamahiriya","LBY",0);
143
+ $iclISOCountryList->add(438,"Liechtenstein","LIE",0);
144
+ $iclISOCountryList->add(440,"Lithuania","LTU",0);
145
+ $iclISOCountryList->add(442,"Luxembourg","LUX",0);
146
+ $iclISOCountryList->add(446,"Macau","MAC",0);
147
+ $iclISOCountryList->add(807,"Macedonia","MKD",0);
148
+ $iclISOCountryList->add(450,"Madagascar","MDG",0);
149
+ $iclISOCountryList->add(454,"Malawi","MWI",0);
150
+ $iclISOCountryList->add(458,"Malaysia","MYS",0);
151
+ $iclISOCountryList->add(462,"Maldives","MDV",0);
152
+ $iclISOCountryList->add(466,"Mali","MLI",0);
153
+ $iclISOCountryList->add(470,"Malta","MLT",0);
154
+ $iclISOCountryList->add(584,"Marshall Islands","MHL",0);
155
+ $iclISOCountryList->add(474,"Martinique","MTQ",0);
156
+ $iclISOCountryList->add(478,"Mauritania Islamic","MRT",0);
157
+ $iclISOCountryList->add(480,"Mauritius","MUS",0);
158
+ $iclISOCountryList->add(175,"Mayotte","MYT",0);
159
+ $iclISOCountryList->add(484,"Mexico","MEX",0);
160
+ $iclISOCountryList->add(583,"Micronesia","FSM",0);
161
+ $iclISOCountryList->add(498,"Moldova","MDA",0);
162
+ $iclISOCountryList->add(492,"Monaco","MCO",0);
163
+ $iclISOCountryList->add(496,"Mongolia","MNG",0);
164
+ $iclISOCountryList->add(499,"Montenegro","MNE",0);
165
+ $iclISOCountryList->add(500,"Montserrat","MSR",0);
166
+ $iclISOCountryList->add(504,"Morocco","MAR",0);
167
+ $iclISOCountryList->add(508,"Mozambique","MOZ",0);
168
+ $iclISOCountryList->add(104,"Myanmar","MMR",0);
169
+ $iclISOCountryList->add(516,"Namibia","NAM",0);
170
+ $iclISOCountryList->add(520,"Nauru","NRU",0);
171
+ $iclISOCountryList->add(524,"Nepal","NPL",0);
172
+ $iclISOCountryList->add(528,"Netherlands","NLD",0);
173
+ $iclISOCountryList->add(530,"Netherlands Antilles","ANT",0);
174
+ $iclISOCountryList->add(540,"New Caledonia","NCL",0);
175
+ $iclISOCountryList->add(554,"New Zealand","NZL",0);
176
+ $iclISOCountryList->add(558,"Nicaragua","NIC",0);
177
+ $iclISOCountryList->add(562,"Niger","NER",0);
178
+ $iclISOCountryList->add(566,"Nigeria","NGA",0);
179
+ $iclISOCountryList->add(570,"Niue","NIU",0);
180
+ $iclISOCountryList->add(574,"Norfolk Island","NFK",0);
181
+ $iclISOCountryList->add(580,"Northern Mariana Islands","MNP",0);
182
+ $iclISOCountryList->add(578,"Norway","NOR",0);
183
+ $iclISOCountryList->add(512,"Oman","OMN",0);
184
+ $iclISOCountryList->add(586,"Pakistan","PAK",0);
185
+ $iclISOCountryList->add(585,"Palau","PLW",0);
186
+ $iclISOCountryList->add(275,"Palestine","PSE",0);
187
+ $iclISOCountryList->add(591,"Panama","PAN",0);
188
+ $iclISOCountryList->add(598,"Papua New Guinea","PNG",0);
189
+ $iclISOCountryList->add(600,"Paraguay","PRY",0);
190
+ $iclISOCountryList->add(604,"Peru","PER",0);
191
+ $iclISOCountryList->add(608,"Philippines","PHL",0);
192
+ $iclISOCountryList->add(612,"Pitcairn","PCN",0);
193
+ $iclISOCountryList->add(616,"Poland","POL",0);
194
+ $iclISOCountryList->add(620,"Portugal","PRT",0);
195
+ $iclISOCountryList->add(630,"Puerto Rico","PRI",0);
196
+ $iclISOCountryList->add(634,"Qatar","QAT",0);
197
+ $iclISOCountryList->add(638,"R�union","REU",0);
198
+ $iclISOCountryList->add(642,"Romania","ROM",0);
199
+ $iclISOCountryList->add(643,"Russian Federation","RUS",0);
200
+ $iclISOCountryList->add(646,"Rwanda","RWA",0);
201
+ $iclISOCountryList->add(652,"Saint Barth�lemy","BLM",0);
202
+ $iclISOCountryList->add(654,"Saint Helena","SHN",0);
203
+ $iclISOCountryList->add(659,"Saint Kitts and Nevis","KNA",0);
204
+ $iclISOCountryList->add(662,"Saint Lucia","LCA",0);
205
+ $iclISOCountryList->add(663,"Saint Martin (French part)","MAF",0);
206
+ $iclISOCountryList->add(666,"Saint Pierre and Miquelon","SPM",0);
207
+ $iclISOCountryList->add(670,"Saint Vincent and the Grenadines","VCT",0);
208
+ $iclISOCountryList->add(882,"Samoa","WSM",0);
209
+ $iclISOCountryList->add(674,"San Marino","SMR",0);
210
+ $iclISOCountryList->add(678,"S�o Tom� and Pr�ncipe Democratic","STP",0);
211
+ $iclISOCountryList->add(682,"Saudi Arabia","SAU",0);
212
+ $iclISOCountryList->add(686,"Senegal","SEN",0);
213
+ $iclISOCountryList->add(688,"Serbia","SRB",0);
214
+ $iclISOCountryList->add(690,"Seychelles","SYC",0);
215
+ $iclISOCountryList->add(694,"Sierra Leone","SLE",0);
216
+ $iclISOCountryList->add(702,"Singapore","SGP",0);
217
+ $iclISOCountryList->add(703,"Slovakia","SVK",0);
218
+ $iclISOCountryList->add(705,"Slovenia","SVN",0);
219
+ $iclISOCountryList->add(90,"Solomon Islands","SLB",0);
220
+ $iclISOCountryList->add(706,"Somalia","SOM",0);
221
+ $iclISOCountryList->add(710,"South Africa","ZAF",0);
222
+ $iclISOCountryList->add(239,"South Georgia and the South Sandwich Islands","SGS",0);
223
+ $iclISOCountryList->add(724,"Spain","ESP",0);
224
+ $iclISOCountryList->add(144,"Sri Lanka","LKA",0);
225
+ $iclISOCountryList->add(736,"Sudan","SDN",0);
226
+ $iclISOCountryList->add(740,"Suriname","SUR",0);
227
+ $iclISOCountryList->add(744,"Svalbard and Jan Mayen","SJM",0);
228
+ $iclISOCountryList->add(748,"Swaziland","SWZ",0);
229
+ $iclISOCountryList->add(752,"Sweden","SWE",0);
230
+ $iclISOCountryList->add(756,"Switzerland","CHE",0);
231
+ $iclISOCountryList->add(760,"Syrian Arab Republic","SYR",0);
232
+ $iclISOCountryList->add(158,"Taiwan,","TWN",0);
233
+ $iclISOCountryList->add(762,"Tajikistan","TJK",0);
234
+ $iclISOCountryList->add(834,"Tanzania","TZA",0);
235
+ $iclISOCountryList->add(764,"Thailand","THA",0);
236
+ $iclISOCountryList->add(768,"Togo","TGO",0);
237
+ $iclISOCountryList->add(772,"Tokelau","TKL",0);
238
+ $iclISOCountryList->add(776,"Tonga","TON",0);
239
+ $iclISOCountryList->add(780,"Trinidad and Tobago","TTO",0);
240
+ $iclISOCountryList->add(788,"Tunisia","TUN",0);
241
+ $iclISOCountryList->add(792,"Turkey","TUR",0);
242
+ $iclISOCountryList->add(795,"Turkmenistan","TKM",0);
243
+ $iclISOCountryList->add(796,"Turks and Caicos Islands","TCA",0);
244
+ $iclISOCountryList->add(798,"Tuvalu","TUV",0);
245
+ $iclISOCountryList->add(800,"Uganda","UGA",0);
246
+ $iclISOCountryList->add(804,"Ukraine","UKR",0);
247
+ $iclISOCountryList->add(784,"United Arab Emirates","ARE",0);
248
+ $iclISOCountryList->add(581,"United States Minor Outlying Islands","UMI",0);
249
+ $iclISOCountryList->add(858,"Uruguay Eastern","URY",0);
250
+ $iclISOCountryList->add(860,"Uzbekistan","UZB",0);
251
+ $iclISOCountryList->add(548,"Vanuatu","VUT",0);
252
+ $iclISOCountryList->add(336,"Vatican City State","VAT",0);
253
+ $iclISOCountryList->add(862,"Venezuela","VEN",0);
254
+ $iclISOCountryList->add(704,"Vietnam","VNM",0);
255
+ $iclISOCountryList->add(92,"Virgin Islands, British","VGB",0);
256
+ $iclISOCountryList->add(850,"Virgin Islands, U.S.","VIR",0);
257
+ $iclISOCountryList->add(876,"Wallis and Futuna","WLF",0);
258
+ $iclISOCountryList->add(732,"Western Sahara","ESH",0);
259
+ $iclISOCountryList->add(887,"Yemen","YEM",0);
260
+ $iclISOCountryList->add(894,"Zambia","ZMB",0);
261
+ $iclISOCountryList->add(716,"Zimbabwe","ZWE",0);
262
+
263
+ return $iclISOCountryList;
264
+ }
265
+ }
app/code/local/Iridiumcorp/Tpg/Model/Tpg/ISOCurrencies.php ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ include_once ("ThePaymentGateway/TPG_Common.php");
4
+
5
+ class IRC_ISOCurrencies
6
+ {
7
+ /**
8
+ * Get the list of ISO Currencies
9
+ *
10
+ * @return ISOCurrencyList
11
+ */
12
+ public static function getISOCurrencyList()
13
+ {
14
+ $iclISOCurrencyList = new IRC_ISOCurrencyList();
15
+
16
+ $iclISOCurrencyList->add(634, "Qatari Rial","QAR", 2);
17
+ $iclISOCurrencyList->add(566, "Naira", "NGN", 2);
18
+ $iclISOCurrencyList->add(678, "Dobra", "STD", 2);
19
+ $iclISOCurrencyList->add(943, "Metical", "MZN", 2);
20
+ $iclISOCurrencyList->add(826, "Pound Sterling", "GBP", 2);
21
+ $iclISOCurrencyList->add(654, "Saint Helena Pound", "SHP", 2);
22
+ $iclISOCurrencyList->add(704, "Vietnamese ??ng", "VND", 2);
23
+ $iclISOCurrencyList->add(952, "CFA Franc BCEAO", "XOF", 0);
24
+ $iclISOCurrencyList->add(356, "Indian Rupee", "INR", 2);
25
+ $iclISOCurrencyList->add(807, "Denar", "MKD", 2);
26
+ $iclISOCurrencyList->add(959, "Gold (one Troy ounce)", "XAU", 0);
27
+ $iclISOCurrencyList->add(410, "South Korean Won", "KRW", 0);
28
+ $iclISOCurrencyList->add(946, "Romanian New Leu", "RON", 2);
29
+ $iclISOCurrencyList->add(949, "New Turkish Lira", "TRY", 2);
30
+ $iclISOCurrencyList->add(532, "Netherlands Antillian Guilder", "ANG", 2);
31
+ $iclISOCurrencyList->add(788, "Tunisian Dinar", "TND", 3);
32
+ $iclISOCurrencyList->add(646, "Rwanda Franc", "RWF", 0);
33
+ $iclISOCurrencyList->add(504, "Moroccan Dirham", "MAD", 2);
34
+ $iclISOCurrencyList->add(174, "Comoro Franc", "KMF", 0);
35
+ $iclISOCurrencyList->add(484, "Mexican Peso", "MXN", 2);
36
+ $iclISOCurrencyList->add(478, "Ouguiya", "MRO", 2);
37
+ $iclISOCurrencyList->add(233, "Kroon", "EEK", 2);
38
+ $iclISOCurrencyList->add(400, "Jordanian Dinar", "JOD", 3);
39
+ $iclISOCurrencyList->add(292, "Gibraltar pound", "GIP", 2);
40
+ $iclISOCurrencyList->add(690, "Seychelles Rupee", "SCR", 2);
41
+ $iclISOCurrencyList->add(422, "Lebanese Pound", "LBP", 2);
42
+ $iclISOCurrencyList->add(232, "Nakfa", "ERN", 2);
43
+ $iclISOCurrencyList->add(496, "Tugrik", "MNT", 2);
44
+ $iclISOCurrencyList->add(328, "Guyana Dollar", "GYD", 2);
45
+ $iclISOCurrencyList->add(970, "Unidad de Valor Real", "COU", 2);
46
+ $iclISOCurrencyList->add(974, "Belarusian Ruble", "BYR", 0);
47
+ $iclISOCurrencyList->add(608, "Philippine Peso", "PHP", 2);
48
+ $iclISOCurrencyList->add(598, "Kina", "PGK", 2);
49
+ $iclISOCurrencyList->add(951, "East Caribbean Dollar", "XCD", 2);
50
+ $iclISOCurrencyList->add(52, "Barbados Dollar", "BBD", 2);
51
+ $iclISOCurrencyList->add(944, "Azerbaijanian Manat", "AZN", 2);
52
+ $iclISOCurrencyList->add(434, "Libyan Dinar", "LYD", 3);
53
+ $iclISOCurrencyList->add(706, "Somali Shilling", "SOS", 2);
54
+ $iclISOCurrencyList->add(950, "CFA Franc BEAC", "XAF", 0);
55
+ $iclISOCurrencyList->add(840, "US Dollar", "USD", 2);
56
+ $iclISOCurrencyList->add(68, "Boliviano", "BOB", 2);
57
+ $iclISOCurrencyList->add(214, "Dominican Peso", "DOP", 2);
58
+ $iclISOCurrencyList->add(818, "Egyptian Pound", "EGP", 2);
59
+ $iclISOCurrencyList->add(170, "Colombian Peso", "COP", 2);
60
+ $iclISOCurrencyList->add(986, "Brazilian Real", "BRL", 2);
61
+ $iclISOCurrencyList->add(961, "Silver (one Troy ounce)", "XAG", 0);
62
+ $iclISOCurrencyList->add(973, "Kwanza", "AOA", 2);
63
+ $iclISOCurrencyList->add(962, "Platinum (one Troy ounce)", "XPT", 0);
64
+ $iclISOCurrencyList->add(414, "Kuwaiti Dinar", "KWD", 3);
65
+ $iclISOCurrencyList->add(604, "Nuevo Sol", "PEN", 2);
66
+ $iclISOCurrencyList->add(702, "Singapore Dollar", "SGD", 2);
67
+ $iclISOCurrencyList->add(862, "Venezuelan bol�var", "VEB", 2);
68
+ $iclISOCurrencyList->add(953, "CFP franc", "XPF", 0);
69
+ $iclISOCurrencyList->add(558, "Cordoba Oro", "NIO", 2);
70
+ $iclISOCurrencyList->add(348, "Forint", "HUF", 2);
71
+ $iclISOCurrencyList->add(948, "WIR Franc ", "CHW", 2);
72
+ $iclISOCurrencyList->add(116, "Riel", "KHR", 2);
73
+ $iclISOCurrencyList->add(956, "European Monetary Unit", "XBB", 0);
74
+ $iclISOCurrencyList->add(156, "Yuan Renminbi", "CNY", 2);
75
+ $iclISOCurrencyList->add(834, "Tanzanian Shilling", "TZS", 2);
76
+ $iclISOCurrencyList->add(997, "", "USN", 2);
77
+ $iclISOCurrencyList->add(981, "Lari", "GEL", 2);
78
+ $iclISOCurrencyList->add(242, "Fiji Dollar", "FJD", 2);
79
+ $iclISOCurrencyList->add(941, "Serbian Dinar", "RSD", 2);
80
+ $iclISOCurrencyList->add(104, "Kyat", "MMK", 2);
81
+ $iclISOCurrencyList->add(84, " Belize Dollar", "BZD", 2);
82
+ $iclISOCurrencyList->add(710, "South African Rand", "ZAR", 2);
83
+ $iclISOCurrencyList->add(760, "Syrian Pound", "SYP", 2);
84
+ $iclISOCurrencyList->add(512, "Rial Omani", "OMR", 3);
85
+ $iclISOCurrencyList->add(324, "Guinea Franc", "GNF", 0);
86
+ $iclISOCurrencyList->add(196, "Cyprus Pound", "CYP", 2);
87
+ $iclISOCurrencyList->add(960, "Special Drawing Rights", "XDR", 0);
88
+ $iclISOCurrencyList->add(716, "Zimbabwe Dollar", "ZWD", 2);
89
+ $iclISOCurrencyList->add(972, "Somoni", "TJS", 2);
90
+ $iclISOCurrencyList->add(462, "Rufiyaa", "MVR", 2);
91
+ $iclISOCurrencyList->add(979, "Mexican Unidad de Inversion (UDI)", "MXV", 2);
92
+ $iclISOCurrencyList->add(860, "Uzbekistan Som", "UZS", 2);
93
+ $iclISOCurrencyList->add(12, "Algerian Dinar", "DZD", 2);
94
+ $iclISOCurrencyList->add(332, "Haiti Gourde", "HTG", 2);
95
+ $iclISOCurrencyList->add(963, "Code reserved for testing purposes", "XTS", 0);
96
+ $iclISOCurrencyList->add(32, "Argentine Peso", "ARS", 2);
97
+ $iclISOCurrencyList->add(642, "Romanian Leu", "ROL", 2);
98
+ $iclISOCurrencyList->add(984, "Bolivian Mvdol (Funds code)", "BOV", 2);
99
+ $iclISOCurrencyList->add(440, "Lithuanian Litas", "LTL", 2);
100
+ $iclISOCurrencyList->add(480, "Mauritius Rupee", "MUR", 2);
101
+ $iclISOCurrencyList->add(426, "Loti", "LSL", 2);
102
+ $iclISOCurrencyList->add(262, "Djibouti Franc", "DJF", 0);
103
+ $iclISOCurrencyList->add(886, "Yemeni Rial", "YER", 2);
104
+ $iclISOCurrencyList->add(748, "Lilangeni", "SZL", 2);
105
+ $iclISOCurrencyList->add(192, "Cuban Peso", "CUP", 2);
106
+ $iclISOCurrencyList->add(548, "Vatu", "VUV", 0);
107
+ $iclISOCurrencyList->add(360, "Rupiah", "IDR", 2);
108
+ $iclISOCurrencyList->add(51, "Armenian Dram", "AMD", 2);
109
+ $iclISOCurrencyList->add(894, "Kwacha", "ZMK", 2);
110
+ $iclISOCurrencyList->add(90, "Solomon Islands Dollar", "SBD", 2);
111
+ $iclISOCurrencyList->add(132, "Cape Verde Escudo", "CVE", 2);
112
+ $iclISOCurrencyList->add(999, "No currency", "XXX", 0);
113
+ $iclISOCurrencyList->add(524, "Nepalese Rupee", "NPR", 2);
114
+ $iclISOCurrencyList->add(203, "Czech Koruna", "CZK", 2);
115
+ $iclISOCurrencyList->add(44, "Bahamian Dollar", "BSD", 2);
116
+ $iclISOCurrencyList->add(96, "Brunei Dollar", "BND", 2);
117
+ $iclISOCurrencyList->add(50, "Bangladeshi Taka", "BDT", 2);
118
+ $iclISOCurrencyList->add(404, "Kenyan Shilling", "KES", 2);
119
+ $iclISOCurrencyList->add(947, "WIR Euro ", "CHE", 2);
120
+ $iclISOCurrencyList->add(964, "Palladium (one Troy ounce)", "XPD", 0);
121
+ $iclISOCurrencyList->add(398, "Tenge", "KZT", 2);
122
+ $iclISOCurrencyList->add(352, "Iceland Krona", "ISK", 2);
123
+ $iclISOCurrencyList->add(64, "Ngultrum", "BTN", 2);
124
+ $iclISOCurrencyList->add(533, "Aruban Guilder", "AWG", 2);
125
+ $iclISOCurrencyList->add(230, "Ethiopian Birr", "ETB", 2);
126
+ $iclISOCurrencyList->add(800, "Uganda Shilling", "UGX", 2);
127
+ $iclISOCurrencyList->add(968, "Surinam Dollar", "SRD", 2);
128
+ $iclISOCurrencyList->add(882, "Samoan Tala", "WST", 2);
129
+ $iclISOCurrencyList->add(454, "Kwacha", "MWK", 2);
130
+ $iclISOCurrencyList->add(985, "Zloty", "PLN", 2);
131
+ $iclISOCurrencyList->add(124, "Canadian Dollar", "CAD", 2);
132
+ $iclISOCurrencyList->add(776, "Pa'anga", "TOP", 2);
133
+ $iclISOCurrencyList->add(208, "Danish Krone", "DKK", 2);
134
+ $iclISOCurrencyList->add(108, "Burundian Franc", "BIF", 0);
135
+ $iclISOCurrencyList->add(764, "Baht", "THB", 2);
136
+ $iclISOCurrencyList->add(458, "Malaysian Ringgit", "MYR", 2);
137
+ $iclISOCurrencyList->add(364, "Iranian Rial", "IRR", 2);
138
+ $iclISOCurrencyList->add(600, "Guarani", "PYG", 0);
139
+ $iclISOCurrencyList->add(977, "Convertible Marks", "BAM", 2);
140
+ $iclISOCurrencyList->add(446, "Pataca", "MOP", 2);
141
+ $iclISOCurrencyList->add(780, "Trinidad and Tobago Dollar", "TTD", 2);
142
+ $iclISOCurrencyList->add(703, "Slovak Koruna", "SKK", 2);
143
+ $iclISOCurrencyList->add(958, "European Unit of Account 17 (E.U.A.-17)", "XBD", 0);
144
+ $iclISOCurrencyList->add(430, "Liberian Dollar", "LRD", 2);
145
+ $iclISOCurrencyList->add(191, "Croatian Kuna", "HRK", 2);
146
+ $iclISOCurrencyList->add(694, "Leone", "SLL", 2);
147
+ $iclISOCurrencyList->add(756, "Swiss Franc", "CHF", 2);
148
+ $iclISOCurrencyList->add(969, "Malagasy Ariary", "MGA", 0);
149
+ $iclISOCurrencyList->add(270, "Dalasi", "GMD", 2);
150
+ $iclISOCurrencyList->add(418, "Kip", "LAK", 2);
151
+ $iclISOCurrencyList->add(516, "Namibian Dollar", "NAD", 2);
152
+ $iclISOCurrencyList->add(392, "Japanese yen", "JPY", 0);
153
+ $iclISOCurrencyList->add(320, "Quetzal", "GTQ", 2);
154
+ $iclISOCurrencyList->add(554, "New Zealand Dollar", "NZD", 2);
155
+ $iclISOCurrencyList->add(578, "Norwegian Krone", "NOK", 2);
156
+ $iclISOCurrencyList->add(376, "New Israeli Shekel", "ILS", 2);
157
+ $iclISOCurrencyList->add(957, "European Unit of Account 9 (E.U.A.-9)", "XBC", 0);
158
+ $iclISOCurrencyList->add(498, "Moldovan Leu", "MDL", 2);
159
+ $iclISOCurrencyList->add(998, "", "USS", 2);
160
+ $iclISOCurrencyList->add(955, "European Composite Unit (EURCO)", "XBA", 0);
161
+ $iclISOCurrencyList->add(344, "Hong Kong Dollar", "HKD", 2);
162
+ $iclISOCurrencyList->add(417, "Som", "KGS", 2);
163
+ $iclISOCurrencyList->add(858, "Peso Uruguayo", "UYU", 2);
164
+ $iclISOCurrencyList->add(60, "Bermudian Dollar ", "BMD", 2);
165
+ $iclISOCurrencyList->add(682, "Saudi Riyal", "SAR", 2);
166
+ $iclISOCurrencyList->add(643, "Russian Ruble", "RUB", 2);
167
+ $iclISOCurrencyList->add(470, "Maltese Lira", "MTL", 2);
168
+ $iclISOCurrencyList->add(340, "Lempira", "HNL", 2);
169
+ $iclISOCurrencyList->add(72, "Pula", "BWP", 2);
170
+ $iclISOCurrencyList->add(368, "Iraqi Dinar", "IQD", 3);
171
+ $iclISOCurrencyList->add(188, "Costa Rican Colon", "CRC", 2);
172
+ $iclISOCurrencyList->add(144, "Sri Lanka Rupee", "LKR", 2);
173
+ $iclISOCurrencyList->add(752, "Swedish Krona", "SEK", 2);
174
+ $iclISOCurrencyList->add(136, "Cayman Islands Dollar", "KYD", 2);
175
+ $iclISOCurrencyList->add(8, "Lek", "ALL", 2);
176
+ $iclISOCurrencyList->add(48, "Bahraini Dinar", "BHD", 3);
177
+ $iclISOCurrencyList->add(795, "Manat", "TMM", 2);
178
+ $iclISOCurrencyList->add(938, "Sudanese Pound", "SDG", 2);
179
+ $iclISOCurrencyList->add(590, "Balboa", "PAB", 2);
180
+ $iclISOCurrencyList->add(152, "Chilean Peso", "CLP", 0);
181
+ $iclISOCurrencyList->add(980, "Hryvnia", "UAH", 2);
182
+ $iclISOCurrencyList->add(428, "Latvian Lats", "LVL", 2);
183
+ $iclISOCurrencyList->add(288, "Cedi", "GHS", 2);
184
+ $iclISOCurrencyList->add(978, "Euro", "EUR", 2);
185
+ $iclISOCurrencyList->add(976, "Franc Congolais", "CDF", 2);
186
+ $iclISOCurrencyList->add(586, "Pakistan Rupee", "PKR", 2);
187
+ $iclISOCurrencyList->add(408, "North Korean Won", "KPW", 2);
188
+ $iclISOCurrencyList->add(388, "Jamaican Dollar", "JMD", 2);
189
+ $iclISOCurrencyList->add(990, "Unidades de formento", "CLF", 0);
190
+ $iclISOCurrencyList->add(971, "Afghani", "AFN", 2);
191
+ $iclISOCurrencyList->add(975, "Bulgarian Lev", "BGN", 2);
192
+ $iclISOCurrencyList->add(36, "Australian Dollar", "AUD", 2);
193
+ $iclISOCurrencyList->add(238, "Falkland Islands Pound", "FKP", 2);
194
+ $iclISOCurrencyList->add(901, "New Taiwan Dollar", "TWD", 2);
195
+ $iclISOCurrencyList->add(784, "United Arab Emirates dirham", "AED", 2);
196
+
197
+ return $iclISOCurrencyList;
198
+ }
199
+ }
app/code/local/Iridiumcorp/Tpg/Model/Tpg/PaymentFormHelper.php ADDED
@@ -0,0 +1,444 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once "app/code/local/Iridiumcorp/Tpg/Model/Source/HashMethod.php";
4
+
5
+ class IRC_ListItemList
6
+ {
7
+ private $m_lilListItemList;
8
+
9
+ public function getCount()
10
+ {
11
+ return count($this->m_lilListItemList);
12
+ }
13
+
14
+ public function getAt($nIndex)
15
+ {
16
+ if ($nIndex < 0 ||
17
+ $nIndex >= count($this->m_lilListItemList))
18
+ {
19
+ throw new Exception('Array index out of bounds');
20
+ }
21
+
22
+ return $this->m_lilListItemList[$nIndex];
23
+ }
24
+
25
+ public function add($szName, $szValue, $boIsSelected)
26
+ {
27
+ $liListItem = new IRC_ListItem($szName, $szValue, $boIsSelected);
28
+
29
+ $this->m_lilListItemList[] = $liListItem;
30
+ }
31
+
32
+ public function toString()
33
+ {
34
+ $szReturnString = "";
35
+
36
+ for ($nCount = 0; $nCount < count($this->m_lilListItemList); $nCount++)
37
+ {
38
+ $liListItem = $this->m_lilListItemList[$nCount];
39
+
40
+ $szReturnString = $szReturnString."<option";
41
+
42
+ if ($liListItem->getValue() != null &&
43
+ $liListItem->getValue() != "")
44
+ {
45
+ $szReturnString = $szReturnString." value=\"".$liListItem->getValue()."\"";
46
+ }
47
+
48
+ if ($liListItem->getIsSelected() == true)
49
+ {
50
+ $szReturnString = $szReturnString." selected=\"selected\"";
51
+ }
52
+
53
+ $szReturnString = $szReturnString.">".$liListItem->getName()."</option>\n";
54
+ }
55
+
56
+ return ($szReturnString);
57
+ }
58
+
59
+ //constructor
60
+ public function __construct()
61
+ {
62
+ $this->m_lilListItemList = array();
63
+ }
64
+ }
65
+
66
+ class IRC_ListItem
67
+ {
68
+ private $m_szName;
69
+ private $m_szValue;
70
+ private $m_boIsSelected;
71
+
72
+ //public properties
73
+ public function getName()
74
+ {
75
+ return $this->m_szName;
76
+ }
77
+
78
+ public function getValue()
79
+ {
80
+ return $this->m_szValue;
81
+ }
82
+
83
+ public function getIsSelected()
84
+ {
85
+ return $this->m_boIsSelected;
86
+ }
87
+
88
+ //constructor
89
+ public function __construct($szName, $szValue, $boIsSelected)
90
+ {
91
+ $this->m_szName = $szName;
92
+ $this->m_szValue = $szValue;
93
+ $this->m_boIsSelected = $boIsSelected;
94
+ }
95
+ }
96
+
97
+ class IRC_PaymentFormHelper
98
+ {
99
+ /**
100
+ * Hash mechanism for hosted payment form trasaction
101
+ *
102
+ * @param unknown_type $szMerchantID
103
+ * @param unknown_type $szPassword
104
+ * @param unknown_type $hmHashMethod
105
+ * @param unknown_type $szPreSharedKey
106
+ * @param unknown_type $nAmount
107
+ * @param unknown_type $nCurrencyCode
108
+ * @param unknown_type $szOrderID
109
+ * @param unknown_type $szTransactionType
110
+ * @param unknown_type $szTransactionDateTime
111
+ * @param unknown_type $szCallbackURL
112
+ * @param unknown_type $szOrderDescription
113
+ * @param unknown_type $szCustomerName
114
+ * @param unknown_type $szAddress1
115
+ * @param unknown_type $szAddress2
116
+ * @param unknown_type $szAddress3
117
+ * @param unknown_type $szAddress4
118
+ * @param unknown_type $szCity
119
+ * @param unknown_type $szState
120
+ * @param unknown_type $szPostCode
121
+ * @param unknown_type $nCountryCode
122
+ * @param unknown_type $boCV2Mandatory
123
+ * @param unknown_type $boAddress1Mandatory
124
+ * @param unknown_type $boCityMandatory
125
+ * @param unknown_type $boPostCodeMandatory
126
+ * @param unknown_type $boStateMandatory
127
+ * @param unknown_type $boCountryMandatory
128
+ * @param unknown_type $rdmResultdeliveryMethod
129
+ * @param unknown_type $szServerResultURL
130
+ * @param unknown_type $boPaymentFormDisplaysResult
131
+ * @return unknown
132
+ */
133
+ public static function calculateHashDigest($szMerchantID, $szPassword, $hmHashMethod, $szPreSharedKey, $nAmount, $nCurrencyCode, $szOrderID, $szTransactionType, $szTransactionDateTime, $szCallbackURL, $szOrderDescription, $szCustomerName, $szAddress1, $szAddress2, $szAddress3, $szAddress4, $szCity, $szState, $szPostCode, $nCountryCode, $boCV2Mandatory, $boAddress1Mandatory, $boCityMandatory, $boPostCodeMandatory, $boStateMandatory, $boCountryMandatory, $rdmResultdeliveryMethod, $szServerResultURL, $boPaymentFormDisplaysResult)
134
+ {
135
+ $szHashDigest = '';
136
+ $szStringBeforeHash;
137
+
138
+ $szStringBeforeHash = 'MerchantID='.$szMerchantID.'&'.
139
+ 'Password='.$szPassword.'&'.
140
+ 'Amount='.$nAmount.'&'.
141
+ 'CurrencyCode='.$nCurrencyCode.'&'.
142
+ 'OrderID='.$szOrderID.'&'.
143
+ 'TransactionType='.$szTransactionType.'&'.
144
+ 'TransactionDateTime='.$szTransactionDateTime.'&'.
145
+ 'CallbackURL='.$szCallbackURL.'&'.
146
+ 'OrderDescription='.$szOrderDescription.'&'.
147
+ 'CustomerName='.$szCustomerName.'&'.
148
+ 'Address1='.$szAddress1.'&'.
149
+ 'Address2='.$szAddress2.'&'.
150
+ 'Address3='.$szAddress3.'&'.
151
+ 'Address4='.$szAddress4.'&'.
152
+ 'City='.$szCity.'&'.
153
+ 'State='.$szState.'&'.
154
+ 'PostCode='.$szPostCode.'&'.
155
+ 'CountryCode='.$nCountryCode.'&'.
156
+ 'CV2Mandatory='.$boCV2Mandatory.'&'.
157
+ 'Address1Mandatory='.$boAddress1Mandatory.'&'.
158
+ 'CityMandatory='.$boCityMandatory.'&'.
159
+ 'PostCodeMandatory='.$boPostCodeMandatory.'&'.
160
+ 'StateMandatory='.$boStateMandatory.'&'.
161
+ 'CountryMandatory='.$boCountryMandatory.'&'.
162
+ 'ResultDeliveryMethod='.$rdmResultdeliveryMethod.'&'.
163
+ 'ServerResultURL='.$szServerResultURL.'&'.
164
+ 'PaymentFormDisplaysResult='.$boPaymentFormDisplaysResult;
165
+
166
+ if ($hmHashMethod == Iridiumcorp_Tpg_Model_Source_HashMethod::HASH_METHOD_MD5 ||
167
+ $hmHashMethod == Iridiumcorp_Tpg_Model_Source_HashMethod::HASH_METHOD_SHA1)
168
+ {
169
+ $szStringBeforeHash = 'PreSharedKey='.$szPreSharedKey.'&'.$szStringBeforeHash;
170
+ }
171
+
172
+ $szHashDigest = self::_hashCalculator($hmHashMethod, $szPreSharedKey, $szStringBeforeHash);
173
+
174
+ return $szHashDigest;
175
+ }
176
+
177
+ /**
178
+ * Hash mechanism for transparent redirect trasaction
179
+ *
180
+ * @param unknown_type $szMerchantID
181
+ * @param unknown_type $szPassword
182
+ * @param unknown_type $hmHashMethod
183
+ * @param unknown_type $szPreSharedKey
184
+ * @param unknown_type $nAmount
185
+ * @param unknown_type $nCurrencyCode
186
+ * @param unknown_type $szOrderID
187
+ * @param unknown_type $szTransactionType
188
+ * @param unknown_type $szTransactionDateTime
189
+ * @param unknown_type $szCallbackURL
190
+ * @param unknown_type $szOrderDescription
191
+ * @return unknown
192
+ */
193
+ public static function calculateTransparentRedirectHashDigest($szMerchantID, $szPassword, $hmHashMethod, $szPreSharedKey, $nAmount, $nCurrencyCode, $szOrderID, $szTransactionType, $szTransactionDateTime, $szCallbackURL, $szOrderDescription)
194
+ {
195
+ $szHashDigest = '';
196
+ $szStringBeforeHash;
197
+
198
+ $szStringBeforeHash = 'MerchantID='.$szMerchantID.'&'.
199
+ 'Password='.$szPassword.'&'.
200
+ 'Amount='.$nAmount.'&'.
201
+ 'CurrencyCode='.$nCurrencyCode.'&'.
202
+ 'OrderID='.$szOrderID.'&'.
203
+ 'TransactionType='.$szTransactionType.'&'.
204
+ 'TransactionDateTime='.$szTransactionDateTime.'&'.
205
+ 'CallbackURL='.$szCallbackURL.'&'.
206
+ 'OrderDescription='.$szOrderDescription;
207
+
208
+ if ($hmHashMethod == Iridiumcorp_Tpg_Model_Source_HashMethod::HASH_METHOD_MD5 ||
209
+ $hmHashMethod == Iridiumcorp_Tpg_Model_Source_HashMethod::HASH_METHOD_SHA1)
210
+ {
211
+ $szStringBeforeHash = 'PreSharedKey='.$szPreSharedKey.'&'.$szStringBeforeHash;
212
+ }
213
+
214
+ $szHashDigest = self::_hashCalculator($hmHashMethod, $szPreSharedKey, $szStringBeforeHash);
215
+
216
+ return $szHashDigest;
217
+ }
218
+
219
+ /**
220
+ * Hash mechanism for calculating the hash digest for the post 3D Secure Authentication in the transparent redirect payment mode
221
+ *
222
+ * @param unknown_type $szMerchantID
223
+ * @param unknown_type $szPassword
224
+ * @param unknown_type $hmHashMethod
225
+ * @param unknown_type $szPreSharedKey
226
+ * @param unknown_type $szPaRES
227
+ * @param unknown_type $szCrossReference
228
+ * @param unknown_type $szTransactionDateTime
229
+ * @param unknown_type $szCallbackURL
230
+ * @return unknown
231
+ */
232
+ public static function calculatePostThreeDSecureAuthenticationHashDigest($szMerchantID, $szPassword, $hmHashMethod, $szPreSharedKey, $szPaRES, $szCrossReference, $szTransactionDateTime, $szCallbackURL)
233
+ {
234
+ $szHashDigest = '';
235
+ $szStringBeforeHash;
236
+
237
+ $szStringBeforeHash = 'MerchantID='.$szMerchantID.'&'.
238
+ 'Password='.$szPassword.'&'.
239
+ 'CrossReference='.$szCrossReference.'&'.
240
+ 'TransactionDateTime='.$szTransactionDateTime.'&'.
241
+ 'CallbackURL='.$szCallbackURL.'&'.
242
+ 'PaRES='.$szPaRES;
243
+
244
+
245
+ if ($hmHashMethod == Iridiumcorp_Tpg_Model_Source_HashMethod::HASH_METHOD_MD5 ||
246
+ $hmHashMethod == Iridiumcorp_Tpg_Model_Source_HashMethod::HASH_METHOD_SHA1)
247
+ {
248
+ $szStringBeforeHash = 'PreSharedKey='.$szPreSharedKey.'&'.$szStringBeforeHash;
249
+ }
250
+
251
+ $szHashDigest = self::_hashCalculator($hmHashMethod, $szPreSharedKey, $szStringBeforeHash);
252
+
253
+ return $szHashDigest;
254
+ }
255
+
256
+ /**
257
+ * Private hash calculator for hashing the raw string
258
+ *
259
+ * @param unknown_type $hmHashMethod
260
+ * @param unknown_type $szPreSharedKey
261
+ * @param unknown_type $szStringBeforeHash
262
+ * @return unknown
263
+ */
264
+ private static function _hashCalculator($hmHashMethod, $szPreSharedKey, $szStringBeforeHash)
265
+ {
266
+ $szHashDigest = '';
267
+
268
+ switch ($hmHashMethod)
269
+ {
270
+ case Iridiumcorp_Tpg_Model_Source_HashMethod::HASH_METHOD_MD5:
271
+ $szHashDigest = md5($szStringBeforeHash);
272
+ break;
273
+ case Iridiumcorp_Tpg_Model_Source_HashMethod::HASH_METHOD_SHA1:
274
+ $szHashDigest = sha1($szStringBeforeHash);
275
+ break;
276
+ case Iridiumcorp_Tpg_Model_Source_HashMethod::HASH_METHOD_HMACMD5:
277
+ $szHashDigest = hash_hmac('md5', $szStringBeforeHash, $szPreSharedKey);
278
+ break;
279
+ case Iridiumcorp_Tpg_Model_Source_HashMethod::HASH_METHOD_HMACSHA1:
280
+ $szHashDigest = hash_hmac('sha1', $szStringBeforeHash, $szPreSharedKey);
281
+ break;
282
+ default:
283
+ throw new Exception('Invalid hash method used for hash digest calculation: '.$hmHashMethod);
284
+ break;
285
+ }
286
+
287
+ $szHashDigest = strtoupper($szHashDigest);
288
+
289
+ return $szHashDigest;
290
+ }
291
+
292
+ /**
293
+ * Hash validator mechanism for hosted payment form transaction
294
+ *
295
+ * @param unknown_type $szHashDigest
296
+ * @param unknown_type $szMerchantID
297
+ * @param unknown_type $szStatusCode
298
+ * @param unknown_type $szMessage
299
+ * @param unknown_type $szPreviousStatusCode
300
+ * @param unknown_type $szPreviousMessage
301
+ * @param unknown_type $szCrossReference
302
+ * @param unknown_type $szAmount
303
+ * @param unknown_type $szCurrencyCode
304
+ * @param unknown_type $szOrderID
305
+ * @param unknown_type $szTransactionType
306
+ * @param unknown_type $szTransactionDateTime
307
+ * @param unknown_type $szOrderDescription
308
+ * @param unknown_type $szCustomerName
309
+ * @param unknown_type $szAddress1
310
+ * @param unknown_type $szAddress2
311
+ * @param unknown_type $szAddress3
312
+ * @param unknown_type $szAddress4
313
+ * @param unknown_type $szCity
314
+ * @param unknown_type $szState
315
+ * @param unknown_type $szPostCode
316
+ * @param unknown_type $szCountryCode
317
+ * @return unknown
318
+ */
319
+ public static function compareHostedPaymentFormHashDigest($formVariables, $szPassword, $hmHashMethod, $szPreSharedKey)
320
+ {
321
+ $boMatch = false;
322
+ $szCalculatedHashDigest;
323
+ $szStringBeforeHash;
324
+
325
+ $szStringBeforeHash = 'MerchantID='.$formVariables['MerchantID'].'&'.
326
+ 'Password='.$szPassword.'&'.
327
+ 'StatusCode='.$formVariables['StatusCode'].'&'.
328
+ 'Message='.$formVariables['Message'].'&'.
329
+ 'PreviousStatusCode='.$formVariables['PreviousStatusCode'].'&'.
330
+ 'PreviousMessage='.$formVariables['PreviousMessage'].'&'.
331
+ 'CrossReference='.$formVariables['CrossReference'].'&'.
332
+ 'Amount='.$formVariables['Amount'].'&'.
333
+ 'CurrencyCode='.$formVariables['CurrencyCode'].'&'.
334
+ 'OrderID='.$formVariables['OrderID'].'&'.
335
+ 'TransactionType='.$formVariables['TransactionType'].'&'.
336
+ 'TransactionDateTime='.$formVariables['TransactionDateTime'].'&'.
337
+ 'OrderDescription='.$formVariables['OrderDescription'].'&'.
338
+ 'CustomerName='.$formVariables['CustomerName'].'&'.
339
+ 'Address1='.$formVariables['Address1'].'&'.
340
+ 'Address2='.$formVariables['Address2'].'&'.
341
+ 'Address3='.$formVariables['Address3'].'&'.
342
+ 'Address4='.$formVariables['Address4'].'&'.
343
+ 'City='.$formVariables['City'].'&'.
344
+ 'State='.$formVariables['State'].'&'.
345
+ 'PostCode='.$formVariables['PostCode'].'&'.
346
+ 'CountryCode='.$formVariables['CountryCode'];
347
+
348
+ if ($hmHashMethod == Iridiumcorp_Tpg_Model_Source_HashMethod::HASH_METHOD_MD5 ||
349
+ $hmHashMethod == Iridiumcorp_Tpg_Model_Source_HashMethod::HASH_METHOD_SHA1)
350
+ {
351
+ $szStringBeforeHash = 'PreSharedKey='.$szPreSharedKey.'&'.$szStringBeforeHash;
352
+ }
353
+
354
+ $szCalculatedHashDigest = self::_hashCalculator($hmHashMethod, $szPreSharedKey, $szStringBeforeHash);
355
+ if($formVariables['HashDigest'] == $szCalculatedHashDigest)
356
+ {
357
+ $boMatch = true;
358
+ }
359
+
360
+ return $boMatch;
361
+ }
362
+
363
+ /**
364
+ * Hash validator mechanism for the incoming payment complete hash in transparent redirect payment mode
365
+ *
366
+ * @param unknown_type $formVariables
367
+ * @param unknown_type $szPassword
368
+ * @param unknown_type $hmHashMethod
369
+ * @param unknown_type $szPreSharedKey
370
+ * @return unknown
371
+ */
372
+ public static function comparePaymentCompleteHashDigest($formVariables, $szPassword, $hmHashMethod, $szPreSharedKey)
373
+ {
374
+ $boMatch = false;
375
+ $szCalculatedHashDigest;
376
+ $szStringBeforeHash;
377
+
378
+ $szStringBeforeHash = 'MerchantID='.$formVariables['MerchantID'].'&'.
379
+ 'Password='.$szPassword.'&'.
380
+ 'Amount='.$formVariables['Amount'].'&'.
381
+ 'CurrencyCode='.$formVariables['CurrencyCode'].'&'.
382
+ 'OrderID='.$formVariables['OrderID'].'&'.
383
+ 'TransactionType='.$formVariables['TransactionType'].'&'.
384
+ 'TransactionDateTime='.$formVariables['TransactionDateTime'].'&'.
385
+ 'OrderDescription='.$formVariables['OrderDescription'];
386
+
387
+ if ($hmHashMethod == Iridiumcorp_Tpg_Model_Source_HashMethod::HASH_METHOD_MD5 ||
388
+ $hmHashMethod == Iridiumcorp_Tpg_Model_Source_HashMethod::HASH_METHOD_SHA1)
389
+ {
390
+ $szStringBeforeHash = 'PreSharedKey='.$szPreSharedKey.'&'.$szStringBeforeHash;
391
+ }
392
+
393
+ $szCalculatedHashDigest = self::_hashCalculator($hmHashMethod, $szPreSharedKey, $szStringBeforeHash);
394
+ if($formVariables['HashDigest'] == $szCalculatedHashDigest)
395
+ {
396
+ $boMatch = true;
397
+ }
398
+
399
+ return $boMatch;
400
+ }
401
+
402
+ /**
403
+ * Hash validator mechanism for the 3D Secure Authentication required hash in the transparent redirect payment mode
404
+ *
405
+ * @param unknown_type $formVariables
406
+ * @param unknown_type $szPassword
407
+ * @param unknown_type $hmHashMethod
408
+ * @param unknown_type $szPreSharedKey
409
+ * @return unknown
410
+ */
411
+ public static function compareThreeDSecureAuthenticationRequiredHashDigest($formVariables, $szPassword, $hmHashMethod, $szPreSharedKey)
412
+ {
413
+ $boMatch = false;
414
+ $szCalculatedHashDigest;
415
+ $szStringBeforeHash;
416
+
417
+ $szStringBeforeHash = 'MerchantID='.$formVariables['MerchantID'].'&'.
418
+ 'Password='.$szPassword.'&'.
419
+ 'StatusCode='.$formVariables['StatusCode'].'&'.
420
+ 'Message='.$formVariables['Message'].'&'.
421
+ 'CrossReference='.$formVariables['CrossReference'].'&'.
422
+ 'OrderID='.$formVariables['OrderID'].'&'.
423
+ 'TransactionDateTime='.$formVariables['TransactionDateTime'].'&'.
424
+ 'ACSURL='.$formVariables['ACSURL'].'&'.
425
+ 'PaREQ='.$formVariables['PaREQ'];
426
+
427
+ if ($hmHashMethod == Iridiumcorp_Tpg_Model_Source_HashMethod::HASH_METHOD_MD5 ||
428
+ $hmHashMethod == Iridiumcorp_Tpg_Model_Source_HashMethod::HASH_METHOD_SHA1)
429
+ {
430
+ $szStringBeforeHash = 'PreSharedKey='.$szPreSharedKey.'&'.$szStringBeforeHash;
431
+ }
432
+
433
+ $szCalculatedHashDigest = self::_hashCalculator($hmHashMethod, $szPreSharedKey, $szStringBeforeHash);
434
+ if($formVariables['HashDigest'] == $szCalculatedHashDigest)
435
+ {
436
+ $boMatch = true;
437
+ }
438
+
439
+ return $boMatch;
440
+ }
441
+
442
+
443
+ }
444
+ ?>
app/code/local/Iridiumcorp/Tpg/Model/Tpg/ThePaymentGateway/PaymentSystem.php ADDED
@@ -0,0 +1,2398 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once('TPG_Common.php');
3
+ require_once('SOAP.php');
4
+
5
+ /*****************/
6
+ /* Input classes */
7
+ /*****************/
8
+ class IRC_RequestGatewayEntryPoint extends IRC_GatewayEntryPoint
9
+ {
10
+ private $m_nRetryAttempts;
11
+
12
+ public function getRetryAttempts()
13
+ {
14
+ return $this->m_nRetryAttempts;
15
+ }
16
+
17
+ //constructor
18
+ public function __construct($szEntryPointURL, $nMetric, $nRetryAttempts)
19
+ {
20
+ //do NOT forget to call the parent constructor too
21
+ //parent::GatewayEntryPoint($szEntryPointURL, $nMetric);
22
+ IRC_GatewayEntryPoint::__construct($szEntryPointURL, $nMetric);
23
+
24
+ $this->m_nRetryAttempts = $nRetryAttempts;
25
+ }
26
+ }
27
+
28
+ class IRC_RequestGatewayEntryPointList
29
+ {
30
+ private $m_lrgepRequestGatewayEntryPoint;
31
+
32
+ public function getAt($nIndex)
33
+ {
34
+ if ($nIndex < 0 ||
35
+ $nIndex >= count($this->m_lrgepRequestGatewayEntryPoint))
36
+ {
37
+ throw new Exception("Array index out of bounds");
38
+ }
39
+
40
+ return $this->m_lrgepRequestGatewayEntryPoint[$nIndex];
41
+ }
42
+
43
+ public function getCount()
44
+ {
45
+ return count($this->m_lrgepRequestGatewayEntryPoint);
46
+ }
47
+
48
+ public function sort($ComparerClassName, $ComparerMethodName)
49
+ {
50
+ usort($this->m_lrgepRequestGatewayEntryPoint, array("$ComparerClassName","$ComparerMethodName"));
51
+ }
52
+
53
+ public function add($EntryPointURL, $nMetric, $nRetryAttempts)
54
+ {
55
+ return array_push($this->m_lrgepRequestGatewayEntryPoint, new IRC_RequestGatewayEntryPoint($EntryPointURL, $nMetric, $nRetryAttempts));
56
+ }
57
+
58
+ //constructor
59
+ public function __construct()
60
+ {
61
+ $this->m_lrgepRequestGatewayEntryPoint = array();
62
+ }
63
+ }
64
+
65
+ class IRC_GenericVariable
66
+ {
67
+ private $m_szName;
68
+ private $m_szValue;
69
+
70
+ public function getName()
71
+ {
72
+ return $this->m_szName;
73
+ }
74
+ public function getValue()
75
+ {
76
+ return $this->m_szValue;
77
+ }
78
+
79
+ //constructor
80
+ public function __construct($szName, $szValue)
81
+ {
82
+ $this->m_szName = $szName;
83
+ $this->m_szValue = $szValue;
84
+ }
85
+ }
86
+
87
+ class IRC_GenericVariableList
88
+ {
89
+ private $m_lgvGenericVariableList;
90
+
91
+ public function getAt($intOrStringValue)
92
+ {
93
+ $nCount = 0;
94
+ $boFound = false;
95
+ $gvGenericVariable = null;
96
+
97
+ if (is_int($intOrStringValue))
98
+ {
99
+ if ($intOrStringValue < 0 ||
100
+ $intOrStringValue >= count($this->m_lgvGenericVariableList))
101
+ {
102
+ throw new Exception("Array index out of bounds");
103
+ }
104
+
105
+ return $this->m_lgvGenericVariableList[$intOrStringValue];
106
+ }
107
+ elseif (is_string($intOrStringValue))
108
+ {
109
+ if ($intOrStringValue == null ||
110
+ $intOrStringValue == '')
111
+ {
112
+ return (null);
113
+ }
114
+
115
+ while (!$boFound &&
116
+ $nCount < count($this->m_lgvGenericVariableList))
117
+ {
118
+ if (strtoupper($this->m_lgvGenericVariableList[$nCount]->getName()) ==
119
+ strtoupper($intOrStringValue))
120
+ {
121
+ $gvGenericVariable = $this->m_lgvGenericVariableList[$nCount];
122
+ $boFound = true;
123
+ }
124
+ $nCount++;
125
+ }
126
+
127
+ return $gvGenericVariable;
128
+ }
129
+ else
130
+ {
131
+ throw new Exception('Invalid parameter type:$intOrStringValue');
132
+ }
133
+ }
134
+
135
+ public function getCount()
136
+ {
137
+ return count($this->m_lgvGenericVariableList);
138
+ }
139
+
140
+ public function add($Name, $szValue)
141
+ {
142
+ $nReturnValue = -1;
143
+
144
+ if ($Name != null &&
145
+ $Name != "")
146
+ {
147
+ $nReturnValue = array_push($this->m_lgvGenericVariableList, new IRC_GenericVariable($Name, $szValue));
148
+ }
149
+
150
+ return ($nReturnValue);
151
+ }
152
+
153
+ //constructor
154
+ public function __construct()
155
+ {
156
+ $this->m_lgvGenericVariableList = array();
157
+ }
158
+ }
159
+
160
+ class IRC_CustomerDetails
161
+ {
162
+ private $m_adBillingAddress;
163
+ private $m_szEmailAddress;
164
+ private $m_szPhoneNumber;
165
+ private $m_szCustomerIPAddress;
166
+
167
+ public function getBillingAddress()
168
+ {
169
+ return $this->m_adBillingAddress;
170
+ }
171
+ public function getEmailAddress()
172
+ {
173
+ return $this->m_szEmailAddress;
174
+ }
175
+ public function getPhoneNumber()
176
+ {
177
+ return $this->m_szPhoneNumber;
178
+ }
179
+ public function getCustomerIPAddress()
180
+ {
181
+ return $this->m_szCustomerIPAddress;
182
+ }
183
+
184
+ //constructor
185
+ public function __construct($adBillingAddress = null, $szEmailAddress, $szPhoneNumber, $szCustomerIPAddress)
186
+ {
187
+ $this->m_adBillingAddress = $adBillingAddress;
188
+ $this->m_szEmailAddress = $szEmailAddress;
189
+ $this->m_szPhoneNumber = $szPhoneNumber;
190
+ $this->m_szCustomerIPAddress = $szCustomerIPAddress;
191
+ }
192
+ }
193
+
194
+ class IRC_AddressDetails
195
+ {
196
+ private $m_szAddress1;
197
+ private $m_szAddress2;
198
+ private $m_szAddress3;
199
+ private $m_szAddress4;
200
+ private $m_szCity;
201
+ private $m_szState;
202
+ private $m_szPostCode;
203
+ private $m_nCountryCode;
204
+
205
+ public function getAddress1()
206
+ {
207
+ return $this->m_szAddress1;
208
+ }
209
+ public function getAddress2()
210
+ {
211
+ return $this->m_szAddress2;
212
+ }
213
+ public function getAddress3()
214
+ {
215
+ return $this->m_szAddress3;
216
+ }
217
+ public function getAddress4()
218
+ {
219
+ return $this->m_szAddress4;
220
+ }
221
+ public function getCity()
222
+ {
223
+ return $this->m_szCity;
224
+ }
225
+ public function getState()
226
+ {
227
+ return $this->m_szState;
228
+ }
229
+ public function getPostCode()
230
+ {
231
+ return $this->m_szPostCode;
232
+ }
233
+ public function getCountryCode()
234
+ {
235
+ return $this->m_nCountryCode;
236
+ }
237
+
238
+ //constructor
239
+ public function __construct($szAddress1, $szAddress2, $szAddress3, $szAddress4, $szCity, $szState, $szPostCode, IRC_NullableInt $nCountryCode = null)
240
+ {
241
+ $this->m_szAddress1 = $szAddress1;
242
+ $this->m_szAddress2 = $szAddress2;
243
+ $this->m_szAddress3 = $szAddress3;
244
+ $this->m_szAddress4 = $szAddress4;
245
+ $this->m_szCity = $szCity;
246
+ $this->m_szState = $szState;
247
+ $this->m_szPostCode = $szPostCode;
248
+ $this->m_nCountryCode = $nCountryCode;
249
+ }
250
+ }
251
+
252
+ abstract class IRC_CreditCardDate
253
+ {
254
+ private $m_nMonth;
255
+ private $m_nYear;
256
+
257
+ public function getMonth()
258
+ {
259
+ return $this->m_nMonth;
260
+ }
261
+ public function getYear()
262
+ {
263
+ return $this->m_nYear;
264
+ }
265
+
266
+ //constructor
267
+ public function __construct(IRC_NullableInt $nMonth = null, IRC_NullableInt $nYear = null)
268
+ {
269
+ $this->m_nMonth = $nMonth;
270
+ $this->m_nYear = $nYear;
271
+ }
272
+ }
273
+
274
+ class IRC_ExpiryDate extends IRC_CreditCardDate
275
+ {
276
+ public function __construct(IRC_NullableInt $nMonth = null, IRC_NullableInt $nYear = null)
277
+ {
278
+ parent::__construct($nMonth, $nYear);
279
+ }
280
+ }
281
+
282
+ class IRC_StartDate extends IRC_CreditCardDate
283
+ {
284
+ public function __construct(IRC_NullableInt $nMonth = null, IRC_NullableInt $nYear = null)
285
+ {
286
+ parent::__construct($nMonth, $nYear);
287
+ }
288
+ }
289
+
290
+ class IRC_CardDetails
291
+ {
292
+ private $m_szCardName;
293
+ private $m_szCardNumber;
294
+ private $m_edExpiryDate;
295
+ private $m_sdStartDate;
296
+ private $m_szIssueNumber;
297
+ private $m_szCV2;
298
+
299
+ public function getCardName()
300
+ {
301
+ return $this->m_szCardName;
302
+ }
303
+ public function getCardNumber()
304
+ {
305
+ return $this->m_szCardNumber;
306
+ }
307
+
308
+ public function getExpiryDate()
309
+ {
310
+ return $this->m_edExpiryDate;
311
+ }
312
+
313
+ public function getStartDate()
314
+ {
315
+ return $this->m_sdStartDate;
316
+ }
317
+
318
+ public function getIssueNumber()
319
+ {
320
+ return $this->m_szIssueNumber;
321
+ }
322
+
323
+ public function getCV2()
324
+ {
325
+ return $this->m_szCV2;
326
+ }
327
+
328
+ //constructor
329
+ public function __construct($szCardName, $szCardNumber, IRC_ExpiryDate $edExpiryDate = null, IRC_StartDate $sdStartDate = null, $IssueNumber, $CV2)
330
+ {
331
+ $this->m_szCardName = $szCardName;
332
+ $this->m_szCardNumber = $szCardNumber;
333
+ $this->m_edExpiryDate = $edExpiryDate;
334
+ $this->m_sdStartDate = $sdStartDate;
335
+ $this->m_szIssueNumber = $IssueNumber;
336
+ $this->m_szCV2 = $CV2;
337
+ }
338
+ }
339
+
340
+ class IRC_OverrideCardDetails extends IRC_CardDetails
341
+ {
342
+ public function __construct($szCardName, $szCardNumber, IRC_ExpiryDate $edExpiryDate = null, IRC_StartDate $sdStartDate = null, $IssueNumber, $CV2)
343
+ {
344
+ parent::__construct($szCardName, $szCardNumber, $edExpiryDate, $sdStartDate, $IssueNumber, $CV2);
345
+ }
346
+ }
347
+
348
+ class IRC_MerchantAuthentication
349
+ {
350
+ private $m_szMerchantID;
351
+ private $m_szPassword;
352
+
353
+ public function getMerchantID()
354
+ {
355
+ return $this->m_szMerchantID;
356
+ }
357
+ public function getPassword()
358
+ {
359
+ return $this->m_szPassword;
360
+ }
361
+
362
+ //constructor
363
+ public function __construct($szMerchantID, $szPassword)
364
+ {
365
+ $this->m_szMerchantID = $szMerchantID;
366
+ $this->m_szPassword = $szPassword;
367
+ }
368
+ }
369
+
370
+ class IRC_MessageDetails
371
+ {
372
+ private $m_szTransactionType;
373
+ private $m_boNewTransaction;
374
+ private $m_szCrossReference;
375
+
376
+ public function getTransactionType()
377
+ {
378
+ return $this->m_szTransactionType;
379
+ }
380
+ public function getNewTransaction()
381
+ {
382
+ return $this->m_boNewTransaction;
383
+ }
384
+ public function getCrossReference()
385
+ {
386
+ return $this->m_szCrossReference;
387
+ }
388
+
389
+ //constructor
390
+ public function __construct($szTransactionType, $szCrossReference = null, IRC_NullableBool $boNewTransaction = null)
391
+ {
392
+ $this->m_szTransactionType = $szTransactionType;
393
+
394
+ if ($szCrossReference != null)
395
+ {
396
+ $this->m_szCrossReference = $szCrossReference;
397
+ }
398
+ if ($boNewTransaction != null)
399
+ {
400
+ $this->m_boNewTransaction = $boNewTransaction;
401
+ }
402
+ }
403
+ }
404
+
405
+ class IRC_TransactionDetails
406
+ {
407
+ private $m_mdMessageDetails;
408
+ private $m_nAmount;
409
+ private $m_nCurrencyCode;
410
+ private $m_szOrderID;
411
+ private $m_szOrderDescription;
412
+ private $m_tcTransactionControl;
413
+ private $m_tdsbdThreeDSecureBrowserDetails;
414
+
415
+ public function getMessageDetails()
416
+ {
417
+ return $this->m_mdMessageDetails;
418
+ }
419
+ public function getAmount()
420
+ {
421
+ return $this->m_nAmount;
422
+ }
423
+ public function getCurrencyCode()
424
+ {
425
+ return $this->m_nCurrencyCode;
426
+ }
427
+ public function getOrderID()
428
+ {
429
+ return $this->m_szOrderID;
430
+ }
431
+ public function getOrderDescription()
432
+ {
433
+ return $this->m_szOrderDescription;
434
+ }
435
+ public function getTransactionControl()
436
+ {
437
+ return $this->m_tcTransactionControl;
438
+ }
439
+ public function getThreeDSecureBrowserDetails()
440
+ {
441
+ return $this->m_tdsbdThreeDSecureBrowserDetails;
442
+ }
443
+
444
+ //constructor
445
+ public function __construct($TransactionTypeOrMessageDetails, IRC_NullableInt $nAmount = null, IRC_NullableInt $nCurrencyCode = null, $szOrderID, $szOrderDescription, IRC_TransactionControl $tcTransactionControl = null, IRC_ThreeDSecureBrowserDetails $tdsbdThreeDSecureBrowserDetails = null)
446
+ {
447
+ if ($TransactionTypeOrMessageDetails instanceof IRC_MessageDetails)
448
+ {
449
+ $this->m_mdMessageDetails = $TransactionTypeOrMessageDetails;
450
+ $this->m_nAmount = $nAmount;
451
+ $this->m_nCurrencyCode = $nCurrencyCode;
452
+ $this->m_szOrderID = $szOrderID;
453
+ $this->m_szOrderDescription = $szOrderDescription;
454
+ $this->m_tcTransactionControl = $tcTransactionControl;
455
+ $this->m_tdsbdThreeDSecureBrowserDetails = $tdsbdThreeDSecureBrowserDetails;
456
+ }
457
+ else
458
+ {
459
+ $this->__construct(new IRC_MessageDetails($TransactionTypeOrMessageDetails), $nAmount, $nCurrencyCode, $szOrderID, $szOrderDescription, $tcTransactionControl, $tdsbdThreeDSecureBrowserDetails);
460
+ }
461
+ }
462
+ }
463
+
464
+ class IRC_ThreeDSecureBrowserDetails
465
+ {
466
+ private $m_nDeviceCategory;
467
+ private $m_szAcceptHeaders;
468
+ private $m_szUserAgent;
469
+
470
+ public function getDeviceCategory()
471
+ {
472
+ return $this->m_nDeviceCategory;
473
+ }
474
+
475
+ public function getAcceptHeaders()
476
+ {
477
+ return $this->m_szAcceptHeaders;
478
+ }
479
+
480
+ public function getUserAgent()
481
+ {
482
+ return $this->m_szUserAgent;
483
+ }
484
+
485
+ //constructor
486
+ public function __construct(IRC_NullableInt $nDeviceCategory = null, $szAcceptHeaders, $szUserAgent)
487
+ {
488
+ $this->m_nDeviceCategory = $nDeviceCategory;
489
+ $this->m_szAcceptHeaders = $szAcceptHeaders;
490
+ $this->m_szUserAgent = $szUserAgent;
491
+ }
492
+ }
493
+
494
+ class IRC_TransactionControl
495
+ {
496
+ private $m_boEchoCardType;
497
+ private $m_boEchoAVSCheckResult;
498
+ private $m_boEchoCV2CheckResult;
499
+ private $m_boEchoAmountReceived;
500
+ private $m_nDuplicateDelay;
501
+ private $m_szAVSOverridePolicy;
502
+ private $m_szCV2OverridePolicy;
503
+ private $m_boThreeDSecureOverridePolicy;
504
+ private $m_szAuthCode;
505
+ private $m_tdsptThreeDSecurePassthroughData;
506
+ private $m_lgvCustomVariables;
507
+
508
+ public function getEchoCardType()
509
+ {
510
+ return $this->m_boEchoCardType;
511
+ }
512
+
513
+ public function getEchoAVSCheckResult()
514
+ {
515
+ return $this->m_boEchoAVSCheckResult;
516
+ }
517
+
518
+ public function getEchoCV2CheckResult()
519
+ {
520
+ return $this->m_boEchoCV2CheckResult;
521
+ }
522
+
523
+ public function getEchoAmountReceived()
524
+ {
525
+ return $this->m_boEchoAmountReceived;
526
+ }
527
+
528
+ public function getDuplicateDelay()
529
+ {
530
+ return $this->m_nDuplicateDelay;
531
+ }
532
+
533
+ public function getAVSOverridePolicy()
534
+ {
535
+ return $this->m_szAVSOverridePolicy;
536
+ }
537
+
538
+ public function getCV2OverridePolicy()
539
+ {
540
+ return $this->m_szCV2OverridePolicy;
541
+ }
542
+
543
+ public function getThreeDSecureOverridePolicy()
544
+ {
545
+ return $this->m_boThreeDSecureOverridePolicy;
546
+ }
547
+
548
+ public function getAuthCode()
549
+ {
550
+ return $this->m_szAuthCode;
551
+ }
552
+
553
+ function getThreeDSecurePassthroughData()
554
+ {
555
+ return $this->m_tdsptThreeDSecurePassthroughData;
556
+ }
557
+
558
+ public function getCustomVariables()
559
+ {
560
+ return $this->m_lgvCustomVariables;
561
+ }
562
+
563
+ //constructor
564
+ public function __construct(IRC_NullableBool $boEchoCardType = null, IRC_NullableBool $boEchoAVSCheckResult = null, IRC_NullableBool $boEchoCV2CheckResult = null, IRC_NullableBool $boEchoAmountReceived = null, IRC_NullableInt $nDuplicateDelay = null, $szAVSOverridePolicy, $szCV2OverridePolicy, IRC_NullableBool $boThreeDSecureOverridePolicy = null, $szAuthCode, IRC_ThreeDSecurePassthroughData $tdsptThreeDSecurePassthroughData = null, IRC_GenericVariableList $lgvCustomVariables = null)
565
+ {
566
+ $this->m_boEchoCardType = $boEchoCardType;
567
+ $this->m_boEchoAVSCheckResult = $boEchoAVSCheckResult;
568
+ $this->m_boEchoCV2CheckResult = $boEchoCV2CheckResult;
569
+ $this->m_boEchoAmountReceived = $boEchoAmountReceived;
570
+ $this->m_nDuplicateDelay = $nDuplicateDelay;
571
+ $this->m_szAVSOverridePolicy = $szAVSOverridePolicy;
572
+ $this->m_szCV2OverridePolicy = $szCV2OverridePolicy;
573
+ $this->m_boThreeDSecureOverridePolicy = $boThreeDSecureOverridePolicy;
574
+ $this->m_szAuthCode = $szAuthCode;
575
+ $this->m_tdsptThreeDSecurePassthroughData = $tdsptThreeDSecurePassthroughData;
576
+ $this->m_lgvCustomVariables = $lgvCustomVariables;
577
+ }
578
+ }
579
+
580
+ class IRC_ThreeDSecureInputData
581
+ {
582
+ private $m_szCrossReference;
583
+ private $m_szPaRES;
584
+
585
+ public function getCrossReference()
586
+ {
587
+ return $this->m_szCrossReference;
588
+ }
589
+
590
+ public function getPaRES()
591
+ {
592
+ return $this->m_szPaRES;
593
+ }
594
+
595
+ //constructor
596
+ public function __construct($szCrossReference, $szPaRES)
597
+ {
598
+ $this->m_szCrossReference = $szCrossReference;
599
+ $this->m_szPaRES = $szPaRES;
600
+ }
601
+ }
602
+
603
+ class IRC_ThreeDSecurePassthroughData
604
+ {
605
+ private $m_szEnrolmentStatus;
606
+ private $m_szAuthenticationStatus;
607
+ private $m_szElectronicCommerceIndicator;
608
+ private $m_szAuthenticationValue;
609
+ private $m_szTransactionIdentifier;
610
+
611
+ function getEnrolmentStatus()
612
+ {
613
+ return $this->m_szEnrolmentStatus;
614
+ }
615
+
616
+ function getAuthenticationStatus()
617
+ {
618
+ return $this->m_szAuthenticationStatus;
619
+ }
620
+
621
+ function getElectronicCommerceIndicator()
622
+ {
623
+ return $this->m_szElectronicCommerceIndicator;
624
+ }
625
+
626
+ function getAuthenticationValue()
627
+ {
628
+ return $this->m_szAuthenticationValue;
629
+ }
630
+
631
+ function getTransactionIdentifier()
632
+ {
633
+ return $this->m_szTransactionIdentifier;
634
+ }
635
+
636
+ //constructor
637
+ function __construct($szEnrolmentStatus,
638
+ $szAuthenticationStatus,
639
+ $szElectronicCommerceIndicator,
640
+ $szAuthenticationValue,
641
+ $szTransactionIdentifier)
642
+ {
643
+ $this->m_szEnrolmentStatus = $szEnrolmentStatus;
644
+ $this->m_szAuthenticationStatus = $szAuthenticationStatus;
645
+ $this->m_szElectronicCommerceIndicator = $szElectronicCommerceIndicator;
646
+ $this->m_szAuthenticationValue = $szAuthenticationValue;
647
+ $this->m_szTransactionIdentifier = $szTransactionIdentifier;
648
+ }
649
+ }
650
+
651
+
652
+ /******************/
653
+ /* Output classes */
654
+ /******************/
655
+ class IRC_Issuer
656
+ {
657
+ private $m_szIssuer;
658
+ private $m_nISOCode;
659
+
660
+ public function getValue()
661
+ {
662
+ return $this->m_szIssuer;
663
+ }
664
+
665
+ public function getISOCode()
666
+ {
667
+ return $this->m_nISOCode;
668
+ }
669
+
670
+ //constructor
671
+ public function __construct($szIssuer, $nISOCode)
672
+ {
673
+ $this->m_szIssuer = $szIssuer;
674
+ $this->m_nISOCode = $nISOCode;
675
+ }
676
+ }
677
+
678
+ class IRC_CardTypeData
679
+ {
680
+ private $m_szCardType;
681
+ private $m_iIssuer;
682
+ private $m_boLuhnCheckRequired;
683
+ private $m_szIssueNumberStatus;
684
+ private $m_szStartDateStatus;
685
+
686
+ public function getCardType()
687
+ {
688
+ return $this->m_szCardType;
689
+ }
690
+
691
+ public function getIssuer()
692
+ {
693
+ return $this->m_iIssuer;
694
+ }
695
+
696
+ public function getLuhnCheckRequired()
697
+ {
698
+ return $this->m_boLuhnCheckRequired;
699
+ }
700
+
701
+ public function getIssueNumberStatus()
702
+ {
703
+ return $this->m_szIssueNumberStatus;
704
+ }
705
+
706
+ public function getStartDateStatus()
707
+ {
708
+ return $this->m_szStartDateStatus;
709
+ }
710
+
711
+ //constructor
712
+ public function __construct($szCardType, $iIssuer, IRC_NullableBool $boLuhnCheckRequired = null, $szIssueNumberStatus, $szStartDateStatus)
713
+ {
714
+ $this->m_szCardType = $szCardType;
715
+ //$this->m_szIssuer = $szIssuer;
716
+ $this->m_iIssuer = $iIssuer;
717
+ $this->m_boLuhnCheckRequired = $boLuhnCheckRequired;
718
+ $this->m_szIssueNumberStatus = $szIssueNumberStatus;
719
+ $this->m_szStartDateStatus = $szStartDateStatus;
720
+ }
721
+ }
722
+
723
+ class IRC_GatewayEntryPoint
724
+ {
725
+ private $m_szEntryPointURL;
726
+ private $m_nMetric;
727
+
728
+ public function getEntryPointURL()
729
+ {
730
+ return $this->m_szEntryPointURL;
731
+ }
732
+
733
+ public function getMetric()
734
+ {
735
+ return $this->m_nMetric;
736
+ }
737
+
738
+ //constructor
739
+ public function __construct($szEntryPointURL, $nMetric)
740
+ {
741
+ $this->m_szEntryPointURL = $szEntryPointURL;
742
+ $this->m_nMetric = $nMetric;
743
+ }
744
+ }
745
+
746
+ class IRC_GatewayEntryPointList
747
+ {
748
+ private $m_lgepGatewayEntryPoint;
749
+
750
+ public function getAt($nIndex)
751
+ {
752
+ if ($nIndex < 0 ||
753
+ $nIndex >= count($this->m_lgepGatewayEntryPoint))
754
+ {
755
+ throw new Exception("Array index out of bounds");
756
+ }
757
+
758
+ return $this->m_lgepGatewayEntryPoint[$nIndex];
759
+ }
760
+
761
+ public function getCount()
762
+ {
763
+ return count($this->m_lgepGatewayEntryPoint);
764
+ }
765
+
766
+ public function add($GatewayEntrypointOrEntrypointURL, $nMetric)
767
+ {
768
+ return array_push($this->m_lgepGatewayEntryPoint, new IRC_GatewayEntryPoint($GatewayEntrypointOrEntrypointURL, $nMetric));
769
+ }
770
+
771
+ //constructor
772
+ public function __construct()
773
+ {
774
+ $this->m_lgepGatewayEntryPoint = array();
775
+ }
776
+ }
777
+
778
+ class IRC_PreviousTransactionResult
779
+ {
780
+ private $m_nStatusCode;
781
+ private $m_szMessage;
782
+
783
+ function getStatusCode()
784
+ {
785
+ return $this->m_nStatusCode;
786
+ }
787
+
788
+ function getMessage()
789
+ {
790
+ return $this->m_szMessage;
791
+ }
792
+
793
+ function __construct(IRC_NullableInt $nStatusCode = null,
794
+ $szMessage)
795
+ {
796
+ $this->m_nStatusCode = $nStatusCode;
797
+ $this->m_szMessage = $szMessage;
798
+ }
799
+ }
800
+
801
+ class IRC_GatewayOutput
802
+ {
803
+ private $m_nStatusCode;
804
+ private $m_szMessage;
805
+ private $m_szPassOutData;
806
+ //private $m_ptdPreviousTransactionResult;
807
+ //private $m_boAuthorisationAttempted;
808
+ private $m_lszErrorMessages;
809
+
810
+ public function getStatusCode()
811
+ {
812
+ return $this->m_nStatusCode;
813
+ }
814
+
815
+ public function getMessage()
816
+ {
817
+ return $this->m_szMessage;
818
+ }
819
+
820
+ public function getPassOutData()
821
+ {
822
+ return $this->m_szPassOutData;
823
+ }
824
+
825
+ public function getErrorMessages()
826
+ {
827
+ return $this->m_lszErrorMessages;
828
+ }
829
+
830
+ //constructor
831
+ public function __construct($nStatusCode, $szMessage, $szPassOutData, IRC_StringList $lszErrorMessages = null)
832
+ {
833
+ $this->m_nStatusCode = $nStatusCode;
834
+ $this->m_szMessage = $szMessage;
835
+ $this->m_szPassOutData = $szPassOutData;
836
+ $this->m_lszErrorMessages = $lszErrorMessages;
837
+ }
838
+ }
839
+
840
+ class IRC_PaymentMessageGatewayOutput extends IRC_GatewayOutput
841
+ {
842
+ private $m_ptdPreviousTransactionResult;
843
+ private $m_boAuthorisationAttempted;
844
+
845
+ public function getPreviousTransactionResult()
846
+ {
847
+ return $this->m_ptdPreviousTransactionResult;
848
+ }
849
+
850
+ public function getAuthorisationAttempted()
851
+ {
852
+ return $this->m_boAuthorisationAttempted;
853
+ }
854
+ //constructor
855
+ public function __construct($nStatusCode, $szMessage, $szPassOutData, IRC_NullableBool $boAuthorisationAttempted = null, IRC_PreviousTransactionResult $ptdPreviousTransactionResult = null, IRC_StringList $lszErrorMessages = null)
856
+ {
857
+ parent::__construct($nStatusCode, $szMessage, $szPassOutData, $lszErrorMessages);
858
+ $this->m_boAuthorisationAttempted = $boAuthorisationAttempted;
859
+ $this->m_ptdPreviousTransactionResult = $ptdPreviousTransactionResult;
860
+ }
861
+ }
862
+
863
+ class IRC_CardDetailsTransactionResult extends IRC_PaymentMessageGatewayOutput
864
+ {
865
+ public function __construct($nStatusCode, $szMessage, $szPassOutData, IRC_NullableBool $boAuthorisationAttempted = null, IRC_PreviousTransactionResult $ptdPreviousTransactionResult = null, IRC_StringList $lszErrorMessages = null)
866
+ {
867
+ parent::__construct($nStatusCode, $szMessage, $szPassOutData, $boAuthorisationAttempted, $ptdPreviousTransactionResult, $lszErrorMessages);
868
+ }
869
+ }
870
+ class IRC_CrossReferenceTransactionResult extends IRC_PaymentMessageGatewayOutput
871
+ {
872
+ public function __construct($nStatusCode, $szMessage, $szPassOutData, IRC_NullableBool $boAuthorisationAttempted = null, IRC_PreviousTransactionResult $ptdPreviousTransactionResult = null, IRC_StringList $lszErrorMessages = null)
873
+ {
874
+ parent::__construct($nStatusCode, $szMessage, $szPassOutData, $boAuthorisationAttempted, $ptdPreviousTransactionResult, $lszErrorMessages);
875
+ }
876
+ }
877
+ class IRC_ThreeDSecureTransactionResult extends IRC_PaymentMessageGatewayOutput
878
+ {
879
+ public function __construct($nStatusCode, $szMessage, $szPassOutData, IRC_NullableBool $boAuthorisationAttempted = null, IRC_PreviousTransactionResult $ptdPreviousTransactionResult = null, IRC_StringList $lszErrorMessages = null)
880
+ {
881
+ parent::__construct($nStatusCode, $szMessage, $szPassOutData, $boAuthorisationAttempted, $ptdPreviousTransactionResult, $lszErrorMessages);
882
+ }
883
+ }
884
+ class IRC_GetGatewayEntryPointsResult extends IRC_GatewayOutput
885
+ {
886
+ public function __construct($nStatusCode, $szMessage, $szPassOutData, IRC_StringList $lszErrorMessages = null)
887
+ {
888
+ parent::__construct($nStatusCode, $szMessage, $szPassOutData, $lszErrorMessages);
889
+ }
890
+ }
891
+ class IRC_GetCardTypeResult extends IRC_GatewayOutput
892
+ {
893
+ public function __construct($nStatusCode, $szMessage, $szPassOutData, IRC_StringList $lszErrorMessages = null)
894
+ {
895
+ parent::__construct($nStatusCode, $szMessage, $szPassOutData, $lszErrorMessages);
896
+ }
897
+ }
898
+
899
+ class IRC_ThreeDSecureOutputData
900
+ {
901
+ private $m_szPaREQ;
902
+ private $m_szACSURL;
903
+
904
+ public function getPaREQ()
905
+ {
906
+ return $this->m_szPaREQ;
907
+ }
908
+
909
+ public function getACSURL()
910
+ {
911
+ return ($this->m_szACSURL);
912
+ }
913
+
914
+ //constructor
915
+ public function __construct($szPaREQ, $szACSURL)
916
+ {
917
+ $this->m_szPaREQ = $szPaREQ;
918
+ $this->m_szACSURL = $szACSURL;
919
+ }
920
+ }
921
+
922
+ class IRC_GetGatewayEntryPointsOutputData extends IRC_BaseOutputData
923
+ {
924
+ //constructor
925
+ function __construct(IRC_GatewayEntryPointList $lgepGatewayEntryPoints = null)
926
+ {
927
+ parent::__construct($lgepGatewayEntryPoints);
928
+ }
929
+ }
930
+
931
+ class IRC_TransactionOutputData extends IRC_BaseOutputData
932
+ {
933
+ private $m_szCrossReference;
934
+ private $m_szAuthCode;
935
+ private $m_szAddressNumericCheckResult;
936
+ private $m_szPostCodeCheckResult;
937
+ private $m_szThreeDSecureAuthenticationCheckResult;
938
+ private $m_szCV2CheckResult;
939
+ private $m_ctdCardTypeData;
940
+ private $m_nAmountReceived;
941
+ private $m_tdsodThreeDSecureOutputData;
942
+ private $m_lgvCustomVariables;
943
+
944
+ public function getCrossReference()
945
+ {
946
+ return $this->m_szCrossReference;
947
+ }
948
+
949
+ public function getAuthCode()
950
+ {
951
+ return $this->m_szAuthCode;
952
+ }
953
+
954
+ public function getAddressNumericCheckResult()
955
+ {
956
+ return $this->m_szAddressNumericCheckResult;
957
+ }
958
+
959
+ public function getPostCodeCheckResult()
960
+ {
961
+ return $this->m_szPostCodeCheckResult;
962
+ }
963
+
964
+ public function getThreeDSecureAuthenticationCheckResult()
965
+ {
966
+ return $this->m_szThreeDSecureAuthenticationCheckResult;
967
+ }
968
+
969
+ public function getCV2CheckResult()
970
+ {
971
+ return $this->m_szCV2CheckResult;
972
+ }
973
+
974
+ public function getCardTypeData()
975
+ {
976
+ return $this->m_ctdCardTypeData;
977
+ }
978
+
979
+ public function getAmountReceived()
980
+ {
981
+ return $this->m_nAmountReceived;
982
+ }
983
+
984
+ public function getThreeDSecureOutputData()
985
+ {
986
+ return $this->m_tdsodThreeDSecureOutputData;
987
+ }
988
+
989
+ public function getCustomVariables()
990
+ {
991
+ return $this->m_lgvCustomVariables;
992
+ }
993
+
994
+ //constructor
995
+ public function __construct($szCrossReference,
996
+ $szAuthCode,
997
+ $szAddressNumericCheckResult,
998
+ $szPostCodeCheckResult,
999
+ $szThreeDSecureAuthenticationCheckResult,
1000
+ $szCV2CheckResult,
1001
+ IRC_CardTypeData $ctdCardTypeData = null,
1002
+ IRC_NullableInt $nAmountReceived = null,
1003
+ IRC_ThreeDSecureOutputData $tdsodThreeDSecureOutputData = null,
1004
+ IRC_GenericVariableList $lgvCustomVariables = null,
1005
+ IRC_GatewayEntryPointList $lgepGatewayEntryPoints = null)
1006
+ {
1007
+ //first calling the parent constructor
1008
+ parent::__construct($lgepGatewayEntryPoints);
1009
+
1010
+ $this->m_szCrossReference = $szCrossReference;
1011
+ $this->m_szAuthCode = $szAuthCode;
1012
+ $this->m_szAddressNumericCheckResult = $szAddressNumericCheckResult;
1013
+ $this->m_szPostCodeCheckResult = $szPostCodeCheckResult;
1014
+ $this->m_szThreeDSecureAuthenticationCheckResult = $szThreeDSecureAuthenticationCheckResult;
1015
+ $this->m_szCV2CheckResult = $szCV2CheckResult;
1016
+ $this->m_ctdCardTypeData = $ctdCardTypeData;
1017
+ $this->m_nAmountReceived = $nAmountReceived;
1018
+ $this->m_tdsodThreeDSecureOutputData = $tdsodThreeDSecureOutputData;
1019
+ $this->m_lgvCustomVariables = $lgvCustomVariables;
1020
+ }
1021
+ }
1022
+
1023
+ class IRC_GetCardTypeOutputData extends IRC_BaseOutputData
1024
+ {
1025
+ private $m_ctdCardTypeData;
1026
+
1027
+ public function getCardTypeData()
1028
+ {
1029
+ return $this->m_ctdCardTypeData;
1030
+ }
1031
+
1032
+ //constructor
1033
+ public function __construct(IRC_CardTypeData $ctdCardTypeData = null,
1034
+ IRC_GatewayEntryPointList $lgepGatewayEntryPoints = null)
1035
+ {
1036
+ parent::__construct($lgepGatewayEntryPoints);
1037
+
1038
+ $this->m_ctdCardTypeData = $ctdCardTypeData;
1039
+ }
1040
+ }
1041
+
1042
+ class IRC_BaseOutputData
1043
+ {
1044
+ private $m_lgepGatewayEntryPoints;
1045
+
1046
+ public function getGatewayEntryPoints()
1047
+ {
1048
+ return $this->m_lgepGatewayEntryPoints;
1049
+ }
1050
+
1051
+ //constructor
1052
+ public function __construct(IRC_GatewayEntryPointList $lgepGatewayEntryPoints = null)
1053
+ {
1054
+ $this->m_lgepGatewayEntryPoints = $lgepGatewayEntryPoints;
1055
+ }
1056
+ }
1057
+
1058
+
1059
+ /********************/
1060
+ /* Gateway messages */
1061
+ /********************/
1062
+ class IRC_GetGatewayEntryPoints extends IRC_GatewayTransaction
1063
+ {
1064
+ function processTransaction(IRC_GetGatewayEntryPointsResult &$ggeprGetGatewayEntryPointsResult = null, IRC_GetGatewayEntryPointsOutputData &$ggepGetGatewayEntryPointsOutputData = null)
1065
+ {
1066
+ $boTransactionSubmitted = false;
1067
+ $sSOAPClient;
1068
+ $lgepGatewayEntryPoints;
1069
+
1070
+ $ggepGetGatewayEntryPointsOutputData = null;
1071
+ $goGatewayOutput = null;
1072
+
1073
+ $sSOAPClient = new IRC_SOAP('GetGatewayEntryPoints', IRC_GatewayTransaction::getSOAPNamespace());
1074
+
1075
+ $boTransactionSubmitted = IRC_GatewayTransaction::processTransactionBase($sSOAPClient, 'GetGatewayEntryPointsMessage', 'GetGatewayEntryPointsResult', 'GetGatewayEntryPointsOutputData', $sxXmlDocument, $goGatewayOutput, $lgepGatewayEntryPoints);
1076
+
1077
+ if ($boTransactionSubmitted)
1078
+ {
1079
+ $ggeprGetGatewayEntryPointsResult = $goGatewayOutput;
1080
+
1081
+ $ggepGetGatewayEntryPointsOutputData = new IRC_GetGatewayEntryPointsOutputData($lgepGatewayEntryPoints);
1082
+ }
1083
+
1084
+ return $boTransactionSubmitted;
1085
+ }
1086
+
1087
+ //constructor
1088
+ public function __construct(IRC_RequestGatewayEntryPointList $lrgepRequestGatewayEntryPoints = null,
1089
+ $nRetryAttempts,
1090
+ IRC_NullableInt $nTimeout = null,
1091
+ IRC_MerchantAuthentication $maMerchantAuthentication = null,
1092
+ $szPassOutData)
1093
+ {
1094
+ if ($nRetryAttempts == null &&
1095
+ $nTimeout == null)
1096
+ {
1097
+ IRC_GatewayTransaction::__construct($lrgepRequestGatewayEntryPoints, 1, null, $maMerchantAuthentication, $szPassOutData);
1098
+ }
1099
+ else
1100
+ {
1101
+ IRC_GatewayTransaction::__construct($lrgepRequestGatewayEntryPoints, $nRetryAttempts, $nTimeout, $maMerchantAuthentication, $szPassOutData);
1102
+ }
1103
+ }
1104
+ }
1105
+
1106
+
1107
+ class IRC_CardDetailsTransaction extends IRC_GatewayTransaction
1108
+ {
1109
+ private $m_tdTransactionDetails;
1110
+ private $m_cdCardDetails;
1111
+ private $m_cdCustomerDetails;
1112
+
1113
+ public function getTransactionDetails()
1114
+ {
1115
+ return $this->m_tdTransactionDetails;
1116
+ }
1117
+
1118
+ public function getCardDetails()
1119
+ {
1120
+ return $this->m_cdCardDetails;
1121
+ }
1122
+
1123
+ public function getCustomerDetails()
1124
+ {
1125
+ return $this->m_cdCardDetails;
1126
+ }
1127
+
1128
+ public function processTransaction(IRC_CardDetailsTransactionResult &$cdtrCardDetailsTransactionResult = null, IRC_TransactionOutputData &$todTransactionOutputData = null)
1129
+ {
1130
+ $boTransactionSubmitted = false;
1131
+ $sSOAPClient;
1132
+ $lgepGatewayEntryPoints = null;
1133
+ $sxXmlDocument;
1134
+ $goGatewayOutput = null;
1135
+
1136
+ $todTransactionOutputData = null;
1137
+ $cdtrCardDetailsTransactionResult = null;
1138
+
1139
+ $sSOAPClient = new IRC_SOAP('CardDetailsTransaction', parent::getSOAPNamespace());
1140
+
1141
+ // transaction details
1142
+ if ($this->m_tdTransactionDetails != null)
1143
+ {
1144
+ $test = $this->m_tdTransactionDetails->getAmount();
1145
+ if ($this->m_tdTransactionDetails->getAmount() != null)
1146
+ {
1147
+ if ($this->m_tdTransactionDetails->getAmount()->getHasValue())
1148
+ {
1149
+ $sSOAPClient->addParamAttribute('PaymentMessage.TransactionDetails', 'Amount', (string)$this->m_tdTransactionDetails->getAmount()->getValue());
1150
+ }
1151
+ }
1152
+ if ($this->m_tdTransactionDetails->getCurrencyCode() != null)
1153
+ {
1154
+ if ($this->m_tdTransactionDetails->getCurrencyCode()->getHasValue())
1155
+ {
1156
+ $sSOAPClient->addParamAttribute('PaymentMessage.TransactionDetails', 'CurrencyCode', (string)$this->m_tdTransactionDetails->getCurrencyCode()->getValue());
1157
+ }
1158
+ }
1159
+ if ($this->m_tdTransactionDetails->getMessageDetails() != null)
1160
+ {
1161
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getMessageDetails()->getTransactionType()))
1162
+ {
1163
+ $sSOAPClient->addParamAttribute('PaymentMessage.TransactionDetails.MessageDetails', 'TransactionType', $this->m_tdTransactionDetails->getMessageDetails()->getTransactionType());
1164
+ }
1165
+ }
1166
+ if ($this->m_tdTransactionDetails->getTransactionControl() != null)
1167
+ {
1168
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getTransactionControl()->getAuthCode()))
1169
+ {
1170
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.AuthCode', $this->m_tdTransactionDetails->getTransactionControl()->getAuthCode());
1171
+ }
1172
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getThreeDSecureOverridePolicy() != null)
1173
+ {
1174
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.ThreeDSecureOverridePolicy', IRC_SharedFunctions::boolToString($this->m_tdTransactionDetails->getTransactionControl()->getThreeDSecureOverridePolicy()->getValue()));
1175
+ }
1176
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getTransactionControl()->getAVSOverridePolicy()))
1177
+ {
1178
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.AVSOverridePolicy', $this->m_tdTransactionDetails->getTransactionControl()->getAVSOverridePolicy());
1179
+ }
1180
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getTransactionControl()->getCV2OverridePolicy()))
1181
+ {
1182
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.CV2OverridePolicy', ($this->m_tdTransactionDetails->getTransactionControl()->getCV2OverridePolicy()));
1183
+ }
1184
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getDuplicateDelay() != null)
1185
+ {
1186
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getDuplicateDelay()->getHasValue())
1187
+ {
1188
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.DuplicateDelay', (string)$this->m_tdTransactionDetails->getTransactionControl()->getDuplicateDelay()->getValue());
1189
+ }
1190
+ }
1191
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoCardType() != null)
1192
+ {
1193
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoCardType()->getHasValue())
1194
+ {
1195
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.EchoCardType', IRC_SharedFunctions::boolToString($this->m_tdTransactionDetails->getTransactionControl()->getEchoCardType()->getValue()));
1196
+ }
1197
+ }
1198
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoAVSCheckResult() != null)
1199
+ {
1200
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoAVSCheckResult()->getHasValue())
1201
+ {
1202
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.EchoAVSCheckResult', IRC_SharedFunctions::boolToString($this->m_tdTransactionDetails->getTransactionControl()->getEchoAVSCheckResult()->getValue()));
1203
+ }
1204
+ }
1205
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoAVSCheckResult() != null)
1206
+ {
1207
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoAVSCheckResult()->getHasValue())
1208
+ {
1209
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.EchoAVSCheckResult', IRC_SharedFunctions::boolToString($this->m_tdTransactionDetails->getTransactionControl()->getEchoAVSCheckResult()->getValue()));
1210
+ }
1211
+ }
1212
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoCV2CheckResult() != null)
1213
+ {
1214
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoCV2CheckResult()->getHasValue())
1215
+ {
1216
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.EchoCV2CheckResult', IRC_SharedFunctions::boolToString($this->m_tdTransactionDetails->getTransactionControl()->getEchoCV2CheckResult()->getValue()));
1217
+ }
1218
+ }
1219
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoAmountReceived() != null)
1220
+ {
1221
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoAmountReceived()->getHasValue())
1222
+ {
1223
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.EchoAmountReceived', IRC_SharedFunctions::boolToString($this->m_tdTransactionDetails->getTransactionControl()->getEchoAmountReceived()->getValue()));
1224
+ }
1225
+ }
1226
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getThreeDSecurePassthroughData() != null)
1227
+ {
1228
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getTransactionControl()->getThreeDSecurePassthroughData()->getEnrolmentStatus()))
1229
+ {
1230
+ $sSOAPClient->addParamAttribute('PaymentMessage.TransactionDetails.TransactionControl.ThreeDSecurePassthroughData', 'EnrolmentStatus', $this->m_tdTransactionDetails->getTransactionControl()->getThreeDSecurePassthroughData()->getEnrolmentStatus());
1231
+ }
1232
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getTransactionControl()->getThreeDSecurePassthroughData()->getAuthenticationStatus()))
1233
+ {
1234
+ $sSOAPClient->addParamAttribute('PaymentMessage.TransactionDetails.TransactionControl.ThreeDSecurePassthroughData', 'AuthenticationStatus', $this->m_tdTransactionDetails->getTransactionControl()->getThreeDSecurePassthroughData()->getAuthenticationStatus());
1235
+ }
1236
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getTransactionControl()->getThreeDSecurePassthroughData()->getElectronicCommerceIndicator()))
1237
+ {
1238
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.ThreeDSecurePassthroughData.ElectronicCommerceIndicator', $this->m_tdTransactionDetails->getTransactionControl()->getThreeDSecurePassthroughData()->getElectronicCommerceIndicator());
1239
+ }
1240
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getTransactionControl()->getThreeDSecurePassthroughData()->getAuthenticationValue()))
1241
+ {
1242
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.ThreeDSecurePassthroughData.AuthenticationValue', $this->m_tdTransactionDetails->getTransactionControl()->getThreeDSecurePassthroughData()->getAuthenticationValue());
1243
+ }
1244
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getTransactionControl()->getThreeDSecurePassthroughData()->getTransactionIdentifier()))
1245
+ {
1246
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.ThreeDSecurePassthroughData.TransactionIdentifier', $this->m_tdTransactionDetails->getTransactionControl()->getThreeDSecurePassthroughData()->getTransactionIdentifier());
1247
+ }
1248
+ }
1249
+ }
1250
+ if ($this->m_tdTransactionDetails->getThreeDSecureBrowserDetails() != null)
1251
+ {
1252
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getThreeDSecureBrowserDetails()->getAcceptHeaders()))
1253
+ {
1254
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.ThreeDSecureBrowserDetails.AcceptHeaders', $this->m_tdTransactionDetails->getThreeDSecureBrowserDetails()->getAcceptHeaders());
1255
+ }
1256
+ if ($this->m_tdTransactionDetails->getThreeDSecureBrowserDetails()->getDeviceCategory() != null)
1257
+ {
1258
+ if ($this->m_tdTransactionDetails->getThreeDSecureBrowserDetails()->getDeviceCategory()->getHasValue())
1259
+ {
1260
+ $sSOAPClient->addParamAttribute('PaymentMessage.TransactionDetails.ThreeDSecureBrowserDetails', 'DeviceCategory', (string)$this->m_tdTransactionDetails->getThreeDSecureBrowserDetails()->getDeviceCategory()->getValue());
1261
+ }
1262
+ }
1263
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getThreeDSecureBrowserDetails()->getUserAgent()))
1264
+ {
1265
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.ThreeDSecureBrowserDetails.UserAgent', $this->m_tdTransactionDetails->getThreeDSecureBrowserDetails()->getUserAgent());
1266
+ }
1267
+ }
1268
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getOrderID()))
1269
+ {
1270
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.OrderID', $this->m_tdTransactionDetails->getOrderID());
1271
+ }
1272
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getOrderDescription()))
1273
+ {
1274
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.OrderDescription', $this->m_tdTransactionDetails->getOrderDescription());
1275
+ }
1276
+ }
1277
+
1278
+ // card details
1279
+ if ($this->m_cdCardDetails != null)
1280
+ {
1281
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_cdCardDetails->getCardName()))
1282
+ {
1283
+ $sSOAPClient->addParam('PaymentMessage.CardDetails.CardName', $this->m_cdCardDetails->getCardName());
1284
+ }
1285
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_cdCardDetails->getCV2()))
1286
+ {
1287
+ $sSOAPClient->addParam('PaymentMessage.CardDetails.CV2', $this->m_cdCardDetails->getCV2());
1288
+ }
1289
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_cdCardDetails->getCardNumber()))
1290
+ {
1291
+ $sSOAPClient->addParam('PaymentMessage.CardDetails.CardNumber', $this->m_cdCardDetails->getCardNumber());
1292
+ }
1293
+ if ($this->m_cdCardDetails->getExpiryDate() != null)
1294
+ {
1295
+ if ($this->m_cdCardDetails->getExpiryDate()->getMonth() != null)
1296
+ {
1297
+ if ($this->m_cdCardDetails->getExpiryDate()->getMonth()->getHasValue())
1298
+ {
1299
+ $sSOAPClient->addParamAttribute('PaymentMessage.CardDetails.ExpiryDate', 'Month', (string)$this->m_cdCardDetails->getExpiryDate()->getMonth()->getValue());
1300
+ }
1301
+ }
1302
+ if ($this->m_cdCardDetails->getExpiryDate()->getYear() != null)
1303
+ {
1304
+ if ($this->m_cdCardDetails->getExpiryDate()->getYear()->getHasValue())
1305
+ {
1306
+ $sSOAPClient->addParamAttribute('PaymentMessage.CardDetails.ExpiryDate', 'Year', (string)$this->m_cdCardDetails->getExpiryDate()->getYear()->getValue());
1307
+ }
1308
+ }
1309
+ }
1310
+ if ($this->m_cdCardDetails->getStartDate() != null)
1311
+ {
1312
+ if ($this->m_cdCardDetails->getStartDate()->getMonth() != null)
1313
+ {
1314
+ if ($this->m_cdCardDetails->getStartDate()->getMonth()->getHasValue())
1315
+ {
1316
+ $sSOAPClient->addParamAttribute('PaymentMessage.CardDetails.StartDate', 'Month', (string)$this->m_cdCardDetails->getStartDate()->getMonth()->getValue());
1317
+ }
1318
+ }
1319
+ if ($this->m_cdCardDetails->getStartDate()->getYear() != null)
1320
+ {
1321
+ if ($this->m_cdCardDetails->getStartDate()->getYear()->getHasValue())
1322
+ {
1323
+ $sSOAPClient->addParamAttribute('PaymentMessage.CardDetails.StartDate', 'Year', (string)$this->m_cdCardDetails->getStartDate()->getYear()->getValue());
1324
+ }
1325
+ }
1326
+ }
1327
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_cdCardDetails->getIssueNumber()))
1328
+ {
1329
+ $sSOAPClient->addParam('PaymentMessage.CardDetails.IssueNumber', $this->m_cdCardDetails->getIssueNumber());
1330
+ }
1331
+ }
1332
+
1333
+ // customer details
1334
+ if ($this->m_cdCustomerDetails != null)
1335
+ {
1336
+ if ($this->m_cdCustomerDetails->getBillingAddress() != null)
1337
+ {
1338
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getAddress1()))
1339
+ {
1340
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.Address1', $this->m_cdCustomerDetails->getBillingAddress()->getAddress1());
1341
+ }
1342
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getAddress2()))
1343
+ {
1344
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.Address2', $this->m_cdCustomerDetails->getBillingAddress()->getAddress2());
1345
+ }
1346
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getAddress3()))
1347
+ {
1348
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.Address3', $this->m_cdCustomerDetails->getBillingAddress()->getAddress3());
1349
+ }
1350
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getAddress4()))
1351
+ {
1352
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.Address4', $this->m_cdCustomerDetails->getBillingAddress()->getAddress4());
1353
+ }
1354
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getCity()))
1355
+ {
1356
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.City', $this->m_cdCustomerDetails->getBillingAddress()->getCity());
1357
+ }
1358
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getState()))
1359
+ {
1360
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.State', $this->m_cdCustomerDetails->getBillingAddress()->getState());
1361
+ }
1362
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getPostCode()))
1363
+ {
1364
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.PostCode', $this->m_cdCustomerDetails->getBillingAddress()->getPostCode());
1365
+ }
1366
+ if ($this->m_cdCustomerDetails->getBillingAddress()->getCountryCode() != null)
1367
+ {
1368
+ if ($this->m_cdCustomerDetails->getBillingAddress()->getCountryCode()->getHasValue())
1369
+ {
1370
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.CountryCode', (string)$this->m_cdCustomerDetails->getBillingAddress()->getCountryCode()->getValue());
1371
+ }
1372
+ }
1373
+ }
1374
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getEmailAddress()))
1375
+ {
1376
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.EmailAddress', $this->m_cdCustomerDetails->getEmailAddress());
1377
+ }
1378
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getPhoneNumber()))
1379
+ {
1380
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.PhoneNumber', $this->m_cdCustomerDetails->getPhoneNumber());
1381
+ }
1382
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getCustomerIPAddress()))
1383
+ {
1384
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.CustomerIPAddress', $this->m_cdCustomerDetails->getCustomerIPAddress());
1385
+ }
1386
+ }
1387
+
1388
+ $boTransactionSubmitted = IRC_GatewayTransaction::processTransactionBase($sSOAPClient, 'PaymentMessage', 'CardDetailsTransactionResult', 'TransactionOutputData', $sxXmlDocument, $goGatewayOutput, $lgepGatewayEntryPoints);
1389
+
1390
+ if ($boTransactionSubmitted)
1391
+ {
1392
+ $cdtrCardDetailsTransactionResult = IRC_SharedFunctionsPaymentSystemShared::getPaymentMessageGatewayOutput($sxXmlDocument->CardDetailsTransactionResult, $goGatewayOutput);
1393
+
1394
+ $todTransactionOutputData = IRC_SharedFunctionsPaymentSystemShared::getTransactionOutputData($sxXmlDocument, $lgepGatewayEntryPoints);
1395
+ }
1396
+
1397
+ return ($boTransactionSubmitted);
1398
+ }
1399
+
1400
+ public function __construct(IRC_RequestGatewayEntryPointList $lrgepRequestGatewayEntryPoints = null,
1401
+ $nRetryAttempts,
1402
+ IRC_NullableInt $nTimeout = null,
1403
+ IRC_MerchantAuthentication $maMerchantAuthentication = null,
1404
+ IRC_TransactionDetails $tdTransactionDetails = null,
1405
+ IRC_CardDetails $cdCardDetails = null,
1406
+ IRC_CustomerDetails $cdCustomerDetails = null,
1407
+ $szPassOutData)
1408
+ {
1409
+ parent::__construct($lrgepRequestGatewayEntryPoints, $nRetryAttempts, $nTimeout, $maMerchantAuthentication, $szPassOutData);
1410
+
1411
+ $this->m_tdTransactionDetails = $tdTransactionDetails;
1412
+ $this->m_cdCardDetails = $cdCardDetails;
1413
+ $this->m_cdCustomerDetails = $cdCustomerDetails;
1414
+ }
1415
+
1416
+ }
1417
+ class IRC_CrossReferenceTransaction extends IRC_GatewayTransaction
1418
+ {
1419
+ private $m_tdTransactionDetails;
1420
+ private $m_ocdOverrideCardDetails;
1421
+ private $m_cdCustomerDetails;
1422
+
1423
+ public function getTransactionDetails()
1424
+ {
1425
+ return $this->m_tdTransactionDetails;
1426
+ }
1427
+ public function getOverrideCardDetails()
1428
+ {
1429
+ return $this->m_ocdOverrideCardDetails;
1430
+ }
1431
+ public function getCustomerDetails()
1432
+ {
1433
+ return $this->m_cdCustomerDetails;
1434
+ }
1435
+
1436
+ public function processTransaction(IRC_CrossReferenceTransactionResult &$crtrCrossReferenceTransactionResult = null, IRC_TransactionOutputData &$todTransactionOutputData = null)
1437
+ {
1438
+ $boTransactionSubmitted = false;
1439
+ $sSOAPClient;
1440
+ $lgepGatewayEntryPoints = null;
1441
+ $sxXmlDocument = null;
1442
+
1443
+ $todTransactionOutputData = null;
1444
+ $goGatewayOutput = null;
1445
+
1446
+ $sSOAPClient = new IRC_SOAP('CrossReferenceTransaction', IRC_GatewayTransaction::getSOAPNamespace());
1447
+ // transaction details
1448
+ if ($this->m_tdTransactionDetails != null)
1449
+ {
1450
+ if ($this->m_tdTransactionDetails->getAmount() != null)
1451
+ {
1452
+ if ($this->m_tdTransactionDetails->getAmount()->getHasValue())
1453
+ {
1454
+ $sSOAPClient->addParamAttribute('PaymentMessage.TransactionDetails', 'Amount', (string)$this->m_tdTransactionDetails->getAmount()->getValue());
1455
+ }
1456
+ }
1457
+ if ($this->m_tdTransactionDetails->getCurrencyCode() != null)
1458
+ {
1459
+ if ($this->m_tdTransactionDetails->getCurrencyCode()->getHasValue())
1460
+ {
1461
+ $sSOAPClient->addParamAttribute('PaymentMessage.TransactionDetails', 'CurrencyCode', (string)$this->m_tdTransactionDetails->getCurrencyCode()->getValue());
1462
+ }
1463
+ }
1464
+ if ($this->m_tdTransactionDetails->getMessageDetails() != null)
1465
+ {
1466
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getMessageDetails()->getTransactionType()))
1467
+ {
1468
+ $sSOAPClient->addParamAttribute('PaymentMessage.TransactionDetails.MessageDetails', 'TransactionType', $this->m_tdTransactionDetails->getMessageDetails()->getTransactionType());
1469
+ }
1470
+ if ($this->m_tdTransactionDetails->getMessageDetails()->getNewTransaction() != null)
1471
+ {
1472
+ if ($this->m_tdTransactionDetails->getMessageDetails()->getNewTransaction()->getHasValue())
1473
+ {
1474
+ $sSOAPClient->addParamAttribute('PaymentMessage.TransactionDetails.MessageDetails', 'NewTransaction', IRC_SharedFunctions::boolToString($this->m_tdTransactionDetails->getMessageDetails()->getNewTransaction()->getValue()));
1475
+ }
1476
+ }
1477
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getMessageDetails()->getCrossReference()))
1478
+ {
1479
+ $sSOAPClient->addParamAttribute('PaymentMessage.TransactionDetails.MessageDetails', 'CrossReference', $this->m_tdTransactionDetails->getMessageDetails()->getCrossReference());
1480
+ }
1481
+ }
1482
+ if ($this->m_tdTransactionDetails->getTransactionControl() != null)
1483
+ {
1484
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getTransactionControl()->getAuthCode()))
1485
+ {
1486
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.AuthCode', $this->m_tdTransactionDetails->getTransactionControl()->getAuthCode());
1487
+ }
1488
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getTransactionControl()->getAVSOverridePolicy()))
1489
+ {
1490
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.AVSOverridePolicy', $this->m_tdTransactionDetails->getTransactionControl()->getAVSOverridePolicy());
1491
+ }
1492
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getTransactionControl()->getCV2OverridePolicy()))
1493
+ {
1494
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.CV2OverridePolicy', $this->m_tdTransactionDetails->getTransactionControl()->getCV2OverridePolicy());
1495
+ }
1496
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getDuplicateDelay() != null)
1497
+ {
1498
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getDuplicateDelay()->getHasValue())
1499
+ {
1500
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.DuplicateDelay', (string)($this->m_tdTransactionDetails->getTransactionControl()->getDuplicateDelay()->getValue()));
1501
+ }
1502
+ }
1503
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoCardType() != null)
1504
+ {
1505
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoCardType()->getHasValue())
1506
+ {
1507
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.EchoCardType', IRC_SharedFunctions::boolToString($this->m_tdTransactionDetails->getTransactionControl()->getEchoCardType()->getValue()));
1508
+ }
1509
+ }
1510
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoAVSCheckResult() != null)
1511
+ {
1512
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoAVSCheckResult()->getHasValue())
1513
+ {
1514
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.EchoAVSCheckResult', IRC_SharedFunctions::boolToString($this->m_tdTransactionDetails->getTransactionControl()->getEchoAVSCheckResult()->getValue()));
1515
+ }
1516
+ }
1517
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoAVSCheckResult() != null)
1518
+ {
1519
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoAVSCheckResult()->getHasValue())
1520
+ {
1521
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.EchoAVSCheckResult', IRC_SharedFunctions::boolToString($this->m_tdTransactionDetails->getTransactionControl()->getEchoAVSCheckResult()->getValue()));
1522
+ }
1523
+ }
1524
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoCV2CheckResult() != null)
1525
+ {
1526
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoCV2CheckResult()->getHasValue())
1527
+ {
1528
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.EchoCV2CheckResult', IRC_SharedFunctions::boolToString($this->m_tdTransactionDetails->getTransactionControl()->getEchoCV2CheckResult()->getValue()));
1529
+ }
1530
+ }
1531
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoAmountReceived() != null)
1532
+ {
1533
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoAmountReceived()->getHasValue())
1534
+ {
1535
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.EchoAmountReceived', IRC_SharedFunctions::boolToString($this->m_tdTransactionDetails->getTransactionControl()->getEchoAmountReceived()->getValue()));
1536
+ }
1537
+ }
1538
+ }
1539
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getOrderID()))
1540
+ {
1541
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.OrderID', $this->m_tdTransactionDetails->getOrderID());
1542
+ }
1543
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getOrderDescription()))
1544
+ {
1545
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.OrderDescription', $this->m_tdTransactionDetails->getOrderDescription());
1546
+ }
1547
+ }
1548
+ // card details
1549
+ if ($this->m_ocdOverrideCardDetails != null)
1550
+ {
1551
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_ocdOverrideCardDetails->getCardName()))
1552
+ {
1553
+ $sSOAPClient->addParam('PaymentMessage.OverrideCardDetails.CardName', $this->m_ocdOverrideCardDetails->getCardName());
1554
+ }
1555
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_ocdOverrideCardDetails->getCV2()))
1556
+ {
1557
+ $sSOAPClient->addParam('PaymentMessage.CardDetails.CV2', $this->m_ocdOverrideCardDetails->getCV2());
1558
+ }
1559
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_ocdOverrideCardDetails->getCardNumber()))
1560
+ {
1561
+ $sSOAPClient->addParam('PaymentMessage.OverrideCardDetails.CardNumber', $this->m_ocdOverrideCardDetails->getCardNumber());
1562
+ }
1563
+ if ($this->m_ocdOverrideCardDetails->getExpiryDate() != null)
1564
+ {
1565
+ if ($this->m_ocdOverrideCardDetails->getExpiryDate()->getMonth() != null)
1566
+ {
1567
+ if ($this->m_ocdOverrideCardDetails->getExpiryDate()->getMonth()->getHasValue())
1568
+ {
1569
+ $sSOAPClient->addParamAttribute('PaymentMessage.OverrideCardDetails.ExpiryDate', 'Month', (string)$this->m_ocdOverrideCardDetails->getExpiryDate()->getMonth()->getValue());
1570
+ }
1571
+ }
1572
+ if ($this->m_ocdOverrideCardDetails->getExpiryDate()->getYear() != null)
1573
+ {
1574
+ if ($this->m_ocdOverrideCardDetails->getExpiryDate()->getYear()->getHasValue())
1575
+ {
1576
+ $sSOAPClient->addParamAttribute('PaymentMessage.OverrideCardDetails.ExpiryDate', 'Year', (string)$this->m_ocdOverrideCardDetails->getExpiryDate()->getYear()->getValue());
1577
+ }
1578
+ }
1579
+ }
1580
+ if ($this->m_ocdOverrideCardDetails->getStartDate() != null)
1581
+ {
1582
+ if ($this->m_ocdOverrideCardDetails->getStartDate()->getMonth() != null)
1583
+ {
1584
+ if ($this->m_ocdOverrideCardDetails->getStartDate()->getMonth()->getHasValue())
1585
+ {
1586
+ $sSOAPClient->addParamAttribute('PaymentMessage.OverrideCardDetails.StartDate', 'Month', (string)$this->m_ocdOverrideCardDetails->getStartDate()->getMonth()->getValue());
1587
+ }
1588
+ }
1589
+ if ($this->m_ocdOverrideCardDetails->getStartDate()->getYear() != null)
1590
+ {
1591
+ if ($this->m_ocdOverrideCardDetails->getStartDate()->getYear()->getHasValue())
1592
+ {
1593
+ $sSOAPClient->addParamAttribute('PaymentMessage.OverrideCardDetails.StartDate', 'Year', (string)$this->m_ocdOverrideCardDetails->getStartDate()->getYear()->getValue());
1594
+ }
1595
+ }
1596
+ }
1597
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_ocdOverrideCardDetails->getIssueNumber()))
1598
+ {
1599
+ $sSOAPClient->addParam('PaymentMessage.CardDetails.IssueNumber', $this->m_ocdOverrideCardDetails->getIssueNumber());
1600
+ }
1601
+ }
1602
+ // customer details
1603
+ if ($this->m_cdCustomerDetails != null)
1604
+ {
1605
+ if ($this->m_cdCustomerDetails->getBillingAddress() != null)
1606
+ {
1607
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getAddress1()))
1608
+ {
1609
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.Address1', $this->m_cdCustomerDetails->getBillingAddress()->getAddress1());
1610
+ }
1611
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getAddress2()))
1612
+ {
1613
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.Address2', $this->m_cdCustomerDetails->getBillingAddress()->getAddress2());
1614
+ }
1615
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getAddress3()))
1616
+ {
1617
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.Address3', $this->m_cdCustomerDetails->getBillingAddress()->getAddress3());
1618
+ }
1619
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getAddress4()))
1620
+ {
1621
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.Address4', $this->m_cdCustomerDetails->getBillingAddress()->getAddress4());
1622
+ }
1623
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getCity()))
1624
+ {
1625
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.City', $this->m_cdCustomerDetails->getBillingAddress()->getCity());
1626
+ }
1627
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getState()))
1628
+ {
1629
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.State', $this->m_cdCustomerDetails->getBillingAddress()->getState());
1630
+ }
1631
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getPostCode()))
1632
+ {
1633
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.PostCode', (string)$this->m_cdCustomerDetails->getBillingAddress()->getPostCode());
1634
+ }
1635
+ if ($this->m_cdCustomerDetails->getBillingAddress()->getCountryCode() != null)
1636
+ {
1637
+ if ($this->m_cdCustomerDetails->getBillingAddress()->getCountryCode()->getHasValue())
1638
+ {
1639
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.CountryCode', (string)$this->m_cdCustomerDetails->getBillingAddress()->getCountryCode()->getValue());
1640
+ }
1641
+ }
1642
+ }
1643
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getEmailAddress()))
1644
+ {
1645
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.EmailAddress', $this->m_cdCustomerDetails->getEmailAddress());
1646
+ }
1647
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getPhoneNumber()))
1648
+ {
1649
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.PhoneNumber', $this->m_cdCustomerDetails->getPhoneNumber());
1650
+ }
1651
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getCustomerIPAddress()))
1652
+ {
1653
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.CustomerIPAddress', $this->m_cdCustomerDetails->getCustomerIPAddress());
1654
+ }
1655
+ }
1656
+
1657
+ $boTransactionSubmitted = IRC_GatewayTransaction::processTransactionBase($sSOAPClient, 'PaymentMessage', 'CrossReferenceTransactionResult', 'TransactionOutputData', $sxXmlDocument, $goGatewayOutput, $lgepGatewayEntryPoints);
1658
+
1659
+ if ($boTransactionSubmitted)
1660
+ {
1661
+ $crtrCrossReferenceTransactionResult = IRC_SharedFunctionsPaymentSystemShared::getPaymentMessageGatewayOutput($sxXmlDocument->CrossReferenceTransactionResult, $goGatewayOutput);
1662
+
1663
+ $todTransactionOutputData = IRC_SharedFunctionsPaymentSystemShared::getTransactionOutputData($sxXmlDocument, $lgepGatewayEntryPoints);
1664
+ }
1665
+
1666
+ return $boTransactionSubmitted;
1667
+ }
1668
+
1669
+ //constructor
1670
+ public function __construct(IRC_RequestGatewayEntryPointList $lrgepRequestGatewayEntryPoints = null,
1671
+ $nRetryAttempts,
1672
+ IRC_NullableInt $nTimeout = null,
1673
+ IRC_MerchantAuthentication $maMerchantAuthentication = null,
1674
+ IRC_TransactionDetails $tdTransactionDetails = null,
1675
+ IRC_CardDetails $cdOverrideCardDetails = null,
1676
+ IRC_CustomerDetails $cdCustomerDetails = null,
1677
+ $szPassOutData)
1678
+ {
1679
+ IRC_GatewayTransaction::__construct($lrgepRequestGatewayEntryPoints, $nRetryAttempts, $nTimeout, $maMerchantAuthentication, $szPassOutData);
1680
+
1681
+ $this->m_tdTransactionDetails = $tdTransactionDetails;
1682
+ $this->m_ocdOverrideCardDetails = $cdOverrideCardDetails;
1683
+ $this->m_cdCustomerDetails = $cdCustomerDetails;
1684
+ }
1685
+ }
1686
+
1687
+ class IRC_ThreeDSecureAuthentication extends IRC_GatewayTransaction
1688
+ {
1689
+ private $m_tdsidThreeDSecureInputData;
1690
+
1691
+ public function getThreeDSecureInputData()
1692
+ {
1693
+ return $this->m_tdsidThreeDSecureInputData;
1694
+ }
1695
+
1696
+ public function processTransaction(IRC_ThreeDSecureAuthenticationResult &$tdsarThreeDSecureAuthenticationResult = null, IRC_TransactionOutputData &$todTransactionOutputData = null)
1697
+ {
1698
+ $boTransactionSubmitted = false;
1699
+ $sSOAPClient;
1700
+ $lgepGatewayEntryPoints = null;
1701
+ $sxXmlDocument = null;
1702
+
1703
+ $todTransactionOutputData = null;
1704
+ $goGatewayOutput = null;
1705
+
1706
+ $sSOAPClient = new IRC_SOAP('ThreeDSecureAuthentication', IRC_GatewayTransaction::getSOAPNamespace());
1707
+ if ($this->m_tdsidThreeDSecureInputData != null)
1708
+ {
1709
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_tdsidThreeDSecureInputData->getCrossReference()))
1710
+ {
1711
+ $sSOAPClient->addParamAttribute('ThreeDSecureMessage.ThreeDSecureInputData', 'CrossReference', $this->m_tdsidThreeDSecureInputData->getCrossReference());
1712
+ }
1713
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_tdsidThreeDSecureInputData->getPaRES()))
1714
+ {
1715
+ $sSOAPClient->addParam('ThreeDSecureMessage.ThreeDSecureInputData.PaRES', $this->m_tdsidThreeDSecureInputData->getPaRES());
1716
+ }
1717
+ }
1718
+
1719
+ $boTransactionSubmitted = IRC_GatewayTransaction::processTransactionBase($sSOAPClient, 'ThreeDSecureMessage', 'ThreeDSecureAuthenticationResult', 'TransactionOutputData', $sxXmlDocument, $goGatewayOutput, $lgepGatewayEntryPoints);
1720
+
1721
+ if ($boTransactionSubmitted)
1722
+ {
1723
+ $tdsarThreeDSecureAuthenticationResult = IRC_SharedFunctionsPaymentSystemShared::getPaymentMessageGatewayOutput($sxXmlDocument->ThreeDSecureAuthenticationResult, $goGatewayOutput);
1724
+
1725
+ $todTransactionOutputData = IRC_SharedFunctionsPaymentSystemShared::getTransactionOutputData($sxXmlDocument, $lgepGatewayEntryPoints);
1726
+ }
1727
+
1728
+ return $boTransactionSubmitted;
1729
+ }
1730
+
1731
+ //constructor
1732
+ public function __construct(IRC_RequestGatewayEntryPointList $lrgepRequestGatewayEntryPoints = null,
1733
+ $nRetryAttempts,
1734
+ IRC_NullableInt $nTimeout = null,
1735
+ IRC_MerchantAuthentication $maMerchantAuthentication = null,
1736
+ IRC_ThreeDSecureInputData $tdsidThreeDSecureInputData = null,
1737
+ $szPassOutData)
1738
+ {
1739
+ IRC_GatewayTransaction::__construct($lrgepRequestGatewayEntryPoints, $nRetryAttempts, $nTimeout, $maMerchantAuthentication, $szPassOutData);
1740
+
1741
+ $this->m_tdsidThreeDSecureInputData = $tdsidThreeDSecureInputData;
1742
+ }
1743
+ }
1744
+
1745
+ class IRC_GetCardType extends IRC_GatewayTransaction
1746
+ {
1747
+ private $m_szCardNumber;
1748
+
1749
+ public function getCardNumber()
1750
+ {
1751
+ return $this->m_szCardNumber;
1752
+ }
1753
+
1754
+ public function processTransaction(IRC_GetCardTypeResult &$gctrGetCardTypeResult = null, IRC_GetCardTypeOutputData &$gctodGetCardTypeOutputData = null)
1755
+ {
1756
+ $boTransactionSubmitted = false;
1757
+ $sSOAPClient;
1758
+ $lgepGatewayEntryPoints = null;
1759
+ $ctdCardTypeData = null;
1760
+ $sxXmlDocument = null;
1761
+
1762
+ $gctodGetCardTypeOutputData = null;
1763
+ $goGatewayOutput = null;
1764
+
1765
+ $sSOAPClient = new IRC_SOAP('GetCardType', IRC_GatewayTransaction::getSOAPNamespace());
1766
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_szCardNumber))
1767
+ {
1768
+ $sSOAPClient->addParam('GetCardTypeMessage.CardNumber', $this->m_szCardNumber);
1769
+ }
1770
+
1771
+ $boTransactionSubmitted = IRC_GatewayTransaction::processTransactionBase($sSOAPClient, 'GetCardTypeMessage', 'GetCardTypeResult', 'GetCardTypeOutputData', $sxXmlDocument, $goGatewayOutput, $lgepGatewayEntryPoints);
1772
+
1773
+ if ($boTransactionSubmitted)
1774
+ {
1775
+ $gctrGetCardTypeResult = $goGatewayOutput;
1776
+
1777
+ if(!$sxXmlDocument->GetCardTypeOutputData->CardTypeData)
1778
+ {
1779
+ $ctdCardTypeData = null;
1780
+ }
1781
+ else
1782
+ {
1783
+ $ctdCardTypeData = IRC_SharedFunctionsPaymentSystemShared::getCardTypeData($sxXmlDocument->GetCardTypeOutputData->CardTypeData);
1784
+ }
1785
+
1786
+ if (!is_null($ctdCardTypeData))
1787
+ {
1788
+ $gctodGetCardTypeOutputData = new IRC_GetCardTypeOutputData($ctdCardTypeData, $lgepGatewayEntryPoints);
1789
+ }
1790
+ }
1791
+ return $boTransactionSubmitted;
1792
+ }
1793
+
1794
+ //constructor
1795
+ public function __construct(IRC_RequestGatewayEntryPointList $lrgepRequestGatewayEntryPoints = null,
1796
+ $nRetryAttempts,
1797
+ IRC_NullableInt $nTimeout = null,
1798
+ IRC_MerchantAuthentication $maMerchantAuthentication = null,
1799
+ $szCardNumber,
1800
+ $szPassOutData)
1801
+ {
1802
+ IRC_GatewayTransaction::__construct($lrgepRequestGatewayEntryPoints, $nRetryAttempts, $nTimeout, $maMerchantAuthentication, $szPassOutData);
1803
+
1804
+ $this->m_szCardNumber = $szCardNumber;
1805
+ }
1806
+ }
1807
+
1808
+ abstract class IRC_GatewayTransaction
1809
+ {
1810
+ private $m_maMerchantAuthentication;
1811
+ private $m_szPassOutData;
1812
+ private $m_lrgepRequestGatewayEntryPoints;
1813
+ private $m_nRetryAttempts;
1814
+ private $m_nTimeout;
1815
+ private $m_szSOAPNamespace = 'https://www.thepaymentgateway.net/';
1816
+ private $m_szLastRequest;
1817
+ private $m_szLastResponse;
1818
+ private $m_eLastException;
1819
+ private $m_szEntryPointUsed;
1820
+
1821
+ public function getMerchantAuthentication()
1822
+ {
1823
+ return $this->m_maMerchantAuthentication;
1824
+ }
1825
+
1826
+ public function getPassOutData()
1827
+ {
1828
+ return $this->m_szPassOutData;
1829
+ }
1830
+
1831
+ public function getRequestGatewayEntryPoints()
1832
+ {
1833
+ return $this->m_lrgepRequestGatewayEntryPoints;
1834
+ }
1835
+
1836
+ public function getRetryAttempts()
1837
+ {
1838
+ return $this->m_nRetryAttempts;
1839
+ }
1840
+
1841
+ public function getTimeout()
1842
+ {
1843
+ return $this->m_nTimeout;
1844
+ }
1845
+
1846
+ public function getSOAPNamespace()
1847
+ {
1848
+ return $this->m_szSOAPNamespace;
1849
+ }
1850
+ public function setSOAPNamespace($value)
1851
+ {
1852
+ $this->m_szSOAPNamespace = $value;
1853
+ }
1854
+
1855
+ public function getLastRequest()
1856
+ {
1857
+ return $this->m_szLastRequest;
1858
+ }
1859
+
1860
+ public function getLastResponse()
1861
+ {
1862
+ return $this->m_szLastResponse;
1863
+ }
1864
+
1865
+ public function getLastException()
1866
+ {
1867
+ return $this->m_eLastException;
1868
+ }
1869
+ public function getEntryPointUsed()
1870
+ {
1871
+ return $this->m_szEntryPointUsed;
1872
+ }
1873
+
1874
+ public static function compare($x, $y)
1875
+ {
1876
+ $rgepFirst = null;
1877
+ $rgepSecond = null;
1878
+
1879
+ $rgepFirst = $x;
1880
+ $rgepSecond = $y;
1881
+
1882
+ return (IRC_GatewayTransaction::compareGatewayEntryPoints($rgepFirst, $rgepSecond));
1883
+ }
1884
+
1885
+ private static function compareGatewayEntryPoints(IRC_RequestGatewayEntryPoint $rgepFirst, IRC_RequestGatewayEntryPoint $rgepSecond)
1886
+ {
1887
+ $nReturnValue = 0;
1888
+ // returns >0 if rgepFirst greater than rgepSecond
1889
+ // returns 0 if they are equal
1890
+ // returns <0 if rgepFirst less than rgepSecond
1891
+
1892
+ // both null, then they are the same
1893
+ if ($rgepFirst == null &&
1894
+ $rgepSecond == null)
1895
+ {
1896
+ $nReturnValue = 0;
1897
+ }
1898
+ // just first null? then second is greater
1899
+ elseif ($rgepFirst == null &&
1900
+ $rgepSecond != null)
1901
+ {
1902
+ $nReturnValue = 1;
1903
+ }
1904
+ // just second null? then first is greater
1905
+ elseif ($rgepFirst != null && $rgepSecond == null)
1906
+ {
1907
+ $nReturnValue = -1;
1908
+ }
1909
+ // can now assume that first & second both have a value
1910
+ elseif ($rgepFirst->getMetric() == $rgepSecond->getMetric())
1911
+ {
1912
+ $nReturnValue = 0;
1913
+ }
1914
+ elseif ($rgepFirst->getMetric() < $rgepSecond->getMetric())
1915
+ {
1916
+ $nReturnValue = -1;
1917
+ }
1918
+ elseif ($rgepFirst->getMetric() > $rgepSecond->getMetric())
1919
+ {
1920
+ $nReturnValue = 1;
1921
+ }
1922
+
1923
+ return $nReturnValue;
1924
+ }
1925
+
1926
+ protected function processTransactionBase(IRC_SOAP $sSOAPClient, $szMessageXMLPath, $szGatewayOutputXMLPath, $szTransactionMessageXMLPath, SimpleXMLElement &$sxXmlDocument = null, IRC_GatewayOutput &$goGatewayOutput = null, IRC_GatewayEntryPointList &$lgepGatewayEntryPoints = null)
1927
+ {
1928
+ $boTransactionSubmitted = false;
1929
+ $nOverallRetryCount = 0;
1930
+ $nOverallGatewayEntryPointCount = 0;
1931
+ $nGatewayEntryPointCount = 0;
1932
+ $nErrorMessageCount = 0;
1933
+ $rgepCurrentGatewayEntryPoint;
1934
+ $nStatusCode;
1935
+ $szMessage = null;
1936
+ $lszErrorMessages;
1937
+ $szString;
1938
+ $sbXMLString;
1939
+ $szXMLFormatString;
1940
+ $nCount = 0;
1941
+ $szEntryPointURL;
1942
+ $nMetric;
1943
+ $gepGatewayEntryPoint = null;
1944
+ $szPassOutData = null;
1945
+ $ResponseDocument = null;
1946
+ $ResponseMethod = null;
1947
+
1948
+ $lgepGatewayEntryPoints = null;
1949
+ $goGatewayOutput = null;
1950
+
1951
+ $this->m_szEntryPointUsed = null;
1952
+
1953
+ if ($sSOAPClient == null)
1954
+ {
1955
+ return false;
1956
+ }
1957
+
1958
+ // populate the merchant details
1959
+ if ($this->m_maMerchantAuthentication != null)
1960
+ {
1961
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_maMerchantAuthentication->getMerchantID()))
1962
+ {
1963
+ $sSOAPClient->addParamAttribute($szMessageXMLPath. '.MerchantAuthentication', 'MerchantID', $this->m_maMerchantAuthentication->getMerchantID());
1964
+ }
1965
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_maMerchantAuthentication->getPassword()))
1966
+ {
1967
+ $sSOAPClient->addParamAttribute($szMessageXMLPath. '.MerchantAuthentication', 'Password', $this->m_maMerchantAuthentication->getPassword());
1968
+ }
1969
+ }
1970
+
1971
+ // populate the passout data
1972
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($this->m_szPassOutData))
1973
+ {
1974
+ $sSOAPClient->addParam($szMessageXMLPath. '.PassOutData', $this->m_szPassOutData, null);
1975
+ }
1976
+
1977
+ // first need to sort the gateway entry points into the correct usage order
1978
+ $number = $this->m_lrgepRequestGatewayEntryPoints->sort('IRC_GatewayTransaction','Compare');
1979
+
1980
+ // loop over the overall number of transaction attempts
1981
+ while (!$boTransactionSubmitted &&
1982
+ $nOverallRetryCount < $this->m_nRetryAttempts)
1983
+ {
1984
+ $nOverallGatewayEntryPointCount = 0;
1985
+
1986
+ // loop over the number of gateway entry points in the list
1987
+ while (!$boTransactionSubmitted &&
1988
+ $nOverallGatewayEntryPointCount < $this->m_lrgepRequestGatewayEntryPoints->getCount())
1989
+ {
1990
+
1991
+ $rgepCurrentGatewayEntryPoint = $this->m_lrgepRequestGatewayEntryPoints->getAt($nOverallGatewayEntryPointCount);
1992
+
1993
+ // ignore if the metric is "-1" this indicates that the entry point is offline
1994
+ if ($rgepCurrentGatewayEntryPoint->getMetric() >= 0)
1995
+ {
1996
+ $nGatewayEntryPointCount = 0;
1997
+ $sSOAPClient->setURL($rgepCurrentGatewayEntryPoint->getEntryPointURL());
1998
+
1999
+ // loop over the number of times to try this specific entry point
2000
+ while (!$boTransactionSubmitted &&
2001
+ $nGatewayEntryPointCount < $rgepCurrentGatewayEntryPoint->getRetryAttempts())
2002
+ {
2003
+ if ($sSOAPClient->sendRequest($ResponseDocument, $ResponseMethod))
2004
+ {
2005
+ //getting the valid transaction type document format
2006
+ $sxXmlDocument = $ResponseDocument->$ResponseMethod;
2007
+
2008
+ $lszErrorMessages = new IRC_StringList();
2009
+
2010
+ $nStatusCode = (int)current($ResponseDocument->$ResponseMethod->$szGatewayOutputXMLPath->StatusCode[0]);
2011
+
2012
+ // a status code of 50 means that this entry point is not to be used
2013
+ if ($nStatusCode != 50)
2014
+ {
2015
+ $this->m_szEntryPointUsed = $rgepCurrentGatewayEntryPoint->getEntryPointURL();
2016
+
2017
+ // the transaction was submitted
2018
+ $boTransactionSubmitted = true;
2019
+
2020
+ if ($ResponseDocument->$ResponseMethod->$szGatewayOutputXMLPath->Message)
2021
+ {
2022
+ $szMessage = current($ResponseDocument->$ResponseMethod->$szGatewayOutputXMLPath->Message[0]);
2023
+ }
2024
+ if ($ResponseDocument->$ResponseMethod->$szGatewayOutputXMLPath->ErrorMessages)
2025
+ {
2026
+ foreach ($ResponseDocument->$ResponseMethod->$szGatewayOutputXMLPath->ErrorMessages->MessageDetail as $key => $value)
2027
+ {
2028
+ $lszErrorMessages->add(current($value->Detail));
2029
+ }
2030
+ }
2031
+
2032
+ if ($ResponseDocument->$ResponseMethod->$szGatewayOutputXMLPath->PassOutData)
2033
+ {
2034
+ $szPassOutData = current($ResponseDocument->$ResponseMethod->$szGatewayOutputXMLPath->PassOutData[0]);
2035
+ }
2036
+ else
2037
+ {
2038
+ $szPassOutData = null;
2039
+ }
2040
+
2041
+ $goGatewayOutput = new IRC_GatewayOutput($nStatusCode, $szMessage, $szPassOutData/*, $boAuthorisationAttempted, $ptdPreviousTransactionResult*/, $lszErrorMessages);
2042
+
2043
+ // look to see if there are any gateway entry points
2044
+ $nCount = 0;
2045
+
2046
+ $nMetric = -1;
2047
+
2048
+ if ($ResponseDocument->$ResponseMethod->$szTransactionMessageXMLPath->GatewayEntryPoints)
2049
+ {
2050
+ if($ResponseDocument->$ResponseMethod->$szTransactionMessageXMLPath->GatewayEntryPoints->GatewayEntryPoint)
2051
+ {
2052
+ $szXMLFormatString = $ResponseDocument->$ResponseMethod->$szTransactionMessageXMLPath->GatewayEntryPoints->GatewayEntryPoint;
2053
+
2054
+ foreach($szXMLFormatString->attributes() as $key => $value)
2055
+ {
2056
+ if (is_numeric(current($value)))
2057
+ {
2058
+ $nMetric = current($value);
2059
+ }
2060
+ else
2061
+ {
2062
+ $szEntryPointURL = current($value);
2063
+ }
2064
+ }
2065
+
2066
+ //$gepGatewayEntryPoint = new GatewayEntryPoint($szEntryPointURL, $nMetric);
2067
+ if ($lgepGatewayEntryPoints == null)
2068
+ {
2069
+ $lgepGatewayEntryPoints = new IRC_GatewayEntryPointList();
2070
+ }
2071
+ $lgepGatewayEntryPoints->add($szEntryPointURL, $nMetric); //$lgepGatewayEntryPoints->add($gepGatewayEntryPoint);
2072
+ }
2073
+ }
2074
+ $nCount++;
2075
+ }
2076
+ }
2077
+
2078
+ $nGatewayEntryPointCount++;
2079
+ }
2080
+ }
2081
+ $nOverallGatewayEntryPointCount++;
2082
+ }
2083
+ $nOverallRetryCount++;
2084
+ }
2085
+ $this->m_szLastRequest = $sSOAPClient->getSOAPPacket();
2086
+ $this->m_szLastResponse = $sSOAPClient->getLastResponse();
2087
+ $this->m_eLastException = $sSOAPClient->getLastException();
2088
+
2089
+ return $boTransactionSubmitted;
2090
+ }
2091
+
2092
+ public function __construct(IRC_RequestGatewayEntryPointList $lrgepRequestGatewayEntryPoints = null,
2093
+ $nRetryAttempts,
2094
+ IRC_NullableInt $nTimeout = null,
2095
+ IRC_MerchantAuthentication $maMerchantAuthentication = null,
2096
+ $szPassOutData)
2097
+ {
2098
+ $this->m_maMerchantAuthentication = $maMerchantAuthentication;
2099
+ $this->m_szPassOutData = $szPassOutData;
2100
+ $this->m_lrgepRequestGatewayEntryPoints = $lrgepRequestGatewayEntryPoints;
2101
+ $this->m_nRetryAttempts = $nRetryAttempts;
2102
+ $this->m_nTimeout = $nTimeout;
2103
+ }
2104
+ }
2105
+
2106
+ class IRC_SharedFunctionsPaymentSystemShared
2107
+ {
2108
+ public static function getTransactionOutputData(SimpleXMLElement $sxXmlDocument, IRC_GatewayEntryPointList $lgepGatewayEntryPoints = null)
2109
+ {
2110
+ $szCrossReference = null;
2111
+ $szAddressNumericCheckResult = null;
2112
+ $szPostCodeCheckResult = null;
2113
+ $szThreeDSecureAuthenticationCheckResult = null;
2114
+ $szCV2CheckResult = null;
2115
+ $nAmountReceived = null;
2116
+ $szPaREQ = null;
2117
+ $szACSURL = null;
2118
+ $ctdCardTypeData = null;
2119
+ $tdsodThreeDSecureOutputData = null;
2120
+ $lgvCustomVariables = null;
2121
+ $nCount = 0;
2122
+ $sbString;
2123
+ $szXMLFormatString;
2124
+ $szName;
2125
+ $szValue;
2126
+ $gvGenericVariable;
2127
+ $nCount = 0;
2128
+ $szCardTypeData;
2129
+
2130
+ $todTransactionOutputData = null;
2131
+
2132
+ if (!$sxXmlDocument->TransactionOutputData)
2133
+ {
2134
+ return (null);
2135
+ }
2136
+
2137
+ if ($sxXmlDocument->TransactionOutputData->attributes())
2138
+ {
2139
+ foreach($sxXmlDocument->TransactionOutputData->attributes() as $key => $value)
2140
+ {
2141
+ $szCrossReference = current($value);
2142
+ }
2143
+ }
2144
+ else
2145
+ {
2146
+ $szCrossReference = null;
2147
+ }
2148
+
2149
+ if ($sxXmlDocument->TransactionOutputData->AuthCode)
2150
+ {
2151
+ $szAuthCode = current($sxXmlDocument->TransactionOutputData->AuthCode[0]);
2152
+ }
2153
+ else
2154
+ {
2155
+ $szAuthCode = null;
2156
+ }
2157
+
2158
+ if ($sxXmlDocument->TransactionOutputData->AddressNumericCheckResult)
2159
+ {
2160
+ $szAddressNumericCheckResult = current($sxXmlDocument->TransactionOutputData->AddressNumericCheckResult[0]);
2161
+ }
2162
+
2163
+ if ($sxXmlDocument->TransactionOutputData->PostCodeCheckResult)
2164
+ {
2165
+ $szPostCodeCheckResult = current($sxXmlDocument->TransactionOutputData->PostCodeCheckResult[0]);
2166
+ }
2167
+
2168
+ if ($sxXmlDocument->TransactionOutputData->ThreeDSecureAuthenticationCheckResult)
2169
+ {
2170
+ $szThreeDSecureAuthenticationCheckResult = current($sxXmlDocument->TransactionOutputData->ThreeDSecureAuthenticationCheckResult[0]);
2171
+ }
2172
+
2173
+ if ($sxXmlDocument->TransactionOutputData->CV2CheckResult)
2174
+ {
2175
+ $szCV2CheckResult = current($sxXmlDocument->TransactionOutputData->CV2CheckResult[0]);
2176
+ }
2177
+
2178
+ if ($sxXmlDocument->TransactionOutputData->CardTypeData)
2179
+ {
2180
+ $ctdCardTypeData = self::getCardTypeData($sxXmlDocument->TransactionOutputData->CardTypeData);
2181
+ }
2182
+ else
2183
+ {
2184
+ $ctdCardTypeData = null;
2185
+ }
2186
+
2187
+ if ($sxXmlDocument->TransactionOutputData->AmountReceived)
2188
+ {
2189
+ $nAmountReceived = new IRC_NullableInt(current($sxXmlDocument->TransactionOutputData->AmountReceived[0]));
2190
+ }
2191
+ else
2192
+ {
2193
+ $nAmountReceived = new IRC_NullableInt(null);
2194
+ }
2195
+
2196
+ if ($sxXmlDocument->TransactionOutputData->ThreeDSecureOutputData)
2197
+ {
2198
+ $szPaREQ = current($sxXmlDocument->TransactionOutputData->ThreeDSecureOutputData->PaREQ[0]);
2199
+ $szACSURL = current($sxXmlDocument->TransactionOutputData->ThreeDSecureOutputData->ACSURL[0]);
2200
+ }
2201
+ else
2202
+ {
2203
+ $szPaREQ = null;
2204
+ $szACSURL = null;
2205
+ }
2206
+
2207
+
2208
+ if (!IRC_SharedFunctions::isStringNullOrEmpty($szACSURL) &&
2209
+ !IRC_SharedFunctions::isStringNullOrEmpty($szPaREQ))
2210
+ {
2211
+ $tdsodThreeDSecureOutputData = new IRC_ThreeDSecureOutputData($szPaREQ, $szACSURL);
2212
+ }
2213
+
2214
+ if ($sxXmlDocument->TransactionOutputData->CustomVariables->GenericVariable)
2215
+ {
2216
+ if ($lgvCustomVariables == null)
2217
+ {
2218
+ $lgvCustomVariables = new IRC_GenericVariableList();
2219
+ }
2220
+ for ($nCount=0; $nCount < count($sxXmlDocument->TransactionOutputData->CustomVariables->GenericVariable); $nCount++)
2221
+ {
2222
+ $szName = current($sxXmlDocument->TransactionOutputData->CustomVariables->GenericVariable[$nCount]->Name[0]);
2223
+ $szValue = current($sxXmlDocument->TransactionOutputData->CustomVariables->GenericVariable[$nCount]->Value[0]);
2224
+ $gvGenericVariable = new IRC_GenericVariable($szName, $szValue);
2225
+ $lgvCustomVariables->add($gvGenericVariable);
2226
+ }
2227
+ }
2228
+ else
2229
+ {
2230
+ $lgvCustomVariables = null;
2231
+ }
2232
+
2233
+
2234
+ $todTransactionOutputData = new IRC_TransactionOutputData($szCrossReference,
2235
+ $szAuthCode,
2236
+ $szAddressNumericCheckResult,
2237
+ $szPostCodeCheckResult,
2238
+ $szThreeDSecureAuthenticationCheckResult,
2239
+ $szCV2CheckResult,
2240
+ $ctdCardTypeData,
2241
+ $nAmountReceived,
2242
+ $tdsodThreeDSecureOutputData,
2243
+ $lgvCustomVariables,
2244
+ $lgepGatewayEntryPoints);
2245
+
2246
+ return $todTransactionOutputData;
2247
+ }
2248
+
2249
+ public static function getCardTypeData($CardTypeDataTag)
2250
+ {
2251
+ $ctdCardTypeData = null;
2252
+ $szCardType = null;
2253
+ $boLuhnCheckRequired = null;
2254
+ $szStartDateStatus = null;
2255
+ $szIssueNumberStatus = null;
2256
+ $szIssuer = null;
2257
+ $nISOCode = null;
2258
+ $iIssuer;
2259
+
2260
+ if ($CardTypeDataTag->CardType)
2261
+ {
2262
+ $szCardType = current($CardTypeDataTag->CardType[0]);
2263
+ }
2264
+
2265
+ if ($CardTypeDataTag->Issuer)
2266
+ {
2267
+ try
2268
+ {
2269
+ $szIssuer = (string)$CardTypeDataTag->Issuer[0];
2270
+ }
2271
+ catch (Exception $e)
2272
+ {
2273
+ $szIssuer = null;
2274
+ }
2275
+
2276
+ try
2277
+ {
2278
+ $nISOCode = current($CardTypeDataTag->Issuer->attributes()->ISOCode);
2279
+ }
2280
+ catch (Exception $e)
2281
+ {
2282
+ $nISOCode = null;
2283
+ }
2284
+
2285
+ $iIssuer = new IRC_Issuer($szIssuer, $nISOCode);
2286
+ }
2287
+ else
2288
+ {
2289
+ $iIssuer = null;
2290
+ }
2291
+
2292
+ if ($CardTypeDataTag->LuhnCheckRequired)
2293
+ {
2294
+ $boLuhnCheckRequired = new IRC_NullableBool(current($CardTypeDataTag->LuhnCheckRequired[0]));
2295
+ }
2296
+ else
2297
+ {
2298
+ $boLuhnCheckRequired = null;
2299
+ }
2300
+
2301
+ if ($CardTypeDataTag->IssueNumberStatus)
2302
+ {
2303
+ try
2304
+ {
2305
+ $szIssueNumberStatus = current($CardTypeDataTag->IssueNumberStatus[0]);
2306
+ }
2307
+ catch (Exception $e)
2308
+ {
2309
+ $szIssueNumberStatus = null;
2310
+ }
2311
+ }
2312
+ else
2313
+ {
2314
+ $szIssueNumberStatus = null;
2315
+ }
2316
+
2317
+ if ($CardTypeDataTag->StartDateStatus)
2318
+ {
2319
+ try
2320
+ {
2321
+ $szStartDateStatus = current($CardTypeDataTag->StartDateStatus[0]);
2322
+ }
2323
+ catch (Exception $e)
2324
+ {
2325
+ $szStartDateStatus = null;
2326
+ }
2327
+ }
2328
+ else
2329
+ {
2330
+ $szStartDateStatus = null;
2331
+ }
2332
+
2333
+ $ctdCardTypeData = new IRC_CardTypeData($szCardType, $iIssuer, $boLuhnCheckRequired, $szIssueNumberStatus, $szStartDateStatus);
2334
+
2335
+ return ($ctdCardTypeData);
2336
+ }
2337
+
2338
+
2339
+
2340
+ public static function getPaymentMessageGatewayOutput($GatewayOutput, IRC_GatewayOutput $goGatewayOutput = null)
2341
+ {
2342
+ $nPreviousStatusCode = null;
2343
+ $szPreviousMessage = null;
2344
+ $ptdPreviousTransactionResult = null;
2345
+ $pmgoPaymentMessageGatewayOutput = null;
2346
+ $boAuthorisationAttempted = null;
2347
+
2348
+ if ($GatewayOutput->attributes())
2349
+ {
2350
+ try
2351
+ {
2352
+ $szAuthorisationAttempted = current($GatewayOutput->attributes()->AuthorisationAttempted);
2353
+ if (strtolower($boAuthorisationAttempted) == 'false')
2354
+ {
2355
+ $boAuthorisationAttempted = new IRC_NullableBool(false);
2356
+ }
2357
+ elseif (strtolower($boAuthorisationAttempted) == 'true')
2358
+ {
2359
+ $boAuthorisationAttempted = new IRC_NullableBool(true);
2360
+ }
2361
+ else
2362
+ {
2363
+ throw new Exception('Return value must be true or false');
2364
+ }
2365
+ }
2366
+ catch (Exception $e)
2367
+ {
2368
+ $boAuthorisationAttempted = null;
2369
+ }
2370
+ }
2371
+
2372
+ //check to see if there is any previous transaction data
2373
+ if ($GatewayOutput->PreviousTransactionResult->StatusCode)
2374
+ {
2375
+ $nPreviousStatusCode = new IRC_NullableInt(current($GatewayOutput->PreviousTransactionResult->StatusCode[0]));
2376
+ }
2377
+
2378
+ if ($GatewayOutput->PreviousTransactionResult->Message)
2379
+ {
2380
+ $szPreviousMessage = current($GatewayOutput->PreviousTransactionResult->Message[0]);
2381
+ }
2382
+
2383
+ if ($nPreviousStatusCode != null &&
2384
+ !IRC_SharedFunctions::isStringNullOrEmpty($szPreviousMessage))
2385
+ {
2386
+ $ptdPreviousTransactionResult = new IRC_PreviousTransactionResult($nPreviousStatusCode, $szPreviousMessage);
2387
+ }
2388
+
2389
+ $pmgoPaymentMessageGatewayOutput = new IRC_PaymentMessageGatewayOutput($goGatewayOutput->getStatusCode(),
2390
+ $goGatewayOutput->getMessage(),
2391
+ $goGatewayOutput->getPassOutData(),
2392
+ $boAuthorisationAttempted,
2393
+ $ptdPreviousTransactionResult,
2394
+ $goGatewayOutput->getErrorMessages());
2395
+
2396
+ return $pmgoPaymentMessageGatewayOutput;
2397
+ }
2398
+ }
app/code/local/Iridiumcorp/Tpg/Model/Tpg/ThePaymentGateway/SOAP.php ADDED
@@ -0,0 +1,968 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //accessing external files
3
+ require_once('TPG_Common.php');
4
+
5
+ class IRC_SOAPNamespace
6
+ {
7
+ private $m_szNamespace;
8
+ private $m_szPrefix;
9
+
10
+ public function getNamespace()
11
+ {
12
+ return $this->m_szNamespace;
13
+ }
14
+ public function getPrefix()
15
+ {
16
+ return $this->m_szPrefix;
17
+ }
18
+
19
+ public function __construct($szPrefix,$szNamespace)
20
+ {
21
+ $this->m_szNamespace = $szNamespace;
22
+ $this->m_szPrefix = $szPrefix;
23
+ }
24
+ }
25
+
26
+ class IRC_SOAPNamespaceList
27
+ {
28
+ private $m_lsnSOAPNamespaceList;
29
+
30
+ function getAt($nIndex)
31
+ {
32
+ if ($nIndex < 0 ||
33
+ $nIndex >= count($this->m_lsnSOAPNamespaceList))
34
+ {
35
+ throw new Exception('Array index out of bounds');
36
+ }
37
+
38
+ return $this->m_lsnSOAPNamespaceList[$nIndex];
39
+ }
40
+
41
+ function getCount()
42
+ {
43
+ return count($this->m_lsnSOAPNamespaceList);
44
+ }
45
+
46
+ private function add1(IRC_SOAPNamespace $snSOAPNamespace)
47
+ {
48
+ $this->m_lsnSOAPNamespaceList[] = $snSOAPNamespace;
49
+ }
50
+ private function add2($szPrefix, $szSOAPNamespace)
51
+ {
52
+ if (!is_string($szPrefix) || !is_string($szSOAPNamespace))
53
+ {
54
+ throw new Exception('Invalid parameter type');
55
+ }
56
+
57
+ $this->m_lsnSOAPNamespaceList[] = new IRC_SOAPNamespace($szPrefix, $szSOAPNamespace);
58
+ }
59
+
60
+ //function overloading
61
+ public function add()
62
+ {
63
+ $num_args = func_num_args();
64
+ $args = func_get_args();
65
+
66
+ switch ($num_args)
67
+ {
68
+ case 1:
69
+ //$this->__call('add1', $args);
70
+ $this->add1($args[0]);
71
+ break;
72
+ case 3:
73
+ //$this->__call('add2', $args);
74
+ $this->add2($args[0], $args[1], $args[2]);
75
+ break;
76
+ default:
77
+ throw new Exception('Invalid number of parameters for fucntion Add');
78
+ }
79
+ }
80
+
81
+ //constructor
82
+ public function __construct()
83
+ {
84
+ $this->m_lsnSOAPNamespaceList = array();
85
+ }
86
+ }
87
+
88
+ class IRC_SOAPParameter
89
+ {
90
+ private $m_szName;
91
+ private $m_szValue;
92
+ //private $m_lspaSOAPParamAttributeList = array();
93
+ private $m_lspaSOAPParamAttributeList;
94
+ private $m_lspSOAPParamList;
95
+
96
+ //public property functions
97
+ public function getName()
98
+ {
99
+ return $this->m_szName;
100
+ }
101
+ public function getValue()
102
+ {
103
+ return $this->m_szValue;
104
+ }
105
+ public function setValue($szValue)
106
+ {
107
+ $this->m_szValue = $szValue;
108
+ }
109
+ public function getSOAPParamAttributeList()
110
+ {
111
+ return $this->m_lspaSOAPParamAttributeList;
112
+ }
113
+ public function getSOAPParamList()
114
+ {
115
+ return $this->m_lspSOAPParamList;
116
+ }
117
+
118
+ //constructor
119
+ public function __construct($szName, $szValue, IRC_SOAPParamAttributeList $lspaSOAPParamAttributeList = null)
120
+ {
121
+ $nCount = 0;
122
+ $spaSOAPParamAttribute = null;
123
+
124
+ if (!is_string($szName) ||
125
+ !is_string($szValue))
126
+ {
127
+ throw new Exception('Invalid parameter type');
128
+ }
129
+
130
+ $this->m_szName = $szName;
131
+ //$this->m_szValue = SharedFunctions::replaceCharsInStringWithEntities($szValue);
132
+ $this->setValue($szValue);
133
+
134
+ $this->m_lspSOAPParamList = new IRC_SOAPParamList();
135
+ $this->m_lspaSOAPParamAttributeList = new IRC_SOAPParamAttributeList();
136
+
137
+ if ($lspaSOAPParamAttributeList != null)
138
+ {
139
+ for ($nCount = 0; $nCount < $lspaSOAPParamAttributeList->getCount();$nCount++)
140
+ {
141
+ $spaSOAPParamAttribute = new IRC_SOAPParamAttribute($lspaSOAPParamAttributeList->getAt($nCount)->getName(), $lspaSOAPParamAttributeList->getAt($nCount)->getValue());
142
+
143
+ $this->m_lspaSOAPParamAttributeList->add($spaSOAPParamAttribute);
144
+ }
145
+ }
146
+ }
147
+
148
+ function toXMLString()
149
+ {
150
+ $sbReturnString = null;
151
+ $nCount = null;
152
+ $spParam = null;
153
+ $spaAttribute = null;
154
+ $sbString = null;
155
+
156
+ $sbReturnString = '';
157
+ $sbReturnString .= '<' . $this->getName();
158
+
159
+ if ($this->m_lspaSOAPParamAttributeList != null)
160
+ {
161
+ for ($nCount = 0; $nCount < $this->m_lspaSOAPParamAttributeList->getCount(); $nCount++)
162
+ {
163
+ $spaAttribute = $this->m_lspaSOAPParamAttributeList->getAt($nCount);
164
+
165
+ if ($spaAttribute != null)
166
+ {
167
+ $sbString = '';
168
+ $sbString .= ' ' .$spaAttribute->getName(). '="' .IRC_SharedFunctions::replaceCharsInStringWithEntities($spaAttribute->getValue()). '"';
169
+ $sbReturnString .= (string)$sbString;
170
+ }
171
+ }
172
+ }
173
+
174
+ if ($this->m_lspSOAPParamList->getCount() == 0 &&
175
+ $this->getValue() == '')
176
+ {
177
+ $sbReturnString .= ' />';
178
+ }
179
+ else
180
+ {
181
+ $sbReturnString .= '>';
182
+
183
+ if ($this->getValue() != '')
184
+ {
185
+ $sbReturnString .= IRC_SharedFunctions::replaceCharsInStringWithEntities($this->getValue());
186
+ }
187
+
188
+ for ($nCount = 0; $nCount < $this->m_lspSOAPParamList->getCount(); $nCount++)
189
+ {
190
+ $spParam = $this->m_lspSOAPParamList->getAt($nCount);
191
+
192
+ if ($spParam != null)
193
+ {
194
+ $sbReturnString .= $spParam->toXMLString();
195
+ }
196
+ }
197
+
198
+ $sbReturnString .= '</' . $this->getName() . '>';
199
+ }
200
+
201
+ return (string)$sbReturnString;
202
+ }
203
+ }
204
+
205
+ class IRC_SOAPParamList
206
+ {
207
+ private $m_lspSOAPParamList;
208
+
209
+ public function getAt($nIndex)
210
+ {
211
+ if ($nIndex < 0 ||
212
+ $nIndex > count($this->m_lspSOAPParamList))
213
+ {
214
+ throw new Exception('Array index out of bounds');
215
+ }
216
+
217
+ return $this->m_lspSOAPParamList[$nIndex];
218
+ }
219
+
220
+ function getCount()
221
+ {
222
+ return count($this->m_lspSOAPParamList);
223
+ }
224
+
225
+ protected function add1(IRC_SOAPParameter $spSOAPParam)
226
+ {
227
+ $this->m_lspSOAPParamList[] = $spSOAPParam;
228
+ }
229
+ protected function add2($szName, $szValue)
230
+ {
231
+ $nReturnValue = -1;
232
+
233
+ if (!is_string($szName) ||
234
+ !is_string($szValue))
235
+ {
236
+ throw new Exception('Invalid parameter type: '. $szName .', '. $szValue);
237
+ }
238
+
239
+ if ($szName != '' &&
240
+ $szName != null)
241
+ {
242
+ $this->m_lspSOAPParamList[] = new IRC_SOAPParameter($szName, $szValue);
243
+ }
244
+
245
+ return $nReturnValue;
246
+ }
247
+
248
+ //overloading
249
+ public function add()
250
+ {
251
+ $num_args = func_num_args();
252
+ $args = func_get_args();
253
+
254
+ switch ($num_args)
255
+ {
256
+ case 1:
257
+ //$this->__call('add1', $args);
258
+ $this->add1($args[0]);
259
+ break;
260
+ case 2:
261
+ //$this->__call('add2', $args);
262
+ $this->add2($args[0], $args[1]);
263
+ break;
264
+ default:
265
+ throw new Exception('Invalid number of parameters');
266
+ }
267
+ }
268
+
269
+ //constructor
270
+ public function __construct()
271
+ {
272
+ $this->m_lspSOAPParamList = array();
273
+ }
274
+ }
275
+
276
+ class IRC_SOAPParamAttribute
277
+ {
278
+ private $m_szName;
279
+ private $m_szValue;
280
+
281
+ public function getName()
282
+ {
283
+ return $this->m_szName;
284
+ }
285
+ public function getValue()
286
+ {
287
+ return $this->m_szValue;
288
+ }
289
+
290
+ //constructor
291
+ public function __construct($szName, $szValue)
292
+ {
293
+ if (!is_string($szName) ||
294
+ !is_string($szValue))
295
+ {
296
+ throw new Exception('Invalid parameter type');
297
+ }
298
+
299
+ $this->m_szName = $szName;
300
+ $this->m_szValue = $szValue;
301
+ }
302
+ }
303
+
304
+ class IRC_SOAPParamAttributeList
305
+ {
306
+ private $m_lspaSOAPParamAttributeAttributeList;
307
+
308
+ public function getAt($nIndex)
309
+ {
310
+ if ($nIndex < 0 ||
311
+ $nIndex >= count($this->m_lspaSOAPParamAttributeAttributeList))
312
+ {
313
+ throw new Exception('Array index out of bounds');
314
+ }
315
+
316
+ return $this->m_lspaSOAPParamAttributeAttributeList[$nIndex];
317
+ }
318
+ public function getCount()
319
+ {
320
+ return count($this->m_lspaSOAPParamAttributeAttributeList);
321
+ }
322
+
323
+ private function add1(IRC_SOAPParamAttribute $spaSOAPParamAttributeAttribute)
324
+ {
325
+ $result = array_push($this->m_lspaSOAPParamAttributeAttributeList, $spaSOAPParamAttributeAttribute);
326
+ return $result;
327
+ }
328
+ private function add2($szName, $szValue)
329
+ {
330
+ $nReturnValue = -1;
331
+
332
+ if (!is_string($szName) ||
333
+ !is_string($szValue))
334
+ {
335
+ throw new Exception('Invalid parameter type');
336
+ }
337
+
338
+ if ($szName != '' &&
339
+ $szName != null)
340
+ {
341
+ $nReturnValue = array_push($this->m_lspaSOAPParamAttributeAttributeList, new IRC_SOAPParamAttribute($szName, $szValue));
342
+ }
343
+
344
+ return $nReturnValue;
345
+ }
346
+
347
+
348
+ public function add()
349
+ {
350
+ $num_args = func_num_args();
351
+ $args = func_get_args();
352
+
353
+ switch ($num_args)
354
+ {
355
+ case 1:
356
+ //$this->__call('add1', $args);
357
+ $this->add1($args[0]);
358
+ break;
359
+ case 2:
360
+ //$this->__call('add2', $args);
361
+ $this->add2($args[0], $args[1]);
362
+ break;
363
+ default:
364
+ throw new Exception('Invalid number of parameters for fucntion Add');
365
+ }
366
+ }
367
+
368
+ //constructor
369
+ public function __construct()
370
+ {
371
+ $this->m_lspaSOAPParamAttributeAttributeList = array();
372
+ }
373
+ }
374
+
375
+ class IRC_SOAP
376
+ {
377
+ private $m_szMethod;
378
+ private $m_szMethodURI;
379
+ private $m_szURL;
380
+ private $m_szActionURI;
381
+ private $m_szSOAPEncoding;
382
+ private $m_boPacketBuilt;
383
+ private $m_szLastResponse;
384
+ private $m_szSOAPPacket;
385
+ private $m_xmlParser;
386
+ private $m_xmlTag;
387
+ private $m_nTimeout;
388
+ private $m_eLastException;
389
+
390
+ private $m_lsnSOAPNamespaceList;
391
+ private $m_lspSOAPParamList;
392
+
393
+ //public property like functions
394
+ public function getMethod()
395
+ {
396
+ return $this->m_szMethod;
397
+ }
398
+ public function getMethodURI()
399
+ {
400
+ return $this->m_szMethodURI;
401
+ }
402
+ public function getURL()
403
+ {
404
+ return $this->m_szURL;
405
+ }
406
+ public function setURL($value)
407
+ {
408
+ $this->m_szURL = $value;
409
+ }
410
+ public function getActionURI()
411
+ {
412
+ return $this->m_szActionURI;
413
+ }
414
+ public function getSOAPEncoding()
415
+ {
416
+ return $this->m_szSOAPEncoding;
417
+ }
418
+ public function getPacketBuilt()
419
+ {
420
+ return $this->m_boPacketBuilt;
421
+ }
422
+ public function getLastResponse()
423
+ {
424
+ return $this->m_szLastResponse;
425
+ }
426
+ public function getSOAPPacket()
427
+ {
428
+ return $this->m_szSOAPPacket;
429
+ }
430
+ public function getXmlTag()
431
+ {
432
+ return $this->m_xmlTag;
433
+ }
434
+ public function getTimeout()
435
+ {
436
+ return $this->m_nTimeout;
437
+ }
438
+ public function setTimeout($value)
439
+ {
440
+ $this->m_nTimeout = $value;
441
+ }
442
+ public function getLastException()
443
+ {
444
+ $this->m_eLastException;
445
+ }
446
+
447
+ public function buildPacket()
448
+ {
449
+ $sbString = null;
450
+ $sbString2 = null;
451
+ $snNamespace = null;
452
+ $szFirstNamespace = null;
453
+ $szFirstPrefix = null;
454
+ $nCount = 0;
455
+ $spSOAPParam = null;
456
+
457
+ // build the xml SOAP request
458
+ // start with the XML version
459
+ $sbString = '';
460
+ $sbString .= '<?xml version="1.0" encoding="utf-8" ?>';
461
+
462
+ if ($this->m_lsnSOAPNamespaceList->getCount() == 0)
463
+ {
464
+ $szFirstNamespace = 'http://schemas.xmlsoap.org/soap/envelope/';
465
+ $szFirstPrefix = 'soap';
466
+ }
467
+ else
468
+ {
469
+ $snNamespace = $this->m_lsnSOAPNamespaceList->getAt(0);
470
+
471
+ if ($snNamespace == null)
472
+ {
473
+ $szFirstNamespace = 'http://schemas.xmlsoap.org/soap/envelope/';
474
+ $szFirstPrefix = 'soap';
475
+ }
476
+ else
477
+ {
478
+ if ($snNamespace->getNamespace() == null ||
479
+ $snNamespace->getNamespace() == '')
480
+ {
481
+ $szFirstNamespace = 'http://schemas.xmlsoap.org/soap/envelope/';
482
+ }
483
+ else
484
+ {
485
+ $szFirstNamespace = $snNamespace->getNamespace();
486
+ }
487
+
488
+ if ($snNamespace->getPrefix() == null ||
489
+ $snNamespace->getPrefix() == '')
490
+ {
491
+ $szFirstPrefix = 'soap';
492
+ }
493
+ else
494
+ {
495
+ $szFirstPrefix = $snNamespace->getPrefix();
496
+ }
497
+ }
498
+ }
499
+
500
+ $sbString2 = '';
501
+ $sbString2 .= '<' .$szFirstPrefix. ':Envelope xmlns:' .$szFirstPrefix. '="' .$szFirstNamespace. '"';
502
+
503
+ for ($nCount = 1; $nCount <$this->m_lsnSOAPNamespaceList->getCount(); $nCount++)
504
+ {
505
+ $snNamespace = $this->m_lsnSOAPNamespaceList->getAt($nCount);
506
+
507
+ if ($snNamespace != null)
508
+ {
509
+ if ($snNamespace->getNamespace() != '' &&
510
+ $snNamespace->getPrefix() != '')
511
+ {
512
+ $sbString2 .= ' xmlns:' .$snNamespace->getPrefix(). '="' .$snNamespace->getNamespace(). '"';
513
+ }
514
+ }
515
+ }
516
+
517
+ $sbString2 .= '>';
518
+
519
+ $sbString .= (string)$sbString2;
520
+ $sbString2 = '';
521
+ $sbString2 .= '<' .$szFirstPrefix. ':Body>';
522
+ $sbString .= (string)$sbString2;
523
+ $sbString2 = '';
524
+ $sbString2 .= '<' .$this->getMethod(). ' xmlns="' .$this->getMethodURI(). '">';
525
+ $sbString .= (string)$sbString2;
526
+
527
+ for ($nCount = 0;$nCount < $this->m_lspSOAPParamList->getCount(); $nCount++)
528
+ {
529
+ $spSOAPParam = $this->m_lspSOAPParamList->getAt($nCount);
530
+
531
+ if ($spSOAPParam != null)
532
+ {
533
+ $sbString .= $spSOAPParam->toXMLString();
534
+ }
535
+ }
536
+
537
+ $sbString2 = '';
538
+ $sbString2 .= '</' .$this->getMethod(). '>';
539
+ $sbString .= (string)$sbString2;
540
+ $sbString2 = '';
541
+ $sbString2 .= '</' .$szFirstPrefix. ':Body></' .$szFirstPrefix. ':Envelope>';
542
+ $sbString .= (string)$sbString2;
543
+
544
+ $this->m_szSOAPPacket = (string)$sbString;
545
+ $this->m_boPacketBuilt = true;
546
+ }
547
+
548
+ public function sendRequest(&$ResponseDocument, &$ResponseMethod)
549
+ {
550
+ $szString = ''; //response string
551
+ $sbString;
552
+ $XmlDoc; //response in parsed array format
553
+ $boReturnValue = false;
554
+ $szUserAgent = 'ThePaymentGateway SOAP Library PHP';
555
+
556
+
557
+ if (!$this->m_boPacketBuilt)
558
+ {
559
+ $this->buildPacket();
560
+ }
561
+
562
+ $this->m_xmlParser = null;
563
+ $this->m_xmlTag = null;
564
+
565
+ try
566
+ {
567
+ //intialising the curl for XML parsing
568
+ $cURL = curl_init();
569
+
570
+ //http settings
571
+ $HttpHeader[] = 'SOAPAction:'. $this->getActionURI();
572
+ $HttpHeader[] = 'Content-Type: text/xml; charset = utf-8';
573
+ $HttpHeader[] = 'Connection: close';
574
+
575
+ /*$http_options = array( CURLOPT_HEADER => false,
576
+ CURLOPT_HTTPHEADER => $HttpHeader,
577
+ CURLOPT_POST => true,
578
+ CURLOPT_URL => $this->getURL(),
579
+ CURLOPT_USERAGENT => $szUserAgent,
580
+ CURLOPT_POSTFIELDS => $this->getSOAPPacket(),
581
+ CURLOPT_RETURNTRANSFER => true,
582
+ CURLOPT_ENCODING => "UTF-8",
583
+ CURLOPT_SSL_VERIFYPEER => false, //disabling default peer SSL certificate verification
584
+ );
585
+
586
+ curl_setopt_array($cURL, $http_options);*/
587
+
588
+ curl_setopt($cURL, CURLOPT_HEADER, false);
589
+ curl_setopt($cURL, CURLOPT_HTTPHEADER, $HttpHeader);
590
+ curl_setopt($cURL, CURLOPT_POST, true);
591
+ curl_setopt($cURL, CURLOPT_URL, $this->getURL());
592
+ curl_setopt($cURL, CURLOPT_USERAGENT, $szUserAgent);
593
+ curl_setopt($cURL, CURLOPT_POSTFIELDS, $this->getSOAPPacket());
594
+ curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true);
595
+ curl_setopt($cURL, CURLOPT_ENCODING, "UTF-8");
596
+ curl_setopt($cURL, CURLOPT_SSL_VERIFYPEER, false);
597
+
598
+ if ($this->getTimeout() != null)
599
+ {
600
+ curl_setopt($cURL, CURLOPT_TIMEOUT, $this->getTimeout());
601
+ }
602
+
603
+ //$this->m_szLastResponse = curl_exec($cURL);
604
+ $szString = curl_exec($cURL);
605
+ $errorNo = curl_errno($cURL);//test
606
+ $errorMsg = curl_error($cURL);//test
607
+ $header = curl_getinfo($cURL);//test
608
+ curl_close($cURL);
609
+
610
+ $this->m_szLastResponse = $szString;
611
+
612
+ $szString = str_replace("<soap:", '<soap', $szString);
613
+ $szString = str_replace("</soap:", '</soap', $szString);
614
+
615
+ $XmlDoc = new SimpleXMLElement($szString);
616
+ $ResponseDocument = $XmlDoc->soapBody;
617
+ $ResponseMethod = $this->getMethod(). 'Response';
618
+
619
+ $boReturnValue = true;
620
+ }
621
+ catch (Exception $exc)
622
+ {
623
+ $boReturnValue = false;
624
+ $m_eLastException = $exc;
625
+ }
626
+
627
+ return $boReturnValue;
628
+ }
629
+
630
+ public function addParam1($szName, $szValue, IRC_SOAPParamAttributeList $lspaSOAPParamAttributeList = null)
631
+ {
632
+ $spSOAPParam;
633
+
634
+ $spSOAPParam = new IRC_SOAPParameter($szName, $szValue, $lspaSOAPParamAttributeList);
635
+
636
+ $this->addParam2($spSOAPParam, true);
637
+ }
638
+ public function addParam2(IRC_SOAPParameter $spSOAPParam, $boOverWriteValue)
639
+ {
640
+ $lszHierarchicalNames;
641
+ $nCurrentIndex = 0;
642
+ $szTagNameToFind;
643
+ $szString;
644
+ $nCount = 0;
645
+ $nCount2 = 0;
646
+ $lspParamList;
647
+ $spWorkingSOAPParam;
648
+ $spNewSOAPParam;
649
+ $boFound = false;
650
+ $lspaAttributeList;
651
+ $spaAttribute;
652
+ $spaNewAttribute;
653
+ $spaSOAPParamAttributeList;
654
+
655
+ // need to check the name of the incoming item to see if it is a
656
+ // complex soap parameter
657
+ $lszHierarchicalNames = new IRC_StringList();
658
+
659
+ $lszHierarchicalNames = IRC_SharedFunctions::getStringListFromCharSeparatedString($spSOAPParam->getName(), '.');
660
+
661
+ if ($lszHierarchicalNames->getCount() == 1)
662
+ {
663
+ $this->m_lspSOAPParamList->add($spSOAPParam);
664
+ }
665
+ else
666
+ {
667
+ $lspParamList = $this->m_lspSOAPParamList;
668
+
669
+ //complex
670
+ for ($nCount = 0; $nCount < $lszHierarchicalNames->getCount(); $nCount++)
671
+ {
672
+ // get the current tag name
673
+ $szString = (string)$lszHierarchicalNames->getAt($nCount);
674
+ //continuework
675
+ $szTagNameToFind = IRC_SharedFunctions::getArrayNameAndIndex($szString, $nCurrentIndex);
676
+
677
+ // first thing is to try to find the tag in the list
678
+ if ($boFound ||
679
+ $nCount == 0)
680
+ {
681
+ // try to find this tag name in the list
682
+ $spWorkingSOAPParam = IRC_Functions::isSOAPParamInParamList($lspParamList, $szTagNameToFind, $nCurrentIndex);
683
+
684
+ if ($spWorkingSOAPParam == null)
685
+ {
686
+ $boFound = false;
687
+ }
688
+ else
689
+ {
690
+ $boFound = true;
691
+
692
+ // is this the last item in the hierarchy?
693
+ if ($nCount == ($lszHierarchicalNames->getCount() - 1))
694
+ {
695
+ if ($boOverWriteValue)
696
+ {
697
+ // change the value
698
+ $spWorkingSOAPParam->setValue($spSOAPParam->getValue());
699
+ }
700
+
701
+ // add the attributes to the list
702
+ for ($nCount2 = 0; $nCount2 < $spSOAPParam->getSOAPParamAttributeList()->getCount(); $nCount2++)
703
+ {
704
+ //$spaAttribute = $spaSOAPParamAttributeList[$nCount2];
705
+ $spaAttribute = $spSOAPParam->getSOAPParamAttributeList()->getAt($nCount2);
706
+
707
+ if ($spaAttribute != null)
708
+ {
709
+ $spaNewAttribute = new IRC_SOAPParamAttribute($spaAttribute->getName(), $spaAttribute->getValue());
710
+
711
+ $spWorkingSOAPParam->getSOAPParamAttributeList()->add($spaNewAttribute);
712
+ }
713
+ }
714
+ }
715
+ $lspParamList = $spWorkingSOAPParam->getSOAPParamList();
716
+ }
717
+ }
718
+
719
+ if (!$boFound)
720
+ {
721
+ // is this the last tag?
722
+ if ($nCount == ($lszHierarchicalNames->getCount() - 1))
723
+ {
724
+ $lspaAttributeList = new IRC_SOAPParamAttributeList();
725
+
726
+ for ($nCount2 = 0; $nCount2 < $spSOAPParam->getSOAPParamAttributeList()->getCount(); $nCount2++)
727
+ {
728
+ $spaSOAPParamAttributeList = $spSOAPParam->getSOAPParamAttributeList();
729
+
730
+ $spaAttribute = $spaSOAPParamAttributeList->getAt( $nCount2);
731
+
732
+ if ($spaAttribute != null)
733
+ {
734
+ $spaNewAttribute = new IRC_SOAPParamAttribute($spaAttribute->getName(), $spaAttribute->getValue());
735
+ $lspaAttributeList->add($spaNewAttribute);
736
+ }
737
+ }
738
+
739
+ $spNewSOAPParam = new IRC_SOAPParameter($szTagNameToFind, $spSOAPParam->getValue(), $lspaAttributeList);
740
+
741
+ $lspParamList->add($spNewSOAPParam);
742
+ }
743
+ else
744
+ {
745
+ $spNewSOAPParam = new IRC_SOAPParameter($szTagNameToFind, '', null);
746
+ $lspParamList->add($spNewSOAPParam);
747
+ $lspParamList = $spNewSOAPParam->getSOAPParamList();
748
+ }
749
+ }
750
+ }
751
+ }
752
+
753
+ $this->m_boPacketBuilt = false;
754
+ }
755
+
756
+ //overloading for addParam
757
+ public function addParam()
758
+ {
759
+ //number of parameters passed into addParam()
760
+ $num_args = func_num_args();
761
+ //array of parameters passed into addParam()
762
+ $args = func_get_args();
763
+
764
+ switch ($num_args)
765
+ {
766
+ case 2:
767
+ if (is_string($args[0]) &&
768
+ is_string($args[1]))
769
+ {
770
+ //$this->__call('addParam1',$args);
771
+ //$this->addParam1($args[0], $args[1], $args[3]);
772
+ $this->addParam1($args[0], $args[1], null);
773
+ }
774
+ elseif ($args[0] instanceof IRC_SOAPParameter &&
775
+ is_bool($args[1]))
776
+ {
777
+ //$this->__call('addParam2', $args);
778
+ $this->addParam2($args[0], $args[1]);
779
+ }
780
+ else
781
+ {
782
+ throw new Exception('Invalid parameter list for function: addParam');
783
+ }
784
+ break;
785
+ case 3:
786
+ //$this->__call('addParam1', $args);
787
+ $this->addParam1($args[0], $args[1], $args[2]);
788
+ break;
789
+ default:
790
+ throw new Exception('Invalid number of parameters for function Add');
791
+ }
792
+ }
793
+
794
+ private function addParamAttribute1($szName, $szParamAttributeName, $szParamAttributeValue)
795
+ {
796
+ $spSOAPParam;
797
+ $lspaSOAPParamAttributeList;
798
+ $spaSOAPParamAttribute;
799
+
800
+ if (!is_string($szName) ||
801
+ !is_string($szParamAttributeName) ||
802
+ !is_string($szParamAttributeValue))
803
+ {
804
+ throw new Exception('Invalid parameter type');
805
+ }
806
+
807
+ $lspaSOAPParamAttributeList = new IRC_SOAPParamAttributeList();
808
+ $spaSOAPParamAttribute = new IRC_SOAPParamAttribute($szParamAttributeName, $szParamAttributeValue);
809
+ $lspaSOAPParamAttributeList->add($spaSOAPParamAttribute);
810
+
811
+ $spSOAPParam = new IRC_SOAPParameter($szName, '', $lspaSOAPParamAttributeList);
812
+
813
+ $this->addParam2($spSOAPParam, false);
814
+ }
815
+ private function addParamAttribute2($szName, IRC_SOAPParamAttribute $spaSOAPParamAttribute)
816
+ {
817
+ $spSOAPParam;
818
+ $lspaSOAPParamAttributeList;
819
+
820
+ $lspaSOAPParamAttributeList = new IRC_SOAPParamAttributeList();
821
+ $lspaSOAPParamAttributeList->add($spaSOAPParamAttribute);
822
+
823
+ $spSOAPParam = new IRC_SOAPParameter($szName, '', $lspaSOAPParamAttributeList);
824
+
825
+ $this->addParam2($spSOAPParam, false);
826
+ }
827
+
828
+ //overloading for addParamAttribute
829
+ public function addParamAttribute()
830
+ {
831
+ $num_args = func_num_args();
832
+ $args = func_get_args();
833
+
834
+ switch ($num_args)
835
+ {
836
+ case 2:
837
+ //$this->__call('addParamAttribute2', $args);
838
+ $this->addParamAttribute2($args[0], $args[1]);
839
+ break;
840
+ case 3:
841
+ //$this->__call('addParamAttribute1', $args);
842
+ $this->addParamAttribute1($args[0], $args[1], $args[2]);
843
+ break;
844
+ default:
845
+ throw new Exception('Invalid number of parameters for fucntion Add');
846
+ }
847
+ }
848
+
849
+ //overloading constructor
850
+ private function SOAP1($szMethod, $szMethodURI)
851
+ {
852
+ $this->SOAP3($szMethod, $szMethodURI, null, 'http://schemas.xmlsoap.org/soap/encoding/', true, null);
853
+ }
854
+ private function SOAP2($szMethod, $szMethodURI, $szURL)
855
+ {
856
+ $this->SOAP3($szMethod, $szMethodURI, $szURL, 'http://schemas.xmlsoap.org/soap/encoding/', true, null);
857
+ }
858
+ private function SOAP3($szMethod, $szMethodURI, $szURL, $szSOAPEncoding, $boAddDefaultNamespaces, IRC_SOAPNamespaceList $lsnSOAPNamespaceList = null)
859
+ {
860
+ $snSOAPNamespace;
861
+ $nCount = 0;
862
+
863
+ $this->m_szMethod = $szMethod;
864
+ $this->m_szMethodURI = $szMethodURI;
865
+ $this->m_szURL = $szURL;
866
+ $this->m_szSOAPEncoding = $szSOAPEncoding;
867
+
868
+ if ($this->m_szMethodURI != "" &&
869
+ $this->m_szMethod != "")
870
+ {
871
+ if ($this->m_szMethodURI[(strlen($this->m_szMethodURI) - 1)] == '/')
872
+ {
873
+ $this->m_szActionURI = $this->m_szMethodURI . $this->m_szMethod;
874
+ }
875
+ else
876
+ {
877
+ $this->m_szActionURI = $this->m_szMethodURI . '/' . $this->m_szMethod;
878
+ }
879
+ }
880
+
881
+ $this->m_lsnSOAPNamespaceList = new IRC_SOAPNamespaceList();
882
+
883
+ if ($boAddDefaultNamespaces)
884
+ {
885
+ $snSOAPNamespace = new IRC_SOAPNamespace('soap', 'http://schemas.xmlsoap.org/soap/envelope/');
886
+ $this->m_lsnSOAPNamespaceList->add($snSOAPNamespace);
887
+ $snSOAPNamespace = new IRC_SOAPNamespace('xsi', 'http://www.w3.org/2001/XMLSchema-instance');
888
+ $this->m_lsnSOAPNamespaceList->add($snSOAPNamespace);
889
+ $snSOAPNamespace = new IRC_SOAPNamespace('xsd', 'http://www.w3.org/2001/XMLSchema');
890
+ $this->m_lsnSOAPNamespaceList->add($snSOAPNamespace);
891
+ }
892
+ if ($lsnSOAPNamespaceList != null)
893
+ {
894
+ for ($nCount = 0; $nCount < count($lsnSOAPNamespaceList); $nCount++)
895
+ {
896
+ $snSOAPNamespace = new IRC_SOAPNamespace($lsnSOAPNamespaceList->getAt($nCount)->getPrefix(), $lsnSOAPNamespaceList->getAt($nCount)->getNamespace());
897
+ $this->m_lsnSOAPNamespaceList->add($snSOAPNamespace);
898
+ }
899
+ }
900
+ $this->m_lspSOAPParamList = new IRC_SOAPParamList();
901
+
902
+ $this->m_boPacketBuilt = false;
903
+ }
904
+
905
+ //constructor
906
+ public function __construct()
907
+ {
908
+ $num_args = func_num_args();
909
+ $args = func_get_args();
910
+
911
+ switch ($num_args)
912
+ {
913
+ case 2:
914
+ //$this->__call('SOAP1', $args);
915
+ $this->SOAP1($args[0], $args[1]);
916
+ break;
917
+ case 3:
918
+ //$this->__call('SOAP2', $args);
919
+ $this->SOAP2($args[0], $args[1], $args[2]);
920
+ break;
921
+ case 6:
922
+ //$this->__call('SOAP3', $args);
923
+ $this->SOAP3($args[0], $args[1], $args[2], $args[3], $args[4], $args[5]);
924
+ default:
925
+ throw new Exception('Invalid number of parameters for constructor SOAP');
926
+ }
927
+ }
928
+ }
929
+
930
+ class IRC_Functions
931
+ {
932
+ public static function isSOAPParamInParamList(IRC_SOAPParamList $lspParamList, $szTagNameToFind, $nIndex)
933
+ {
934
+ $spReturnParam = null;
935
+ $boFound = false;
936
+ $nFound = 0;
937
+ $nCount = 0;
938
+ $spCurrentParam = null;
939
+
940
+ if ($lspParamList == null)
941
+ {
942
+ return (null);
943
+ }
944
+
945
+ while(!$boFound &&
946
+ $nCount < $lspParamList->getCount())
947
+ {
948
+ $spCurrentParam = $lspParamList->getAt($nCount);
949
+
950
+ if ($spCurrentParam->getName() == $szTagNameToFind)
951
+ {
952
+ if ($nFound == $nIndex)
953
+ {
954
+ $boFound = true;
955
+ $spReturnParam = $spCurrentParam;
956
+ }
957
+ else
958
+ {
959
+ $nFound++;
960
+ }
961
+ }
962
+
963
+ $nCount++;
964
+ }
965
+
966
+ return $spReturnParam;
967
+ }
968
+ }
app/code/local/Iridiumcorp/Tpg/Model/Tpg/ThePaymentGateway/TPG_Common.php ADDED
@@ -0,0 +1,882 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //XMLEntities
3
+ $g_XMLEntities = array();
4
+ $g_XMLEntities[] = new IRC_XMLEntity(0x26, "&amp;");
5
+ $g_XMLEntities[] = new IRC_XMLEntity(0x22, "&quot;");
6
+ $g_XMLEntities[] = new IRC_XMLEntity(0x27, "&apos;");
7
+ $g_XMLEntities[] = new IRC_XMLEntity(0x3c, "&lt;");
8
+ $g_XMLEntities[] = new IRC_XMLEntity(0x3e, "&gt;");
9
+
10
+ abstract class IRC_Nullable
11
+ {
12
+ protected $m_boHasValue;
13
+
14
+ function getHasValue()
15
+ {
16
+ return $this->m_boHasValue;
17
+ }
18
+
19
+ public function __construct()
20
+ {
21
+ $this->m_boHasValue = false;
22
+ }
23
+ }
24
+
25
+ class IRC_NullableInt extends IRC_Nullable
26
+ {
27
+ private $m_nValue;
28
+
29
+ function getValue()
30
+ {
31
+ if ($this->m_boHasValue == false)
32
+ {
33
+ throw new Exception('Object has no value');
34
+ }
35
+
36
+ return $this->m_nValue;
37
+ }
38
+ function setValue($value)
39
+ {
40
+ $this->m_boHasValue = true;
41
+ $this->m_nValue = $value;
42
+ }
43
+
44
+ //constructor
45
+ public function __construct($nValue)
46
+ {
47
+ IRC_Nullable::__construct();
48
+
49
+ $this->setValue($nValue);
50
+ }
51
+ }
52
+
53
+ class IRC_NullableBool extends IRC_Nullable
54
+ {
55
+ private $m_boValue;
56
+
57
+ public function getValue()
58
+ {
59
+ if ($this->m_boHasValue == false)
60
+ {
61
+ throw new Exception("Object has no value");
62
+ }
63
+
64
+ return ($this->m_boValue);
65
+ }
66
+ public function setValue($value)
67
+ {
68
+ $this->m_boHasValue = true;
69
+ $this->m_boValue = $value;
70
+ }
71
+
72
+ //constructor
73
+ public function __construct($boValue)
74
+ {
75
+ IRC_Nullable::__construct();
76
+
77
+ $this->setValue($boValue);
78
+ }
79
+ }
80
+
81
+ /******************/
82
+ /* Common classes */
83
+ /******************/
84
+ class IRC_StringList
85
+ {
86
+ private $m_lszStrings;
87
+
88
+ public function getAt($nIndex)
89
+ {
90
+ if ($nIndex < 0 ||
91
+ $nIndex >= count($this->m_lszStrings))
92
+ {
93
+ throw new Exception('Array index out of bounds');
94
+ }
95
+
96
+ return (string)($this->m_lszStrings[$nIndex]);
97
+ }
98
+
99
+ function getCount()
100
+ {
101
+ return count($this->m_lszStrings);
102
+ }
103
+
104
+ function add($szString)
105
+ {
106
+ if (!is_string($szString))
107
+ {
108
+ throw new Exception('Invalid parameter type');
109
+ }
110
+
111
+ return ($this->m_lszStrings[] = $szString);
112
+ }
113
+
114
+ //constructor
115
+ function __construct()
116
+ {
117
+ $this->m_lszStrings = array();
118
+ }
119
+ }
120
+
121
+ class IRC_ISOCountry
122
+ {
123
+ private $m_szCountryName;
124
+ private $m_szCountryShort;
125
+ private $m_nISOCode;
126
+ private $m_nListPriority;
127
+
128
+ //public properties
129
+ public function getCountryName()
130
+ {
131
+ return $this->m_szCountryName;
132
+ }
133
+ public function getCountryShort()
134
+ {
135
+ return $this->m_szCountryShort;
136
+ }
137
+ public function getISOCode()
138
+ {
139
+ return $this->m_nISOCode;
140
+ }
141
+ public function getListPriority()
142
+ {
143
+ return $this->m_nListPriority;
144
+ }
145
+
146
+ //constructor
147
+ public function __construct($nISOCode, $szCountryName, $szCountryShort, $nListPriority)
148
+ {
149
+ if (!is_int($nISOCode) ||
150
+ !is_string($szCountryName) ||
151
+ !is_string($szCountryShort) ||
152
+ !is_int($nListPriority))
153
+ {
154
+ throw new Exception('Invalid parameter type');
155
+ }
156
+
157
+ $this->m_nISOCode = $nISOCode;
158
+ $this->m_szCountryName = $szCountryName;
159
+ $this->m_szCountryShort = $szCountryShort;
160
+ $this->m_nListPriority = $nListPriority;
161
+ }
162
+ }
163
+
164
+ class IRC_ISOCountryList
165
+ {
166
+ private $m_licISOCountries;
167
+
168
+ public function getISOCountry($szCountryShort, IRC_ISOCountry &$icISOCountry = null)
169
+ {
170
+ $boFound = false;
171
+ $nCount = 0;
172
+ $icISOCountry2;
173
+
174
+ $icISOCountry = null;
175
+
176
+ while(!$boFound &&
177
+ $nCount < count($this->m_licISOCountries))
178
+ {
179
+ $icISOCountry2 = $this->m_licISOCountries[$nCount];
180
+
181
+ if ($szCountryShort == $icISOCountry2->getCountryShort())
182
+ {
183
+ $icISOCountry = new IRC_ISOCountry($icISOCountry2->getISOCode(), $icISOCountry2->getCountryName(), $icISOCountry2->getCountryShort(), $icISOCountry2->getListPriority());
184
+ $boFound = true;
185
+ }
186
+
187
+ $nCount++;
188
+ }
189
+
190
+ return $boFound;
191
+ }
192
+
193
+ public function getCount()
194
+ {
195
+ return count($this->m_licISOCountries);
196
+ }
197
+
198
+ public function getAt($nIndex)
199
+ {
200
+ if ($nIndex < 0 ||
201
+ $nIndex >= count($this->m_licISOCountries))
202
+ {
203
+ throw new Exception('Array index out of bounds');
204
+ }
205
+
206
+ return $this->m_licISOCountries[$nIndex];
207
+ }
208
+
209
+ public function add($nISOCode, $szCountryName, $szCountryShort, $nListPriority)
210
+ {
211
+ $newISOCountry = new IRC_ISOCountry($nISOCode, $szCountryName, $szCountryShort, $nListPriority);
212
+
213
+ $this->m_licISOCountries[] = $newISOCountry;
214
+ }
215
+
216
+ //constructor
217
+ public function __construct()
218
+ {
219
+ $this->m_licISOCountries = array();
220
+ }
221
+ }
222
+
223
+ class IRC_ISOCurrency
224
+ {
225
+ private $m_nExponent;
226
+ private $m_nISOCode;
227
+ private $m_szCurrency;
228
+ private $m_szCurrencyShort;
229
+
230
+ //public properties
231
+ public function getExponent()
232
+ {
233
+ return $this->m_nExponent;
234
+ }
235
+
236
+ public function getCurrency()
237
+ {
238
+ return $this->m_szCurrency;
239
+ }
240
+
241
+ public function getCurrencyShort()
242
+ {
243
+ return $this->m_szCurrencyShort;
244
+ }
245
+
246
+ public function getISOCode()
247
+ {
248
+ return $this->m_nISOCode;
249
+ }
250
+
251
+
252
+ public function getAmountCurrencyString($nAmount, $boAppendCurrencyShort = true)
253
+ {
254
+ $szReturnString = "";
255
+
256
+ $nDivideAmount = pow(10, $this->m_nExponent);
257
+ $lfAmount = $nAmount / $nDivideAmount;
258
+
259
+ $szFormatString = "%.".$this->m_nExponent."f";
260
+ $szReturnString = sprintf($szFormatString, $lfAmount);
261
+
262
+ if ($boAppendCurrencyShort)
263
+ {
264
+ $szReturnString = $szReturnString." ".$this->m_szCurrencyShort;
265
+ }
266
+
267
+ return ($szReturnString);
268
+ }
269
+
270
+
271
+ //constructor
272
+ public function __construct($nISOCode, $szCurrency, $szCurrencyShort, $nExponent)
273
+ {
274
+ $this->m_nISOCode = $nISOCode;
275
+ $this->m_nExponent = $nExponent;
276
+ $this->m_szCurrency = $szCurrency;
277
+ $this->m_szCurrencyShort = $szCurrencyShort;
278
+ }
279
+ }
280
+
281
+ class IRC_ISOCurrencyList
282
+ {
283
+ private $m_licISOCurrencies;
284
+
285
+ public function getISOCurrency($szCurrencyShort, IRC_ISOCurrency &$icISOCurrency = null)
286
+ {
287
+ $boFound = false;
288
+ $nCount = 0;
289
+ $icISOCurrency2;
290
+
291
+ $icISOCurrency = null;
292
+
293
+ while (!$boFound &&
294
+ $nCount < count($this->m_licISOCurrencies))
295
+ {
296
+ $icISOCurrency2 = $this->m_licISOCurrencies[$nCount];
297
+
298
+ if ($szCurrencyShort == $icISOCurrency2->getCurrencyShort())
299
+ {
300
+ $icISOCurrency = new IRC_ISOCurrency($icISOCurrency2->getISOCode(), $icISOCurrency2->getCurrency(),$icISOCurrency2->getCurrencyShort(), $icISOCurrency2->getExponent());
301
+ $boFound = true;
302
+ }
303
+
304
+ $nCount++;
305
+ }
306
+
307
+ return ($boFound);
308
+ }
309
+
310
+ public function getCount()
311
+ {
312
+ return count($this->m_licISOCurrencies);
313
+ }
314
+
315
+ public function getAt($nIndex)
316
+ {
317
+ if ($nIndex < 0 ||
318
+ $nIndex >= count($this->m_licISOCurrencies))
319
+ {
320
+ throw new Exception('Array index out of bounds');
321
+ }
322
+
323
+ return $this->m_licISOCurrencies[$nIndex];
324
+ }
325
+
326
+ public function add($nISOCode, $szCurrency, $szCurrencyShort, $nExponent)
327
+ {
328
+ $newISOCurrency = new IRC_ISOCurrency($nISOCode, $szCurrency, $szCurrencyShort, $nExponent);
329
+
330
+ $this->m_licISOCurrencies[] = $newISOCurrency;
331
+ }
332
+
333
+ //constructor
334
+ public function __construct()
335
+ {
336
+ $this->m_licISOCurrencies = array();
337
+ }
338
+ }
339
+
340
+ class IRC_XMLEntity
341
+ {
342
+ private $m_bCharCode;
343
+ private $m_szReplacement;
344
+
345
+ public function getCharCode()
346
+ {
347
+ return $this->m_bCharCode;
348
+ }
349
+ public function getReplacement()
350
+ {
351
+ return $this->m_szReplacement;
352
+ }
353
+
354
+ //constructor
355
+ public function __construct($bCharCode, $szReplacement)
356
+ {
357
+ $this->m_bCharCode = $bCharCode;
358
+ $this->m_szReplacement = $szReplacement;
359
+ }
360
+ }
361
+
362
+ class IRC_SharedFunctions
363
+ {
364
+ public static function getNamedTagInTagList($szName, $xtlTagList)
365
+ {
366
+ $lszHierarchicalNames = null;
367
+ $nCount = 0;
368
+ $boAbort = false;
369
+ $boFound = false;
370
+ $boLastNode = false;
371
+ $szString;
372
+ $szTagNameToFind;
373
+ $nCurrentIndex = 0;
374
+ $xtReturnTag = null;
375
+ $xtCurrentTag = null;
376
+ $nTagCount = 0;
377
+ $xtlCurrentTagList = null;
378
+ $nCount2 = 0;
379
+
380
+ if (is_null($xtlTagList))
381
+ {
382
+ return null;
383
+ }
384
+
385
+ if (count($xtlTagList) == 0)
386
+ {
387
+ return null;
388
+ }
389
+
390
+ $lszHierarchicalNames = new IRC_StringList();
391
+
392
+ $lszHierarchicalNames = IRC_SharedFunctions::getStringListFromCharSeparatedString($szName, '.');
393
+
394
+ $xtlCurrentTagList = $xtlTagList;
395
+
396
+ // loop over the hierarchical list
397
+ for ($nCount = 0; $nCount <$lszHierarchicalNames->getCount() && !$boAbort; $nCount++)
398
+ {
399
+ if ($nCount == ($lszHierarchicalNames->getCount() - 1))
400
+ {
401
+ $boLastNode = true;
402
+ }
403
+
404
+ $szString = (string)$lszHierarchicalNames[$nCount];
405
+
406
+ // look to see if this tag name has the special "[]" array chars
407
+ $szTagNameToFind = IRC_SharedFunctions::getArrayNameAndIndex(szString, $nCurrentIndex);
408
+ $nCurrentIndex = $nIndex;
409
+
410
+ $boFound = false;
411
+ $nCount2 = 0;
412
+
413
+ for ($nTagCount = 0; $nTagCount < $xtlCurrentTagList->getCount() && !$boFound; $nTagCount++)
414
+ {
415
+ $xtCurrentTag = $xtlCurrentTagList->getXmlTagForIndex($nTagCount);
416
+
417
+ // if this is the last node then check the attributes of the tag first
418
+
419
+ if ($xtCurrentTag->getName() == $szTagNameToFind)
420
+ {
421
+ if ($nCount2 == $nCurrentIndex)
422
+ {
423
+ $boFound = true;
424
+ }
425
+ else
426
+ {
427
+ $nCount2++;
428
+ }
429
+ }
430
+
431
+ if ($boFound)
432
+ {
433
+ if (!$boLastNode)
434
+ {
435
+ $xtlCurrentTagList = $xtCurrentTag->getChildTags();
436
+ }
437
+ else
438
+ {
439
+ // don't continue the search
440
+ $xtReturnTag = $xtCurrentTag;
441
+ }
442
+ }
443
+ }
444
+
445
+ if (!$boFound)
446
+ {
447
+ $boAbort = true;
448
+ }
449
+ }
450
+
451
+ return $xtReturnTag;
452
+ }
453
+
454
+ public static function getStringListFromCharSeparatedString($szString, $cDelimiter)
455
+ {
456
+ $nCount = 0;
457
+ $nLastCount = -1;
458
+ $szSubString;
459
+ $nStringLength;
460
+ $lszStringList;
461
+
462
+ if ($szString == null ||
463
+ $szString == "" ||
464
+ (string)$cDelimiter == "")
465
+ {
466
+ return null;
467
+ }
468
+
469
+ $lszStringList = new IRC_StringList();
470
+
471
+ $nStringLength = strlen($szString);
472
+
473
+ for ($nCount = 0; $nCount < $nStringLength; $nCount++)
474
+ {
475
+ if ($szString[$nCount] == $cDelimiter)
476
+ {
477
+ $szSubString = substr($szString, ($nLastCount + 1), ($nCount - $nLastCount - 1));
478
+ $nLastCount = $nCount;
479
+ $lszStringList->add($szSubString);
480
+
481
+ if ($nCount == $nStringLength)
482
+ {
483
+ $lszStringList->add('');
484
+ }
485
+ }
486
+ else
487
+ {
488
+ if ($nCount == ($nStringLength - 1))
489
+ {
490
+ $szSubString = substr($szString, ($nLastCount + 1), ($nCount - $nLastCount));
491
+ $lszStringList->add($szSubString);
492
+ }
493
+ }
494
+ }
495
+
496
+ return $lszStringList;
497
+ }
498
+
499
+ public static function getValue($szXMLVariable, $xtlTagList, & $szValue)
500
+ {
501
+ $boReturnValue = false;
502
+ $lszHierarchicalNames;
503
+ $szXMLTagName;
504
+ $szLastXMLTagName;
505
+ $nCount = 0;
506
+ $xtCurrentTag = null;
507
+ $xaXmlAttribute = null;
508
+ $lXmlTagAttributeList;
509
+
510
+ if (xtlTagList == null)
511
+ {
512
+ $szValue = null;
513
+ return (false);
514
+ }
515
+
516
+ $lszHierarchicalNames = new IRC_StringList();
517
+ $szValue = null;
518
+ $lszHierarchicalNames = IRC_SharedFunctions::getStringListFromCharSeparatedString($szXMLVariable, '.');
519
+
520
+ if (count($lszHierarchicalNames) == 1)
521
+ {
522
+ $szXMLTagName = $lszHierarchicalNames->getAt(0);
523
+
524
+ $xtCurrentTag = IRC_SharedFunctions::GetNamedTagInTagList($szXMLTagName, $xtlTagList);
525
+
526
+ if ($xtCurrentTag != null)
527
+ {
528
+ $lXmlTagAttributeList = $xtCurrentTag->getAttributes();
529
+ $xaXmlAttribute = $lXmlTagAttributeList->getAt($szXMLTagName);
530
+
531
+ if ($xaXmlAttribute != null)
532
+ {
533
+ $szValue = $xaXmlAttribute->getValue();
534
+ $boReturnValue = true;
535
+ }
536
+ else
537
+ {
538
+ $szValue = $xtCurrentTag->getContent();
539
+ $boReturnValue = true;
540
+ }
541
+ }
542
+ }
543
+ else
544
+ {
545
+ if (count($lszHierarchicalNames) > 1)
546
+ {
547
+ $szXMLTagName = $lszHierarchicalNames->getAt(0);
548
+ $szLastXMLTagName = $lszHierarchicalNames->getAt(($lszHierarchicalNames->getCount() - 1));
549
+
550
+ // need to remove the last variable from the passed name
551
+ for ($nCount = 1; $nCount < ($lszHierarchicalNames->getCount() - 1); $nCount++)
552
+ {
553
+ $szXMLTagName .= "." . $lszHierarchicalNames->getAt($nCount);
554
+ }
555
+
556
+ $xtCurrentTag = IRC_SharedFunctions::getNamedTagInTagList($szXMLTagName, $xtlTagList);
557
+
558
+ // first check the attributes of this tag
559
+ if ($xtCurrentTag != null)
560
+ {
561
+ $lXmlTagAttributeList = $xtCurrentTag->getAttributes();
562
+ $xaXmlAttribute = $lXmlTagAttributeList->getXmlAttributeForAttributeName($szLastXMLTagName);
563
+
564
+ if ($xaXmlAttribute != null)
565
+ {
566
+ $szValue = $xaXmlAttribute->getValue();
567
+ $boReturnValue = true;
568
+ }
569
+ else
570
+ {
571
+ // check to see if it's actually a tag
572
+ $xtCurrentTag = IRC_SharedFunctions::getNamedTagInTagList($szLastXMLTagName, $xtCurrentTag->getChildTags());
573
+
574
+ if ($xtCurrentTag != null)
575
+ {
576
+ $szValue = IRC_SharedFunctions::replaceEntitiesInStringWithChars($xtCurrentTag->getContent());
577
+ $boReturnValue = true;
578
+ }
579
+ }
580
+ }
581
+ }
582
+ }
583
+
584
+ return $boReturnValue;
585
+ }
586
+
587
+ public static function getArrayNameAndIndex($szName, &$nIndex)
588
+ {
589
+ $szReturnString;
590
+ $nCount = 0;
591
+ $szSubString;
592
+ $boFound = false;
593
+ $boAbort = false;
594
+ $boAtLeastOneDigitFound = false;
595
+
596
+ if ($szName == '')
597
+ {
598
+ $nIndex = 0;
599
+ return $szName;
600
+ }
601
+
602
+ $szReturnString = $szName;
603
+ $nIndex = 0;
604
+
605
+ if ($szName[(strlen($szName) - 1)] == ']')
606
+ {
607
+ $nCount = strlen($szName) - 2;
608
+
609
+ while (!$boFound &&
610
+ !$boAbort &&
611
+ $nCount >= 0)
612
+ {
613
+ // if we've found the closing array brace
614
+ if ($szName[$nCount] == '[')
615
+ {
616
+ $boFound = true;
617
+ }
618
+ else
619
+ {
620
+ if (!is_numeric($szName[$nCount]))
621
+ {
622
+ $boAbort = true;
623
+ }
624
+ else
625
+ {
626
+ $boAtLeastOneDigitFound = true;
627
+ $nCount--;
628
+ }
629
+ }
630
+ }
631
+
632
+ // did we finish successfully?
633
+ if ($boFound &&
634
+ $boAtLeastOneDigitFound)
635
+ {
636
+ $szSubString = substr($szName, ($nCount + 1), (strlen($szName) - $nCount - 2));
637
+ $szReturnString = substr($szName, 0, $nCount);
638
+ $nIndex = (int)($szSubString);
639
+ }
640
+ }
641
+
642
+ return $szReturnString;
643
+ }
644
+
645
+ public static function stringToByteArray($str)
646
+ {
647
+ $encoded;
648
+
649
+ $encoded = utf8_encode($str);
650
+
651
+ return $encoded;
652
+ }
653
+
654
+ public static function byteArrayToString($aByte)
655
+ {
656
+ return utf8_decode($aByte);
657
+ }
658
+
659
+ public static function forwardPaddedNumberString($nNumber, $nPaddingAmount, $cPaddingChar)
660
+ {
661
+ $szReturnString;
662
+ $sbString;
663
+ $nCount = 0;
664
+
665
+ $szReturnString = (string)$nNumber;
666
+
667
+ if (strlen($szReturnString) < $nPaddingAmount &&
668
+ $nPaddingAmount > 0)
669
+ {
670
+ $sbString = '';
671
+
672
+ for ($nCount = 0; $nCount < ($nPaddingAmount - strlen($szReturnString)); $nCount++)
673
+ {
674
+ $sbString .= $cPaddingChar;
675
+ }
676
+
677
+ $sbString .= $szReturnString;
678
+ $szReturnString = (string)$sbString;
679
+ }
680
+
681
+ return $szReturnString;
682
+ }
683
+
684
+ public static function stripAllWhitespace($szString)
685
+ {
686
+ $sbReturnString;
687
+ $nCount = 0;
688
+
689
+ if ($szString == null)
690
+ {
691
+ return (null);
692
+ }
693
+
694
+ $sbReturnString = '';
695
+
696
+ for ($nCount = 0; $nCount < strlen($szString); $nCount++)
697
+ {
698
+ if ($szString[$nCount] != ' ' &&
699
+ $szString[$nCount] != '\t' &&
700
+ $szString[$nCount] != '\n' &&
701
+ $szString[$nCount] != '\r')
702
+ {
703
+ $sbReturnString .= $szString[$nCount];
704
+ }
705
+ }
706
+
707
+ return (string)$sbReturnString;
708
+ }
709
+
710
+ public static function getAmountCurrencyString($nAmount, $nExponent)
711
+ {
712
+ $szReturnString = "";
713
+ $lfAmount;
714
+ $nDivideAmount;
715
+
716
+ $nDivideAmount = (int)(pow(10, $nExponent));
717
+ $lfAmount = (double)($nAmount/$nDivideAmount);
718
+ $szReturnString = (string)$lfAmount;
719
+
720
+ return ($szReturnString);
721
+ }
722
+
723
+ public static function isStringNullOrEmpty($szString)
724
+ {
725
+ $boReturnValue = false;
726
+
727
+ if ($szString == null ||
728
+ $szString == '')
729
+ {
730
+ $boReturnValue = true;
731
+ }
732
+
733
+ return ($boReturnValue);
734
+ }
735
+
736
+ public static function replaceCharsInStringWithEntities($szString)
737
+ {
738
+ //give access to enum like associated array
739
+ global $g_XMLEntities;
740
+
741
+ $szReturnString;
742
+ $nCount;
743
+ $boFound;
744
+ $nHTMLEntityCount;
745
+
746
+ $szReturnString = null;
747
+
748
+ for ($nCount = 0; $nCount < strlen($szString); $nCount++)
749
+ {
750
+ $boFound = false;
751
+ $nHTMLEntityCount = 0;
752
+
753
+ while (!$boFound &&
754
+ $nHTMLEntityCount < count($g_XMLEntities))
755
+ {
756
+ //$test1 = htmlspecialchars('&');
757
+
758
+ if ($g_XMLEntities[$nHTMLEntityCount]->getReplacement() == htmlspecialchars($szString[$nCount]))
759
+ {
760
+ $boFound = true;
761
+ }
762
+ else
763
+ {
764
+ $nHTMLEntityCount++;
765
+ }
766
+ }
767
+
768
+ if ($boFound)
769
+ {
770
+ $szReturnString .= $g_XMLEntities[$nHTMLEntityCount]->getReplacement();
771
+ }
772
+ else
773
+ {
774
+ $szReturnString .= $szString[$nCount];
775
+ }
776
+ }
777
+
778
+ return $szReturnString;
779
+ }
780
+
781
+ public static function replaceEntitiesInStringWithChars($szString)
782
+ {
783
+ $szReturnString = null;
784
+ $nCount;
785
+ $boFound = false;
786
+ $boFoundAmpersand = false;
787
+ $nHTMLEntityCount;
788
+ $szAmpersandBuffer = "";
789
+ $nAmpersandBufferCount = 0;
790
+
791
+ for ($nCount = 0; $nCount < strlen($szString); $nCount++)
792
+ {
793
+ $boFound = false;
794
+ $nHTMLEntityCount = 0;
795
+
796
+ if (!$boFoundAmpersand)
797
+ {
798
+ if ($szString[$nCount] == '&')
799
+ {
800
+ $boFoundAmpersand = true;
801
+ $szAmpersandBuffer = (string)$szString[$nCount];
802
+ $nAmpersandBufferCount = 0;
803
+ }
804
+ else
805
+ {
806
+ $szReturnString .= $szString[$nCount];
807
+ }
808
+ }
809
+ else
810
+ {
811
+ $szAmpersandBuffer .= $szString[$nCount];
812
+
813
+ if ($nAmpersandBufferCount < (10 - 2))
814
+ {
815
+ if ($szString[$nCount] == ';')
816
+ {
817
+ $boFound = true;
818
+ $boFoundAmpersand = false;
819
+ }
820
+ else
821
+ {
822
+ $nAmpersandBufferCount++;
823
+ }
824
+ }
825
+ else
826
+ {
827
+ $szReturnString .= $szAmpersandBuffer;
828
+ $boFoundAmpersand = false;
829
+ }
830
+ }
831
+
832
+ if ($boFound)
833
+ {
834
+ // need to find the entity in the list
835
+ $boFoundEntity = false;
836
+ $nXMLEntityCount = 0;
837
+
838
+ while (!$boFoundEntity &&
839
+ $nXMLEntityCount < count($g_XMLEntities))
840
+ {
841
+ if (strtoupper($g_XMLEntities[$nXMLEntityCount]->getReplacement()) == strtoupper($szAmpersandBuffer))
842
+ {
843
+ $boFoundEntity = true;
844
+ }
845
+ else
846
+ {
847
+ $nXMLEntityCount++;
848
+ }
849
+ }
850
+
851
+ if ($boFoundEntity)
852
+ {
853
+ $szReturnString .= $g_XMLEntities[$nXMLEntityCount]->getCharCode();
854
+ }
855
+ else
856
+ {
857
+ $szReturnString .= $szAmpersandBuffer;
858
+ }
859
+ $boFound = false;
860
+ }
861
+ }
862
+
863
+ if ($boFoundAmpersand && !$boFound)
864
+ {
865
+ $szReturnString .= $szAmpersandBuffer;
866
+ }
867
+
868
+ return $szReturnString;
869
+ }
870
+
871
+ public static function boolToString($boValue)
872
+ {
873
+ if ($boValue == true)
874
+ {
875
+ return 'true';
876
+ }
877
+ elseif ($boValue == false)
878
+ {
879
+ return 'false';
880
+ }
881
+ }
882
+ }
app/code/local/Iridiumcorp/Tpg/controllers/PaymentController.php ADDED
@@ -0,0 +1,411 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once "app/code/local/Iridiumcorp/Tpg/Model/Tpg/PaymentFormHelper.php";
4
+
5
+ /**
6
+ * Standard Checkout Controller
7
+ *
8
+ */
9
+ class Iridiumcorp_Tpg_PaymentController extends Mage_Core_Controller_Front_Action
10
+ {
11
+ protected function _expireAjax()
12
+ {
13
+ if (!Mage::getSingleton('checkout/session')->getQuote()->hasItems())
14
+ {
15
+ $this->getResponse()->setHeader('HTTP/1.1','403 Session Expired');
16
+ exit;
17
+ }
18
+ }
19
+
20
+ public function errorAction()
21
+ {
22
+ Mage::log('error navigation.');
23
+ //$this->_redirect('checkout/cart');
24
+ $this->_redirect('checkout/onepage/failure');
25
+ #$this->loadLayout();
26
+ #$this->renderLayout();
27
+ }
28
+
29
+ /**
30
+ * When a customer cancel payment from paypal.
31
+ */
32
+ public function cancelAction()
33
+ {
34
+ $session = Mage::getSingleton('checkout/session');
35
+ $session->setQuoteId($session->getPaypalStandardQuoteId(true));
36
+
37
+ $this->_redirect('checkout/cart');
38
+ }
39
+
40
+ /**
41
+ * Action logic for Hosted Payment mode
42
+ *
43
+ */
44
+ public function redirectAction()
45
+ {
46
+ $this->getResponse()->setBody($this->getLayout()->createBlock('tpg/redirect')->toHtml());
47
+ }
48
+
49
+ /**
50
+ * Action logic for 3D Secure redirection
51
+ *
52
+ */
53
+ public function threedsecureAction()
54
+ {
55
+ $this->getResponse()->setBody($this->getLayout()->createBlock('tpg/threedsecure')->toHtml());
56
+ }
57
+
58
+ /**
59
+ * Action for handling the reception of the 3D Secure authentication result (PaRes)
60
+ *
61
+ * @return unknown
62
+ */
63
+ public function callback3dAction()
64
+ {
65
+ $boError = false;
66
+ $szMessage = '';
67
+
68
+ try
69
+ {
70
+ // get the PaRes and MD from the post
71
+ $szPaRes = $this->getRequest()->getPost('PaRes');
72
+ $szMD = $this->getRequest()->getPost('MD');
73
+
74
+ // complete the 3D Secure transaction with the 3D Authorization result
75
+ Mage::getSingleton('checkout/type_onepage')->saveOrderAfter3DSecure($szPaRes, $szMD);
76
+ }
77
+ catch (Exception $exc)
78
+ {
79
+ $boError = true;
80
+ Mage::log('Callback 3DSecure action failed, exception details: '.$exc);
81
+
82
+ if( isset($_SESSION['tpg_message']) )
83
+ {
84
+ $szMessage = $_SESSION['tpg_message'];
85
+ unset($_SESSION['tpg_message']);
86
+ }
87
+ else
88
+ {
89
+ $szMessage = Iridiumcorp_Tpg_Model_Tpg_GlobalErrors::ERROR_7655;
90
+ }
91
+
92
+ // report out an fatal error
93
+ Mage::getSingleton('core/session')->addError($szMessage);
94
+ $this->_redirect('checkout/onepage/failure');
95
+ }
96
+
97
+ if (!$boError)
98
+ {
99
+ // report out an payment result
100
+ if($GLOBALS['m_bo3DSecureError'] == 1)
101
+ {
102
+ // if the global message is empty report out a general error message
103
+ if(!$GLOBALS['m_sz3DSecureMessage'])
104
+ {
105
+ Mage::getSingleton('core/session')->addError("3DSecure Validation was not successfull, please try again.");
106
+ }
107
+ else
108
+ {
109
+ Mage::getSingleton('core/session')->addError($GLOBALS['m_sz3DSecureMessage']);
110
+ }
111
+ $this->_redirect('checkout/onepage/failure');
112
+ }
113
+ else
114
+ {
115
+ // set the quote as inactive after back from 3DS Authorization page
116
+ Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
117
+
118
+ // send confirmation email to customer
119
+ $order = Mage::getModel('sales/order');
120
+
121
+ $order->load(Mage::getSingleton('checkout/session')->getLastOrderId());
122
+ if($order->getId())
123
+ {
124
+ $order->sendNewOrderEmail();
125
+ }
126
+
127
+ //Mage::getSingleton('checkout/session')->unsQuoteId();
128
+ if($GLOBALS['m_sz3DSecureMessage'])
129
+ {
130
+ Mage::getSingleton('core/session')->addSuccess($GLOBALS['m_sz3DSecureMessage']);
131
+ }
132
+ $this->_redirect('checkout/onepage/success');
133
+ }
134
+ }
135
+ }
136
+
137
+ /**
138
+ * Action for handling the result from the Hosted Payment page
139
+ *
140
+ */
141
+ public function callbackhostedpaymentAction()
142
+ {
143
+ $error = false;
144
+ $formVariables = array();
145
+ $model = Mage::getModel('tpg/direct');
146
+
147
+ try
148
+ {
149
+ $hmHashMethod = $model->getConfigData('hashmethod');
150
+ $szPassword = $model->getConfigData('password');
151
+ $szPreSharedKey = $model->getConfigData('presharedkey');
152
+
153
+ $formVariables['HashDigest'] = $this->getRequest()->getPost('HashDigest');
154
+ $formVariables['MerchantID'] = $this->getRequest()->getPost('MerchantID');
155
+ $formVariables['StatusCode'] = $this->getRequest()->getPost('StatusCode');
156
+ $formVariables['Message'] = $this->getRequest()->getPost('Message');
157
+ $formVariables['PreviousStatusCode'] = $this->getRequest()->getPost('PreviousStatusCode');
158
+ $formVariables['PreviousMessage'] = $this->getRequest()->getPost('PreviousMessage');
159
+ $formVariables['CrossReference'] = $this->getRequest()->getPost('CrossReference');
160
+ $formVariables['Amount'] = $this->getRequest()->getPost('Amount');
161
+ $formVariables['CurrencyCode'] = $this->getRequest()->getPost('CurrencyCode');
162
+ $formVariables['OrderID'] = $this->getRequest()->getPost('OrderID');
163
+ $formVariables['TransactionType'] = $this->getRequest()->getPost('TransactionType');
164
+ $formVariables['TransactionDateTime'] = $this->getRequest()->getPost('TransactionDateTime');
165
+ $formVariables['OrderDescription'] = $this->getRequest()->getPost('OrderDescription');
166
+ $formVariables['CustomerName'] = $this->getRequest()->getPost('CustomerName');
167
+ $formVariables['Address1'] = $this->getRequest()->getPost('Address1');
168
+ $formVariables['Address2'] = $this->getRequest()->getPost('Address2');
169
+ $formVariables['Address3'] = $this->getRequest()->getPost('Address3');
170
+ $formVariables['Address4'] = $this->getRequest()->getPost('Address4');
171
+ $formVariables['City'] = $this->getRequest()->getPost('City');
172
+ $formVariables['State'] = $this->getRequest()->getPost('State');
173
+ $formVariables['PostCode'] = $this->getRequest()->getPost('PostCode');
174
+ $formVariables['CountryCode'] = $this->getRequest()->getPost('CountryCode');
175
+
176
+ if(!IRC_PaymentFormHelper::compareHostedPaymentFormHashDigest($formVariables, $szPassword, $hmHashMethod, $szPreSharedKey))
177
+ {
178
+ $error = "The payment was rejected for a SECURITY reason: the incoming payment data was tampered with.";
179
+ Mage::log("The Hosted Payment Form transaction couldn't be completed for the following reason: ".$error. " Form variables: ".$formVariables);
180
+ }
181
+ }
182
+ catch (Exception $exc)
183
+ {
184
+ $error = Iridiumcorp_Tpg_Model_Tpg_GlobalErrors::ERROR_183;
185
+ Mage::logException($exc);
186
+ Mage::log($error." Order ID: ".$formVariables['OrderID'].". Exception details: ".$exc);
187
+ }
188
+
189
+ // check the incoming hash digest
190
+ if($error)
191
+ {
192
+ Mage::getSingleton('core/session')->addError($error);
193
+ $this->_redirect('checkout/onepage/failure');
194
+ }
195
+ else
196
+ {
197
+ switch ($formVariables['StatusCode'])
198
+ {
199
+ case "0":
200
+ Mage::getSingleton('checkout/type_onepage')->saveOrderAfterHostedPayment();
201
+
202
+ Mage::log("Hosted Payment Form transaction successfully completed. Transaction details: ".print_r($formVariables, 1));
203
+ Mage::getSingleton('core/session')->addSuccess("Payment Processor Response: ".$formVariables['Message']);
204
+ $this->_redirect('checkout/onepage/success');
205
+ break;
206
+ case "20":
207
+ Mage::log("Duplicate Hosted Payment Form transaction. Transaction details: ".print_r($formVariables, 1));
208
+ $szNotificationMessage = "Payment Processor Response: ".$szMessage.". A duplicate transaction means that a transaction with these details has already been processed by the payment provider. The details of the original transaction - Previous Transaction Response: ".$formVariables['PreviousMessage'];
209
+ if($formVariables['PreviousStatusCode'] == "0")
210
+ {
211
+ Mage::getSingleton('core/session')->addSuccess($szNotificationMessage);
212
+ $this->_redirect('checkout/onepage/success');
213
+ }
214
+ else
215
+ {
216
+ Mage::getSingleton('core/session')->addError($szNotificationMessage);
217
+ $this->_redirect('checkout/onepage/failure');
218
+ }
219
+ break;
220
+ case "5":
221
+ case "30":
222
+ default:
223
+ Mage::log("Hosted Payment Form transaction couldn't be completed. Transaction details: ".print_r($formVariables, 1));
224
+ Mage::getSingleton('core/session')->addError("Payment Processor Response: ".$formVariables['Message']);
225
+ $this->_redirect('checkout/onepage/failure');
226
+ break;
227
+ }
228
+ }
229
+ }
230
+
231
+ public function callbacktransparentredirectAction()
232
+ {
233
+ $model = Mage::getModel('tpg/direct');
234
+
235
+ try
236
+ {
237
+ $hmHashMethod = $model->getConfigData('hashmethod');
238
+ $szPassword = $model->getConfigData('password');
239
+ $szPreSharedKey = $model->getConfigData('presharedkey');
240
+
241
+ $szPaREQ = $this->getRequest()->getPost('PaREQ');
242
+ $szPaRES = $this->getRequest()->getPost('PaRes');
243
+ $nStatusCode = $this->getRequest()->getPost('StatusCode');
244
+
245
+ if(isset($szPaREQ))
246
+ {
247
+ // 3D Secure authentication required
248
+ self::_threeDSecureAuthenticationRequired($szPassword, $hmHashMethod, $szPreSharedKey);
249
+ }
250
+ else if(isset($szPaRES))
251
+ {
252
+ // 3D Secure post authentication
253
+ self::_postThreeDSecureAuthentication($szPassword, $hmHashMethod, $szPreSharedKey);
254
+ }
255
+ else
256
+ {
257
+ // payment complete
258
+ self::_paymentComplete($szPassword, $hmHashMethod, $szPreSharedKey);
259
+ }
260
+
261
+ }
262
+ catch (Exception $exc)
263
+ {
264
+ $error = Iridiumcorp_Tpg_Model_Tpg_GlobalErrors::ERROR_260;
265
+ Mage::logException($exc);
266
+ Mage::log($error." Exception details: ".$exc);
267
+
268
+ Mage::getSingleton('core/session')->addError($error);
269
+ $this->_redirect('checkout/onepage/failure');
270
+ }
271
+ }
272
+
273
+ private function _threeDSecureAuthenticationRequired($szPassword, $hmHashMethod, $szPreSharedKey)
274
+ {
275
+ $error = false;
276
+ $formVariables = array();
277
+
278
+ $formVariables['HashDigest'] = $this->getRequest()->getPost('HashDigest');
279
+ $formVariables['MerchantID'] = $this->getRequest()->getPost('MerchantID');
280
+ $formVariables['StatusCode'] = $this->getRequest()->getPost('StatusCode');
281
+ $formVariables['Message'] = $this->getRequest()->getPost('Message');
282
+ $formVariables['CrossReference'] = $this->getRequest()->getPost('CrossReference');
283
+ $formVariables['OrderID'] = $this->getRequest()->getPost('OrderID');
284
+ $formVariables['TransactionDateTime'] = $this->getRequest()->getPost('TransactionDateTime');
285
+ $formVariables['ACSURL'] = $this->getRequest()->getPost('ACSURL');
286
+ $formVariables['PaREQ'] = $this->getRequest()->getPost('PaREQ');
287
+
288
+ if(!IRC_PaymentFormHelper::compareThreeDSecureAuthenticationRequiredHashDigest($formVariables, $szPassword, $hmHashMethod, $szPreSharedKey))
289
+ {
290
+ $error = "The payment was rejected for a SECURITY reason: the incoming payment data was tampered with.";
291
+ Mage::log("The Transparent Redirect transaction couldn't be completed for the following reason: ".$error. " Form variables: ".print_r($formVariables, 1));
292
+ }
293
+
294
+ if($error)
295
+ {
296
+ Mage::getSingleton('core/session')->addError($error);
297
+ $this->_redirect('checkout/onepage/failure');
298
+ }
299
+ else
300
+ {
301
+ // redirect to a secure 3DS authentication page
302
+ Mage::getSingleton('checkout/session')->setMd($formVariables['CrossReference'])
303
+ ->setAcsurl($formVariables['ACSURL'])
304
+ ->setPareq($formVariables['PaREQ'])
305
+ ->setTermurl('tpg/payment/callbacktransparentredirect');
306
+
307
+ // redirect to a 3D Secure page
308
+ $this->_redirect('tpg/payment/threedsecure');
309
+ }
310
+ }
311
+
312
+ private function _postThreeDSecureAuthentication($szPassword, $hmHashMethod, $szPreSharedKey)
313
+ {
314
+ $error = false;
315
+ $formVariables = array();
316
+ $model = Mage::getModel('tpg/direct');
317
+
318
+ $szPaRES = $this->getRequest()->getPost('PaRes');
319
+ $szCrossReference = $this->getRequest()->getPost('MD');
320
+ $szMerchantID = $model->getConfigData('merchantid');
321
+ $szTransactionDateTime = date('Y-m-d H:i:s P');
322
+ $szCallbackURL = Mage::getUrl('tpg/payment/callbacktransparentredirect');
323
+ $szHashDigest = IRC_PaymentFormHelper::calculatePostThreeDSecureAuthenticationHashDigest($szMerchantID, $szPassword, $hmHashMethod, $szPreSharedKey, $szPaRES, $szCrossReference, $szTransactionDateTime, $szCallbackURL);
324
+
325
+
326
+ Mage::getSingleton('checkout/session')->setHashdigest($szHashDigest)
327
+ ->setMerchantid($szMerchantID)
328
+ ->setCrossreference($szCrossReference)
329
+ ->setTransactiondatetime($szTransactionDateTime)
330
+ ->setCallbackurl($szCallbackURL)
331
+ ->setPares($szPaRES);
332
+
333
+ // redirect to the redirection bridge page
334
+ $this->_redirect('tpg/payment/redirect');
335
+ }
336
+
337
+ private function _paymentComplete($szPassword, $hmHashMethod, $szPreSharedKey)
338
+ {
339
+ $error = false;
340
+ $formVariables = array();
341
+
342
+ $formVariables['HashDigest'] = $this->getRequest()->getPost('HashDigest');
343
+ $formVariables['MerchantID'] = $this->getRequest()->getPost('MerchantID');
344
+ $formVariables['StatusCode'] = $this->getRequest()->getPost('StatusCode');
345
+ $formVariables['Message'] = $this->getRequest()->getPost('Message');
346
+ $formVariables['PreviousStatusCode'] = $this->getRequest()->getPost('PreviousStatusCode');
347
+ $formVariables['PreviousMessage'] = $this->getRequest()->getPost('PreviousMessage');
348
+ $formVariables['CrossReference'] = $this->getRequest()->getPost('CrossReference');
349
+ $formVariables['Amount'] = $this->getRequest()->getPost('Amount');
350
+ $formVariables['CurrencyCode'] = $this->getRequest()->getPost('CurrencyCode');
351
+ $formVariables['OrderID'] = $this->getRequest()->getPost('OrderID');
352
+ $formVariables['TransactionType'] = $this->getRequest()->getPost('TransactionType');
353
+ $formVariables['TransactionDateTime'] = $this->getRequest()->getPost('TransactionDateTime');
354
+ $formVariables['OrderDescription'] = $this->getRequest()->getPost('OrderDescription');
355
+ $formVariables['Address1'] = $this->getRequest()->getPost('Address1');
356
+ $formVariables['Address2'] = $this->getRequest()->getPost('Address2');
357
+ $formVariables['Address3'] = $this->getRequest()->getPost('Address3');
358
+ $formVariables['Address4'] = $this->getRequest()->getPost('Address4');
359
+ $formVariables['City'] = $this->getRequest()->getPost('City');
360
+ $formVariables['State'] = $this->getRequest()->getPost('State');
361
+ $formVariables['PostCode'] = $this->getRequest()->getPost('PostCode');
362
+ $formVariables['CountryCode'] = $this->getRequest()->getPost('CountryCode');
363
+
364
+ if(!IRC_PaymentFormHelper::comparePaymentCompleteHashDigest($formVariables, $szPassword, $hmHashMethod, $szPreSharedKey))
365
+ {
366
+ $error = "The payment was rejected for a SECURITY reason: the incoming payment data was tampered with.";
367
+ Mage::log("The Transparent Redirect transaction couldn't be completed for the following reason: ".$error." Form variables: ".print_r($formVariables, 1));
368
+ }
369
+
370
+ if($error)
371
+ {
372
+ Mage::getSingleton('core/session')->addError($error);
373
+ $this->_redirect('checkout/onepage/failure');
374
+ }
375
+ else
376
+ {
377
+ switch ($formVariables['StatusCode'])
378
+ {
379
+ case "0":
380
+ // TODO : replace with PCI compliant version of data saving
381
+ Mage::getSingleton('checkout/type_onepage')->saveOrderAfterHostedPayment();
382
+
383
+ Mage::log("Transparent Redirect transaction successfully completed. Transaction details: ".print_r($formVariables, 1));
384
+ Mage::getSingleton('core/session')->addSuccess("Payment Processor Response: ".$formVariables['Message']);
385
+ $this->_redirect('checkout/onepage/success');
386
+ break;
387
+ case "20":
388
+ Mage::log("Duplicate Transparent Redirect transaction. Transaction details: ".print_r($formVariables, 1));
389
+ $szNotificationMessage = "Payment Processor Response: ".$formVariables['Message'].". A duplicate transaction means that a transaction with these details has already been processed by the payment provider. The details of the original transaction - Previous Transaction Response: ".$formVariables['PreviousMessage'];
390
+ if($formVariables['PreviousStatusCode'] == "0")
391
+ {
392
+ Mage::getSingleton('core/session')->addSuccess($szNotificationMessage);
393
+ $this->_redirect('checkout/onepage/success');
394
+ }
395
+ else
396
+ {
397
+ Mage::getSingleton('core/session')->addError($szNotificationMessage);
398
+ $this->_redirect('checkout/onepage/failure');
399
+ }
400
+ break;
401
+ case "5":
402
+ case "30":
403
+ default:
404
+ Mage::log("Transparent Redirect transaction couldn't be completed. Transaction details: ".print_r($formVariables, 1));
405
+ Mage::getSingleton('core/session')->addError("Payment Processor Response: ".$formVariables['Message']);
406
+ $this->_redirect('checkout/onepage/failure');
407
+ break;
408
+ }
409
+ }
410
+ }
411
+ }
app/code/local/Iridiumcorp/Tpg/etc/config.xml ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Iridiumcorp_Tpg>
5
+ <version>0.1.0</version>
6
+ </Iridiumcorp_Tpg>
7
+ </modules>
8
+
9
+ <global>
10
+ <models>
11
+ <tpg>
12
+ <class>Iridiumcorp_Tpg_Model</class>
13
+ </tpg>
14
+ </models>
15
+ <resources>
16
+ <tpg_setup>
17
+ <setup>
18
+ <module>Iridiumcorp_Tpg</module>
19
+ </setup>
20
+ <connection>
21
+ <use>core_setup</use>
22
+ </connection>
23
+ </tpg_setup>
24
+ <tpg_write>
25
+ <connection>
26
+ <use>core_write</use>
27
+ </connection>
28
+ </tpg_write>
29
+ <tpg_read>
30
+ <connection>
31
+ <use>core_read</use>
32
+ </connection>
33
+ </tpg_read>
34
+ </resources>
35
+ <blocks>
36
+ <tpg>
37
+ <class>Iridiumcorp_Tpg_Block</class>
38
+ </tpg>
39
+ </blocks>
40
+ <!-- Define the helper class type -->
41
+ <helpers>
42
+ <Tpg>
43
+ <class>Iridiumcorp_Tpg_Helper</class>
44
+ </Tpg>
45
+ <tpg>
46
+ <rewrite>
47
+ <data>Iridiumcorp_Tpg_Helper_Data</data>
48
+ </rewrite>
49
+ </tpg>
50
+ </helpers>
51
+ </global>
52
+
53
+ <frontend>
54
+ <secure_url>
55
+ <tpg>/tpg/standard</tpg>
56
+ </secure_url>
57
+ <routers>
58
+ <tpg>
59
+ <use>standard</use>
60
+ <args>
61
+ <module>Iridiumcorp_Tpg</module>
62
+ <frontName>tpg</frontName>
63
+ </args>
64
+ </tpg>
65
+ </routers>
66
+ <translate>
67
+ <modules>
68
+ <Iridiumcorp_Tpg>
69
+ <files>
70
+ <default>Iridiumcorp_Tpg.csv</default>
71
+ </files>
72
+ </Iridiumcorp_Tpg>
73
+ </modules>
74
+ </translate>
75
+ </frontend>
76
+
77
+ <!-- declare default configuration values for this module -->
78
+ <default>
79
+ <payment>
80
+ <tpg>
81
+ <active>1</active>
82
+ <model>tpg/direct</model>
83
+ <order_status>pending</order_status>
84
+ <title>Iridium Corporation</title>
85
+ <hashmethod>sha1</hashmethod>
86
+ <paymentprocessordomain>iridiumcorp.net</paymentprocessordomain>
87
+ <paymentprocessorport>443</paymentprocessorport>
88
+ <hostedpaymentactionurl>https://mms.iridiumcorp.net/Pages/PublicPages/PaymentForm.aspx</hostedpaymentactionurl>
89
+ <transparentredirectactionurl>https://mms.iridiumcorp.net/Pages/PublicPages/TransparentRedirect.aspx</transparentredirectactionurl>
90
+ <payment_action>capture</payment_action>
91
+ <mode>direct</mode>
92
+ <cv2mandatory>1</cv2mandatory>
93
+ <address1mandatory>1</address1mandatory>
94
+ <citymandatory>1</citymandatory>
95
+ <statemandatory>1</statemandatory>
96
+ <postcodemandatory>1</postcodemandatory>
97
+ <countrymandatory>1</countrymandatory>
98
+ <resultdeliverymethod>POST</resultdeliverymethod>
99
+ <serverresulturl></serverresulturl>
100
+ <paymentformdisplaysresult>0</paymentformdisplaysresult>
101
+ <allowspecific>0</allowspecific>
102
+ </tpg>
103
+ </payment>
104
+ </default>
105
+ </config>
app/code/local/Iridiumcorp/Tpg/etc/system.xml ADDED
@@ -0,0 +1,249 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <payment>
5
+ <groups>
6
+ <tpg translate="label">
7
+ <label>Iridium Corporation</label>
8
+ <comment>
9
+ <![CDATA[
10
+ <div style="color:Blue;font-weight:bold;">
11
+ Merchant Management System (MMS) <a href="https://mms.iridiumcorp.net" target="_blank">login</a>
12
+ </div>
13
+ ]]>
14
+ </comment>
15
+ <sort_order>670</sort_order>
16
+ <show_in_default>1</show_in_default>
17
+ <show_in_website>1</show_in_website>
18
+ <show_in_store>1</show_in_store>
19
+ <fields>
20
+ <title translate="label">
21
+ <label>Title</label>
22
+ <frontend_type>text</frontend_type>
23
+ <sort_order>10</sort_order>
24
+ <show_in_default>1</show_in_default>
25
+ <show_in_website>1</show_in_website>
26
+ <show_in_store>0</show_in_store>
27
+ </title>
28
+ <active translate="label">
29
+ <label>Enabled</label>
30
+ <sort_order>20</sort_order>
31
+ <frontend_type>select</frontend_type>
32
+ <source_model>adminhtml/system_config_source_yesno</source_model>
33
+ <show_in_default>1</show_in_default>
34
+ <show_in_website>1</show_in_website>
35
+ <show_in_store>0</show_in_store>
36
+ </active>
37
+ <debug translate="label">
38
+ <label>Debug</label>
39
+ <frontend_type>select</frontend_type>
40
+ <source_model>adminhtml/system_config_source_yesno</source_model>
41
+ <sort_order>30</sort_order>
42
+ <show_in_default>1</show_in_default>
43
+ <show_in_website>1</show_in_website>
44
+ <show_in_store>0</show_in_store>
45
+ </debug>
46
+ <order_status translate="label">
47
+ <label>New order status</label>
48
+ <sort_order>40</sort_order>
49
+ <frontend_type>select</frontend_type>
50
+ <source_model>adminhtml/system_config_source_order_status_processing</source_model>
51
+ <sort_order>50</sort_order>
52
+ <show_in_default>1</show_in_default>
53
+ <show_in_website>1</show_in_website>
54
+ <show_in_store>0</show_in_store>
55
+ </order_status>
56
+ <merchantid translate="label">
57
+ <label>Merchant ID</label>
58
+ <frontend_type>text</frontend_type>
59
+ <sort_order>60</sort_order>
60
+ <show_in_default>1</show_in_default>
61
+ <show_in_website>1</show_in_website>
62
+ <show_in_store>0</show_in_store>
63
+ </merchantid>
64
+ <password translate="label">
65
+ <label>Password</label>
66
+ <frontend_type>password</frontend_type>
67
+ <sort_order>70</sort_order>
68
+ <show_in_default>1</show_in_default>
69
+ <show_in_website>1</show_in_website>
70
+ <show_in_store>0</show_in_store>
71
+ </password>
72
+ <presharedkey translate="label">
73
+ <label>Pre Shared Key</label>
74
+ <frontend_type>text</frontend_type>
75
+ <sort_order>80</sort_order>
76
+ <show_in_default>1</show_in_default>
77
+ <show_in_website>1</show_in_website>
78
+ <show_in_store>0</show_in_store>
79
+ </presharedkey>
80
+ <hashmethod translate="label">
81
+ <label>Hash Method</label>
82
+ <frontend_type>select</frontend_type>
83
+ <sort_order>81</sort_order>
84
+ <source_model>tpg/source_hashMethod</source_model>
85
+ <show_in_default>1</show_in_default>
86
+ <show_in_website>1</show_in_website>
87
+ <show_in_store>0</show_in_store>
88
+ </hashmethod>
89
+ <paymentprocessordomain translate="label">
90
+ <label>Payment Processor Domain</label>
91
+ <frontend_type>text</frontend_type>
92
+ <sort_order>100</sort_order>
93
+ <show_in_default>1</show_in_default>
94
+ <show_in_website>1</show_in_website>
95
+ <show_in_store>0</show_in_store>
96
+ </paymentprocessordomain>
97
+ <paymentprocessorport translate="label">
98
+ <label>Payment Processor Port</label>
99
+ <frontend_type>text</frontend_type>
100
+ <sort_order>110</sort_order>
101
+ <show_in_default>1</show_in_default>
102
+ <show_in_website>1</show_in_website>
103
+ <show_in_store>0</show_in_store>
104
+ </paymentprocessorport>
105
+ <payment_action translate="label">
106
+ <label>Payment Action</label>
107
+ <sort_order>120</sort_order>
108
+ <frontend_type>select</frontend_type>
109
+ <source_model>tpg/source_paymentAction</source_model>
110
+ <show_in_default>1</show_in_default>
111
+ <show_in_website>1</show_in_website>
112
+ <show_in_store>0</show_in_store>
113
+ </payment_action>
114
+ <mode translate="label">
115
+ <label>Payment Integration Method</label>
116
+ <sort_order>130</sort_order>
117
+ <frontend_type>select</frontend_type>
118
+ <source_model>tpg/source_paymentMode</source_model>
119
+ <show_in_default>1</show_in_default>
120
+ <show_in_website>1</show_in_website>
121
+ <show_in_store>0</show_in_store>
122
+ </mode>
123
+ <hostedpaymentactionurl>
124
+ <label>Hosted Payment Form Action URL</label>
125
+ <frontend_type>label</frontend_type>
126
+ <sort_order>131</sort_order>
127
+ <show_in_default>1</show_in_default>
128
+ <show_in_website>1</show_in_website>
129
+ <show_in_store>0</show_in_store>
130
+ </hostedpaymentactionurl>
131
+ <transparentredirectactionurl>
132
+ <label>Transparent Redirect Action URL</label>
133
+ <frontend_type>label</frontend_type>
134
+ <sort_order>132</sort_order>
135
+ <show_in_default>1</show_in_default>
136
+ <show_in_website>1</show_in_website>
137
+ <show_in_store>0</show_in_store>
138
+ </transparentredirectactionurl>
139
+ <cv2mandatory>
140
+ <label>CV2 Mandatory <![CDATA[<span style="color:Red;font-weight:bold;font-size:12px;">(ON FORM ONLY)</span>]]></label>
141
+ <sort_order>140</sort_order>
142
+ <frontend_type>select</frontend_type>
143
+ <source_model>adminhtml/system_config_source_yesno</source_model>
144
+ <show_in_default>1</show_in_default>
145
+ <show_in_website>1</show_in_website>
146
+ <show_in_store>0</show_in_store>
147
+ <comment><![CDATA[<strong>Please note</strong>: The above value is only applicable to Hosted Payment Form payment mode. If you want to change the CV2 behaviour, please log into the <span style="font-weight:bold;color:Blue;">MMS</span> and update your Account Settings]]></comment>
148
+ </cv2mandatory>
149
+ <address1mandatory>
150
+ <label>Address1 Mandatory</label>
151
+ <sort_order>150</sort_order>
152
+ <frontend_type>select</frontend_type>
153
+ <source_model>adminhtml/system_config_source_yesno</source_model>
154
+ <show_in_default>1</show_in_default>
155
+ <show_in_website>1</show_in_website>
156
+ <show_in_store>0</show_in_store>
157
+ <comment>
158
+ <![CDATA[<strong>Please note</strong>: The above value is only applicable to Hosted Payment Form payment mode]]>
159
+ </comment>
160
+ </address1mandatory>
161
+ <citymandatory>
162
+ <label>City Mandatory</label>
163
+ <sort_order>160</sort_order>
164
+ <frontend_type>select</frontend_type>
165
+ <source_model>adminhtml/system_config_source_yesno</source_model>
166
+ <show_in_default>1</show_in_default>
167
+ <show_in_website>1</show_in_website>
168
+ <show_in_store>0</show_in_store>
169
+ <comment>
170
+ <![CDATA[<strong>Please note</strong>: The above value is only applicable to Hosted Payment Form payment mode]]>
171
+ </comment>
172
+ </citymandatory>
173
+ <postcodemandatory>
174
+ <label>PostCode Mandatory</label>
175
+ <sort_order>170</sort_order>
176
+ <frontend_type>select</frontend_type>
177
+ <source_model>adminhtml/system_config_source_yesno</source_model>
178
+ <show_in_default>1</show_in_default>
179
+ <show_in_website>1</show_in_website>
180
+ <show_in_store>0</show_in_store>
181
+ <comment>
182
+ <![CDATA[<strong>Please note</strong>: The above value is only applicable to Hosted Payment Form payment mode]]>
183
+ </comment>
184
+ </postcodemandatory>
185
+ <statemandatory>
186
+ <label>State Mandatory</label>
187
+ <sort_order>180</sort_order>
188
+ <frontend_type>select</frontend_type>
189
+ <source_model>adminhtml/system_config_source_yesno</source_model>
190
+ <show_in_default>1</show_in_default>
191
+ <show_in_website>1</show_in_website>
192
+ <show_in_store>0</show_in_store>
193
+ <comment>
194
+ <![CDATA[<strong>Please note</strong>: The above value is only applicable to Hosted Payment Form payment mode]]>
195
+ </comment>
196
+ </statemandatory>
197
+ <countrymandatory>
198
+ <label>Country Mandatory</label>
199
+ <sort_order>190</sort_order>
200
+ <frontend_type>select</frontend_type>
201
+ <source_model>adminhtml/system_config_source_yesno</source_model>
202
+ <show_in_default>1</show_in_default>
203
+ <show_in_website>1</show_in_website>
204
+ <show_in_store>0</show_in_store>
205
+ <comment>
206
+ <![CDATA[<strong>Please note</strong>: The above value is only applicable to Hosted Payment Form payment mode]]>
207
+ </comment>
208
+ </countrymandatory>
209
+ <resultdeliverymethod>
210
+ <label>Result Delivery Method</label>
211
+ <sort_order>200</sort_order>
212
+ <frontend_type>select</frontend_type>
213
+ <source_model>tpg/source_resultDeliveryMethod</source_model>
214
+ <show_in_default>1</show_in_default>
215
+ <show_in_website>1</show_in_website>
216
+ <show_in_store>0</show_in_store>
217
+ <comment>
218
+ <![CDATA[<strong>Please note</strong>: The above value is only applicable to Hosted Payment Form payment mode]]>
219
+ </comment>
220
+ </resultdeliverymethod>
221
+ <serverresulturl>
222
+ <label>Server Result URL</label>
223
+ <sort_order>210</sort_order>
224
+ <frontend_type>text</frontend_type>
225
+ <show_in_default>1</show_in_default>
226
+ <show_in_website>1</show_in_website>
227
+ <show_in_store>0</show_in_store>
228
+ <comment>
229
+ <![CDATA[<strong>Please note</strong>: The above value is only applicable to Hosted Payment Form payment mode]]>
230
+ </comment>
231
+ </serverresulturl>
232
+ <paymentformdisplaysresult>
233
+ <label>Payment Form Displays Result</label>
234
+ <sort_order>220</sort_order>
235
+ <frontend_type>select</frontend_type>
236
+ <source_model>adminhtml/system_config_source_yesno</source_model>
237
+ <show_in_default>1</show_in_default>
238
+ <show_in_website>1</show_in_website>
239
+ <show_in_store>0</show_in_store>
240
+ <comment>
241
+ <![CDATA[<strong>Please note</strong>: The above value is only applicable to Hosted Payment Form payment mode]]>
242
+ </comment>
243
+ </paymentformdisplaysresult>
244
+ </fields>
245
+ </tpg>
246
+ </groups>
247
+ </payment>
248
+ </sections>
249
+ </config>
app/design/adminhtml/default/default/template/tpg/form.phtml ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $direct = Mage::getModel('tpg/direct'); ?>
2
+ <?php if ($direct->getConfigData('mode') == Iridiumcorp_Tpg_Model_Source_PaymentMode::PAYMENT_MODE_HOSTED_PAYMENT_FORM) {?>
3
+ <fieldset class="form-list">
4
+ <?php $_code=$this->getMethodCode() ?>
5
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
6
+ <li>
7
+ <?php echo $this->__('You will be redirected to a secure page where you can complete your payment.') ?>
8
+ </li>
9
+ </ul>
10
+ </fieldset>
11
+ <?php } else {?>
12
+ <fieldset class="form-list">
13
+ <?php $_code = $this->getMethodCode(); ?>
14
+ <ul id="payment_form_<?php echo $_code; ?>" style="display:none">
15
+ <li>
16
+ <div class="input-box">
17
+ <label for="<?php echo $_code; ?>_cc_owner"><?php echo $this->__('Name On Card') ?> <span class="required">*</span></label><br/>
18
+ <input type="text" title="<?php echo $this->__('Name On Card') ?>" class="required-entry input-text" id="<?php echo $_code; ?>_cc_owner" name="payment[cc_owner]" value="<?php echo $this->htmlEscape($this->getInfoData('cc_owner')) ?>"/>
19
+ </div>
20
+ </li>
21
+ <li>
22
+ <div class="input-box">
23
+ <label for="<?php echo $_code; ?>_cc_number"><?php echo $this->__('Card Number') ?> <span class="required">*</span></label><br/>
24
+ <input type="text" id="<?php echo $_code; ?>_cc_number" name="payment[cc_number]" title="<?php echo $this->__('Card Number') ?>" class="required-entry input-text" value=""/>
25
+ </div>
26
+ </li>
27
+ <li>
28
+ <div class="input-box">
29
+ <label for="<?php echo $_code; ?>_expiration"><?php echo $this->__('Expiration Date') ?> <span class="required">*</span></label><br/>
30
+ <div class="v-fix">
31
+ <select id="<?php echo $_code; ?>_expiration" style="width:140px;" name="payment[cc_exp_month]" class="required-entry">
32
+ <?php $_ccExpMonth = $this->getInfoData('cc_exp_month') ?>
33
+ <?php foreach ($this->getCcMonths() as $k=>$v): ?>
34
+ <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
35
+ <?php endforeach ?>
36
+ </select>
37
+ </div>
38
+
39
+ <div class="v-fix" style="padding-left:5px;">
40
+ <?php $_ccExpYear = $this->getInfoData('cc_exp_year') ?>
41
+ <select id="<?php echo $_code; ?>_expiration_yr" style="width:103px;" name="payment[cc_exp_year]" class="required-entry">
42
+ <?php foreach ($this->getCcYears() as $k=>$v): ?>
43
+ <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
44
+ <?php endforeach ?>
45
+ </select>
46
+ </div>
47
+ </div>
48
+ </li>
49
+ <li>
50
+ <div class="input-box">
51
+ <label for="<?php echo $_code; ?>_cc_ss_start_month"><?php echo $this->__('Start Date') ?></label><br />
52
+ <div class="v-fix">
53
+ <select id="<?php echo $_code; ?>_cc_ss_start_month" style="width:140px;" name="payment[cc_ss_start_month]" class="validate-cc-start">
54
+ <?php $_ccStartMonth = $this->getInfoData('cc_ss_start_month') ?>
55
+ <?php foreach ($this->getCcStartMonths() as $k=>$v): ?>
56
+ <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccStartMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
57
+ <?php endforeach ?>
58
+ </select>
59
+ </div>
60
+ <div class="v-fix" style="padding-left:5px;">
61
+ <?php $_ccStartYear = $this->getInfoData('cc_ss_start_year') ?>
62
+ <select id="<?php echo $_code ?>_cc_ss_start_year" style="width:103px;" name="payment[cc_ss_start_year]">
63
+ <?php foreach ($this->getCcStartYears() as $k=>$v): ?>
64
+ <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccStartYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
65
+ <?php endforeach ?>
66
+ </select>
67
+ </div>
68
+ </div>
69
+ </li>
70
+ <li>
71
+ <div class="input-box">
72
+ <label for="<?php echo $_code; ?>_cc_ss_issue"><?php echo $this->__('Issue Number') ?></label><br />
73
+ <div class="v-fix"><input type="text" title="<?php echo $this->__('Issue Number') ?>" class="input-text" id="<?php echo $_code ?>_cc_ss_issue" name="payment[cc_ss_issue]" style="width:3em;" value="" /></div>
74
+ </div>
75
+ </li>
76
+ <li>
77
+ <div class="input-box">
78
+ <label for="<?php echo $_code; ?>_cc_cid"><?php echo $this->__('CV2') ?> <span class="required">*</span></label><br/>
79
+ <div class="v-fix"><input type="text" title="<?php echo $this->__('CV2') ?>" class="required-entry input-text" id="<?php echo $_code; ?>_cc_cid" name="payment[cc_cid]" style="width:3em;" value=""/></div>
80
+ &nbsp;
81
+ <a href="#" class="cvv-what-is-this"><?php echo $this->__('What is this?') ?></a>
82
+ </div>
83
+ </li>
84
+ </ul>
85
+ </fieldset>
86
+ <?php }?>
app/design/adminhtml/default/default/template/tpg/info.phtml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $direct = Mage::getModel('tpg/direct'); ?>
2
+ <?php if ($direct->getConfigData('mode') != Iridiumcorp_Tpg_Model_Source_PaymentMode::PAYMENT_MODE_DIRECT_API) {?>
3
+ <?php if ($direct->getConfigData('mode') == Iridiumcorp_Tpg_Model_Source_PaymentMode::PAYMENT_MODE_HOSTED_PAYMENT_FORM) {?>
4
+ <?php echo $this->__('You will be redirected to a secure payment page'); ?>
5
+ <?php } else {?>
6
+ <?php echo $this->__('No card information is available'); ?>
7
+ <?php }?>
8
+ <?php } else {?>
9
+ <?php if($_info = $this->getInfo()): ?>
10
+ <?php echo $this->__('Name on the Card: %s', $this->htmlEscape($this->getInfo()->getCcOwner())) ?>
11
+ <br/>
12
+ <?php echo $this->__('Card Number: %s', $this->htmlEscape($this->getCcNumber())) ?>
13
+ <br/>
14
+ <?php echo $this->__('Expiration Date: %s/%s', $this->htmlEscape($this->getInfo()->getCcExpMonth()), $this->htmlEscape($this->getInfo()->getCcExpYear())) ?>
15
+ <br />
16
+ <?php else: ?>
17
+ <?php endif; ?>
18
+ <?php }?>
app/design/frontend/default/default/template/tpg/form.phtml ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $direct = Mage::getModel('tpg/direct'); ?>
2
+ <?php if ($direct->getConfigData('mode') == Iridiumcorp_Tpg_Model_Source_PaymentMode::PAYMENT_MODE_HOSTED_PAYMENT_FORM) {?>
3
+ <fieldset class="form-list">
4
+ <?php $_code=$this->getMethodCode() ?>
5
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
6
+ <li>
7
+ <?php echo $this->__('You will be redirected to a secure page where you can complete your payment.') ?>
8
+ </li>
9
+ </ul>
10
+ </fieldset>
11
+ <?php } else {?>
12
+ <fieldset class="form-list">
13
+ <?php $_code = $this->getMethodCode(); ?>
14
+ <ul id="payment_form_<?php echo $_code; ?>" style="display:none">
15
+ <li>
16
+ <div class="input-box">
17
+ <label for="<?php echo $_code; ?>_cc_owner"><?php echo $this->__('Name On Card') ?> <span class="required">*</span></label><br/>
18
+ <input type="text" title="<?php echo $this->__('Name On Card') ?>" class="required-entry input-text" id="<?php echo $_code; ?>_cc_owner" name="payment[cc_owner]" value="<?php echo $this->htmlEscape($this->getInfoData('cc_owner')) ?>"/>
19
+ </div>
20
+ </li>
21
+ <li>
22
+ <div class="input-box">
23
+ <label for="<?php echo $_code; ?>_cc_number"><?php echo $this->__('Card Number') ?> <span class="required">*</span></label><br/>
24
+ <input type="text" id="<?php echo $_code; ?>_cc_number" name="payment[cc_number]" title="<?php echo $this->__('Card Number') ?>" class="required-entry input-text" value=""/>
25
+ </div>
26
+ </li>
27
+ <li>
28
+ <div class="input-box">
29
+ <label for="<?php echo $_code; ?>_expiration"><?php echo $this->__('Expiry Date') ?> <span class="required">*</span></label><br/>
30
+ <div class="v-fix">
31
+ <select id="<?php echo $_code; ?>_expiration" style="width:140px;" name="payment[cc_exp_month]" class="required-entry">
32
+ <?php $_ccExpMonth = $this->getInfoData('cc_exp_month') ?>
33
+ <?php foreach ($this->getCcMonths() as $k=>$v): ?>
34
+ <option value="<?php echo $k?$k:'' ?>" <?php if($k==$_ccExpMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
35
+ <?php endforeach ?>
36
+ </select>
37
+ </div>
38
+
39
+ <div class="v-fix" style="padding-left:5px;">
40
+ <?php $_ccExpYear = $this->getInfoData('cc_exp_year') ?>
41
+ <select id="<?php echo $_code; ?>_expiration_yr" style="width:103px;" name="payment[cc_exp_year]" class="required-entry">
42
+ <?php foreach ($this->getCcYears() as $k=>$v): ?>
43
+ <option value="<?php echo $k?$k:'' ?>" <?php if($k==$_ccExpYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
44
+ <?php endforeach ?>
45
+ </select>
46
+ </div>
47
+ </div>
48
+ </li>
49
+ <li>
50
+ <div class="input-box">
51
+ <label for="<?php echo $_code; ?>_cc_ss_start_month"><?php echo $this->__('Start Date') ?></label><br />
52
+ <div class="v-fix">
53
+ <select id="<?php echo $_code; ?>_cc_ss_start_month" style="width:140px;" name="payment[cc_ss_start_month]" class="validate-cc-start">
54
+ <?php $_ccStartMonth = $this->getInfoData('cc_ss_start_month') ?>
55
+ <?php foreach ($this->getCcStartMonths() as $k=>$v): ?>
56
+ <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccStartMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
57
+ <?php endforeach ?>
58
+ </select>
59
+ </div>
60
+ <div class="v-fix" style="padding-left:5px;">
61
+ <?php $_ccStartYear = $this->getInfoData('cc_ss_start_year') ?>
62
+ <select id="<?php echo $_code ?>_cc_ss_start_year" style="width:103px;" name="payment[cc_ss_start_year]">
63
+ <?php foreach ($this->getCcStartYears() as $k=>$v): ?>
64
+ <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccStartYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
65
+ <?php endforeach ?>
66
+ </select>
67
+ </div>
68
+ </div>
69
+ </li>
70
+ <li>
71
+ <div class="input-box">
72
+ <label for="<?php echo $_code; ?>_cc_ss_issue"><?php echo $this->__('Issue Number') ?></label><br />
73
+ <div class="v-fix"><input type="text" title="<?php echo $this->__('Issue Number') ?>" class="input-text" id="<?php echo $_code ?>_cc_ss_issue" name="payment[cc_ss_issue]" style="width:3em;" value="" /></div>
74
+ </div>
75
+ </li>
76
+ <li>
77
+ <div class="input-box">
78
+ <label for="<?php echo $_code; ?>_cc_cid"><?php echo $this->__('CV2') ?> <span class="required">*</span></label><br/>
79
+ <div class="v-fix"><input type="text" title="<?php echo $this->__('CV2') ?>" class="required-entry input-text" id="<?php echo $_code; ?>_cc_cid" name="payment[cc_cid]" style="width:3em;" value=""/></div>
80
+ &nbsp;
81
+ <a href="#" class="cvv-what-is-this"><?php echo $this->__('What is this?') ?></a>
82
+ </div>
83
+ </li>
84
+ </ul>
85
+ </fieldset>
86
+ <?php }?>
app/design/frontend/default/default/template/tpg/info.phtml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $direct = Mage::getModel('tpg/direct'); ?>
2
+ <?php if ($direct->getConfigData('mode') != Iridiumcorp_Tpg_Model_Source_PaymentMode::PAYMENT_MODE_DIRECT_API) {?>
3
+ <?php if ($direct->getConfigData('mode') == Iridiumcorp_Tpg_Model_Source_PaymentMode::PAYMENT_MODE_HOSTED_PAYMENT_FORM) {?>
4
+ <?php echo $this->__('You will be redirected to a secure payment page'); ?>
5
+ <?php } else {?>
6
+ <?php echo $this->__('No card information is available'); ?>
7
+ <?php }?>
8
+ <?php } else {?>
9
+ <?php if($_info = $this->getInfo()): ?>
10
+ <?php echo $this->__('Name on the Card: %s', $this->htmlEscape($this->getInfo()->getCcOwner())) ?>
11
+ <br/>
12
+ <?php echo $this->__('Card Number: xxxx-%s', $this->htmlEscape($this->getInfo()->getCcLast4())) ?>
13
+ <br/>
14
+ <?php echo $this->__('Expiration Date: %s/%s', $this->htmlEscape($this->getInfo()->getCcExpMonth()), $this->htmlEscape($this->getInfo()->getCcExpYear())) ?>
15
+ <?php else: ?>
16
+ <?php endif; ?>
17
+ <?php }?>
app/etc/modules/Iridiumcorp_All.xml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <modules>
3
+ <Iridiumcorp_Tpg>
4
+ <active>true</active>
5
+ <codePool>local</codePool>
6
+ <depends>
7
+ <Mage_Payment />
8
+ </depends>
9
+ </Iridiumcorp_Tpg>
10
+ <Iridiumcorp_Checkout>
11
+ <active>true</active>
12
+ <codePool>local</codePool>
13
+ </Iridiumcorp_Checkout>
14
+ </modules>
15
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Iridiumcorp_Tpg</name>
4
+ <version>1.3</version>
5
+ <stability>stable</stability>
6
+ <license>OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Iridium Corporation Payment Extension</summary>
10
+ <description>Magento payment extension for the Iridium Corporation gateway. This extension fully supports the processing of 3D secure (Verified By Visa and Mastercard SecureCode) transactions. It also supports all of the integration methods provided by Iridium.</description>
11
+ <notes>3D Secure transactions redirected to an outer ACS page rather than using iframe. System log file contains transaction specific result details.</notes>
12
+ <authors><author><name>Iridium Support</name><user>auto-converted</user><email>support@iridiumcorp.co.uk</email></author><author><name>Benjamin Kovac</name><user>auto-converted</user><email>ben.kovac@iridiumcorp.co.uk</email></author></authors>
13
+ <date>2010-06-03</date>
14
+ <time>12:48:25</time>
15
+ <contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="tpg"><file name="form.phtml" hash="9b2afd627d6e9e4f9ad43b0a7153962b"/><file name="info.phtml" hash="3164afadd87c4811b5f7d0879537f10e"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="tpg"><file name="form.phtml" hash="241c59ebeb925aa93f3b133030b6c346"/><file name="info.phtml" hash="7d72d07f3afa018d0402219e50573439"/></dir></dir></dir></dir></dir></target><target name="magelocal"><dir name="Iridiumcorp"><dir name="Checkout"><dir name="etc"><file name="config.xml" hash="394797540b82a26aeade86688adfb490"/></dir><dir name="Model"><dir name="Type"><file name="Onepage.php" hash="66b3f92c53198f9c3c24605160103f07"/></dir></dir></dir><dir name="Tpg"><dir name="Block"><file name="Error.php" hash="905367210beb53a0bc68dc6033e24127"/><file name="Form.php" hash="4b1d51aa84982486f3139510c41a221a"/><file name="Info.php" hash="f88445c4880bfe14914252bc76b6fc28"/><file name="Redirect.php" hash="121b7025034eff6316a0205b41ec2a0b"/><file name="Threedsecure.php" hash="43c2c7197a8b25eed6c2cf88d5ee0df4"/></dir><dir name="controllers"><file name="PaymentController.php" hash="1437bdd68d5ac8197e4bf37c80c1ac91"/></dir><dir name="etc"><file name="config.xml" hash="8652c85a0f22713ce36e134a8e98f2d4"/><file name="system.xml" hash="0f05e89acfdacadb82b189ee8933f6e7"/></dir><dir name="Helper"><file name="Data.php" hash="a72fba87e718c94d993a57199e20ca96"/></dir><dir name="Model"><file name="Direct.php" hash="ac7085ee2e22dc1ab4f9990d26b7733c"/><file name="Request.php" hash="a96e462ed3c1882048ea45f2c3a6662c"/><dir name="Source"><file name="HashMethod.php" hash="36d7fb4fc762feae459f0e67d51006f4"/><file name="PaymentAction.php" hash="bd8dc40852b9ff8c80c08fc01f35a988"/><file name="PaymentMode.php" hash="6849defade8a7da4cfaeff3227ae5b83"/><file name="ResultDeliveryMethod.php" hash="b79d6fc714a25aba26cdb0ab572ae06f"/></dir><dir name="Tpg"><file name="GlobalErrors.php" hash="06beaf8042e351b95259d0e8e4cb1142"/><file name="ISOCountries.php" hash="fc63d76fbe25458ba351f114782074cb"/><file name="ISOCurrencies.php" hash="89ac1e124e89c0713ef43a0cf6dd0e2b"/><file name="PaymentFormHelper.php" hash="f7643e2e5a5fa567a4f2e3f2151ccd7e"/><dir name="ThePaymentGateway"><file name="PaymentSystem.php" hash="4ad38bdb85f865e967153d9f253390cd"/><file name="SOAP.php" hash="504dcb0cb7c60c134b25652881349cc3"/><file name="TPG_Common.php" hash="df1033ef855c7e0e715076a105acb84a"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Iridiumcorp_All.xml" hash="cbea3fee7ee3724d21288145b27bbd74"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies/>
18
+ </package>