Cardsave_Cardsaveonlinepayments - Version 1.10.1

Version Notes

Fixed sql script

Download this release

Release Info

Developer Magento Core Team
Extension Cardsave_Cardsaveonlinepayments
Version 1.10.1
Comparing to
See all releases


Code changes from version 1.10.0 to 1.10.1

Files changed (45) hide show
  1. app/code/local/Cardsave/Cardsaveonlinepayments/Block/Error.php +6 -0
  2. app/code/local/Cardsave/Cardsaveonlinepayments/Block/Form.php +127 -0
  3. app/code/local/Cardsave/Cardsaveonlinepayments/Block/Info.php +36 -0
  4. app/code/local/Cardsave/Cardsaveonlinepayments/Block/Redirect.php +267 -0
  5. app/code/local/Cardsave/Cardsaveonlinepayments/Block/Threedsecure.php +46 -0
  6. app/code/local/Cardsave/Cardsaveonlinepayments/Helper/Data.php +6 -0
  7. app/code/local/Cardsave/Cardsaveonlinepayments/Model/Common/GlobalErrors.php +36 -0
  8. app/code/local/Cardsave/Cardsaveonlinepayments/Model/Common/ISOCountries.php +265 -0
  9. app/code/local/Cardsave/Cardsaveonlinepayments/Model/Common/ISOCurrencies.php +199 -0
  10. app/code/local/Cardsave/Cardsaveonlinepayments/Model/Common/PaymentFormHelper.php +532 -0
  11. app/code/local/Cardsave/Cardsaveonlinepayments/Model/Common/ThePaymentGateway/PaymentSystem.php +2400 -0
  12. app/code/local/Cardsave/Cardsaveonlinepayments/Model/Common/ThePaymentGateway/SOAP.php +968 -0
  13. app/code/local/Cardsave/Cardsaveonlinepayments/Model/Common/ThePaymentGateway/TPG_Common.php +882 -0
  14. app/code/local/Cardsave/Cardsaveonlinepayments/Model/Direct.php +976 -0
  15. app/code/local/Cardsave/Cardsaveonlinepayments/Model/Request.php +22 -0
  16. app/code/local/Cardsave/Cardsaveonlinepayments/Model/Resource/Eav/Mysql4/Setup.php +6 -0
  17. app/code/local/Cardsave/Cardsaveonlinepayments/Model/Source/HashMethod.php +33 -0
  18. app/code/local/Cardsave/Cardsaveonlinepayments/Model/Source/OrderStatus.php +15 -0
  19. app/code/local/Cardsave/Cardsaveonlinepayments/Model/Source/PaymentAction.php +15 -0
  20. app/code/local/Cardsave/Cardsaveonlinepayments/Model/Source/PaymentMode.php +28 -0
  21. app/code/local/Cardsave/Cardsaveonlinepayments/Model/Source/ResultDeliveryMethod.php +28 -0
  22. app/code/local/Cardsave/Cardsaveonlinepayments/controllers/PaymentController.php +918 -0
  23. app/code/local/Cardsave/Cardsaveonlinepayments/etc/config.xml +105 -0
  24. app/code/local/Cardsave/Cardsaveonlinepayments/etc/system.xml +246 -0
  25. app/code/local/Cardsave/Cardsaveonlinepayments/sql/cardsaveonlinepayments_setup/mysql4-install-0.1.0.php +27 -0
  26. app/code/local/Cardsave/Checkout/Block/Onepage/Payment/Methods.php +38 -0
  27. app/code/local/Cardsave/Checkout/Model/Type/Onepage.php +1001 -0
  28. app/code/local/Cardsave/Checkout/etc/config.xml +24 -0
  29. app/code/local/Cardsave/Sales/Model/Order.php +32 -0
  30. app/code/local/Cardsave/Sales/Model/Order/Invoice.php +76 -0
  31. app/code/local/Cardsave/Sales/Model/Order/Payment.php +403 -0
  32. app/code/local/Cardsave/Sales/Model/Service/Quote.php +92 -0
  33. app/code/local/Cardsave/Sales/etc/config.xml +44 -0
  34. app/design/adminhtml/base/default/template/cardsaveonlinepayments/form.phtml +87 -0
  35. app/design/adminhtml/base/default/template/cardsaveonlinepayments/info.phtml +18 -0
  36. app/design/adminhtml/default/default/template/cardsaveonlinepayments/form.phtml +87 -0
  37. app/design/adminhtml/default/default/template/cardsaveonlinepayments/info.phtml +18 -0
  38. app/design/frontend/base/default/template/cardsaveonlinepayments/form.phtml +93 -0
  39. app/design/frontend/base/default/template/cardsaveonlinepayments/info.phtml +17 -0
  40. app/design/frontend/default/default/template/cardsaveonlinepayments/form.phtml +93 -0
  41. app/design/frontend/default/default/template/cardsaveonlinepayments/info.phtml +17 -0
  42. app/etc/modules/Cardsave_All.xml +19 -0
  43. package.xml +7 -7
  44. skin/frontend/base/default/images/cardsave_online.jpg +0 -0
  45. skin/frontend/default/default/images/cardsave_online.jpg +0 -0
app/code/local/Cardsave/Cardsaveonlinepayments/Block/Error.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Cardsave_Cardsaveonlinepayments_Block_Error extends Mage_Core_Block_Template
4
+ {
5
+
6
+ }
app/code/local/Cardsave/Cardsaveonlinepayments/Block/Form.php ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Cardsave_Cardsaveonlinepayments_Block_Form extends Mage_Payment_Block_Form
3
+ {
4
+ protected function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->setTemplate('cardsaveonlinepayments/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/Cardsave/Cardsaveonlinepayments/Block/Info.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Cardsave_Cardsaveonlinepayments_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('cardsaveonlinepayments/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/Cardsave/Cardsaveonlinepayments/Block/Redirect.php ADDED
@@ -0,0 +1,267 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Cardsave_Cardsaveonlinepayments_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('cardsaveonlinepayments/direct');
12
+ $pmPaymentMode = $model->getConfigData('mode');
13
+
14
+ switch ($pmPaymentMode)
15
+ {
16
+ case Cardsave_Cardsaveonlinepayments_Model_Source_PaymentMode::PAYMENT_MODE_HOSTED_PAYMENT_FORM:
17
+ $html = self::_redirectToHostedPaymentForm();
18
+ break;
19
+ case Cardsave_Cardsaveonlinepayments_Model_Source_PaymentMode::PAYMENT_MODE_TRANSPARENT_REDIRECT:
20
+ $html = self::_redirectToTransparentRedirect();
21
+ break;
22
+ }
23
+
24
+ return $html;
25
+ }
26
+
27
+ /**
28
+ * Build the redirect form for the Hosted Payment Form payment type
29
+ *
30
+ * @return unknown
31
+ */
32
+ private function _redirectToHostedPaymentForm()
33
+ {
34
+ $html = '';
35
+ $model = Mage::getModel('cardsaveonlinepayments/direct');
36
+ $szActionURL = $model->getConfigData('hostedpaymentactionurl');
37
+ $cookies = Mage::getSingleton('core/cookie')->get();
38
+ $szServerResultURLCookieVariables;
39
+ $szServerResultURLFormVariables = '';
40
+ $szServerResultURLQueryStringVariables = '';
41
+
42
+ // create a Magento form
43
+ $form = new Varien_Data_Form();
44
+ $form->setAction($szActionURL)
45
+ ->setId('HostedPaymentForm')
46
+ ->setName('HostedPaymentForm')
47
+ ->setMethod('POST')
48
+ ->setUseContainer(true);
49
+
50
+ $form->addField("HashDigest", 'hidden', array('name'=>"HashDigest", 'value'=>Mage::getSingleton('checkout/session')->getHashdigest()));
51
+ $form->addField("MerchantID", 'hidden', array('name'=>"MerchantID", 'value'=>Mage::getSingleton('checkout/session')->getMerchantid()));
52
+ $form->addField("Amount", 'hidden', array('name'=>"Amount", 'value'=>Mage::getSingleton('checkout/session')->getAmount()));
53
+ $form->addField("CurrencyCode", 'hidden', array('name'=>"CurrencyCode", 'value'=>Mage::getSingleton('checkout/session')->getCurrencycode()));
54
+ $form->addField("OrderID", 'hidden', array('name'=>"OrderID", 'value'=>Mage::getSingleton('checkout/session')->getOrderid()));
55
+ $form->addField("TransactionType", 'hidden', array('name'=>"TransactionType", 'value'=>Mage::getSingleton('checkout/session')->getTransactiontype()));
56
+ $form->addField("TransactionDateTime", 'hidden', array('name'=>"TransactionDateTime", 'value'=>Mage::getSingleton('checkout/session')->getTransactiondatetime()));
57
+ $form->addField("CallbackURL", 'hidden', array('name'=>"CallbackURL", 'value'=>Mage::getSingleton('checkout/session')->getCallbackurl()));
58
+ $form->addField("OrderDescription", 'hidden', array('name'=>"OrderDescription", 'value'=>Mage::getSingleton('checkout/session')->getOrderdescription()));
59
+ $form->addField("CustomerName", 'hidden', array('name'=>"CustomerName", 'value'=>Mage::getSingleton('checkout/session')->getCustomername()));
60
+ $form->addField("Address1", 'hidden', array('name'=>"Address1", 'value'=>Mage::getSingleton('checkout/session')->getAddress1()));
61
+ $form->addField("Address2", 'hidden', array('name'=>"Address2", 'value'=>Mage::getSingleton('checkout/session')->getAddress2()));
62
+ $form->addField("Address3", 'hidden', array('name'=>"Address3", 'value'=>Mage::getSingleton('checkout/session')->getAddress3()));
63
+ $form->addField("Address4", 'hidden', array('name'=>"Address4", 'value'=>Mage::getSingleton('checkout/session')->getAddress4()));
64
+ $form->addField("City", 'hidden', array('name'=>"City", 'value'=>Mage::getSingleton('checkout/session')->getCity()));
65
+ $form->addField("State", 'hidden', array('name'=>"State", 'value'=>Mage::getSingleton('checkout/session')->getState()));
66
+ $form->addField("PostCode", 'hidden', array('name'=>"PostCode", 'value'=>Mage::getSingleton('checkout/session')->getPostcode()));
67
+ $form->addField("CountryCode", 'hidden', array('name'=>"CountryCode", 'value'=>Mage::getSingleton('checkout/session')->getCountrycode()));
68
+ $form->addField("CV2Mandatory", 'hidden', array('name'=>"CV2Mandatory", 'value'=>Mage::getSingleton('checkout/session')->getCv2mandatory()));
69
+ $form->addField("Address1Mandatory", 'hidden', array('name'=>"Address1Mandatory", 'value'=>Mage::getSingleton('checkout/session')->getAddress1mandatory()));
70
+ $form->addField("CityMandatory", 'hidden', array('name'=>"CityMandatory", 'value'=>Mage::getSingleton('checkout/session')->getCitymandatory()));
71
+ $form->addField("PostCodeMandatory", 'hidden', array('name'=>"PostCodeMandatory", 'value'=>Mage::getSingleton('checkout/session')->getPostcodemandatory()));
72
+ $form->addField("StateMandatory", 'hidden', array('name'=>"StateMandatory", 'value'=>Mage::getSingleton('checkout/session')->getStatemandatory()));
73
+ $form->addField("CountryMandatory", 'hidden', array('name'=>"CountryMandatory", 'value'=>Mage::getSingleton('checkout/session')->getCountrymandatory()));
74
+ $form->addField("ResultDeliveryMethod", 'hidden', array('name'=>"ResultDeliveryMethod", 'value'=>Mage::getSingleton('checkout/session')->getResultdeliverymethod()));
75
+ $form->addField("ServerResultURL", 'hidden', array('name'=>"ServerResultURL", 'value'=>Mage::getSingleton('checkout/session')->getServerresulturl()));
76
+ $form->addField("PaymentFormDisplaysResult", 'hidden', array('name'=>"PaymentFormDisplaysResult", 'value'=>Mage::getSingleton('checkout/session')->getPaymentformdisplaysresult()));
77
+ $form->addField("ServerResultURLCookieVariables", 'hidden', array('name'=>"ServerResultURLCookieVariables", 'value'=>Mage::getSingleton('checkout/session')->getServerresulturlcookievariables()));
78
+ $form->addField("ServerResultURLFormVariables", 'hidden', array('name'=>"ServerResultURLFormVariables", 'value'=>Mage::getSingleton('checkout/session')->getServerresulturlformvariables()));
79
+ $form->addField("ServerResultURLQueryStringVariables", 'hidden', array('name'=>"ServerResultURLQueryStringVariables", 'value'=>Mage::getSingleton('checkout/session')->getServerresulturlquerystringvariables()));
80
+
81
+ // reset the session items
82
+ Mage::getSingleton('checkout/session')->setHashdigest(null)
83
+ ->setMerchantid(null)
84
+ ->setAmount(null)
85
+ ->setCurrencycode(null)
86
+ ->setOrderid(null)
87
+ ->setTransactiontype(null)
88
+ ->setTransactiondatetime(null)
89
+ ->setCallbackurl(null)
90
+ ->setOrderdescription(null)
91
+ ->setCustomername(null)
92
+ ->setAddress1(null)
93
+ ->setAddress2(null)
94
+ ->setAddress3(null)
95
+ ->setAddress4(null)
96
+ ->setCity(null)
97
+ ->setState(null)
98
+ ->setPostcode(null)
99
+ ->setCountrycode(null)
100
+ ->setCv2mandatory(null)
101
+ ->setAddress1mandatory(null)
102
+ ->setCitymandatory(null)
103
+ ->setPostcodemandatory(null)
104
+ ->setStatemandatory(null)
105
+ ->setCountrymandatory(null)
106
+ ->setResultdeliverymethod(null)
107
+ ->setServerresulturl(null)
108
+ ->setPaymentformdisplaysresult(null)
109
+ ->setServerresulturlcookievariables(null)
110
+ ->setServerresulturlformvariables(null)
111
+ ->setServerresulturlquerystringvariables(null);
112
+
113
+ $html = '<html><body>';
114
+ $html.= $this->__('You will be redirected to a secure payment page in a few seconds.');
115
+ $html.= $form->toHtml();
116
+ $html.= '<script type="text/javascript">document.getElementById("HostedPaymentForm").submit();</script>';
117
+ $html.= '</body></html>';
118
+
119
+ return $html;
120
+ }
121
+
122
+ /**
123
+ * Build the redirect form for the Transparent Redirect payment type
124
+ *
125
+ * @return unknown
126
+ */
127
+ private function _redirectToTransparentRedirect()
128
+ {
129
+ $html;
130
+ $model = Mage::getModel('cardsaveonlinepayments/direct');
131
+ $szActionURL = $model->getConfigData('transparentredirectactionurl');
132
+ $szPaRes = Mage::getSingleton('checkout/session')->getPares();
133
+
134
+ if(isset($szPaRes))
135
+ {
136
+ $html = self::_submitPaRes($szActionURL);
137
+ }
138
+ else
139
+ {
140
+ $html = self::_submitTransaction($szActionURL);
141
+ }
142
+
143
+ return $html;
144
+ }
145
+
146
+ /**
147
+ * Build the submit form for Transparent redirect payment type
148
+ *
149
+ * @param unknown_type $szActionURL
150
+ * @return unknown
151
+ */
152
+ private function _submitTransaction($szActionURL)
153
+ {
154
+ $html = '';
155
+
156
+ // create a Magento form
157
+ $form = new Varien_Data_Form();
158
+ $form->setAction($szActionURL)
159
+ ->setId('TransparentRedirectForm')
160
+ ->setName('TransparentRedirectForm')
161
+ ->setMethod('POST')
162
+ ->setUseContainer(true);
163
+
164
+ $form->addField("HashDigest", 'hidden', array('name'=>"HashDigest", 'value'=>Mage::getSingleton('checkout/session')->getHashdigest()));
165
+ $form->addField("MerchantID", 'hidden', array('name'=>"MerchantID", 'value'=>Mage::getSingleton('checkout/session')->getMerchantid()));
166
+ $form->addField("Amount", 'hidden', array('name'=>"Amount", 'value'=>Mage::getSingleton('checkout/session')->getAmount()));
167
+ $form->addField("CurrencyCode", 'hidden', array('name'=>"CurrencyCode", 'value'=>Mage::getSingleton('checkout/session')->getCurrencycode()));
168
+ $form->addField("OrderID", 'hidden', array('name'=>"OrderID", 'value'=>Mage::getSingleton('checkout/session')->getOrderid()));
169
+ $form->addField("TransactionType", 'hidden', array('name'=>"TransactionType", 'value'=>Mage::getSingleton('checkout/session')->getTransactiontype()));
170
+ $form->addField("TransactionDateTime", 'hidden', array('name'=>"TransactionDateTime", 'value'=>Mage::getSingleton('checkout/session')->getTransactiondatetime()));
171
+ $form->addField("CallbackURL", 'hidden', array('name'=>"CallbackURL", 'value'=>Mage::getSingleton('checkout/session')->getCallbackurl()));
172
+ $form->addField("OrderDescription", 'hidden', array('name'=>"OrderDescription", 'value'=>Mage::getSingleton('checkout/session')->getOrderdescription()));
173
+ $form->addField("Address1", 'hidden', array('name'=>"Address1", 'value'=>Mage::getSingleton('checkout/session')->getAddress1()));
174
+ $form->addField("Address2", 'hidden', array('name'=>"Address2", 'value'=>Mage::getSingleton('checkout/session')->getAddress2()));
175
+ $form->addField("Address3", 'hidden', array('name'=>"Address3", 'value'=>Mage::getSingleton('checkout/session')->getAddress3()));
176
+ $form->addField("Address4", 'hidden', array('name'=>"Address4", 'value'=>Mage::getSingleton('checkout/session')->getAddress4()));
177
+ $form->addField("City", 'hidden', array('name'=>"City", 'value'=>Mage::getSingleton('checkout/session')->getCity()));
178
+ $form->addField("State", 'hidden', array('name'=>"State", 'value'=>Mage::getSingleton('checkout/session')->getState()));
179
+ $form->addField("PostCode", 'hidden', array('name'=>"PostCode", 'value'=>Mage::getSingleton('checkout/session')->getPostcode()));
180
+ $form->addField("CountryCode", 'hidden', array('name'=>"CountryCode", 'value'=>Mage::getSingleton('checkout/session')->getCountrycode()));
181
+ $form->addField("CardName", 'hidden', array('name'=>"CardName", 'value'=>Mage::getSingleton('checkout/session')->getCardname()));
182
+ $form->addField("CardNumber", 'hidden', array('name'=>"CardNumber", 'value'=>Mage::getSingleton('checkout/session')->getCardnumber()));
183
+ $form->addField("ExpiryDateMonth", 'hidden', array('name'=>"ExpiryDateMonth", 'value'=>Mage::getSingleton('checkout/session')->getExpirydatemonth()));
184
+ $form->addField("ExpiryDateYear", 'hidden', array('name'=>"ExpiryDateYear", 'value'=>Mage::getSingleton('checkout/session')->getExpirydateyear()));
185
+ $form->addField("StartDateMonth", 'hidden', array('name'=>"StartDateMonth", 'value'=>Mage::getSingleton('checkout/session')->getStartdatemonth()));
186
+ $form->addField("StartDateYear", 'hidden', array('name'=>"StartDateYear", 'value'=>Mage::getSingleton('checkout/session')->getStartdateyear()));
187
+ $form->addField("IssueNumber", 'hidden', array('name'=>"IssueNumber", 'value'=>Mage::getSingleton('checkout/session')->getIssuenumber()));
188
+ $form->addField("CV2", 'hidden', array('name'=>"CV2", 'value'=>Mage::getSingleton('checkout/session')->getCv2()));
189
+
190
+ // reset the session items
191
+ Mage::getSingleton('checkout/session')->setHashdigest(null)
192
+ ->setMerchantid(null)
193
+ ->setAmount(null)
194
+ ->setCurrencycode(null)
195
+ ->setOrderid(null)
196
+ ->setTransactiontype(null)
197
+ ->setTransactiondatetime(null)
198
+ ->setCallbackurl(null)
199
+ ->setOrderdescription(null)
200
+ ->setAddress1(null)
201
+ ->setAddress2(null)
202
+ ->setAddress3(null)
203
+ ->setAddress4(null)
204
+ ->setCity(null)
205
+ ->setState(null)
206
+ ->setPostcode(null)
207
+ ->setCountrycode(null)
208
+ ->setCardname(null)
209
+ ->setCardnumber(null)
210
+ ->setExpirydatemonth(null)
211
+ ->setExpirydateyear(null)
212
+ ->setStartdatemonth(null)
213
+ ->setStartdateyear(null)
214
+ ->setIssuenumber(null)
215
+ ->setCv2(null);
216
+
217
+
218
+ $html = '<html><body>';
219
+ $html.= $form->toHtml();
220
+ $html.= '<script type="text/javascript">document.getElementById("TransparentRedirectForm").submit();</script>';
221
+ $html.= '</body></html>';
222
+
223
+ return $html;
224
+ }
225
+
226
+ /**
227
+ * Build the form for the Transparent Redirect 3DSecure authentication payment
228
+ *
229
+ * @param unknown_type $szActionURL
230
+ * @return unknown
231
+ */
232
+ private function _submitPaRes($szActionURL)
233
+ {
234
+ $html = '';
235
+
236
+ // create a Magento form
237
+ $form = new Varien_Data_Form();
238
+ $form->setAction($szActionURL)
239
+ ->setId('SubmitPaResForm')
240
+ ->setName('SubmitPaResForm')
241
+ ->setMethod('POST')
242
+ ->setUseContainer(true);
243
+
244
+ $form->addField("HashDigest", 'hidden', array('name'=>"HashDigest", 'value'=>Mage::getSingleton('checkout/session')->getHashdigest()));
245
+ $form->addField("MerchantID", 'hidden', array('name'=>"MerchantID", 'value'=>Mage::getSingleton('checkout/session')->getMerchantid()));
246
+ $form->addField("CrossReference", 'hidden', array('name'=>"CrossReference", 'value'=>Mage::getSingleton('checkout/session')->getCrossreference()));
247
+ $form->addField("TransactionDateTime", 'hidden', array('name'=>"TransactionDateTime", 'value'=>Mage::getSingleton('checkout/session')->getTransactiondatetime()));
248
+ $form->addField("CallbackURL", 'hidden', array('name'=>"CallbackURL", 'value'=>Mage::getSingleton('checkout/session')->getCallbackurl()));
249
+ $form->addField("PaRES", 'hidden', array('name'=>"PaRES", 'value'=>Mage::getSingleton('checkout/session')->getPares()));
250
+
251
+ // reset the session items
252
+ Mage::getSingleton('checkout/session')->setHashdigest(null)
253
+ ->setMerchantid(null)
254
+ ->setCrossreference(null)
255
+ ->setTransactiondatetime(null)
256
+ ->setCallbackurl(null)
257
+ ->setPares(null);
258
+
259
+
260
+ $html = '<html><body>';
261
+ $html.= $form->toHtml();
262
+ $html.= '<script type="text/javascript">document.getElementById("SubmitPaResForm").submit();</script>';
263
+ $html.= '</body></html>';
264
+
265
+ return $html;
266
+ }
267
+ }
app/code/local/Cardsave/Cardsaveonlinepayments/Block/Threedsecure.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Cardsave_Cardsaveonlinepayments_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
+ $mode = Mage::getModel('cardsaveonlinepayments/direct')->getConfigData('mode');
12
+
13
+ if($mode == Cardsave_Cardsaveonlinepayments_Model_Source_PaymentMode::PAYMENT_MODE_TRANSPARENT_REDIRECT)
14
+ {
15
+ $szTermURL = 'cardsaveonlinepayments/payment/callbacktransparentredirect';
16
+ }
17
+ else
18
+ {
19
+ $szTermURL = 'cardsaveonlinepayments/payment/callback3d';
20
+ }
21
+
22
+ $form = new Varien_Data_Form();
23
+ $form->setAction(Mage::getSingleton('checkout/session')->getAcsurl())
24
+ ->setId('ThreeDSecureForm')
25
+ ->setName('ThreeDSecureForm')
26
+ ->setMethod('POST')
27
+ ->setUseContainer(true);
28
+
29
+ $form->addField("PaReq", 'hidden', array('name'=>"PaReq", 'value'=>Mage::getSingleton('checkout/session')->getPareq()));
30
+ $form->addField("MD", 'hidden', array('name'=>"MD", 'value'=>Mage::getSingleton('checkout/session')->getMd()));
31
+ $form->addField("TermUrl", 'hidden', array('name'=>"TermUrl", 'value'=>Mage::getUrl($szTermURL, array('_secure' => true))));
32
+
33
+ $html = '<html><body>';
34
+ $html.= $this->__('You will be redirected to a 3D secure form in a few seconds.');
35
+ $html.= $form->toHtml();
36
+ $html.= '<script type="text/javascript">document.getElementById("ThreeDSecureForm").submit();</script>';
37
+ $html.= '</body></html>';
38
+
39
+ // reset the 3DS session values
40
+ Mage::getSingleton('checkout/session')->setMd(null)
41
+ ->setAcsurl(null)
42
+ ->setPareq(null);
43
+
44
+ return $html;
45
+ }
46
+ }
app/code/local/Cardsave/Cardsaveonlinepayments/Helper/Data.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Cardsave_Cardsaveonlinepayments_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ }
app/code/local/Cardsave/Cardsaveonlinepayments/Model/Common/GlobalErrors.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Cardsave_Cardsaveonlinepayments_Model_Common_GlobalErrors
4
+ {
5
+ /*
6
+ * failure - probably a wrong card details entered in
7
+ * error - payment gateway communication and hashing related issues
8
+ */
9
+ // failure - occurred in the processing of the final callback from the hosted payment form/transparent redirect
10
+ const ERROR_183 = "The payment was not successful and checkout was cancelled.<br/>Please check your credit card details and try again.";
11
+
12
+ // error - occurred during the partial processing of the callback from the transparent redirect page
13
+ const ERROR_260 = "ERROR 260: The payment result couldn't be verified.";
14
+
15
+ // error - direct integration transaction cannot be completed - problem in the communication with the payment gateway
16
+ const ERROR_261 = "ERROR 261: Couldn't communicate with payment gateway.";
17
+
18
+ // error - direct integration 3D Secure transaction couldn't be processed - problem in the communication with the paymwent gateway
19
+ const ERROR_431 = "ERROR 431: Couldn't communicate with payment gateway to complete the 3D Secure authentication.";
20
+
21
+ // failure - occurred during the processing of the data in the callback from the 3D Secure Authentication page
22
+ const ERROR_7655 = "3D Secure payment was not successfull and checkout was cancelled.<br/>Please check your credit card details and try again.";
23
+
24
+ // failure - server pull result related error: no URL variable present in the payment form to merchant webshop redirection
25
+ const ERROR_309 ="ERROR 309: Missing parameters.";
26
+
27
+ // failure - server pull result related error: OrderID or CrossReference is missing from the URL variable list
28
+ const ERROR_304 = "ERROR 304: The payment was rejected for a SECURITY reason: the incoming payment data was tampered with.";
29
+
30
+ // faulire - server pull result related error: Magento web request to the hosted PaymentFormHandler failed while trying to retrieve the transaction details using the CrossReference
31
+ const ERROR_329 = "ERROR 329: Error happened while trying to validate the transaction result.";
32
+
33
+ // failure - server pull result related error: empty response due to invalid CrossReference
34
+ const ERROR_381 = "ERROR 381: Invalid transaction details.";
35
+ }
36
+ ?>
app/code/local/Cardsave/Cardsaveonlinepayments/Model/Common/ISOCountries.php ADDED
@@ -0,0 +1,265 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ include_once ("ThePaymentGateway/TPG_Common.php");
4
+
5
+ class CSV_ISOCountries
6
+ {
7
+ /**
8
+ * Get the list of ISO Countries
9
+ *
10
+ * @return ISOCountryList
11
+ */
12
+ public static function getISOCountryList()
13
+ {
14
+ $iclISOCountryList = new CSV_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/Cardsave/Cardsaveonlinepayments/Model/Common/ISOCurrencies.php ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ include_once ("ThePaymentGateway/TPG_Common.php");
4
+
5
+ class CSV_ISOCurrencies
6
+ {
7
+ /**
8
+ * Get the list of ISO Currencies
9
+ *
10
+ * @return ISOCurrencyList
11
+ */
12
+ public static function getISOCurrencyList()
13
+ {
14
+ $iclISOCurrencyList = new CSV_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/Cardsave/Cardsaveonlinepayments/Model/Common/PaymentFormHelper.php ADDED
@@ -0,0 +1,532 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once "app/code/local/Cardsave/Cardsaveonlinepayments/Model/Source/HashMethod.php";
4
+
5
+ class CSV_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 CSV_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 CSV_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 CSV_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, $szServerResultURLCookieVariables, $szServerResultURLFormVariables, $szServerResultURLQueryStringVariables)
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
+ 'ServerResultURLCookieVariables='.$szServerResultURLCookieVariables.'&'.
166
+ 'ServerResultURLFormVariables='.$szServerResultURLFormVariables.'&'.
167
+ 'ServerResultURLQueryStringVariables='.$szServerResultURLQueryStringVariables;
168
+
169
+ if ($hmHashMethod == Cardsave_Cardsaveonlinepayments_Model_Source_HashMethod::HASH_METHOD_MD5 ||
170
+ $hmHashMethod == Cardsave_Cardsaveonlinepayments_Model_Source_HashMethod::HASH_METHOD_SHA1)
171
+ {
172
+ $szStringBeforeHash = 'PreSharedKey='.$szPreSharedKey.'&'.$szStringBeforeHash;
173
+ }
174
+
175
+ $szHashDigest = self::_hashCalculator($hmHashMethod, $szPreSharedKey, $szStringBeforeHash);
176
+
177
+ return $szHashDigest;
178
+ }
179
+
180
+ /**
181
+ * Hash mechanism for transparent redirect trasaction
182
+ *
183
+ * @param unknown_type $szMerchantID
184
+ * @param unknown_type $szPassword
185
+ * @param unknown_type $hmHashMethod
186
+ * @param unknown_type $szPreSharedKey
187
+ * @param unknown_type $nAmount
188
+ * @param unknown_type $nCurrencyCode
189
+ * @param unknown_type $szOrderID
190
+ * @param unknown_type $szTransactionType
191
+ * @param unknown_type $szTransactionDateTime
192
+ * @param unknown_type $szCallbackURL
193
+ * @param unknown_type $szOrderDescription
194
+ * @return unknown
195
+ */
196
+ public static function calculateTransparentRedirectHashDigest($szMerchantID, $szPassword, $hmHashMethod, $szPreSharedKey, $nAmount, $nCurrencyCode, $szOrderID, $szTransactionType, $szTransactionDateTime, $szCallbackURL, $szOrderDescription)
197
+ {
198
+ $szHashDigest = '';
199
+ $szStringBeforeHash;
200
+
201
+ $szStringBeforeHash = 'MerchantID='.$szMerchantID.'&'.
202
+ 'Password='.$szPassword.'&'.
203
+ 'Amount='.$nAmount.'&'.
204
+ 'CurrencyCode='.$nCurrencyCode.'&'.
205
+ 'OrderID='.$szOrderID.'&'.
206
+ 'TransactionType='.$szTransactionType.'&'.
207
+ 'TransactionDateTime='.$szTransactionDateTime.'&'.
208
+ 'CallbackURL='.$szCallbackURL.'&'.
209
+ 'OrderDescription='.$szOrderDescription;
210
+
211
+ if ($hmHashMethod == Cardsave_Cardsaveonlinepayments_Model_Source_HashMethod::HASH_METHOD_MD5 ||
212
+ $hmHashMethod == Cardsave_Cardsaveonlinepayments_Model_Source_HashMethod::HASH_METHOD_SHA1)
213
+ {
214
+ $szStringBeforeHash = 'PreSharedKey='.$szPreSharedKey.'&'.$szStringBeforeHash;
215
+ }
216
+
217
+ $szHashDigest = self::_hashCalculator($hmHashMethod, $szPreSharedKey, $szStringBeforeHash);
218
+
219
+ return $szHashDigest;
220
+ }
221
+
222
+ /**
223
+ * Hash mechanism for calculating the hash digest for the post 3D Secure Authentication in the transparent redirect payment mode
224
+ *
225
+ * @param unknown_type $szMerchantID
226
+ * @param unknown_type $szPassword
227
+ * @param unknown_type $hmHashMethod
228
+ * @param unknown_type $szPreSharedKey
229
+ * @param unknown_type $szPaRES
230
+ * @param unknown_type $szCrossReference
231
+ * @param unknown_type $szTransactionDateTime
232
+ * @param unknown_type $szCallbackURL
233
+ * @return unknown
234
+ */
235
+ public static function calculatePostThreeDSecureAuthenticationHashDigest($szMerchantID, $szPassword, $hmHashMethod, $szPreSharedKey, $szPaRES, $szCrossReference, $szTransactionDateTime, $szCallbackURL)
236
+ {
237
+ $szHashDigest = '';
238
+ $szStringBeforeHash;
239
+
240
+ $szStringBeforeHash = 'MerchantID='.$szMerchantID.'&'.
241
+ 'Password='.$szPassword.'&'.
242
+ 'CrossReference='.$szCrossReference.'&'.
243
+ 'TransactionDateTime='.$szTransactionDateTime.'&'.
244
+ 'CallbackURL='.$szCallbackURL.'&'.
245
+ 'PaRES='.$szPaRES;
246
+
247
+
248
+ if ($hmHashMethod == Cardsave_Cardsaveonlinepayments_Model_Source_HashMethod::HASH_METHOD_MD5 ||
249
+ $hmHashMethod == Cardsave_Cardsaveonlinepayments_Model_Source_HashMethod::HASH_METHOD_SHA1)
250
+ {
251
+ $szStringBeforeHash = 'PreSharedKey='.$szPreSharedKey.'&'.$szStringBeforeHash;
252
+ }
253
+
254
+ $szHashDigest = self::_hashCalculator($hmHashMethod, $szPreSharedKey, $szStringBeforeHash);
255
+
256
+ return $szHashDigest;
257
+ }
258
+
259
+ /**
260
+ * Private hash calculator for hashing the raw string
261
+ *
262
+ * @param unknown_type $hmHashMethod
263
+ * @param unknown_type $szPreSharedKey
264
+ * @param unknown_type $szStringBeforeHash
265
+ * @return unknown
266
+ */
267
+ private static function _hashCalculator($hmHashMethod, $szPreSharedKey, $szStringBeforeHash)
268
+ {
269
+ $szHashDigest = '';
270
+
271
+ switch ($hmHashMethod)
272
+ {
273
+ case Cardsave_Cardsaveonlinepayments_Model_Source_HashMethod::HASH_METHOD_MD5:
274
+ $szHashDigest = md5($szStringBeforeHash);
275
+ break;
276
+ case Cardsave_Cardsaveonlinepayments_Model_Source_HashMethod::HASH_METHOD_SHA1:
277
+ $szHashDigest = sha1($szStringBeforeHash);
278
+ break;
279
+ case Cardsave_Cardsaveonlinepayments_Model_Source_HashMethod::HASH_METHOD_HMACMD5:
280
+ $szHashDigest = hash_hmac('md5', $szStringBeforeHash, $szPreSharedKey);
281
+ break;
282
+ case Cardsave_Cardsaveonlinepayments_Model_Source_HashMethod::HASH_METHOD_HMACSHA1:
283
+ $szHashDigest = hash_hmac('sha1', $szStringBeforeHash, $szPreSharedKey);
284
+ break;
285
+ default:
286
+ throw new Exception('Invalid hash method used for hash digest calculation: '.$hmHashMethod);
287
+ break;
288
+ }
289
+
290
+ //$szHashDigest = strtoupper($szHashDigest);
291
+
292
+ return $szHashDigest;
293
+ }
294
+
295
+ /**
296
+ * Hash validator mechanism for hosted payment form transaction
297
+ *
298
+ * @param unknown_type $szHashDigest
299
+ * @param unknown_type $szMerchantID
300
+ * @param unknown_type $szStatusCode
301
+ * @param unknown_type $szMessage
302
+ * @param unknown_type $szPreviousStatusCode
303
+ * @param unknown_type $szPreviousMessage
304
+ * @param unknown_type $szCrossReference
305
+ * @param unknown_type $szAmount
306
+ * @param unknown_type $szCurrencyCode
307
+ * @param unknown_type $szOrderID
308
+ * @param unknown_type $szTransactionType
309
+ * @param unknown_type $szTransactionDateTime
310
+ * @param unknown_type $szOrderDescription
311
+ * @param unknown_type $szCustomerName
312
+ * @param unknown_type $szAddress1
313
+ * @param unknown_type $szAddress2
314
+ * @param unknown_type $szAddress3
315
+ * @param unknown_type $szAddress4
316
+ * @param unknown_type $szCity
317
+ * @param unknown_type $szState
318
+ * @param unknown_type $szPostCode
319
+ * @param unknown_type $szCountryCode
320
+ * @return unknown
321
+ */
322
+ public static function compareHostedPaymentFormHashDigest($formVariables, $szPassword, $hmHashMethod, $szPreSharedKey)
323
+ {
324
+ $boMatch = false;
325
+ $szCalculatedHashDigest;
326
+ $szStringBeforeHash;
327
+
328
+ $szStringBeforeHash = 'MerchantID='.$formVariables['MerchantID'].'&'.
329
+ 'Password='.$szPassword.'&'.
330
+ 'StatusCode='.$formVariables['StatusCode'].'&'.
331
+ 'Message='.$formVariables['Message'].'&'.
332
+ 'PreviousStatusCode='.$formVariables['PreviousStatusCode'].'&'.
333
+ 'PreviousMessage='.$formVariables['PreviousMessage'].'&'.
334
+ 'CrossReference='.$formVariables['CrossReference'].'&'.
335
+ 'Amount='.$formVariables['Amount'].'&'.
336
+ 'CurrencyCode='.$formVariables['CurrencyCode'].'&'.
337
+ 'OrderID='.$formVariables['OrderID'].'&'.
338
+ 'TransactionType='.$formVariables['TransactionType'].'&'.
339
+ 'TransactionDateTime='.$formVariables['TransactionDateTime'].'&'.
340
+ 'OrderDescription='.$formVariables['OrderDescription'].'&'.
341
+ 'CustomerName='.$formVariables['CustomerName'].'&'.
342
+ 'Address1='.$formVariables['Address1'].'&'.
343
+ 'Address2='.$formVariables['Address2'].'&'.
344
+ 'Address3='.$formVariables['Address3'].'&'.
345
+ 'Address4='.$formVariables['Address4'].'&'.
346
+ 'City='.$formVariables['City'].'&'.
347
+ 'State='.$formVariables['State'].'&'.
348
+ 'PostCode='.$formVariables['PostCode'].'&'.
349
+ 'CountryCode='.$formVariables['CountryCode'];
350
+
351
+ if ($hmHashMethod == Cardsave_Cardsaveonlinepayments_Model_Source_HashMethod::HASH_METHOD_MD5 ||
352
+ $hmHashMethod == Cardsave_Cardsaveonlinepayments_Model_Source_HashMethod::HASH_METHOD_SHA1)
353
+ {
354
+ $szStringBeforeHash = 'PreSharedKey='.$szPreSharedKey.'&'.$szStringBeforeHash;
355
+ }
356
+
357
+ $szCalculatedHashDigest = self::_hashCalculator($hmHashMethod, $szPreSharedKey, $szStringBeforeHash);
358
+ if(strtoupper($formVariables['HashDigest']) == strtoupper($szCalculatedHashDigest))
359
+ {
360
+ $boMatch = true;
361
+ }
362
+
363
+ return $boMatch;
364
+ }
365
+
366
+ /**
367
+ * Hash validator mechanism for the incoming payment complete hash in transparent redirect payment mode
368
+ *
369
+ * @param unknown_type $formVariables
370
+ * @param unknown_type $szPassword
371
+ * @param unknown_type $hmHashMethod
372
+ * @param unknown_type $szPreSharedKey
373
+ * @return unknown
374
+ */
375
+ public static function comparePaymentCompleteHashDigest($formVariables, $szPassword, $hmHashMethod, $szPreSharedKey)
376
+ {
377
+ $boMatch = false;
378
+ $szCalculatedHashDigest;
379
+ $szStringBeforeHash;
380
+
381
+ $szStringBeforeHash = 'MerchantID='.$formVariables['MerchantID'].'&'.
382
+ 'Password='.$szPassword.'&'.
383
+ 'Amount='.$formVariables['Amount'].'&'.
384
+ 'CurrencyCode='.$formVariables['CurrencyCode'].'&'.
385
+ 'OrderID='.$formVariables['OrderID'].'&'.
386
+ 'TransactionType='.$formVariables['TransactionType'].'&'.
387
+ 'TransactionDateTime='.$formVariables['TransactionDateTime'].'&'.
388
+ 'OrderDescription='.$formVariables['OrderDescription'];
389
+
390
+ if ($hmHashMethod == Cardsave_Cardsaveonlinepayments_Model_Source_HashMethod::HASH_METHOD_MD5 ||
391
+ $hmHashMethod == Cardsave_Cardsaveonlinepayments_Model_Source_HashMethod::HASH_METHOD_SHA1)
392
+ {
393
+ $szStringBeforeHash = 'PreSharedKey='.$szPreSharedKey.'&'.$szStringBeforeHash;
394
+ }
395
+
396
+ $szCalculatedHashDigest = self::_hashCalculator($hmHashMethod, $szPreSharedKey, $szStringBeforeHash);
397
+ if(strtoupper($formVariables['HashDigest']) == strtoupper($szCalculatedHashDigest))
398
+ {
399
+ $boMatch = true;
400
+ }
401
+
402
+ return $boMatch;
403
+ }
404
+
405
+ /**
406
+ * Hash validator mechanism for the 3D Secure Authentication required hash in the transparent redirect payment mode
407
+ *
408
+ * @param unknown_type $formVariables
409
+ * @param unknown_type $szPassword
410
+ * @param unknown_type $hmHashMethod
411
+ * @param unknown_type $szPreSharedKey
412
+ * @return unknown
413
+ */
414
+ public static function compareThreeDSecureAuthenticationRequiredHashDigest($formVariables, $szPassword, $hmHashMethod, $szPreSharedKey)
415
+ {
416
+ $boMatch = false;
417
+ $szCalculatedHashDigest;
418
+ $szStringBeforeHash;
419
+
420
+ $szStringBeforeHash = 'MerchantID='.$formVariables['MerchantID'].'&'.
421
+ 'Password='.$szPassword.'&'.
422
+ 'StatusCode='.$formVariables['StatusCode'].'&'.
423
+ 'Message='.$formVariables['Message'].'&'.
424
+ 'CrossReference='.$formVariables['CrossReference'].'&'.
425
+ 'OrderID='.$formVariables['OrderID'].'&'.
426
+ 'TransactionDateTime='.$formVariables['TransactionDateTime'].'&'.
427
+ 'ACSURL='.$formVariables['ACSURL'].'&'.
428
+ 'PaREQ='.$formVariables['PaREQ'];
429
+
430
+ if ($hmHashMethod == Cardsave_Cardsaveonlinepayments_Model_Source_HashMethod::HASH_METHOD_MD5 ||
431
+ $hmHashMethod == Cardsave_Cardsaveonlinepayments_Model_Source_HashMethod::HASH_METHOD_SHA1)
432
+ {
433
+ $szStringBeforeHash = 'PreSharedKey='.$szPreSharedKey.'&'.$szStringBeforeHash;
434
+ }
435
+
436
+ $szCalculatedHashDigest = self::_hashCalculator($hmHashMethod, $szPreSharedKey, $szStringBeforeHash);
437
+ if(strtoupper($formVariables['HashDigest']) == strtoupper($szCalculatedHashDigest))
438
+ {
439
+ $boMatch = true;
440
+ }
441
+
442
+ return $boMatch;
443
+ }
444
+
445
+ /**
446
+ * Convert a URL string to a name value array collection
447
+ *
448
+ * @param unknown_type $szInputVariableString
449
+ * @return unknown
450
+ */
451
+ public static function getVariableCollectionFromString($szInputVariableString)
452
+ {
453
+ $arVariableCollection = array();
454
+
455
+ $arURLVariableArray = explode('&', $szInputVariableString);
456
+ for($nCount = 0; $nCount < sizeof($arURLVariableArray); $nCount++)
457
+ {
458
+ $szNameValue = $arURLVariableArray[$nCount];
459
+ $arNameValue = explode('=', $szNameValue);
460
+ if(sizeof($arNameValue) == 1)
461
+ {
462
+ $arVariableCollection[$arNameValue[0]] = '';
463
+ }
464
+ else
465
+ {
466
+ $arVariableCollection[$arNameValue[0]] = $arNameValue[1];
467
+ }
468
+ }
469
+
470
+ return ($arVariableCollection);
471
+ }
472
+
473
+ /**
474
+ * Hash validator mechanism for the SERVER and SERVER_PULL methods
475
+ *
476
+ * @param unknown_type $formVariables
477
+ * @param unknown_type $szPassword
478
+ * @param unknown_type $hmHashMethod
479
+ * @param unknown_type $szPreSharedKey
480
+ */
481
+ public static function compareServerHashDigest($formVariables, $szPassword, $hmHashMethod, $szPreSharedKey)
482
+ {
483
+ $boMatch = false;
484
+ $szHashDigest = isset($formVariables['HashDigest']) ? $formVariables['HashDigest'] : false;
485
+ $szMerchantID = isset($formVariables['MerchantID']) ? $formVariables['MerchantID'] : false;
486
+ $szCrossReference = isset($formVariables['CrossReference']) ? $formVariables['CrossReference'] : false;
487
+ $szOrderID = isset($formVariables['OrderID']) ? $formVariables['OrderID'] : false;
488
+
489
+ $szStringBeforeHash = 'MerchantID='.$szMerchantID.'&'.
490
+ 'Password='.$szPassword.'&'.
491
+ 'CrossReference='.$szCrossReference.'&'.
492
+ 'OrderID='.$szOrderID;
493
+
494
+ if ($hmHashMethod == Cardsave_Cardsaveonlinepayments_Model_Source_HashMethod::HASH_METHOD_MD5 ||
495
+ $hmHashMethod == Cardsave_Cardsaveonlinepayments_Model_Source_HashMethod::HASH_METHOD_SHA1)
496
+ {
497
+ $szStringBeforeHash = 'PreSharedKey='.$szPreSharedKey.'&'.$szStringBeforeHash;
498
+ }
499
+
500
+ $szCalculatedHashDigest = self::_hashCalculator($hmHashMethod, $szPreSharedKey, $szStringBeforeHash);
501
+
502
+ if(strtoupper($szHashDigest) === strtoupper($szCalculatedHashDigest))
503
+ {
504
+ $boMatch = true;
505
+ }
506
+
507
+ return $boMatch;
508
+ }
509
+
510
+ // TODO : REMOVE
511
+ /**
512
+ * Transform the string Magento version number into an integer ready for comparison
513
+ *
514
+ * @param unknown_type $magentoVersion
515
+ * @return unknown
516
+ */
517
+ /*public static function getVersion($magentoVersion)
518
+ {
519
+ //$nVersion = Mage::getVersion();
520
+ $pattern = '/[^\d]/';
521
+ $magentoVersion = preg_replace($pattern, '', $magentoVersion);
522
+
523
+ while(strlen($magentoVersion) < 4)
524
+ {
525
+ $magentoVersion .= '0';
526
+ }
527
+ $magentoVersion = (int)$magentoVersion;
528
+
529
+ return $magentoVersion;
530
+ }*/
531
+ }
532
+ ?>
app/code/local/Cardsave/Cardsaveonlinepayments/Model/Common/ThePaymentGateway/PaymentSystem.php ADDED
@@ -0,0 +1,2400 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once('TPG_Common.php');
3
+ require_once('SOAP.php');
4
+
5
+ /*****************/
6
+ /* Input classes */
7
+ /*****************/
8
+ class CSV_RequestGatewayEntryPoint extends CSV_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
+ CSV_GatewayEntryPoint::__construct($szEntryPointURL, $nMetric);
23
+
24
+ $this->m_nRetryAttempts = $nRetryAttempts;
25
+ }
26
+ }
27
+
28
+ class CSV_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 CSV_RequestGatewayEntryPoint($EntryPointURL, $nMetric, $nRetryAttempts));
56
+ }
57
+
58
+ //constructor
59
+ public function __construct()
60
+ {
61
+ $this->m_lrgepRequestGatewayEntryPoint = array();
62
+ }
63
+ }
64
+
65
+ class CSV_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 CSV_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 CSV_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 CSV_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 CSV_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, CSV_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 CSV_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(CSV_NullableInt $nMonth = null, CSV_NullableInt $nYear = null)
268
+ {
269
+ $this->m_nMonth = $nMonth;
270
+ $this->m_nYear = $nYear;
271
+ }
272
+ }
273
+
274
+ class CSV_ExpiryDate extends CSV_CreditCardDate
275
+ {
276
+ public function __construct(CSV_NullableInt $nMonth = null, CSV_NullableInt $nYear = null)
277
+ {
278
+ parent::__construct($nMonth, $nYear);
279
+ }
280
+ }
281
+
282
+ class CSV_StartDate extends CSV_CreditCardDate
283
+ {
284
+ public function __construct(CSV_NullableInt $nMonth = null, CSV_NullableInt $nYear = null)
285
+ {
286
+ parent::__construct($nMonth, $nYear);
287
+ }
288
+ }
289
+
290
+ class CSV_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, CSV_ExpiryDate $edExpiryDate = null, CSV_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 CSV_OverrideCardDetails extends CSV_CardDetails
341
+ {
342
+ public function __construct($szCardName, $szCardNumber, CSV_ExpiryDate $edExpiryDate = null, CSV_StartDate $sdStartDate = null, $IssueNumber, $CV2)
343
+ {
344
+ parent::__construct($szCardName, $szCardNumber, $edExpiryDate, $sdStartDate, $IssueNumber, $CV2);
345
+ }
346
+ }
347
+
348
+ class CSV_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 CSV_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, CSV_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 CSV_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, CSV_NullableInt $nAmount = null, CSV_NullableInt $nCurrencyCode = null, $szOrderID, $szOrderDescription, CSV_TransactionControl $tcTransactionControl = null, CSV_ThreeDSecureBrowserDetails $tdsbdThreeDSecureBrowserDetails = null)
446
+ {
447
+ if ($TransactionTypeOrMessageDetails instanceof CSV_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 CSV_MessageDetails($TransactionTypeOrMessageDetails), $nAmount, $nCurrencyCode, $szOrderID, $szOrderDescription, $tcTransactionControl, $tdsbdThreeDSecureBrowserDetails);
460
+ }
461
+ }
462
+ }
463
+
464
+ class CSV_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(CSV_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 CSV_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(CSV_NullableBool $boEchoCardType = null, CSV_NullableBool $boEchoAVSCheckResult = null, CSV_NullableBool $boEchoCV2CheckResult = null, CSV_NullableBool $boEchoAmountReceived = null, CSV_NullableInt $nDuplicateDelay = null, $szAVSOverridePolicy, $szCV2OverridePolicy, CSV_NullableBool $boThreeDSecureOverridePolicy = null, $szAuthCode, CSV_ThreeDSecurePassthroughData $tdsptThreeDSecurePassthroughData = null, CSV_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 CSV_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 CSV_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 CSV_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 CSV_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, CSV_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 CSV_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 CSV_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 CSV_GatewayEntryPoint($GatewayEntrypointOrEntrypointURL, $nMetric));
769
+ }
770
+
771
+ //constructor
772
+ public function __construct()
773
+ {
774
+ $this->m_lgepGatewayEntryPoint = array();
775
+ }
776
+ }
777
+
778
+ class CSV_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(CSV_NullableInt $nStatusCode = null,
794
+ $szMessage)
795
+ {
796
+ $this->m_nStatusCode = $nStatusCode;
797
+ $this->m_szMessage = $szMessage;
798
+ }
799
+ }
800
+
801
+ class CSV_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, CSV_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 CSV_PaymentMessageGatewayOutput extends CSV_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, CSV_NullableBool $boAuthorisationAttempted = null, CSV_PreviousTransactionResult $ptdPreviousTransactionResult = null, CSV_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 CSV_CardDetailsTransactionResult extends CSV_PaymentMessageGatewayOutput
864
+ {
865
+ public function __construct($nStatusCode, $szMessage, $szPassOutData, CSV_NullableBool $boAuthorisationAttempted = null, CSV_PreviousTransactionResult $ptdPreviousTransactionResult = null, CSV_StringList $lszErrorMessages = null)
866
+ {
867
+ parent::__construct($nStatusCode, $szMessage, $szPassOutData, $boAuthorisationAttempted, $ptdPreviousTransactionResult, $lszErrorMessages);
868
+ }
869
+ }
870
+ class CSV_CrossReferenceTransactionResult extends CSV_PaymentMessageGatewayOutput
871
+ {
872
+ public function __construct($nStatusCode, $szMessage, $szPassOutData, CSV_NullableBool $boAuthorisationAttempted = null, CSV_PreviousTransactionResult $ptdPreviousTransactionResult = null, CSV_StringList $lszErrorMessages = null)
873
+ {
874
+ parent::__construct($nStatusCode, $szMessage, $szPassOutData, $boAuthorisationAttempted, $ptdPreviousTransactionResult, $lszErrorMessages);
875
+ }
876
+ }
877
+ class CSV_ThreeDSecureTransactionResult extends CSV_PaymentMessageGatewayOutput
878
+ {
879
+ public function __construct($nStatusCode, $szMessage, $szPassOutData, CSV_NullableBool $boAuthorisationAttempted = null, CSV_PreviousTransactionResult $ptdPreviousTransactionResult = null, CSV_StringList $lszErrorMessages = null)
880
+ {
881
+ parent::__construct($nStatusCode, $szMessage, $szPassOutData, $boAuthorisationAttempted, $ptdPreviousTransactionResult, $lszErrorMessages);
882
+ }
883
+ }
884
+ class CSV_GetGatewayEntryPointsResult extends CSV_GatewayOutput
885
+ {
886
+ public function __construct($nStatusCode, $szMessage, $szPassOutData, StringList $lszErrorMessages = null)
887
+ {
888
+ parent::__construct($nStatusCode, $szMessage, $szPassOutData, $lszErrorMessages);
889
+ }
890
+ }
891
+ class CSV_GetCardTypeResult extends CSV_GatewayOutput
892
+ {
893
+ public function __construct($nStatusCode, $szMessage, $szPassOutData, CSV_StringList $lszErrorMessages = null)
894
+ {
895
+ parent::__construct($nStatusCode, $szMessage, $szPassOutData, $lszErrorMessages);
896
+ }
897
+ }
898
+
899
+ class CSV_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 CSV_GetGatewayEntryPointsOutputData extends CSV_BaseOutputData
923
+ {
924
+ //constructor
925
+ function __construct(CSV_GatewayEntryPointList $lgepGatewayEntryPoints = null)
926
+ {
927
+ parent::__construct($lgepGatewayEntryPoints);
928
+ }
929
+ }
930
+
931
+ class CSV_TransactionOutputData extends CSV_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
+ CSV_CardTypeData $ctdCardTypeData = null,
1002
+ CSV_NullableInt $nAmountReceived = null,
1003
+ CSV_ThreeDSecureOutputData $tdsodThreeDSecureOutputData = null,
1004
+ CSV_GenericVariableList $lgvCustomVariables = null,
1005
+ CSV_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 CSV_GetCardTypeOutputData extends CSV_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(CSV_CardTypeData $ctdCardTypeData = null,
1034
+ CSV_GatewayEntryPointList $lgepGatewayEntryPoints = null)
1035
+ {
1036
+ parent::__construct($lgepGatewayEntryPoints);
1037
+
1038
+ $this->m_ctdCardTypeData = $ctdCardTypeData;
1039
+ }
1040
+ }
1041
+
1042
+ class CSV_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(CSV_GatewayEntryPointList $lgepGatewayEntryPoints = null)
1053
+ {
1054
+ $this->m_lgepGatewayEntryPoints = $lgepGatewayEntryPoints;
1055
+ }
1056
+ }
1057
+
1058
+
1059
+ /********************/
1060
+ /* Gateway messages */
1061
+ /********************/
1062
+ class CSV_GetGatewayEntryPoints extends CSV_GatewayTransaction
1063
+ {
1064
+ function processTransaction(CSV_GetGatewayEntryPointsResult &$ggeprGetGatewayEntryPointsResult = null, CSV_GetGatewayEntryPointsOutputData &$ggepGetGatewayEntryPointsOutputData = null)
1065
+ {
1066
+ $boTransactionSubmitted = false;
1067
+ $sSOAPClient;
1068
+ $lgepGatewayEntryPoints;
1069
+
1070
+ $ggepGetGatewayEntryPointsOutputData = null;
1071
+ $goGatewayOutput = null;
1072
+
1073
+ $sSOAPClient = new CSV_SOAP('GetGatewayEntryPoints', CSV_GatewayTransaction::getSOAPNamespace());
1074
+
1075
+ $boTransactionSubmitted = CSV_GatewayTransaction::processTransactionBase($sSOAPClient, 'GetGatewayEntryPointsMessage', 'GetGatewayEntryPointsResult', 'GetGatewayEntryPointsOutputData', $sxXmlDocument, $goGatewayOutput, $lgepGatewayEntryPoints);
1076
+
1077
+ if ($boTransactionSubmitted)
1078
+ {
1079
+ $ggeprGetGatewayEntryPointsResult = $goGatewayOutput;
1080
+
1081
+ $ggepGetGatewayEntryPointsOutputData = new CSV_GetGatewayEntryPointsOutputData($lgepGatewayEntryPoints);
1082
+ }
1083
+
1084
+ return $boTransactionSubmitted;
1085
+ }
1086
+
1087
+ //constructor
1088
+ public function __construct(CSV_RequestGatewayEntryPointList $lrgepRequestGatewayEntryPoints = null,
1089
+ $nRetryAttempts,
1090
+ CSV_NullableInt $nTimeout = null,
1091
+ CSV_MerchantAuthentication $maMerchantAuthentication = null,
1092
+ $szPassOutData)
1093
+ {
1094
+ if ($nRetryAttempts == null &&
1095
+ $nTimeout == null)
1096
+ {
1097
+ CSV_GatewayTransaction::__construct($lrgepRequestGatewayEntryPoints, 1, null, $maMerchantAuthentication, $szPassOutData);
1098
+ }
1099
+ else
1100
+ {
1101
+ CSV_GatewayTransaction::__construct($lrgepRequestGatewayEntryPoints, $nRetryAttempts, $nTimeout, $maMerchantAuthentication, $szPassOutData);
1102
+ }
1103
+ }
1104
+ }
1105
+
1106
+
1107
+ class CSV_CardDetailsTransaction extends CSV_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(CSV_CardDetailsTransactionResult &$cdtrCardDetailsTransactionResult = null, CSV_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 CSV_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
+
1160
+ if ($this->m_tdTransactionDetails->getMessageDetails() != null)
1161
+ {
1162
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getMessageDetails()->getTransactionType()))
1163
+ {
1164
+ $sSOAPClient->addParamAttribute('PaymentMessage.TransactionDetails.MessageDetails', 'TransactionType', $this->m_tdTransactionDetails->getMessageDetails()->getTransactionType());
1165
+ }
1166
+ }
1167
+ if ($this->m_tdTransactionDetails->getTransactionControl() != null)
1168
+ {
1169
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getTransactionControl()->getAuthCode()))
1170
+ {
1171
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.AuthCode', $this->m_tdTransactionDetails->getTransactionControl()->getAuthCode());
1172
+ }
1173
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getThreeDSecureOverridePolicy() != null)
1174
+ {
1175
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.ThreeDSecureOverridePolicy', CSV_SharedFunctions::boolToString($this->m_tdTransactionDetails->getTransactionControl()->getThreeDSecureOverridePolicy()->getValue()));
1176
+ }
1177
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getTransactionControl()->getAVSOverridePolicy()))
1178
+ {
1179
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.AVSOverridePolicy', $this->m_tdTransactionDetails->getTransactionControl()->getAVSOverridePolicy());
1180
+ }
1181
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getTransactionControl()->getCV2OverridePolicy()))
1182
+ {
1183
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.CV2OverridePolicy', ($this->m_tdTransactionDetails->getTransactionControl()->getCV2OverridePolicy()));
1184
+ }
1185
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getDuplicateDelay() != null)
1186
+ {
1187
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getDuplicateDelay()->getHasValue())
1188
+ {
1189
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.DuplicateDelay', (string)$this->m_tdTransactionDetails->getTransactionControl()->getDuplicateDelay()->getValue());
1190
+ }
1191
+ }
1192
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoCardType() != null)
1193
+ {
1194
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoCardType()->getHasValue())
1195
+ {
1196
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.EchoCardType', CSV_SharedFunctions::boolToString($this->m_tdTransactionDetails->getTransactionControl()->getEchoCardType()->getValue()));
1197
+ }
1198
+ }
1199
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoAVSCheckResult() != null)
1200
+ {
1201
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoAVSCheckResult()->getHasValue())
1202
+ {
1203
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.EchoAVSCheckResult', CSV_SharedFunctions::boolToString($this->m_tdTransactionDetails->getTransactionControl()->getEchoAVSCheckResult()->getValue()));
1204
+ }
1205
+ }
1206
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoAVSCheckResult() != null)
1207
+ {
1208
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoAVSCheckResult()->getHasValue())
1209
+ {
1210
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.EchoAVSCheckResult', CSV_SharedFunctions::boolToString($this->m_tdTransactionDetails->getTransactionControl()->getEchoAVSCheckResult()->getValue()));
1211
+ }
1212
+ }
1213
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoCV2CheckResult() != null)
1214
+ {
1215
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoCV2CheckResult()->getHasValue())
1216
+ {
1217
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.EchoCV2CheckResult', CSV_SharedFunctions::boolToString($this->m_tdTransactionDetails->getTransactionControl()->getEchoCV2CheckResult()->getValue()));
1218
+ }
1219
+ }
1220
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoAmountReceived() != null)
1221
+ {
1222
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoAmountReceived()->getHasValue())
1223
+ {
1224
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.EchoAmountReceived', CSV_SharedFunctions::boolToString($this->m_tdTransactionDetails->getTransactionControl()->getEchoAmountReceived()->getValue()));
1225
+ }
1226
+ }
1227
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getThreeDSecurePassthroughData() != null)
1228
+ {
1229
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getTransactionControl()->getThreeDSecurePassthroughData()->getEnrolmentStatus()))
1230
+ {
1231
+ $sSOAPClient->addParamAttribute('PaymentMessage.TransactionDetails.TransactionControl.ThreeDSecurePassthroughData', 'EnrolmentStatus', $this->m_tdTransactionDetails->getTransactionControl()->getThreeDSecurePassthroughData()->getEnrolmentStatus());
1232
+ }
1233
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getTransactionControl()->getThreeDSecurePassthroughData()->getAuthenticationStatus()))
1234
+ {
1235
+ $sSOAPClient->addParamAttribute('PaymentMessage.TransactionDetails.TransactionControl.ThreeDSecurePassthroughData', 'AuthenticationStatus', $this->m_tdTransactionDetails->getTransactionControl()->getThreeDSecurePassthroughData()->getAuthenticationStatus());
1236
+ }
1237
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getTransactionControl()->getThreeDSecurePassthroughData()->getElectronicCommerceIndicator()))
1238
+ {
1239
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.ThreeDSecurePassthroughData.ElectronicCommerceIndicator', $this->m_tdTransactionDetails->getTransactionControl()->getThreeDSecurePassthroughData()->getElectronicCommerceIndicator());
1240
+ }
1241
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getTransactionControl()->getThreeDSecurePassthroughData()->getAuthenticationValue()))
1242
+ {
1243
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.ThreeDSecurePassthroughData.AuthenticationValue', $this->m_tdTransactionDetails->getTransactionControl()->getThreeDSecurePassthroughData()->getAuthenticationValue());
1244
+ }
1245
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getTransactionControl()->getThreeDSecurePassthroughData()->getTransactionIdentifier()))
1246
+ {
1247
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.ThreeDSecurePassthroughData.TransactionIdentifier', $this->m_tdTransactionDetails->getTransactionControl()->getThreeDSecurePassthroughData()->getTransactionIdentifier());
1248
+ }
1249
+ }
1250
+ }
1251
+
1252
+ if ($this->m_tdTransactionDetails->getThreeDSecureBrowserDetails() != null)
1253
+ {
1254
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getThreeDSecureBrowserDetails()->getAcceptHeaders()))
1255
+ {
1256
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.ThreeDSecureBrowserDetails.AcceptHeaders', $this->m_tdTransactionDetails->getThreeDSecureBrowserDetails()->getAcceptHeaders());
1257
+ }
1258
+ if ($this->m_tdTransactionDetails->getThreeDSecureBrowserDetails()->getDeviceCategory() != null)
1259
+ {
1260
+ if ($this->m_tdTransactionDetails->getThreeDSecureBrowserDetails()->getDeviceCategory()->getHasValue())
1261
+ {
1262
+ $sSOAPClient->addParamAttribute('PaymentMessage.TransactionDetails.ThreeDSecureBrowserDetails', 'DeviceCategory', (string)$this->m_tdTransactionDetails->getThreeDSecureBrowserDetails()->getDeviceCategory()->getValue());
1263
+ }
1264
+ }
1265
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getThreeDSecureBrowserDetails()->getUserAgent()))
1266
+ {
1267
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.ThreeDSecureBrowserDetails.UserAgent', $this->m_tdTransactionDetails->getThreeDSecureBrowserDetails()->getUserAgent());
1268
+ }
1269
+ }
1270
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getOrderID()))
1271
+ {
1272
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.OrderID', $this->m_tdTransactionDetails->getOrderID());
1273
+ }
1274
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getOrderDescription()))
1275
+ {
1276
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.OrderDescription', $this->m_tdTransactionDetails->getOrderDescription());
1277
+ }
1278
+ }
1279
+
1280
+ // card details
1281
+ if ($this->m_cdCardDetails != null)
1282
+ {
1283
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCardDetails->getCardName()))
1284
+ {
1285
+ $sSOAPClient->addParam('PaymentMessage.CardDetails.CardName', $this->m_cdCardDetails->getCardName());
1286
+ }
1287
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCardDetails->getCV2()))
1288
+ {
1289
+ $sSOAPClient->addParam('PaymentMessage.CardDetails.CV2', $this->m_cdCardDetails->getCV2());
1290
+ }
1291
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCardDetails->getCardNumber()))
1292
+ {
1293
+ $sSOAPClient->addParam('PaymentMessage.CardDetails.CardNumber', $this->m_cdCardDetails->getCardNumber());
1294
+ }
1295
+ if ($this->m_cdCardDetails->getExpiryDate() != null)
1296
+ {
1297
+ if ($this->m_cdCardDetails->getExpiryDate()->getMonth() != null)
1298
+ {
1299
+ if ($this->m_cdCardDetails->getExpiryDate()->getMonth()->getHasValue())
1300
+ {
1301
+ $sSOAPClient->addParamAttribute('PaymentMessage.CardDetails.ExpiryDate', 'Month', (string)$this->m_cdCardDetails->getExpiryDate()->getMonth()->getValue());
1302
+ }
1303
+ }
1304
+ if ($this->m_cdCardDetails->getExpiryDate()->getYear() != null)
1305
+ {
1306
+ if ($this->m_cdCardDetails->getExpiryDate()->getYear()->getHasValue())
1307
+ {
1308
+ $sSOAPClient->addParamAttribute('PaymentMessage.CardDetails.ExpiryDate', 'Year', (string)$this->m_cdCardDetails->getExpiryDate()->getYear()->getValue());
1309
+ }
1310
+ }
1311
+ }
1312
+ if ($this->m_cdCardDetails->getStartDate() != null)
1313
+ {
1314
+ if ($this->m_cdCardDetails->getStartDate()->getMonth() != null)
1315
+ {
1316
+ if ($this->m_cdCardDetails->getStartDate()->getMonth()->getHasValue())
1317
+ {
1318
+ $sSOAPClient->addParamAttribute('PaymentMessage.CardDetails.StartDate', 'Month', (string)$this->m_cdCardDetails->getStartDate()->getMonth()->getValue());
1319
+ }
1320
+ }
1321
+ if ($this->m_cdCardDetails->getStartDate()->getYear() != null)
1322
+ {
1323
+ if ($this->m_cdCardDetails->getStartDate()->getYear()->getHasValue())
1324
+ {
1325
+ $sSOAPClient->addParamAttribute('PaymentMessage.CardDetails.StartDate', 'Year', (string)$this->m_cdCardDetails->getStartDate()->getYear()->getValue());
1326
+ }
1327
+ }
1328
+ }
1329
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCardDetails->getIssueNumber()))
1330
+ {
1331
+ $sSOAPClient->addParam('PaymentMessage.CardDetails.IssueNumber', $this->m_cdCardDetails->getIssueNumber());
1332
+ }
1333
+ }
1334
+
1335
+ // customer details
1336
+ if ($this->m_cdCustomerDetails != null)
1337
+ {
1338
+ if ($this->m_cdCustomerDetails->getBillingAddress() != null)
1339
+ {
1340
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getAddress1()))
1341
+ {
1342
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.Address1', $this->m_cdCustomerDetails->getBillingAddress()->getAddress1());
1343
+ }
1344
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getAddress2()))
1345
+ {
1346
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.Address2', $this->m_cdCustomerDetails->getBillingAddress()->getAddress2());
1347
+ }
1348
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getAddress3()))
1349
+ {
1350
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.Address3', $this->m_cdCustomerDetails->getBillingAddress()->getAddress3());
1351
+ }
1352
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getAddress4()))
1353
+ {
1354
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.Address4', $this->m_cdCustomerDetails->getBillingAddress()->getAddress4());
1355
+ }
1356
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getCity()))
1357
+ {
1358
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.City', $this->m_cdCustomerDetails->getBillingAddress()->getCity());
1359
+ }
1360
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getState()))
1361
+ {
1362
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.State', $this->m_cdCustomerDetails->getBillingAddress()->getState());
1363
+ }
1364
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getPostCode()))
1365
+ {
1366
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.PostCode', $this->m_cdCustomerDetails->getBillingAddress()->getPostCode());
1367
+ }
1368
+ if ($this->m_cdCustomerDetails->getBillingAddress()->getCountryCode() != null)
1369
+ {
1370
+ if ($this->m_cdCustomerDetails->getBillingAddress()->getCountryCode()->getHasValue())
1371
+ {
1372
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.CountryCode', (string)$this->m_cdCustomerDetails->getBillingAddress()->getCountryCode()->getValue());
1373
+ }
1374
+ }
1375
+ }
1376
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getEmailAddress()))
1377
+ {
1378
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.EmailAddress', $this->m_cdCustomerDetails->getEmailAddress());
1379
+ }
1380
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getPhoneNumber()))
1381
+ {
1382
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.PhoneNumber', $this->m_cdCustomerDetails->getPhoneNumber());
1383
+ }
1384
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getCustomerIPAddress()))
1385
+ {
1386
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.CustomerIPAddress', $this->m_cdCustomerDetails->getCustomerIPAddress());
1387
+ }
1388
+ }
1389
+
1390
+ $boTransactionSubmitted = CSV_GatewayTransaction::processTransactionBase($sSOAPClient, 'PaymentMessage', 'CardDetailsTransactionResult', 'TransactionOutputData', $sxXmlDocument, $goGatewayOutput, $lgepGatewayEntryPoints);
1391
+
1392
+ if ($boTransactionSubmitted)
1393
+ {
1394
+ $cdtrCardDetailsTransactionResult = CSV_SharedFunctionsPaymentSystemShared::getPaymentMessageGatewayOutput($sxXmlDocument->CardDetailsTransactionResult, $goGatewayOutput);
1395
+
1396
+ $todTransactionOutputData = CSV_SharedFunctionsPaymentSystemShared::getTransactionOutputData($sxXmlDocument, $lgepGatewayEntryPoints);
1397
+ }
1398
+
1399
+ return ($boTransactionSubmitted);
1400
+ }
1401
+
1402
+ public function __construct(CSV_RequestGatewayEntryPointList $lrgepRequestGatewayEntryPoints = null,
1403
+ $nRetryAttempts,
1404
+ CSV_NullableInt $nTimeout = null,
1405
+ CSV_MerchantAuthentication $maMerchantAuthentication = null,
1406
+ CSV_TransactionDetails $tdTransactionDetails = null,
1407
+ CSV_CardDetails $cdCardDetails = null,
1408
+ CSV_CustomerDetails $cdCustomerDetails = null,
1409
+ $szPassOutData)
1410
+ {
1411
+ parent::__construct($lrgepRequestGatewayEntryPoints, $nRetryAttempts, $nTimeout, $maMerchantAuthentication, $szPassOutData);
1412
+
1413
+ $this->m_tdTransactionDetails = $tdTransactionDetails;
1414
+ $this->m_cdCardDetails = $cdCardDetails;
1415
+ $this->m_cdCustomerDetails = $cdCustomerDetails;
1416
+ }
1417
+
1418
+ }
1419
+ class CSV_CrossReferenceTransaction extends CSV_GatewayTransaction
1420
+ {
1421
+ private $m_tdTransactionDetails;
1422
+ private $m_ocdOverrideCardDetails;
1423
+ private $m_cdCustomerDetails;
1424
+
1425
+ public function getTransactionDetails()
1426
+ {
1427
+ return $this->m_tdTransactionDetails;
1428
+ }
1429
+ public function getOverrideCardDetails()
1430
+ {
1431
+ return $this->m_ocdOverrideCardDetails;
1432
+ }
1433
+ public function getCustomerDetails()
1434
+ {
1435
+ return $this->m_cdCustomerDetails;
1436
+ }
1437
+
1438
+ public function processTransaction(CSV_CrossReferenceTransactionResult &$crtrCrossReferenceTransactionResult = null, CSV_TransactionOutputData &$todTransactionOutputData = null)
1439
+ {
1440
+ $boTransactionSubmitted = false;
1441
+ $sSOAPClient;
1442
+ $lgepGatewayEntryPoints = null;
1443
+ $sxXmlDocument = null;
1444
+
1445
+ $todTransactionOutputData = null;
1446
+ $goGatewayOutput = null;
1447
+
1448
+ $sSOAPClient = new CSV_SOAP('CrossReferenceTransaction', CSV_GatewayTransaction::getSOAPNamespace());
1449
+ // transaction details
1450
+ if ($this->m_tdTransactionDetails != null)
1451
+ {
1452
+ if ($this->m_tdTransactionDetails->getAmount() != null)
1453
+ {
1454
+ if ($this->m_tdTransactionDetails->getAmount()->getHasValue())
1455
+ {
1456
+ $sSOAPClient->addParamAttribute('PaymentMessage.TransactionDetails', 'Amount', (string)$this->m_tdTransactionDetails->getAmount()->getValue());
1457
+ }
1458
+ }
1459
+ if ($this->m_tdTransactionDetails->getCurrencyCode() != null)
1460
+ {
1461
+ if ($this->m_tdTransactionDetails->getCurrencyCode()->getHasValue())
1462
+ {
1463
+ $sSOAPClient->addParamAttribute('PaymentMessage.TransactionDetails', 'CurrencyCode', (string)$this->m_tdTransactionDetails->getCurrencyCode()->getValue());
1464
+ }
1465
+ }
1466
+ if ($this->m_tdTransactionDetails->getMessageDetails() != null)
1467
+ {
1468
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getMessageDetails()->getTransactionType()))
1469
+ {
1470
+ $sSOAPClient->addParamAttribute('PaymentMessage.TransactionDetails.MessageDetails', 'TransactionType', $this->m_tdTransactionDetails->getMessageDetails()->getTransactionType());
1471
+ }
1472
+ if ($this->m_tdTransactionDetails->getMessageDetails()->getNewTransaction() != null)
1473
+ {
1474
+ if ($this->m_tdTransactionDetails->getMessageDetails()->getNewTransaction()->getHasValue())
1475
+ {
1476
+ $sSOAPClient->addParamAttribute('PaymentMessage.TransactionDetails.MessageDetails', 'NewTransaction', CSV_SharedFunctions::boolToString($this->m_tdTransactionDetails->getMessageDetails()->getNewTransaction()->getValue()));
1477
+ }
1478
+ }
1479
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getMessageDetails()->getCrossReference()))
1480
+ {
1481
+ $sSOAPClient->addParamAttribute('PaymentMessage.TransactionDetails.MessageDetails', 'CrossReference', $this->m_tdTransactionDetails->getMessageDetails()->getCrossReference());
1482
+ }
1483
+ }
1484
+ if ($this->m_tdTransactionDetails->getTransactionControl() != null)
1485
+ {
1486
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getTransactionControl()->getAuthCode()))
1487
+ {
1488
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.AuthCode', $this->m_tdTransactionDetails->getTransactionControl()->getAuthCode());
1489
+ }
1490
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getTransactionControl()->getAVSOverridePolicy()))
1491
+ {
1492
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.AVSOverridePolicy', $this->m_tdTransactionDetails->getTransactionControl()->getAVSOverridePolicy());
1493
+ }
1494
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getTransactionControl()->getCV2OverridePolicy()))
1495
+ {
1496
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.CV2OverridePolicy', $this->m_tdTransactionDetails->getTransactionControl()->getCV2OverridePolicy());
1497
+ }
1498
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getDuplicateDelay() != null)
1499
+ {
1500
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getDuplicateDelay()->getHasValue())
1501
+ {
1502
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.DuplicateDelay', (string)($this->m_tdTransactionDetails->getTransactionControl()->getDuplicateDelay()->getValue()));
1503
+ }
1504
+ }
1505
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoCardType() != null)
1506
+ {
1507
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoCardType()->getHasValue())
1508
+ {
1509
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.EchoCardType', CSV_SharedFunctions::boolToString($this->m_tdTransactionDetails->getTransactionControl()->getEchoCardType()->getValue()));
1510
+ }
1511
+ }
1512
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoAVSCheckResult() != null)
1513
+ {
1514
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoAVSCheckResult()->getHasValue())
1515
+ {
1516
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.EchoAVSCheckResult', CSV_SharedFunctions::boolToString($this->m_tdTransactionDetails->getTransactionControl()->getEchoAVSCheckResult()->getValue()));
1517
+ }
1518
+ }
1519
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoAVSCheckResult() != null)
1520
+ {
1521
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoAVSCheckResult()->getHasValue())
1522
+ {
1523
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.EchoAVSCheckResult', CSV_SharedFunctions::boolToString($this->m_tdTransactionDetails->getTransactionControl()->getEchoAVSCheckResult()->getValue()));
1524
+ }
1525
+ }
1526
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoCV2CheckResult() != null)
1527
+ {
1528
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoCV2CheckResult()->getHasValue())
1529
+ {
1530
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.EchoCV2CheckResult', CSV_SharedFunctions::boolToString($this->m_tdTransactionDetails->getTransactionControl()->getEchoCV2CheckResult()->getValue()));
1531
+ }
1532
+ }
1533
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoAmountReceived() != null)
1534
+ {
1535
+ if ($this->m_tdTransactionDetails->getTransactionControl()->getEchoAmountReceived()->getHasValue())
1536
+ {
1537
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.TransactionControl.EchoAmountReceived', CSV_SharedFunctions::boolToString($this->m_tdTransactionDetails->getTransactionControl()->getEchoAmountReceived()->getValue()));
1538
+ }
1539
+ }
1540
+ }
1541
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getOrderID()))
1542
+ {
1543
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.OrderID', $this->m_tdTransactionDetails->getOrderID());
1544
+ }
1545
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdTransactionDetails->getOrderDescription()))
1546
+ {
1547
+ $sSOAPClient->addParam('PaymentMessage.TransactionDetails.OrderDescription', $this->m_tdTransactionDetails->getOrderDescription());
1548
+ }
1549
+ }
1550
+ // card details
1551
+ if ($this->m_ocdOverrideCardDetails != null)
1552
+ {
1553
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_ocdOverrideCardDetails->getCardName()))
1554
+ {
1555
+ $sSOAPClient->addParam('PaymentMessage.OverrideCardDetails.CardName', $this->m_ocdOverrideCardDetails->getCardName());
1556
+ }
1557
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_ocdOverrideCardDetails->getCV2()))
1558
+ {
1559
+ $sSOAPClient->addParam('PaymentMessage.CardDetails.CV2', $this->m_ocdOverrideCardDetails->getCV2());
1560
+ }
1561
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_ocdOverrideCardDetails->getCardNumber()))
1562
+ {
1563
+ $sSOAPClient->addParam('PaymentMessage.OverrideCardDetails.CardNumber', $this->m_ocdOverrideCardDetails->getCardNumber());
1564
+ }
1565
+ if ($this->m_ocdOverrideCardDetails->getExpiryDate() != null)
1566
+ {
1567
+ if ($this->m_ocdOverrideCardDetails->getExpiryDate()->getMonth() != null)
1568
+ {
1569
+ if ($this->m_ocdOverrideCardDetails->getExpiryDate()->getMonth()->getHasValue())
1570
+ {
1571
+ $sSOAPClient->addParamAttribute('PaymentMessage.OverrideCardDetails.ExpiryDate', 'Month', (string)$this->m_ocdOverrideCardDetails->getExpiryDate()->getMonth()->getValue());
1572
+ }
1573
+ }
1574
+ if ($this->m_ocdOverrideCardDetails->getExpiryDate()->getYear() != null)
1575
+ {
1576
+ if ($this->m_ocdOverrideCardDetails->getExpiryDate()->getYear()->getHasValue())
1577
+ {
1578
+ $sSOAPClient->addParamAttribute('PaymentMessage.OverrideCardDetails.ExpiryDate', 'Year', (string)$this->m_ocdOverrideCardDetails->getExpiryDate()->getYear()->getValue());
1579
+ }
1580
+ }
1581
+ }
1582
+ if ($this->m_ocdOverrideCardDetails->getStartDate() != null)
1583
+ {
1584
+ if ($this->m_ocdOverrideCardDetails->getStartDate()->getMonth() != null)
1585
+ {
1586
+ if ($this->m_ocdOverrideCardDetails->getStartDate()->getMonth()->getHasValue())
1587
+ {
1588
+ $sSOAPClient->addParamAttribute('PaymentMessage.OverrideCardDetails.StartDate', 'Month', (string)$this->m_ocdOverrideCardDetails->getStartDate()->getMonth()->getValue());
1589
+ }
1590
+ }
1591
+ if ($this->m_ocdOverrideCardDetails->getStartDate()->getYear() != null)
1592
+ {
1593
+ if ($this->m_ocdOverrideCardDetails->getStartDate()->getYear()->getHasValue())
1594
+ {
1595
+ $sSOAPClient->addParamAttribute('PaymentMessage.OverrideCardDetails.StartDate', 'Year', (string)$this->m_ocdOverrideCardDetails->getStartDate()->getYear()->getValue());
1596
+ }
1597
+ }
1598
+ }
1599
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_ocdOverrideCardDetails->getIssueNumber()))
1600
+ {
1601
+ $sSOAPClient->addParam('PaymentMessage.CardDetails.IssueNumber', $this->m_ocdOverrideCardDetails->getIssueNumber());
1602
+ }
1603
+ }
1604
+ // customer details
1605
+ if ($this->m_cdCustomerDetails != null)
1606
+ {
1607
+ if ($this->m_cdCustomerDetails->getBillingAddress() != null)
1608
+ {
1609
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getAddress1()))
1610
+ {
1611
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.Address1', $this->m_cdCustomerDetails->getBillingAddress()->getAddress1());
1612
+ }
1613
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getAddress2()))
1614
+ {
1615
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.Address2', $this->m_cdCustomerDetails->getBillingAddress()->getAddress2());
1616
+ }
1617
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getAddress3()))
1618
+ {
1619
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.Address3', $this->m_cdCustomerDetails->getBillingAddress()->getAddress3());
1620
+ }
1621
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getAddress4()))
1622
+ {
1623
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.Address4', $this->m_cdCustomerDetails->getBillingAddress()->getAddress4());
1624
+ }
1625
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getCity()))
1626
+ {
1627
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.City', $this->m_cdCustomerDetails->getBillingAddress()->getCity());
1628
+ }
1629
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getState()))
1630
+ {
1631
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.State', $this->m_cdCustomerDetails->getBillingAddress()->getState());
1632
+ }
1633
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getBillingAddress()->getPostCode()))
1634
+ {
1635
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.PostCode', (string)$this->m_cdCustomerDetails->getBillingAddress()->getPostCode());
1636
+ }
1637
+ if ($this->m_cdCustomerDetails->getBillingAddress()->getCountryCode() != null)
1638
+ {
1639
+ if ($this->m_cdCustomerDetails->getBillingAddress()->getCountryCode()->getHasValue())
1640
+ {
1641
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.BillingAddress.CountryCode', (string)$this->m_cdCustomerDetails->getBillingAddress()->getCountryCode()->getValue());
1642
+ }
1643
+ }
1644
+ }
1645
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getEmailAddress()))
1646
+ {
1647
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.EmailAddress', $this->m_cdCustomerDetails->getEmailAddress());
1648
+ }
1649
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getPhoneNumber()))
1650
+ {
1651
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.PhoneNumber', $this->m_cdCustomerDetails->getPhoneNumber());
1652
+ }
1653
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_cdCustomerDetails->getCustomerIPAddress()))
1654
+ {
1655
+ $sSOAPClient->addParam('PaymentMessage.CustomerDetails.CustomerIPAddress', $this->m_cdCustomerDetails->getCustomerIPAddress());
1656
+ }
1657
+ }
1658
+
1659
+ $boTransactionSubmitted = CSV_GatewayTransaction::processTransactionBase($sSOAPClient, 'PaymentMessage', 'CrossReferenceTransactionResult', 'TransactionOutputData', $sxXmlDocument, $goGatewayOutput, $lgepGatewayEntryPoints);
1660
+
1661
+ if ($boTransactionSubmitted)
1662
+ {
1663
+ $crtrCrossReferenceTransactionResult = CSV_SharedFunctionsPaymentSystemShared::getPaymentMessageGatewayOutput($sxXmlDocument->CrossReferenceTransactionResult, $goGatewayOutput);
1664
+
1665
+ $todTransactionOutputData = CSV_SharedFunctionsPaymentSystemShared::getTransactionOutputData($sxXmlDocument, $lgepGatewayEntryPoints);
1666
+ }
1667
+
1668
+ return $boTransactionSubmitted;
1669
+ }
1670
+
1671
+ //constructor
1672
+ public function __construct(CSV_RequestGatewayEntryPointList $lrgepRequestGatewayEntryPoints = null,
1673
+ $nRetryAttempts,
1674
+ CSV_NullableInt $nTimeout = null,
1675
+ CSV_MerchantAuthentication $maMerchantAuthentication = null,
1676
+ CSV_TransactionDetails $tdTransactionDetails = null,
1677
+ CSV_CardDetails $cdOverrideCardDetails = null,
1678
+ CSV_CustomerDetails $cdCustomerDetails = null,
1679
+ $szPassOutData)
1680
+ {
1681
+ GatewayTransaction::__construct($lrgepRequestGatewayEntryPoints, $nRetryAttempts, $nTimeout, $maMerchantAuthentication, $szPassOutData);
1682
+
1683
+ $this->m_tdTransactionDetails = $tdTransactionDetails;
1684
+ $this->m_ocdOverrideCardDetails = $cdOverrideCardDetails;
1685
+ $this->m_cdCustomerDetails = $cdCustomerDetails;
1686
+ }
1687
+ }
1688
+
1689
+ class CSV_ThreeDSecureAuthentication extends CSV_GatewayTransaction
1690
+ {
1691
+ private $m_tdsidThreeDSecureInputData;
1692
+
1693
+ public function getThreeDSecureInputData()
1694
+ {
1695
+ return $this->m_tdsidThreeDSecureInputData;
1696
+ }
1697
+
1698
+ public function processTransaction(CSV_ThreeDSecureAuthenticationResult &$tdsarThreeDSecureAuthenticationResult = null, CSV_TransactionOutputData &$todTransactionOutputData = null)
1699
+ {
1700
+ $boTransactionSubmitted = false;
1701
+ $sSOAPClient;
1702
+ $lgepGatewayEntryPoints = null;
1703
+ $sxXmlDocument = null;
1704
+
1705
+ $todTransactionOutputData = null;
1706
+ $goGatewayOutput = null;
1707
+
1708
+ $sSOAPClient = new CSV_SOAP('ThreeDSecureAuthentication', CSV_GatewayTransaction::getSOAPNamespace());
1709
+ if ($this->m_tdsidThreeDSecureInputData != null)
1710
+ {
1711
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdsidThreeDSecureInputData->getCrossReference()))
1712
+ {
1713
+ $sSOAPClient->addParamAttribute('ThreeDSecureMessage.ThreeDSecureInputData', 'CrossReference', $this->m_tdsidThreeDSecureInputData->getCrossReference());
1714
+ }
1715
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_tdsidThreeDSecureInputData->getPaRES()))
1716
+ {
1717
+ $sSOAPClient->addParam('ThreeDSecureMessage.ThreeDSecureInputData.PaRES', $this->m_tdsidThreeDSecureInputData->getPaRES());
1718
+ }
1719
+ }
1720
+
1721
+ $boTransactionSubmitted = CSV_GatewayTransaction::processTransactionBase($sSOAPClient, 'ThreeDSecureMessage', 'ThreeDSecureAuthenticationResult', 'TransactionOutputData', $sxXmlDocument, $goGatewayOutput, $lgepGatewayEntryPoints);
1722
+
1723
+ if ($boTransactionSubmitted)
1724
+ {
1725
+ $tdsarThreeDSecureAuthenticationResult = CSV_SharedFunctionsPaymentSystemShared::getPaymentMessageGatewayOutput($sxXmlDocument->ThreeDSecureAuthenticationResult, $goGatewayOutput);
1726
+
1727
+ $todTransactionOutputData = CSV_SharedFunctionsPaymentSystemShared::getTransactionOutputData($sxXmlDocument, $lgepGatewayEntryPoints);
1728
+ }
1729
+
1730
+ return $boTransactionSubmitted;
1731
+ }
1732
+
1733
+ //constructor
1734
+ public function __construct(CSV_RequestGatewayEntryPointList $lrgepRequestGatewayEntryPoints = null,
1735
+ $nRetryAttempts,
1736
+ CSV_NullableInt $nTimeout = null,
1737
+ CSV_MerchantAuthentication $maMerchantAuthentication = null,
1738
+ CSV_ThreeDSecureInputData $tdsidThreeDSecureInputData = null,
1739
+ $szPassOutData)
1740
+ {
1741
+ CSV_GatewayTransaction::__construct($lrgepRequestGatewayEntryPoints, $nRetryAttempts, $nTimeout, $maMerchantAuthentication, $szPassOutData);
1742
+
1743
+ $this->m_tdsidThreeDSecureInputData = $tdsidThreeDSecureInputData;
1744
+ }
1745
+ }
1746
+
1747
+ class CSV_GetCardType extends CSV_GatewayTransaction
1748
+ {
1749
+ private $m_szCardNumber;
1750
+
1751
+ public function getCardNumber()
1752
+ {
1753
+ return $this->m_szCardNumber;
1754
+ }
1755
+
1756
+ public function processTransaction(CSV_GetCardTypeResult &$gctrGetCardTypeResult = null, CSV_GetCardTypeOutputData &$gctodGetCardTypeOutputData = null)
1757
+ {
1758
+ $boTransactionSubmitted = false;
1759
+ $sSOAPClient;
1760
+ $lgepGatewayEntryPoints = null;
1761
+ $ctdCardTypeData = null;
1762
+ $sxXmlDocument = null;
1763
+
1764
+ $gctodGetCardTypeOutputData = null;
1765
+ $goGatewayOutput = null;
1766
+
1767
+ $sSOAPClient = new CSV_SOAP('GetCardType', CSV_GatewayTransaction::getSOAPNamespace());
1768
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_szCardNumber))
1769
+ {
1770
+ $sSOAPClient->addParam('GetCardTypeMessage.CardNumber', $this->m_szCardNumber);
1771
+ }
1772
+
1773
+ $boTransactionSubmitted = CSV_GatewayTransaction::processTransactionBase($sSOAPClient, 'GetCardTypeMessage', 'GetCardTypeResult', 'GetCardTypeOutputData', $sxXmlDocument, $goGatewayOutput, $lgepGatewayEntryPoints);
1774
+
1775
+ if ($boTransactionSubmitted)
1776
+ {
1777
+ $gctrGetCardTypeResult = $goGatewayOutput;
1778
+
1779
+ if(!$sxXmlDocument->GetCardTypeOutputData->CardTypeData)
1780
+ {
1781
+ $ctdCardTypeData = null;
1782
+ }
1783
+ else
1784
+ {
1785
+ $ctdCardTypeData = CSV_SharedFunctionsPaymentSystemShared::getCardTypeData($sxXmlDocument->GetCardTypeOutputData->CardTypeData);
1786
+ }
1787
+
1788
+ if (!is_null($ctdCardTypeData))
1789
+ {
1790
+ $gctodGetCardTypeOutputData = new CSV_GetCardTypeOutputData($ctdCardTypeData, $lgepGatewayEntryPoints);
1791
+ }
1792
+ }
1793
+ return $boTransactionSubmitted;
1794
+ }
1795
+
1796
+ //constructor
1797
+ public function __construct(CSV_RequestGatewayEntryPointList $lrgepRequestGatewayEntryPoints = null,
1798
+ $nRetryAttempts,
1799
+ CSV_NullableInt $nTimeout = null,
1800
+ CSV_MerchantAuthentication $maMerchantAuthentication = null,
1801
+ $szCardNumber,
1802
+ $szPassOutData)
1803
+ {
1804
+ CSV_GatewayTransaction::__construct($lrgepRequestGatewayEntryPoints, $nRetryAttempts, $nTimeout, $maMerchantAuthentication, $szPassOutData);
1805
+
1806
+ $this->m_szCardNumber = $szCardNumber;
1807
+ }
1808
+ }
1809
+
1810
+ abstract class CSV_GatewayTransaction
1811
+ {
1812
+ private $m_maMerchantAuthentication;
1813
+ private $m_szPassOutData;
1814
+ private $m_lrgepRequestGatewayEntryPoints;
1815
+ private $m_nRetryAttempts;
1816
+ private $m_nTimeout;
1817
+ private $m_szSOAPNamespace = 'https://www.thepaymentgateway.net/';
1818
+ private $m_szLastRequest;
1819
+ private $m_szLastResponse;
1820
+ private $m_eLastException;
1821
+ private $m_szEntryPointUsed;
1822
+
1823
+ public function getMerchantAuthentication()
1824
+ {
1825
+ return $this->m_maMerchantAuthentication;
1826
+ }
1827
+
1828
+ public function getPassOutData()
1829
+ {
1830
+ return $this->m_szPassOutData;
1831
+ }
1832
+
1833
+ public function getRequestGatewayEntryPoints()
1834
+ {
1835
+ return $this->m_lrgepRequestGatewayEntryPoints;
1836
+ }
1837
+
1838
+ public function getRetryAttempts()
1839
+ {
1840
+ return $this->m_nRetryAttempts;
1841
+ }
1842
+
1843
+ public function getTimeout()
1844
+ {
1845
+ return $this->m_nTimeout;
1846
+ }
1847
+
1848
+ public function getSOAPNamespace()
1849
+ {
1850
+ return $this->m_szSOAPNamespace;
1851
+ }
1852
+ public function setSOAPNamespace($value)
1853
+ {
1854
+ $this->m_szSOAPNamespace = $value;
1855
+ }
1856
+
1857
+ public function getLastRequest()
1858
+ {
1859
+ return $this->m_szLastRequest;
1860
+ }
1861
+
1862
+ public function getLastResponse()
1863
+ {
1864
+ return $this->m_szLastResponse;
1865
+ }
1866
+
1867
+ public function getLastException()
1868
+ {
1869
+ return $this->m_eLastException;
1870
+ }
1871
+ public function getEntryPointUsed()
1872
+ {
1873
+ return $this->m_szEntryPointUsed;
1874
+ }
1875
+
1876
+ public static function compare($x, $y)
1877
+ {
1878
+ $rgepFirst = null;
1879
+ $rgepSecond = null;
1880
+
1881
+ $rgepFirst = $x;
1882
+ $rgepSecond = $y;
1883
+
1884
+ return (CSV_GatewayTransaction::compareGatewayEntryPoints($rgepFirst, $rgepSecond));
1885
+ }
1886
+
1887
+ private static function compareGatewayEntryPoints(CSV_RequestGatewayEntryPoint $rgepFirst, CSV_RequestGatewayEntryPoint $rgepSecond)
1888
+ {
1889
+ $nReturnValue = 0;
1890
+ // returns >0 if rgepFirst greater than rgepSecond
1891
+ // returns 0 if they are equal
1892
+ // returns <0 if rgepFirst less than rgepSecond
1893
+
1894
+ // both null, then they are the same
1895
+ if ($rgepFirst == null &&
1896
+ $rgepSecond == null)
1897
+ {
1898
+ $nReturnValue = 0;
1899
+ }
1900
+ // just first null? then second is greater
1901
+ elseif ($rgepFirst == null &&
1902
+ $rgepSecond != null)
1903
+ {
1904
+ $nReturnValue = 1;
1905
+ }
1906
+ // just second null? then first is greater
1907
+ elseif ($rgepFirst != null && $rgepSecond == null)
1908
+ {
1909
+ $nReturnValue = -1;
1910
+ }
1911
+ // can now assume that first & second both have a value
1912
+ elseif ($rgepFirst->getMetric() == $rgepSecond->getMetric())
1913
+ {
1914
+ $nReturnValue = 0;
1915
+ }
1916
+ elseif ($rgepFirst->getMetric() < $rgepSecond->getMetric())
1917
+ {
1918
+ $nReturnValue = -1;
1919
+ }
1920
+ elseif ($rgepFirst->getMetric() > $rgepSecond->getMetric())
1921
+ {
1922
+ $nReturnValue = 1;
1923
+ }
1924
+
1925
+ return $nReturnValue;
1926
+ }
1927
+
1928
+ protected function processTransactionBase(CSV_SOAP $sSOAPClient, $szMessageXMLPath, $szGatewayOutputXMLPath, $szTransactionMessageXMLPath, SimpleXMLElement &$sxXmlDocument = null, CSV_GatewayOutput &$goGatewayOutput = null, CSV_GatewayEntryPointList &$lgepGatewayEntryPoints = null)
1929
+ {
1930
+ $boTransactionSubmitted = false;
1931
+ $nOverallRetryCount = 0;
1932
+ $nOverallGatewayEntryPointCount = 0;
1933
+ $nGatewayEntryPointCount = 0;
1934
+ $nErrorMessageCount = 0;
1935
+ $rgepCurrentGatewayEntryPoint;
1936
+ $nStatusCode;
1937
+ $szMessage = null;
1938
+ $lszErrorMessages;
1939
+ $szString;
1940
+ $sbXMLString;
1941
+ $szXMLFormatString;
1942
+ $nCount = 0;
1943
+ $szEntryPointURL;
1944
+ $nMetric;
1945
+ $gepGatewayEntryPoint = null;
1946
+ $szPassOutData = null;
1947
+ $ResponseDocument = null;
1948
+ $ResponseMethod = null;
1949
+
1950
+ $lgepGatewayEntryPoints = null;
1951
+ $goGatewayOutput = null;
1952
+
1953
+ $this->m_szEntryPointUsed = null;
1954
+
1955
+ if ($sSOAPClient == null)
1956
+ {
1957
+ return false;
1958
+ }
1959
+
1960
+ // populate the merchant details
1961
+ if ($this->m_maMerchantAuthentication != null)
1962
+ {
1963
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_maMerchantAuthentication->getMerchantID()))
1964
+ {
1965
+ $sSOAPClient->addParamAttribute($szMessageXMLPath. '.MerchantAuthentication', 'MerchantID', $this->m_maMerchantAuthentication->getMerchantID());
1966
+ }
1967
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_maMerchantAuthentication->getPassword()))
1968
+ {
1969
+ $sSOAPClient->addParamAttribute($szMessageXMLPath. '.MerchantAuthentication', 'Password', $this->m_maMerchantAuthentication->getPassword());
1970
+ }
1971
+ }
1972
+
1973
+ // populate the passout data
1974
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_szPassOutData))
1975
+ {
1976
+ $sSOAPClient->addParam($szMessageXMLPath. '.PassOutData', $this->m_szPassOutData, null);
1977
+ }
1978
+
1979
+ // first need to sort the gateway entry points into the correct usage order
1980
+ $number = $this->m_lrgepRequestGatewayEntryPoints->sort('CSV_GatewayTransaction','Compare');
1981
+
1982
+ // loop over the overall number of transaction attempts
1983
+ while (!$boTransactionSubmitted &&
1984
+ $nOverallRetryCount < $this->m_nRetryAttempts)
1985
+ {
1986
+ $nOverallGatewayEntryPointCount = 0;
1987
+
1988
+ // loop over the number of gateway entry points in the list
1989
+ while (!$boTransactionSubmitted &&
1990
+ $nOverallGatewayEntryPointCount < $this->m_lrgepRequestGatewayEntryPoints->getCount())
1991
+ {
1992
+
1993
+ $rgepCurrentGatewayEntryPoint = $this->m_lrgepRequestGatewayEntryPoints->getAt($nOverallGatewayEntryPointCount);
1994
+
1995
+ // ignore if the metric is "-1" this indicates that the entry point is offline
1996
+ if ($rgepCurrentGatewayEntryPoint->getMetric() >= 0)
1997
+ {
1998
+ $nGatewayEntryPointCount = 0;
1999
+ $sSOAPClient->setURL($rgepCurrentGatewayEntryPoint->getEntryPointURL());
2000
+
2001
+ // loop over the number of times to try this specific entry point
2002
+ while (!$boTransactionSubmitted &&
2003
+ $nGatewayEntryPointCount < $rgepCurrentGatewayEntryPoint->getRetryAttempts())
2004
+ {
2005
+ if ($sSOAPClient->sendRequest($ResponseDocument, $ResponseMethod))
2006
+ {
2007
+ //getting the valid transaction type document format
2008
+ $sxXmlDocument = $ResponseDocument->$ResponseMethod;
2009
+
2010
+ $lszErrorMessages = new CSV_StringList();
2011
+
2012
+ $nStatusCode = (int)current($ResponseDocument->$ResponseMethod->$szGatewayOutputXMLPath->StatusCode[0]);
2013
+
2014
+ // a status code of 50 means that this entry point is not to be used
2015
+ if ($nStatusCode != 50)
2016
+ {
2017
+ $this->m_szEntryPointUsed = $rgepCurrentGatewayEntryPoint->getEntryPointURL();
2018
+
2019
+ // the transaction was submitted
2020
+ $boTransactionSubmitted = true;
2021
+
2022
+ if ($ResponseDocument->$ResponseMethod->$szGatewayOutputXMLPath->Message)
2023
+ {
2024
+ $szMessage = current($ResponseDocument->$ResponseMethod->$szGatewayOutputXMLPath->Message[0]);
2025
+ }
2026
+ if ($ResponseDocument->$ResponseMethod->$szGatewayOutputXMLPath->ErrorMessages)
2027
+ {
2028
+ foreach ($ResponseDocument->$ResponseMethod->$szGatewayOutputXMLPath->ErrorMessages->MessageDetail as $key => $value)
2029
+ {
2030
+ $lszErrorMessages->add(current($value->Detail));
2031
+ }
2032
+ }
2033
+
2034
+ if ($ResponseDocument->$ResponseMethod->$szGatewayOutputXMLPath->PassOutData)
2035
+ {
2036
+ $szPassOutData = current($ResponseDocument->$ResponseMethod->$szGatewayOutputXMLPath->PassOutData[0]);
2037
+ }
2038
+ else
2039
+ {
2040
+ $szPassOutData = null;
2041
+ }
2042
+
2043
+ $goGatewayOutput = new CSV_GatewayOutput($nStatusCode, $szMessage, $szPassOutData/*, $boAuthorisationAttempted, $ptdPreviousTransactionResult*/, $lszErrorMessages);
2044
+
2045
+ // look to see if there are any gateway entry points
2046
+ $nCount = 0;
2047
+
2048
+ $nMetric = -1;
2049
+
2050
+ if ($ResponseDocument->$ResponseMethod->$szTransactionMessageXMLPath->GatewayEntryPoints)
2051
+ {
2052
+ if($ResponseDocument->$ResponseMethod->$szTransactionMessageXMLPath->GatewayEntryPoints->GatewayEntryPoint)
2053
+ {
2054
+ $szXMLFormatString = $ResponseDocument->$ResponseMethod->$szTransactionMessageXMLPath->GatewayEntryPoints->GatewayEntryPoint;
2055
+
2056
+ foreach($szXMLFormatString->attributes() as $key => $value)
2057
+ {
2058
+ if (is_numeric(current($value)))
2059
+ {
2060
+ $nMetric = current($value);
2061
+ }
2062
+ else
2063
+ {
2064
+ $szEntryPointURL = current($value);
2065
+ }
2066
+ }
2067
+
2068
+ //$gepGatewayEntryPoint = new GatewayEntryPoint($szEntryPointURL, $nMetric);
2069
+ if ($lgepGatewayEntryPoints == null)
2070
+ {
2071
+ $lgepGatewayEntryPoints = new CSV_GatewayEntryPointList();
2072
+ }
2073
+ $lgepGatewayEntryPoints->add($szEntryPointURL, $nMetric); //$lgepGatewayEntryPoints->add($gepGatewayEntryPoint);
2074
+ }
2075
+ }
2076
+ $nCount++;
2077
+ }
2078
+ }
2079
+
2080
+ $nGatewayEntryPointCount++;
2081
+ }
2082
+ }
2083
+ $nOverallGatewayEntryPointCount++;
2084
+ }
2085
+ $nOverallRetryCount++;
2086
+ }
2087
+ $this->m_szLastRequest = $sSOAPClient->getSOAPPacket();
2088
+ $this->m_szLastResponse = $sSOAPClient->getLastResponse();
2089
+ $this->m_eLastException = $sSOAPClient->getLastException();
2090
+
2091
+ return $boTransactionSubmitted;
2092
+ }
2093
+
2094
+ public function __construct(CSV_RequestGatewayEntryPointList $lrgepRequestGatewayEntryPoints = null,
2095
+ $nRetryAttempts,
2096
+ CSV_NullableInt $nTimeout = null,
2097
+ CSV_MerchantAuthentication $maMerchantAuthentication = null,
2098
+ $szPassOutData)
2099
+ {
2100
+ $this->m_maMerchantAuthentication = $maMerchantAuthentication;
2101
+ $this->m_szPassOutData = $szPassOutData;
2102
+ $this->m_lrgepRequestGatewayEntryPoints = $lrgepRequestGatewayEntryPoints;
2103
+ $this->m_nRetryAttempts = $nRetryAttempts;
2104
+ $this->m_nTimeout = $nTimeout;
2105
+ }
2106
+ }
2107
+
2108
+ class CSV_SharedFunctionsPaymentSystemShared
2109
+ {
2110
+ public static function getTransactionOutputData(SimpleXMLElement $sxXmlDocument, CSV_GatewayEntryPointList $lgepGatewayEntryPoints = null)
2111
+ {
2112
+ $szCrossReference = null;
2113
+ $szAddressNumericCheckResult = null;
2114
+ $szPostCodeCheckResult = null;
2115
+ $szThreeDSecureAuthenticationCheckResult = null;
2116
+ $szCV2CheckResult = null;
2117
+ $nAmountReceived = null;
2118
+ $szPaREQ = null;
2119
+ $szACSURL = null;
2120
+ $ctdCardTypeData = null;
2121
+ $tdsodThreeDSecureOutputData = null;
2122
+ $lgvCustomVariables = null;
2123
+ $nCount = 0;
2124
+ $sbString;
2125
+ $szXMLFormatString;
2126
+ $szName;
2127
+ $szValue;
2128
+ $gvGenericVariable;
2129
+ $nCount = 0;
2130
+ $szCardTypeData;
2131
+
2132
+ $todTransactionOutputData = null;
2133
+
2134
+ if (!$sxXmlDocument->TransactionOutputData)
2135
+ {
2136
+ return (null);
2137
+ }
2138
+
2139
+ if ($sxXmlDocument->TransactionOutputData->attributes())
2140
+ {
2141
+ foreach($sxXmlDocument->TransactionOutputData->attributes() as $key => $value)
2142
+ {
2143
+ $szCrossReference = current($value);
2144
+ }
2145
+ }
2146
+ else
2147
+ {
2148
+ $szCrossReference = null;
2149
+ }
2150
+
2151
+ if ($sxXmlDocument->TransactionOutputData->AuthCode)
2152
+ {
2153
+ $szAuthCode = current($sxXmlDocument->TransactionOutputData->AuthCode[0]);
2154
+ }
2155
+ else
2156
+ {
2157
+ $szAuthCode = null;
2158
+ }
2159
+
2160
+ if ($sxXmlDocument->TransactionOutputData->AddressNumericCheckResult)
2161
+ {
2162
+ $szAddressNumericCheckResult = current($sxXmlDocument->TransactionOutputData->AddressNumericCheckResult[0]);
2163
+ }
2164
+
2165
+ if ($sxXmlDocument->TransactionOutputData->PostCodeCheckResult)
2166
+ {
2167
+ $szPostCodeCheckResult = current($sxXmlDocument->TransactionOutputData->PostCodeCheckResult[0]);
2168
+ }
2169
+
2170
+ if ($sxXmlDocument->TransactionOutputData->ThreeDSecureAuthenticationCheckResult)
2171
+ {
2172
+ $szThreeDSecureAuthenticationCheckResult = current($sxXmlDocument->TransactionOutputData->ThreeDSecureAuthenticationCheckResult[0]);
2173
+ }
2174
+
2175
+ if ($sxXmlDocument->TransactionOutputData->CV2CheckResult)
2176
+ {
2177
+ $szCV2CheckResult = current($sxXmlDocument->TransactionOutputData->CV2CheckResult[0]);
2178
+ }
2179
+
2180
+ if ($sxXmlDocument->TransactionOutputData->CardTypeData)
2181
+ {
2182
+ $ctdCardTypeData = self::getCardTypeData($sxXmlDocument->TransactionOutputData->CardTypeData);
2183
+ }
2184
+ else
2185
+ {
2186
+ $ctdCardTypeData = null;
2187
+ }
2188
+
2189
+ if ($sxXmlDocument->TransactionOutputData->AmountReceived)
2190
+ {
2191
+ $nAmountReceived = new CSV_NullableInt(current($sxXmlDocument->TransactionOutputData->AmountReceived[0]));
2192
+ }
2193
+ else
2194
+ {
2195
+ $nAmountReceived = new CSV_NullableInt(null);
2196
+ }
2197
+
2198
+ if ($sxXmlDocument->TransactionOutputData->ThreeDSecureOutputData)
2199
+ {
2200
+ $szPaREQ = current($sxXmlDocument->TransactionOutputData->ThreeDSecureOutputData->PaREQ[0]);
2201
+ $szACSURL = current($sxXmlDocument->TransactionOutputData->ThreeDSecureOutputData->ACSURL[0]);
2202
+ }
2203
+ else
2204
+ {
2205
+ $szPaREQ = null;
2206
+ $szACSURL = null;
2207
+ }
2208
+
2209
+
2210
+ if (!CSV_SharedFunctions::isStringNullOrEmpty($szACSURL) &&
2211
+ !CSV_SharedFunctions::isStringNullOrEmpty($szPaREQ))
2212
+ {
2213
+ $tdsodThreeDSecureOutputData = new CSV_ThreeDSecureOutputData($szPaREQ, $szACSURL);
2214
+ }
2215
+
2216
+ if ($sxXmlDocument->TransactionOutputData->CustomVariables->GenericVariable)
2217
+ {
2218
+ if ($lgvCustomVariables == null)
2219
+ {
2220
+ $lgvCustomVariables = new CSV_GenericVariableList();
2221
+ }
2222
+ for ($nCount=0; $nCount < count($sxXmlDocument->TransactionOutputData->CustomVariables->GenericVariable); $nCount++)
2223
+ {
2224
+ $szName = current($sxXmlDocument->TransactionOutputData->CustomVariables->GenericVariable[$nCount]->Name[0]);
2225
+ $szValue = current($sxXmlDocument->TransactionOutputData->CustomVariables->GenericVariable[$nCount]->Value[0]);
2226
+ $gvGenericVariable = new CSV_GenericVariable($szName, $szValue);
2227
+ $lgvCustomVariables->add($gvGenericVariable);
2228
+ }
2229
+ }
2230
+ else
2231
+ {
2232
+ $lgvCustomVariables = null;
2233
+ }
2234
+
2235
+
2236
+ $todTransactionOutputData = new CSV_TransactionOutputData($szCrossReference,
2237
+ $szAuthCode,
2238
+ $szAddressNumericCheckResult,
2239
+ $szPostCodeCheckResult,
2240
+ $szThreeDSecureAuthenticationCheckResult,
2241
+ $szCV2CheckResult,
2242
+ $ctdCardTypeData,
2243
+ $nAmountReceived,
2244
+ $tdsodThreeDSecureOutputData,
2245
+ $lgvCustomVariables,
2246
+ $lgepGatewayEntryPoints);
2247
+
2248
+ return $todTransactionOutputData;
2249
+ }
2250
+
2251
+ public static function getCardTypeData($CardTypeDataTag)
2252
+ {
2253
+ $ctdCardTypeData = null;
2254
+ $szCardType = null;
2255
+ $boLuhnCheckRequired = null;
2256
+ $szStartDateStatus = null;
2257
+ $szIssueNumberStatus = null;
2258
+ $szIssuer = null;
2259
+ $nISOCode = null;
2260
+ $iIssuer;
2261
+
2262
+ if ($CardTypeDataTag->CardType)
2263
+ {
2264
+ $szCardType = current($CardTypeDataTag->CardType[0]);
2265
+ }
2266
+
2267
+ if ($CardTypeDataTag->Issuer)
2268
+ {
2269
+ try
2270
+ {
2271
+ $szIssuer = (string)$CardTypeDataTag->Issuer[0];
2272
+ }
2273
+ catch (Exception $e)
2274
+ {
2275
+ $szIssuer = null;
2276
+ }
2277
+
2278
+ try
2279
+ {
2280
+ $nISOCode = current($CardTypeDataTag->Issuer->attributes()->ISOCode);
2281
+ }
2282
+ catch (Exception $e)
2283
+ {
2284
+ $nISOCode = null;
2285
+ }
2286
+
2287
+ $iIssuer = new CSV_Issuer($szIssuer, $nISOCode);
2288
+ }
2289
+ else
2290
+ {
2291
+ $iIssuer = null;
2292
+ }
2293
+
2294
+ if ($CardTypeDataTag->LuhnCheckRequired)
2295
+ {
2296
+ $boLuhnCheckRequired = new CSV_NullableBool(current($CardTypeDataTag->LuhnCheckRequired[0]));
2297
+ }
2298
+ else
2299
+ {
2300
+ $boLuhnCheckRequired = null;
2301
+ }
2302
+
2303
+ if ($CardTypeDataTag->IssueNumberStatus)
2304
+ {
2305
+ try
2306
+ {
2307
+ $szIssueNumberStatus = current($CardTypeDataTag->IssueNumberStatus[0]);
2308
+ }
2309
+ catch (Exception $e)
2310
+ {
2311
+ $szIssueNumberStatus = null;
2312
+ }
2313
+ }
2314
+ else
2315
+ {
2316
+ $szIssueNumberStatus = null;
2317
+ }
2318
+
2319
+ if ($CardTypeDataTag->StartDateStatus)
2320
+ {
2321
+ try
2322
+ {
2323
+ $szStartDateStatus = current($CardTypeDataTag->StartDateStatus[0]);
2324
+ }
2325
+ catch (Exception $e)
2326
+ {
2327
+ $szStartDateStatus = null;
2328
+ }
2329
+ }
2330
+ else
2331
+ {
2332
+ $szStartDateStatus = null;
2333
+ }
2334
+
2335
+ $ctdCardTypeData = new CSV_CardTypeData($szCardType, $iIssuer, $boLuhnCheckRequired, $szIssueNumberStatus, $szStartDateStatus);
2336
+
2337
+ return ($ctdCardTypeData);
2338
+ }
2339
+
2340
+
2341
+
2342
+ public static function getPaymentMessageGatewayOutput($GatewayOutput, CSV_GatewayOutput $goGatewayOutput = null)
2343
+ {
2344
+ $nPreviousStatusCode = null;
2345
+ $szPreviousMessage = null;
2346
+ $ptdPreviousTransactionResult = null;
2347
+ $pmgoPaymentMessageGatewayOutput = null;
2348
+ $boAuthorisationAttempted = null;
2349
+
2350
+ if ($GatewayOutput->attributes())
2351
+ {
2352
+ try
2353
+ {
2354
+ $szAuthorisationAttempted = current($GatewayOutput->attributes()->AuthorisationAttempted);
2355
+ if (strtolower($boAuthorisationAttempted) == 'false')
2356
+ {
2357
+ $boAuthorisationAttempted = new CSV_NullableBool(false);
2358
+ }
2359
+ elseif (strtolower($boAuthorisationAttempted) == 'true')
2360
+ {
2361
+ $boAuthorisationAttempted = new CSV_NullableBool(true);
2362
+ }
2363
+ else
2364
+ {
2365
+ throw new Exception('Return value must be true or false');
2366
+ }
2367
+ }
2368
+ catch (Exception $e)
2369
+ {
2370
+ $boAuthorisationAttempted = null;
2371
+ }
2372
+ }
2373
+
2374
+ //check to see if there is any previous transaction data
2375
+ if ($GatewayOutput->PreviousTransactionResult->StatusCode)
2376
+ {
2377
+ $nPreviousStatusCode = new CSV_NullableInt(current($GatewayOutput->PreviousTransactionResult->StatusCode[0]));
2378
+ }
2379
+
2380
+ if ($GatewayOutput->PreviousTransactionResult->Message)
2381
+ {
2382
+ $szPreviousMessage = current($GatewayOutput->PreviousTransactionResult->Message[0]);
2383
+ }
2384
+
2385
+ if ($nPreviousStatusCode != null &&
2386
+ !CSV_SharedFunctions::isStringNullOrEmpty($szPreviousMessage))
2387
+ {
2388
+ $ptdPreviousTransactionResult = new CSV_PreviousTransactionResult($nPreviousStatusCode, $szPreviousMessage);
2389
+ }
2390
+
2391
+ $pmgoPaymentMessageGatewayOutput = new CSV_PaymentMessageGatewayOutput($goGatewayOutput->getStatusCode(),
2392
+ $goGatewayOutput->getMessage(),
2393
+ $goGatewayOutput->getPassOutData(),
2394
+ $boAuthorisationAttempted,
2395
+ $ptdPreviousTransactionResult,
2396
+ $goGatewayOutput->getErrorMessages());
2397
+
2398
+ return $pmgoPaymentMessageGatewayOutput;
2399
+ }
2400
+ }
app/code/local/Cardsave/Cardsaveonlinepayments/Model/Common/ThePaymentGateway/SOAP.php ADDED
@@ -0,0 +1,968 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //accessing external files
3
+ require_once('TPG_Common.php');
4
+
5
+ class CSV_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 CSV_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(CSV_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 CSV_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 CSV_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, CSV_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 CSV_SOAPParamList();
135
+ $this->m_lspaSOAPParamAttributeList = new CSV_SOAPParamAttributeList();
136
+
137
+ if ($lspaSOAPParamAttributeList != null)
138
+ {
139
+ for ($nCount = 0; $nCount < $lspaSOAPParamAttributeList->getCount();$nCount++)
140
+ {
141
+ $spaSOAPParamAttribute = new CSV_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(). '="' .CSV_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 .= CSV_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 CSV_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(CSV_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 CSV_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 CSV_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 CSV_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(CSV_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 CSV_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 CSV_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, CSV_SOAPParamAttributeList $lspaSOAPParamAttributeList = null)
631
+ {
632
+ $spSOAPParam;
633
+
634
+ $spSOAPParam = new CSV_SOAPParameter($szName, $szValue, $lspaSOAPParamAttributeList);
635
+
636
+ $this->addParam2($spSOAPParam, true);
637
+ }
638
+ public function addParam2(CSV_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 CSV_StringList();
658
+
659
+ $lszHierarchicalNames = CSV_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 = CSV_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 = CSV_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 CSV_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 CSV_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 CSV_SOAPParamAttribute($spaAttribute->getName(), $spaAttribute->getValue());
735
+ $lspaAttributeList->add($spaNewAttribute);
736
+ }
737
+ }
738
+
739
+ $spNewSOAPParam = new CSV_SOAPParameter($szTagNameToFind, $spSOAPParam->getValue(), $lspaAttributeList);
740
+
741
+ $lspParamList->add($spNewSOAPParam);
742
+ }
743
+ else
744
+ {
745
+ $spNewSOAPParam = new CSV_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 CSV_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 CSV_SOAPParamAttributeList();
808
+ $spaSOAPParamAttribute = new CSV_SOAPParamAttribute($szParamAttributeName, $szParamAttributeValue);
809
+ $lspaSOAPParamAttributeList->add($spaSOAPParamAttribute);
810
+
811
+ $spSOAPParam = new CSV_SOAPParameter($szName, '', $lspaSOAPParamAttributeList);
812
+
813
+ $this->addParam2($spSOAPParam, false);
814
+ }
815
+ private function addParamAttribute2($szName, CSV_SOAPParamAttribute $spaSOAPParamAttribute)
816
+ {
817
+ $spSOAPParam;
818
+ $lspaSOAPParamAttributeList;
819
+
820
+ $lspaSOAPParamAttributeList = new CSV_SOAPParamAttributeList();
821
+ $lspaSOAPParamAttributeList->add($spaSOAPParamAttribute);
822
+
823
+ $spSOAPParam = new CSV_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, CSV_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 CSV_SOAPNamespaceList();
882
+
883
+ if ($boAddDefaultNamespaces)
884
+ {
885
+ $snSOAPNamespace = new CSV_SOAPNamespace('soap', 'http://schemas.xmlsoap.org/soap/envelope/');
886
+ $this->m_lsnSOAPNamespaceList->add($snSOAPNamespace);
887
+ $snSOAPNamespace = new CSV_SOAPNamespace('xsi', 'http://www.w3.org/2001/XMLSchema-instance');
888
+ $this->m_lsnSOAPNamespaceList->add($snSOAPNamespace);
889
+ $snSOAPNamespace = new CSV_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 CSV_SOAPNamespace($lsnSOAPNamespaceList->getAt($nCount)->getPrefix(), $lsnSOAPNamespaceList->getAt($nCount)->getNamespace());
897
+ $this->m_lsnSOAPNamespaceList->add($snSOAPNamespace);
898
+ }
899
+ }
900
+ $this->m_lspSOAPParamList = new CSV_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 CSV_Functions
931
+ {
932
+ public static function isSOAPParamInParamList(CSV_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/Cardsave/Cardsaveonlinepayments/Model/Common/ThePaymentGateway/TPG_Common.php ADDED
@@ -0,0 +1,882 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //XMLEntities
3
+ $g_XMLEntities = array();
4
+ $g_XMLEntities[] = new CSV_XMLEntity(0x26, "&amp;");
5
+ $g_XMLEntities[] = new CSV_XMLEntity(0x22, "&quot;");
6
+ $g_XMLEntities[] = new CSV_XMLEntity(0x27, "&apos;");
7
+ $g_XMLEntities[] = new CSV_XMLEntity(0x3c, "&lt;");
8
+ $g_XMLEntities[] = new CSV_XMLEntity(0x3e, "&gt;");
9
+
10
+ abstract class CSV_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 CSV_NullableInt extends CSV_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
+ CSV_Nullable::__construct();
48
+
49
+ $this->setValue($nValue);
50
+ }
51
+ }
52
+
53
+ class CSV_NullableBool extends CSV_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
+ CSV_Nullable::__construct();
76
+
77
+ $this->setValue($boValue);
78
+ }
79
+ }
80
+
81
+ /******************/
82
+ /* Common classes */
83
+ /******************/
84
+ class CSV_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 CSV_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 CSV_ISOCountryList
165
+ {
166
+ private $m_licISOCountries;
167
+
168
+ public function getISOCountry($szCountryShort, CSV_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 CSV_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 CSV_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 CSV_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 CSV_ISOCurrencyList
282
+ {
283
+ private $m_licISOCurrencies;
284
+
285
+ public function getISOCurrency($szCurrencyShort, CSV_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 CSV_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 CSV_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 CSV_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 CSV_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 CSV_StringList();
391
+
392
+ $lszHierarchicalNames = CSV_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 = CSV_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 CSV_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 CSV_StringList();
517
+ $szValue = null;
518
+ $lszHierarchicalNames = CSV_SharedFunctions::getStringListFromCharSeparatedString($szXMLVariable, '.');
519
+
520
+ if (count($lszHierarchicalNames) == 1)
521
+ {
522
+ $szXMLTagName = $lszHierarchicalNames->getAt(0);
523
+
524
+ $xtCurrentTag = CSV_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 = CSV_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 = CSV_SharedFunctions::getNamedTagInTagList($szLastXMLTagName, $xtCurrentTag->getChildTags());
573
+
574
+ if ($xtCurrentTag != null)
575
+ {
576
+ $szValue = CSV_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/Cardsave/Cardsaveonlinepayments/Model/Direct.php ADDED
@@ -0,0 +1,976 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ include ("Common/ThePaymentGateway/PaymentSystem.php");
4
+ include_once ("Common/PaymentFormHelper.php");
5
+ include ("Common/ISOCurrencies.php");
6
+ include ("Common/ISOCountries.php");
7
+
8
+ class Cardsave_Cardsaveonlinepayments_Model_Direct extends Mage_Payment_Model_Method_Abstract
9
+ {
10
+ /**
11
+ * unique internal payment method identifier
12
+ *
13
+ * @var string [a-z0-9_]
14
+ */
15
+ protected $_code = 'cardsaveonlinepayments';
16
+ protected $_formBlockType = 'cardsaveonlinepayments/form';
17
+ protected $_infoBlockType = 'cardsaveonlinepayments/info';
18
+
19
+ protected $_isGateway = true;
20
+ protected $_canAuthorize = true;
21
+ protected $_canCapture = true;
22
+ protected $_canCapturePartial = true;
23
+ protected $_canRefund = false;
24
+ protected $_canVoid = false;
25
+ protected $_canUseInternal = true;
26
+ protected $_canUseCheckout = true;
27
+ protected $_canUseForMultishipping = true;
28
+ protected $_canSaveCc = false;
29
+
30
+ /**
31
+ * Assign data to info model instance
32
+ *
33
+ * @param mixed $data
34
+ * @return Mage_Payment_Model_Info
35
+ */
36
+ public function assignData($data)
37
+ {
38
+ if (!($data instanceof Varien_Object))
39
+ {
40
+ $data = new Varien_Object($data);
41
+ }
42
+
43
+ $info = $this->getInfoInstance();
44
+
45
+ $info->setCcOwner($data->getCcOwner())
46
+ ->setCcLast4(substr($data->getCcNumber(), -4))
47
+ ->setCcNumber($data->getCcNumber())
48
+ ->setCcCid($data->getCcCid())
49
+ ->setCcExpMonth($data->getCcExpMonth())
50
+ ->setCcExpYear($data->getCcExpYear())
51
+ ->setCcSsStartMonth($data->getCcSsStartMonth())
52
+ ->setCcSsStartYear($data->getCcSsStartYear())
53
+ ->setCcSsIssue($data->getCcSsIssue());
54
+
55
+ return $this;
56
+ }
57
+
58
+ /**
59
+ * Validate payment method information object
60
+ *
61
+ * @param Mage_Payment_Model_Info $info
62
+ * @return Mage_Payment_Model_Abstract
63
+ */
64
+ public function validate()
65
+ {
66
+ // NOTE : cancel out the core Magento validator functionality, the payment gateway will overtake this task
67
+
68
+ return $this;
69
+ }
70
+
71
+ /**
72
+ * Authorize - core Mage pre-authorization functionality
73
+ *
74
+ * @param Varien_Object $orderPayment
75
+ * @return Mage_Payment_Model_Abstract
76
+ */
77
+ public function authorize(Varien_Object $payment, $amount)
78
+ {
79
+ $error = false;
80
+
81
+ Mage::throwException('This payment module only allow capture payments.');
82
+
83
+ return $this;
84
+ }
85
+
86
+ /**
87
+ * Capture payment - immediate settlement payments
88
+ *
89
+ * @param Varien_Object $payment
90
+ * @return Mage_Payment_Model_Abstract
91
+ */
92
+ public function capture(Varien_Object $payment, $amount)
93
+ {
94
+ $error = false;
95
+ $session = Mage::getSingleton('checkout/session');
96
+ $mode = $this->getConfigData('mode');
97
+ $nVersion = $this->getVersion();
98
+
99
+ if($amount <= 0)
100
+ {
101
+ Mage::throwException(Mage::helper('paygate')->__('Invalid amount for authorization.'));
102
+ }
103
+ else
104
+ {
105
+ if($session->getThreedsecurerequired())
106
+ {
107
+ $md = $session->getMd();
108
+ $pares = $session->getPares();
109
+
110
+ $session->setThreedsecurerequired(null);
111
+ $this->_run3DSecureTransaction($payment, $pares, $md);
112
+
113
+ return $this;
114
+ }
115
+ if($session->getRedirectedpayment())
116
+ {
117
+ $szStatusCode = $session->getStatuscode();
118
+ $szMessage = $session->getMessage();
119
+ $szPreviousStatusCode = $session->getPreviousstatuscode();
120
+ $szPreviousMessage = $session->getPreviousmessage();
121
+ $szOrderID = $session->getOrderid();
122
+ // check whether it is a hosted payment or a transparent redirect action
123
+ $boIsHostedPaymentAction = $session->getIshostedpayment();
124
+
125
+ $session->setRedirectedpayment(null);
126
+ $session->setIshostedpayment(null);
127
+ $this->_runRedirectedPaymentComplete($payment, $boIsHostedPaymentAction, $szStatusCode, $szMessage, $szPreviousStatusCode, $szPreviousMessage, $szOrderID);
128
+
129
+ return $this;
130
+ }
131
+
132
+ // fresh payment request
133
+ $session->setThreedsecurerequired(null)
134
+ ->setRedirectedpayment(null)
135
+ ->setIshostedpayment(null)
136
+ ->setHostedPayment(null)
137
+ ->setMd(null)
138
+ ->setPareq(null)
139
+ ->setAcsurl(null)
140
+ ->setPaymentprocessorresponse(null);
141
+
142
+ $payment->setAmount($amount);
143
+
144
+ switch ($mode)
145
+ {
146
+ case Cardsave_Cardsaveonlinepayments_Model_Source_PaymentMode::PAYMENT_MODE_DIRECT_API:
147
+ $error = $this->_runTransaction($payment, $amount);
148
+ break;
149
+ case Cardsave_Cardsaveonlinepayments_Model_Source_PaymentMode::PAYMENT_MODE_HOSTED_PAYMENT_FORM:
150
+ $error = $this->_runHostedPaymentTransaction($payment, $amount);
151
+ break;
152
+ case Cardsave_Cardsaveonlinepayments_Model_Source_PaymentMode::PAYMENT_MODE_TRANSPARENT_REDIRECT:
153
+ $error = $this->_runTransparentRedirectTransaction($payment, $amount);
154
+ break;
155
+ default:
156
+ Mage::throwException('Invalid payment type: '.$this->getConfigData('mode'));
157
+ break;
158
+ }
159
+ }
160
+
161
+ if($error)
162
+ {
163
+ Mage::throwException($error);
164
+ }
165
+ else
166
+ {
167
+ if($nVersion == 1324 || $nVersion == 1330)
168
+ {
169
+ $payment->setIsInvoicePaid(true);
170
+ }
171
+ }
172
+
173
+ return $this;
174
+ }
175
+
176
+ /**
177
+ * Processing the transaction using the direct integration
178
+ *
179
+ * @param Varien_Object $orderPayment
180
+ * @param $amount
181
+ * @return void
182
+ */
183
+ public function _runTransaction(Varien_Object $payment, $amount)
184
+ {
185
+ $error = '';
186
+ $session = Mage::getSingleton('checkout/session');
187
+ $nVersion = $this->getVersion();
188
+
189
+ $MerchantID = $this->getConfigData('merchantid');
190
+ $Password = $this->getConfigData('password');
191
+ $SecretKey = $this->getConfigData('secretkey');
192
+ // assign payment form field values to variables
193
+ $order = $payment->getOrder();
194
+ $szOrderID = $payment->getOrder()->increment_id;
195
+ $szOrderDescription = '';
196
+ $szCardName = $payment->getCcOwner();
197
+ $szCardNumber = $payment->getCcNumber();
198
+ $szIssueNumber = $payment->getCcSsIssue();
199
+ $szCV2 = $payment->getCcCid();
200
+ $nCurrencyCode;
201
+ $szCurrencyShort = $order->getOrderCurrency()->getCurrencyCode();
202
+ // address details
203
+ $billingAddress = $order->getBillingAddress();
204
+ $szAddress1 = $billingAddress->getStreet1();
205
+ $szAddress2 = $billingAddress->getStreet2();
206
+ $szAddress3 = $billingAddress->getStreet3();
207
+ $szAddress4 = $billingAddress->getStreet4();
208
+ $szCity = $billingAddress->getCity();
209
+ $szState = $billingAddress->getRegion();
210
+ $szPostCode = $billingAddress->getPostcode();
211
+ $szISO2CountryCode = $billingAddress->getCountry();
212
+ $nCountryCode;
213
+ $szEmailAddress = $billingAddress->getCustomerEmail();
214
+ $szPhoneNumber = $billingAddress->getTelephone();
215
+ $nDecimalAmount;
216
+
217
+ $PaymentProcessorFullDomain = $this->_getPaymentProcessorFullDomain();
218
+
219
+ $rgeplRequestGatewayEntryPointList = new CSV_RequestGatewayEntryPointList();
220
+ $rgeplRequestGatewayEntryPointList->add("https://gw1.".$PaymentProcessorFullDomain, 100, 2);
221
+ $rgeplRequestGatewayEntryPointList->add("https://gw2.".$PaymentProcessorFullDomain, 200, 2);
222
+ $rgeplRequestGatewayEntryPointList->add("https://gw3.".$PaymentProcessorFullDomain, 300, 2);
223
+
224
+ $maMerchantAuthentication = new CSV_MerchantAuthentication($MerchantID, $Password);
225
+
226
+ $mdMessageDetails = new CSV_MessageDetails("SALE");
227
+
228
+ $boEchoCardType = new CSV_NullableBool(true);
229
+ $boEchoAmountReceived = new CSV_NullableBool(true);
230
+ $boEchoAVSCheckResult = new CSV_NullableBool(true);
231
+ $boEchoCV2CheckResult = new CSV_NullableBool(true);
232
+ $boThreeDSecureOverridePolicy = new CSV_NullableBool(true);
233
+ $nDuplicateDelay = new CSV_NullableInt(60);
234
+ $tcTransactionControl = new CSV_TransactionControl($boEchoCardType, $boEchoAVSCheckResult, $boEchoCV2CheckResult, $boEchoAmountReceived, $nDuplicateDelay, "", "", $boThreeDSecureOverridePolicy, "", null, null);
235
+
236
+ $iclISOCurrencyList = CSV_ISOCurrencies::getISOCurrencyList();
237
+
238
+ if ($szCurrencyShort != '' &&
239
+ $iclISOCurrencyList->getISOCurrency($szCurrencyShort, $icISOCurrency))
240
+ {
241
+ $nCurrencyCode = new CSV_NullableInt($icISOCurrency->getISOCode());
242
+ }
243
+
244
+ $power = pow(10, $icISOCurrency->getExponent());
245
+ $nDecimalAmount = $amount * $power;
246
+ $nAmount = new CSV_NullableInt($nDecimalAmount);
247
+
248
+ $nDeviceCategory = new CSV_NullableInt(0);
249
+ $tdsbdThreeDSecureBrowserDetails = new CSV_ThreeDSecureBrowserDetails($nDeviceCategory, "*/*", $_SERVER["HTTP_USER_AGENT"]);;
250
+ $tdTransactionDetails = new CSV_TransactionDetails($mdMessageDetails, $nAmount, $nCurrencyCode, $szOrderID, $szOrderDescription, $tcTransactionControl, $tdsbdThreeDSecureBrowserDetails);
251
+
252
+ $nExpiryDateMonth = null;
253
+ if($payment->getCcExpMonth() != '')
254
+ {
255
+ $nExpiryDateMonth = new CSV_NullableInt($payment->getCcExpMonth());
256
+ }
257
+
258
+ $nExpiryDateYear = null;
259
+ if($payment->getCcExpYear() != '')
260
+ {
261
+ $nExpiryDateYear = new CSV_NullableInt($payment->getCcExpYear());
262
+ }
263
+
264
+ $nStartDateMonth = null;
265
+ if($payment->getCcSsStartMonth() != '')
266
+ {
267
+ $nStartDateMonth = new CSV_NullableInt($payment->getCcSsStartMonth());
268
+ }
269
+
270
+ $nStartDateYear = null;
271
+ if($payment->getCcSsStartYear() != '')
272
+ {
273
+ $nStartDateYear = new CSV_NullableInt($payment->getCcSsStartYear());
274
+ }
275
+
276
+ $edExpiryDate = new CSV_ExpiryDate($nExpiryDateMonth, $nExpiryDateYear);
277
+ $sdStartDate = new CSV_StartDate($nStartDateMonth, $nStartDateYear);
278
+ $cdCardDetails = new CSV_CardDetails($szCardName, $szCardNumber, $edExpiryDate, $sdStartDate, $szIssueNumber, $szCV2);
279
+
280
+ $nCountryCode = null;
281
+ $iclISOCountryList = CSV_ISOCountries::getISOCountryList();
282
+ $szCountryShort = $this->_getISO3Code($szISO2CountryCode);
283
+ if($iclISOCountryList->getISOCountry($szCountryShort, $icISOCountry))
284
+ {
285
+ $nCountryCode = new CSV_NullableInt($icISOCountry->getISOCode());
286
+ }
287
+
288
+ if($szAddress1 == null)
289
+ {
290
+ $szAddress1 = '';
291
+ }
292
+ if($szAddress2 == null)
293
+ {
294
+ $szAddress2 = '';
295
+ }
296
+ if($szAddress2 == null)
297
+ {
298
+ $szAddress2 = '';
299
+ }
300
+ if($szAddress2 == null)
301
+ {
302
+ $szAddress2 = '';
303
+ }
304
+
305
+ $adBillingAddress = new CSV_AddressDetails($szAddress1, $szAddress2, $szAddress3, $szAddress4, $szCity, $szState, $szPostCode, $nCountryCode);
306
+ $cdCustomerDetails = new CSV_CustomerDetails($adBillingAddress, $szEmailAddress, $szPhoneNumber, $_SERVER["REMOTE_ADDR"]);
307
+ $cdtCardDetailsTransaction = new CSV_CardDetailsTransaction($rgeplRequestGatewayEntryPointList, 1, null, $maMerchantAuthentication, $tdTransactionDetails, $cdCardDetails, $cdCustomerDetails, "Some data to be passed out");
308
+ $boTransactionProcessed = $cdtCardDetailsTransaction->processTransaction($cdtrCardDetailsTransactionResult, $todTransactionOutputData);
309
+
310
+ if ($boTransactionProcessed == false)
311
+ {
312
+ // could not communicate with the payment gateway
313
+ $error = Cardsave_Cardsaveonlinepayments_Model_Common_GlobalErrors::ERROR_261;
314
+
315
+ $szLogMessage = "Couldn't complete transaction. Details: ".print_r($cdtrCardDetailsTransactionResult, 1)." ".print_r($todTransactionOutputData, 1); //"Couldn't communicate with payment gateway.";
316
+ Mage::log($szLogMessage);
317
+ }
318
+ else
319
+ {
320
+ $szLogMessage = "Transaction could not be completed for OrderID: ".$szOrderID.". Result details: ";
321
+ $szNotificationMessage = 'Payment Processor Response: '.$cdtrCardDetailsTransactionResult->getMessage();
322
+ $szCrossReference = $todTransactionOutputData->getCrossReference();
323
+
324
+ switch ($cdtrCardDetailsTransactionResult->getStatusCode())
325
+ {
326
+ case 0:
327
+ // status code of 0 - means transaction successful
328
+ $szLogMessage = "Transaction successfully completed for OrderID: ".$szOrderID.". Result object details: ";
329
+ Mage::getSingleton('core/session')->addSuccess($szNotificationMessage);
330
+ break;
331
+ case 3:
332
+ // status code of 3 - means 3D Secure authentication required
333
+ $szLogMessage = "3D Secure Authentication required for OrderID: ".$szOrderID.". Result object details: ";
334
+ $szNotificationMessage = '';
335
+
336
+ $szPaReq = $todTransactionOutputData->getThreeDSecureOutputData()->getPaREQ();
337
+ $szACSURL = $todTransactionOutputData->getThreeDSecureOutputData()->getACSURL();
338
+
339
+ Mage::getSingleton('checkout/session')->setMd($szCrossReference)
340
+ ->setAcsurl($szACSURL)
341
+ ->setPareq($szPaReq);
342
+
343
+ if($nVersion >= 1410)
344
+ {
345
+ Mage::getSingleton('checkout/session')->setRedirectionmethod('_run3DSecureTransaction');
346
+ $order->setIsThreeDSecurePending(true);
347
+ }
348
+ break;
349
+ case 5:
350
+ // status code of 5 - means transaction declined
351
+ $error = $szNotificationMessage;
352
+ break;
353
+ case 20:
354
+ // status code of 20 - means duplicate transaction
355
+ $szPreviousTransactionMessage = $cdtrCardDetailsTransactionResult->getPreviousTransactionResult()->getMessage();
356
+ $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: ";
357
+ $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;
358
+
359
+ if ($cdtrCardDetailsTransactionResult->getPreviousTransactionResult()->getStatusCode()->getValue() != 0)
360
+ {
361
+ $error = $szNotificationMessage;
362
+ }
363
+ else
364
+ {
365
+ Mage::getSingleton('core/session')->addSuccess($szNotificationMessage);
366
+ }
367
+ break;
368
+ case 30:
369
+ // status code of 30 - means an error occurred
370
+ $error = $szNotificationMessage;
371
+ $szLogMessage = "Transaction could not be completed for OrderID: ".$szOrderID.". Error message: ".$cdtrCardDetailsTransactionResult->getMessage();
372
+ if ($cdtrCardDetailsTransactionResult->getErrorMessages()->getCount() > 0)
373
+ {
374
+ $szLogMessage = $szLogMessage.".";
375
+
376
+ for ($LoopIndex = 0; $LoopIndex < $cdtrCardDetailsTransactionResult->getErrorMessages()->getCount(); $LoopIndex++)
377
+ {
378
+ $szLogMessage = $szLogMessage.$cdtrCardDetailsTransactionResult->getErrorMessages()->getAt($LoopIndex).";";
379
+ }
380
+ $szLogMessage = $szLogMessage." ";
381
+ }
382
+ $szLogMessage = $szLogMessage.' Result object details: ';
383
+ break;
384
+ default:
385
+ // unhandled status code
386
+ $error = $szNotificationMessage;
387
+ break;
388
+ }
389
+
390
+ $szLogMessage = $szLogMessage.print_r($cdtrCardDetailsTransactionResult, 1);
391
+ Mage::log($szLogMessage);
392
+ }
393
+
394
+ if($error)
395
+ {
396
+ $payment->setStatus('FAIL')
397
+ ->setCcApproval('FAIL');
398
+ }
399
+ else
400
+ {
401
+ if($nVersion == 1324 || $nVersion == 1330)
402
+ {
403
+ $payment->setIsInvoicePaid(true);
404
+ }
405
+ }
406
+
407
+ if($szCrossReference)
408
+ {
409
+ $szAdditionalData = "CrossReference=".$szCrossReference;
410
+ $payment->setAdditionalData($szAdditionalData);
411
+ }
412
+
413
+ return $error;
414
+ }
415
+
416
+ /**
417
+ * Processing the transaction using the hosted payment form integration
418
+ *
419
+ * @param Varien_Object $payment
420
+ * @param unknown_type $amount
421
+ */
422
+ public function _runHostedPaymentTransaction(Varien_Object $payment, $amount)
423
+ {
424
+ $session = Mage::getSingleton('checkout/session');
425
+ $nVersion = $this->getVersion();
426
+
427
+ $szMerchantID = $this->getConfigData('merchantid');
428
+ $szPassword = $this->getConfigData('password');
429
+ $szPreSharedKey = $this->getConfigData('presharedkey');
430
+ $hmHashMethod = $this->getConfigData('hashmethod');
431
+ $boCV2Mandatory = 'false';
432
+ $boAddress1Mandatory = 'false';
433
+ $boCityMandatory = 'false';
434
+ $boPostCodeMandatory = 'false';
435
+ $boStateMandatory = 'false';
436
+ $boCountryMandatory = 'false';
437
+ $rdmResultdeliveryMethod = $this->getConfigData('resultdeliverymethod');
438
+ $szServerResultURL = '';
439
+ // set to always true to display the result on the Hosted Payment Form
440
+ $boPaymentFormDisplaysResult = '';
441
+
442
+ switch($rdmResultdeliveryMethod)
443
+ {
444
+ case Cardsave_Cardsaveonlinepayments_Model_Source_ResultDeliveryMethod::RESULT_DELIVERY_METHOD_POST:
445
+ $szCallbackURL = Mage::getUrl('cardsaveonlinepayments/payment/callbackhostedpayment', array('_secure' => true));
446
+ break;
447
+ case Cardsave_Cardsaveonlinepayments_Model_Source_ResultDeliveryMethod::RESULT_DELIVERY_METHOD_SERVER:
448
+ $szCallbackURL = Mage::getUrl('cardsaveonlinepayments/payment/callbackhostedpayment', array('_secure' => true));
449
+ $szServerResultURL = Mage::getUrl('cardsaveonlinepayments/payment/serverresult', array('_secure' => true));
450
+ $boPaymentFormDisplaysResult = 'true';
451
+ break;
452
+ case Cardsave_Cardsaveonlinepayments_Model_Source_ResultDeliveryMethod::RESULT_DELIVERY_METHOD_SERVER_PULL:
453
+ $szCallbackURL = Mage::getUrl('cardsaveonlinepayments/payment/serverpullresult', array('_secure' => true));
454
+ break;
455
+ }
456
+
457
+ $order = $payment->getOrder();
458
+ $billingAddress = $order->getBillingAddress();
459
+ $iclISOCurrencyList = CSV_ISOCurrencies::getISOCurrencyList();
460
+ $iclISOCountryList = CSV_ISOCountries::getISOCountryList();
461
+ $cookie = Mage::getSingleton('core/cookie');
462
+ $arCookieArray = $cookie->get();
463
+ $arCookieKeysArray = array_keys($arCookieArray);
464
+ $nKeysArrayLength = count($arCookieKeysArray);
465
+ $szCookiePath = $cookie->getPath();
466
+ $szCookieDomain = $cookie->getDomain();
467
+ $szServerResultURLCookieVariables = '';
468
+ $szServerResultURLFormVariables = '';
469
+ $szServerResultURLQueryStringVariables = '';
470
+ //ServerResutlURLCookieVariables string format: cookie1=123&path=/&domain=www.domain.com@@cookie2=456&path=/&domain=www.domain.com
471
+
472
+ for($nCount = 0; $nCount < $nKeysArrayLength; $nCount++)
473
+ {
474
+ $szEncodedCookieValue = urlencode($arCookieArray[$arCookieKeysArray[$nCount]]);
475
+ $szServerResultURLCookieVariables .= $arCookieKeysArray[$nCount]."=".$szEncodedCookieValue."&path=".$szCookiePath."&domain=".$szCookieDomain;
476
+ if($nCount < $nKeysArrayLength - 1)
477
+ {
478
+ $szServerResultURLCookieVariables .= "@@";
479
+ }
480
+ }
481
+
482
+ $szCurrencyShort = $order->getOrderCurrency()->getCurrencyCode();
483
+ if ($szCurrencyShort != '' &&
484
+ $iclISOCurrencyList->getISOCurrency($szCurrencyShort, $icISOCurrency))
485
+ {
486
+ $nCurrencyCode = $icISOCurrency->getISOCode();
487
+ }
488
+
489
+ $power = pow(10, $icISOCurrency->getExponent());
490
+ $nAmount = $amount * $power;
491
+
492
+ $szISO2CountryCode = $billingAddress->getCountry();
493
+ $szCountryShort = $this->_getISO3Code($szISO2CountryCode);
494
+ if($iclISOCountryList->getISOCountry($szCountryShort, $icISOCountry))
495
+ {
496
+ $nCountryCode = $icISOCountry->getISOCode();
497
+ }
498
+
499
+ $szOrderID = $payment->getOrder()->increment_id;
500
+ $szTransactionType = 'SALE';
501
+ //date time with 2008-12-01 14:12:00 +01:00 format
502
+ $szTransactionDateTime = date('Y-m-d H:i:s P');
503
+ $szOrderDescription = '';
504
+
505
+ $szCustomerName = $billingAddress->getfirstname();
506
+ if($billingAddress->getfirstname())
507
+ {
508
+ $szCustomerName = $szCustomerName.' '.$billingAddress->getlastname();
509
+ }
510
+ $szAddress1 = $billingAddress->getStreet1();
511
+ $szAddress2 = $billingAddress->getStreet2();
512
+ $szAddress3 = $billingAddress->getStreet3();
513
+ $szAddress4 = $billingAddress->getStreet4();
514
+ $szCity = $billingAddress->getCity();
515
+ $szState = $billingAddress->getRegion();
516
+ $szPostCode = $billingAddress->getPostcode();
517
+
518
+ if($this->getConfigData('cv2mandatory'))
519
+ {
520
+ $boCV2Mandatory = 'true';
521
+ }
522
+ if($this->getConfigData('address1mandatory'))
523
+ {
524
+ $boAddress1Mandatory = 'true';
525
+ }
526
+ if($this->getConfigData('citymandatory'))
527
+ {
528
+ $boCityMandatory = 'true';
529
+ }
530
+ if($this->getConfigData('postcodemandatory'))
531
+ {
532
+ $boPostCodeMandatory = 'true';
533
+ }
534
+ if($this->getConfigData('statemandatory'))
535
+ {
536
+ $boStateMandatory = 'true';
537
+ }
538
+ if($this->getConfigData('countrymandatory'))
539
+ {
540
+ $boCountryMandatory = 'true';
541
+ }
542
+ if($this->getConfigData('paymentformdisplaysresult'))
543
+ {
544
+ $boPaymentFormDisplaysResult = 'true';
545
+ }
546
+
547
+ $szHashDigest = CSV_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, $szServerResultURLCookieVariables, $szServerResultURLFormVariables, $szServerResultURLQueryStringVariables);
548
+
549
+ $session->setHashdigest($szHashDigest)
550
+ ->setMerchantid($szMerchantID)
551
+ ->setAmount($nAmount)
552
+ ->setCurrencycode($nCurrencyCode)
553
+ ->setOrderid($szOrderID)
554
+ ->setTransactiontype($szTransactionType)
555
+ ->setTransactiondatetime($szTransactionDateTime)
556
+ ->setCallbackurl($szCallbackURL)
557
+ ->setOrderdescription($szOrderDescription)
558
+ ->setCustomername($szCustomerName)
559
+ ->setAddress1($szAddress1)
560
+ ->setAddress2($szAddress2)
561
+ ->setAddress3($szAddress3)
562
+ ->setAddress4($szAddress4)
563
+ ->setCity($szCity)
564
+ ->setState($szState)
565
+ ->setPostcode($szPostCode)
566
+ ->setCountrycode($nCountryCode)
567
+ ->setCv2mandatory($boCV2Mandatory)
568
+ ->setAddress1mandatory($boAddress1Mandatory)
569
+ ->setCitymandatory($boCityMandatory)
570
+ ->setPostcodemandatory($boPostCodeMandatory)
571
+ ->setStatemandatory($boStateMandatory)
572
+ ->setCountrymandatory($boCountryMandatory)
573
+ ->setResultdeliverymethod($rdmResultdeliveryMethod)
574
+ ->setServerresulturl($szServerResultURL)
575
+ ->setPaymentformdisplaysresult($boPaymentFormDisplaysResult)
576
+ ->setServerresulturlcookievariables($szServerResultURLCookieVariables)
577
+ ->setServerresulturlformvariables($szServerResultURLFormVariables)
578
+ ->setServerresulturlquerystringvariables($szServerResultURLQueryStringVariables);
579
+
580
+ if($nVersion >= 1410)
581
+ {
582
+ $session->setRedirectionmethod('_runRedirectedPaymentComplete');
583
+ $payment->getOrder()->setIsHostedPaymentPending(true);
584
+ }
585
+ }
586
+
587
+ /**
588
+ * Processing the transaction using the transparent redirect integration
589
+ *
590
+ * @param Varien_Object $payment
591
+ * @param unknown_type $amount
592
+ */
593
+ public function _runTransparentRedirectTransaction(Varien_Object $payment, $amount)
594
+ {
595
+ $GLOBALS['m_boPayInvoice'] = false;
596
+ $payment->setIsTransactionPending(true);
597
+ $nVersion = $this->getVersion();
598
+
599
+ $szMerchantID = $this->getConfigData('merchantid');
600
+ $szPassword = $this->getConfigData('password');
601
+ $szPreSharedKey = $this->getConfigData('presharedkey');
602
+ $hmHashMethod = $this->getConfigData('hashmethod');
603
+ $szCallbackURL = Mage::getUrl('cardsaveonlinepayments/payment/callbacktransparentredirect', array('_secure' => true));
604
+ $order = $payment->getOrder();
605
+ $billingAddress = $order->getBillingAddress();
606
+ $iclISOCurrencyList = CSV_ISOCurrencies::getISOCurrencyList();
607
+ $iclISOCountryList = CSV_ISOCountries::getISOCountryList();
608
+ $szStartDateMonth = '';
609
+ $szStartDateYear = '';
610
+
611
+ $szCurrencyShort = $order->getOrderCurrency()->getCurrencyCode();
612
+ if ($szCurrencyShort != '' &&
613
+ $iclISOCurrencyList->getISOCurrency($szCurrencyShort, $icISOCurrency))
614
+ {
615
+ $nCurrencyCode = $icISOCurrency->getISOCode();
616
+ }
617
+
618
+ $power = pow(10, $icISOCurrency->getExponent());
619
+ $nAmount = $amount * $power;
620
+
621
+ $szOrderID = $payment->getOrder()->increment_id;
622
+ $szTransactionType = 'SALE';
623
+ //date time with 2008-12-01 14:12:00 +01:00 format
624
+ $szTransactionDateTime = date('Y-m-d H:i:s P');
625
+ $szOrderDescription = '';
626
+
627
+ $szAddress1 = $billingAddress->getStreet1();
628
+ $szAddress2 = $billingAddress->getStreet2();
629
+ $szAddress3 = $billingAddress->getStreet3();
630
+ $szAddress4 = $billingAddress->getStreet4();
631
+ $szCity = $billingAddress->getCity();
632
+ $szState = $billingAddress->getRegion();
633
+ $szPostCode = $billingAddress->getPostcode();
634
+ $szISO2CountryCode = $billingAddress->getCountry();
635
+ $szCountryShort = $this->_getISO3Code($szISO2CountryCode);
636
+ if($iclISOCountryList->getISOCountry($szCountryShort, $icISOCountry))
637
+ {
638
+ $nCountryCode = $icISOCountry->getISOCode();
639
+ }
640
+
641
+ $szCardName = $payment->getCcOwner();
642
+ $szCardNumber = $payment->getCcNumber();
643
+ $szExpiryDateMonth = $payment->getCcExpMonth();
644
+ $szExpiryDateYear = $payment->getCcExpYear();
645
+ if($payment->getCcSsStartMonth() != '')
646
+ {
647
+ $szStartDateMonth = $payment->getCcSsStartMonth();
648
+ }
649
+ if($payment->getCcSsStartYear() != '')
650
+ {
651
+ $szStartDateYear = $payment->getCcSsStartYear();
652
+ }
653
+ $szIssueNumber = $payment->getCcSsIssue();
654
+ $szCV2 = $payment->getCcCid();
655
+
656
+ $szHashDigest = CSV_PaymentFormHelper::calculateTransparentRedirectHashDigest($szMerchantID, $szPassword, $hmHashMethod, $szPreSharedKey, $nAmount, $nCurrencyCode, $szOrderID, $szTransactionType, $szTransactionDateTime, $szCallbackURL, $szOrderDescription);
657
+
658
+ Mage::getSingleton('checkout/session')->setHashdigest($szHashDigest)
659
+ ->setMerchantid($szMerchantID)
660
+ ->setAmount($nAmount)
661
+ ->setCurrencycode($nCurrencyCode)
662
+ ->setOrderid($szOrderID)
663
+ ->setTransactiontype($szTransactionType)
664
+ ->setTransactiondatetime($szTransactionDateTime)
665
+ ->setCallbackurl($szCallbackURL)
666
+ ->setOrderdescription($szOrderDescription)
667
+ ->setAddress1($szAddress1)
668
+ ->setAddress2($szAddress2)
669
+ ->setAddress3($szAddress3)
670
+ ->setAddress4($szAddress4)
671
+ ->setCity($szCity)
672
+ ->setState($szState)
673
+ ->setPostcode($szPostCode)
674
+ ->setCountrycode($nCountryCode)
675
+ ->setCardname($szCardName)
676
+ ->setCardnumber($szCardNumber)
677
+ ->setExpirydatemonth($szExpiryDateMonth)
678
+ ->setExpirydateyear($szExpiryDateYear)
679
+ ->setStartdatemonth($szStartDateMonth)
680
+ ->setStartdateyear($szStartDateYear)
681
+ ->setIssuenumber($szIssueNumber)
682
+ ->setCv2($szCV2);
683
+
684
+ if($nVersion >= 1410)
685
+ {
686
+ Mage::getSingleton('checkout/session')->setRedirectionmethod('_runRedirectedPaymentComplete');
687
+ $payment->getOrder()->setIsHostedPaymentPending(true);
688
+ }
689
+ }
690
+
691
+ /**
692
+ * Processing the 3D Secure transaction
693
+ *
694
+ * @param Varien_Object $payment
695
+ * @param int $amount
696
+ * @param string $szPaRes
697
+ * @param string $szMD
698
+ */
699
+ public function _run3DSecureTransaction(Varien_Object $payment, $szPaRes, $szMD)
700
+ {
701
+ $error = false;
702
+ $message = '';
703
+ $order = $payment->getOrder();
704
+ $szOrderID = $payment->getOrder()->increment_id;
705
+ $session = Mage::getSingleton('checkout/session');
706
+ $nVersion = $this->getVersion();
707
+
708
+ $MerchantID = $this->getConfigData('merchantid');
709
+ $Password = $this->getConfigData('password');
710
+ $SecretKey = $this->getConfigData('secretkey');
711
+
712
+ $PaymentProcessorFullDomain = $this->_getPaymentProcessorFullDomain();
713
+ $rgeplRequestGatewayEntryPointList = new CSV_RequestGatewayEntryPointList();
714
+ $rgeplRequestGatewayEntryPointList->add("https://gw1.".$PaymentProcessorFullDomain, 100, 2);
715
+ $rgeplRequestGatewayEntryPointList->add("https://gw2.".$PaymentProcessorFullDomain, 200, 2);
716
+ $rgeplRequestGatewayEntryPointList->add("https://gw3.".$PaymentProcessorFullDomain, 300, 2);
717
+
718
+ $maMerchantAuthentication = new CSV_MerchantAuthentication($MerchantID, $Password);
719
+ $tdsidThreeDSecureInputData = new CSV_ThreeDSecureInputData($szMD, $szPaRes);
720
+
721
+ $tdsaThreeDSecureAuthentication = new CSV_ThreeDSecureAuthentication($rgeplRequestGatewayEntryPointList, 1, null, $maMerchantAuthentication, $tdsidThreeDSecureInputData, "Some data to be passed out");
722
+ $boTransactionProcessed = $tdsaThreeDSecureAuthentication->processTransaction($tdsarThreeDSecureAuthenticationResult, $todTransactionOutputData);
723
+
724
+ if ($boTransactionProcessed == false)
725
+ {
726
+ // could not communicate with the payment gateway
727
+ $szLogMessage = Cardsave_Cardsaveonlinepayments_Model_Common_GlobalErrors::ERROR_431;
728
+ $message = Cardsave_Cardsaveonlinepayments_Model_Common_GlobalErrors::ERROR_431;
729
+ Mage::log($szLogMessage);
730
+ }
731
+ else
732
+ {
733
+ $message = "Payment Processor Response: ".$tdsarThreeDSecureAuthenticationResult->getMessage();
734
+ $szLogMessage = "3D Secure transaction could not be completed for OrderID: ".$szOrderID.". Result object details: ";
735
+
736
+ switch ($tdsarThreeDSecureAuthenticationResult->getStatusCode())
737
+ {
738
+ case 0:
739
+ // status code of 0 - means transaction successful
740
+ $szLogMessage = "3D Secure transaction successfully completed for OrderID: ".$szOrderID.". Result object details: ";
741
+ break;
742
+ case 5:
743
+ // status code of 5 - means transaction declined
744
+ $error = true;
745
+ break;
746
+ case 20:
747
+ // status code of 20 - means duplicate transaction
748
+ $szPreviousTransactionMessage = $tdsarThreeDSecureAuthenticationResult->getPreviousTransactionResult()->getMessage();
749
+ $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: ";
750
+
751
+ if ($tdsarThreeDSecureAuthenticationResult->getPreviousTransactionResult()->getStatusCode()->getValue() == 0)
752
+ {
753
+ $message = $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 are - ".$szPreviousTransactionMessage;
754
+ }
755
+ else
756
+ {
757
+ $error = true;
758
+ }
759
+ break;
760
+ case 30:
761
+ $error = true;
762
+ // status code of 30 - means an error occurred
763
+ $szLogMessage = "3D Secure transaction could not be completed for OrderID: ".$szOrderID.". Error message: ".$tdsarThreeDSecureAuthenticationResult->getMessage();
764
+ if ($tdsarThreeDSecureAuthenticationResult->getErrorMessages()->getCount() > 0)
765
+ {
766
+ $szLogMessage = $szLogMessage.".";
767
+ $message =$message.".";
768
+
769
+ for ($LoopIndex = 0; $LoopIndex < $tdsarThreeDSecureAuthenticationResult->getErrorMessages()->getCount(); $LoopIndex++)
770
+ {
771
+ $szLogMessage = $szLogMessage.$tdsarThreeDSecureAuthenticationResult->getErrorMessages()->getAt($LoopIndex).";";
772
+ $message = $message.$tdsarThreeDSecureAuthenticationResult->getErrorMessages()->getAt($LoopIndex).";";
773
+ }
774
+ $szLogMessage = $szLogMessage." ";
775
+ $message = $message." ";
776
+ }
777
+ break;
778
+ default:
779
+ // unhandled status code
780
+ $error = true;
781
+ break;
782
+ }
783
+
784
+ // log 3DS payment result
785
+ $szLogMessage = $szLogMessage.print_r($tdsarThreeDSecureAuthenticationResult, 1);
786
+ Mage::log($szLogMessage);
787
+ }
788
+
789
+ $session->setPaymentprocessorresponse($message);
790
+ if($error == true)
791
+ {
792
+ $message = Mage::helper('cardsaveonlinepayments')->__($message);
793
+ Mage::throwException($message);
794
+ }
795
+ else
796
+ {
797
+ $payment->setStatus(self::STATUS_APPROVED);
798
+
799
+ if($nVersion == 1324 || $nVersion == 1330)
800
+ {
801
+ $payment->setIsInvoicePaid(true);
802
+ Mage::getSingleton('core/session')->addSuccess($message);
803
+ }
804
+ }
805
+
806
+ return $this;
807
+ }
808
+
809
+ public function _runRedirectedPaymentComplete(Varien_Object $payment, $boIsHostedPaymentAction, $szStatusCode, $szMessage, $szPreviousStatusCode, $szPreviousMessage, $szOrderID, $szCrossReference)
810
+ {
811
+ $error = false;
812
+ $message;
813
+ $session = Mage::getSingleton('checkout/session');
814
+ $nVersion = $this->getVersion();
815
+
816
+ if($boIsHostedPaymentAction == true)
817
+ {
818
+ $szWording = "Hosted Payment Form ";
819
+ }
820
+ else
821
+ {
822
+ $szWording = "Transparent Redirect ";
823
+ }
824
+
825
+ $message = "Payment Processor Response: ".$szMessage;
826
+
827
+ switch ($szStatusCode)
828
+ {
829
+ case "0":
830
+ Mage::log($szWording."transaction successfully completed. ".$message);
831
+ break;
832
+ case "20":
833
+ Mage::log("Duplicate ".$szWording."transaction. ".$message);
834
+ $message = $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: ".$szPreviousMessage;
835
+ if($szPreviousStatusCode != "0")
836
+ {
837
+ $error = true;
838
+ }
839
+ break;
840
+ case "5":
841
+ case "30":
842
+ default:
843
+ Mage::log($szWording."transaction couldn't be completed. ".$message);
844
+ $error = true;
845
+ break;
846
+ }
847
+
848
+ $session->setPaymentprocessorresponse($message);
849
+ if($szCrossReference)
850
+ {
851
+ $szAdditionalData = "CrossReference=".$szCrossReference;
852
+ $payment->setAdditionalData($szAdditionalData);
853
+ }
854
+
855
+ if($error == true)
856
+ {
857
+ $message = Mage::helper('cardsaveonlinepayments')->__($message);
858
+ Mage::throwException($message);
859
+ }
860
+ else
861
+ {
862
+ $payment->setStatus(self::STATUS_APPROVED);
863
+
864
+ if($nVersion == 1324 || $nVersion ==1330)
865
+ {
866
+ $payment->setIsInvoicePaid(true);
867
+ Mage::getSingleton('core/session')->addSuccess($message);
868
+ }
869
+ }
870
+
871
+ return $this;
872
+ }
873
+
874
+ /**
875
+ * Override the core Mage function to get the URL to be redirected from the Onepage
876
+ *
877
+ * @return string
878
+ */
879
+ public function getOrderPlaceRedirectUrl()
880
+ {
881
+ $result = false;
882
+ $session = Mage::getSingleton('checkout/session');
883
+
884
+ if($session->getMd() &&
885
+ $session->getAcsurl() &&
886
+ $session->getPareq())
887
+ {
888
+ // Direct (API) for 3D Secure payments
889
+ $result = Mage::getUrl('cardsaveonlinepayments/payment/threedsecure', array('_secure' => true));
890
+ }
891
+ if($session->getHashdigest())
892
+ {
893
+ // Hosted Payment Form and Transparent Redirect payments
894
+ $result = Mage::getUrl('cardsaveonlinepayments/payment/redirect', array('_secure' => true));
895
+ }
896
+
897
+ return $result;
898
+ }
899
+
900
+ /**
901
+ * Get the correct payment processor domain
902
+ *
903
+ * @return string
904
+ */
905
+ private function _getPaymentProcessorFullDomain()
906
+ {
907
+ $szPaymentProcessorFullDomain;
908
+
909
+ // get the stored config setting
910
+ $szPaymentProcessorDomain = $this->getConfigData('paymentprocessordomain');
911
+ $szPaymentProcessorPort = $this->getConfigData('paymentprocessorport');
912
+
913
+ if ($szPaymentProcessorPort == '443')
914
+ {
915
+ $szPaymentProcessorFullDomain = $szPaymentProcessorDomain."/";
916
+ }
917
+ else
918
+ {
919
+ $szPaymentProcessorFullDomain = $szPaymentProcessorDomain.":".$szPaymentProcessorPort."/";
920
+ }
921
+
922
+ return $szPaymentProcessorFullDomain;
923
+ }
924
+
925
+ /**
926
+ * Get the country ISO3 code from the ISO2 code
927
+ *
928
+ * @param ISO2Code
929
+ * @return string
930
+ */
931
+ private function _getISO3Code($szISO2Code)
932
+ {
933
+ $szISO3Code;
934
+ $collection;
935
+ $boFound = false;
936
+ $nCount = 1;
937
+ $item;
938
+
939
+ $collection = Mage::getModel('directory/country_api')->items();
940
+
941
+ while ($boFound == false &&
942
+ $nCount < count($collection))
943
+ {
944
+ $item = $collection[$nCount];
945
+ if($item['iso2_code'] == $szISO2Code)
946
+ {
947
+ $boFound = true;
948
+ $szISO3Code = $item['iso3_code'];
949
+ }
950
+ $nCount++;
951
+ }
952
+
953
+ return $szISO3Code;
954
+ }
955
+
956
+ /**
957
+ * Transform the string Magento version number into an integer ready for comparison
958
+ *
959
+ * @param unknown_type $magentoVersion
960
+ * @return unknown
961
+ */
962
+ public function getVersion()
963
+ {
964
+ $magentoVersion = Mage::getVersion();
965
+ $pattern = '/[^\d]/';
966
+ $magentoVersion = preg_replace($pattern, '', $magentoVersion);
967
+
968
+ while(strlen($magentoVersion) < 4)
969
+ {
970
+ $magentoVersion .= '0';
971
+ }
972
+ $magentoVersion = (int)$magentoVersion;
973
+
974
+ return $magentoVersion;
975
+ }
976
+ }
app/code/local/Cardsave/Cardsaveonlinepayments/Model/Request.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Cardsave_Cardsaveonlinepayments_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/Cardsave/Cardsaveonlinepayments/Model/Resource/Eav/Mysql4/Setup.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Cardsave_Cardsaveonlinepayments_Model_Resource_Eav_Mysql4_Setup extends Mage_Eav_Model_Entity_Setup
4
+ {
5
+
6
+ }
app/code/local/Cardsave/Cardsaveonlinepayments/Model/Source/HashMethod.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Cardsave_Cardsaveonlinepayments_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('cardsaveonlinepayments')->__('MD5')
18
+ ),
19
+ array(
20
+ 'value' => self::HASH_METHOD_SHA1,
21
+ 'label' => Mage::helper('cardsaveonlinepayments')->__('SHA1')
22
+ ),
23
+ array(
24
+ 'value' => self::HASH_METHOD_HMACMD5,
25
+ 'label' => Mage::helper('cardsaveonlinepayments')->__('HMACMD5')
26
+ ),
27
+ array(
28
+ 'value' => self::HASH_METHOD_HMACSHA1,
29
+ 'label' => Mage::helper('cardsaveonlinepayments')->__('HMACSHA1')
30
+ )
31
+ );
32
+ }
33
+ }
app/code/local/Cardsave/Cardsaveonlinepayments/Model/Source/OrderStatus.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Cardsave_Cardsaveonlinepayments_Model_Source_OrderStatus
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ return array(
8
+ // override the order status and ONLY offer "pending" by default
9
+ array(
10
+ 'value' => 'processing',
11
+ 'label' => Mage::helper('cardsaveonlinepayments')->__('Processing')
12
+ ),
13
+ );
14
+ }
15
+ }
app/code/local/Cardsave/Cardsaveonlinepayments/Model/Source/PaymentAction.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Cardsave_Cardsaveonlinepayments_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/Cardsave/Cardsaveonlinepayments/Model/Source/PaymentMode.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Cardsave_Cardsaveonlinepayments_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('cardsaveonlinepayments')->__('Direct (API)')
17
+ ),
18
+ array(
19
+ 'value' => self::PAYMENT_MODE_HOSTED_PAYMENT_FORM,
20
+ 'label' => Mage::helper('cardsaveonlinepayments')->__('Hosted Payment Form')
21
+ ),
22
+ array(
23
+ 'value' => self::PAYMENT_MODE_TRANSPARENT_REDIRECT,
24
+ 'label' => Mage::helper('cardsaveonlinepayments')->__('Transparent Redirect')
25
+ ),
26
+ );
27
+ }
28
+ }
app/code/local/Cardsave/Cardsaveonlinepayments/Model/Source/ResultDeliveryMethod.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Cardsave_Cardsaveonlinepayments_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
+ const RESULT_DELIVERY_METHOD_SERVER_PULL = "SERVER_PULL";
9
+
10
+ public function toOptionArray()
11
+ {
12
+ return array
13
+ (
14
+ array(
15
+ 'value' => self::RESULT_DELIVERY_METHOD_SERVER_PULL,
16
+ 'label' => Mage::helper('cardsaveonlinepayments')->__('Server Pull')
17
+ ),
18
+ /*array(
19
+ 'value' => self::RESULT_DELIVERY_METHOD_SERVER,
20
+ 'label' => Mage::helper('cardsaveonlinepayments')->__('Server')
21
+ ),*/
22
+ array(
23
+ 'value' => self::RESULT_DELIVERY_METHOD_POST,
24
+ 'label' => Mage::helper('cardsaveonlinepayments')->__('Post')
25
+ )
26
+ );
27
+ }
28
+ }
app/code/local/Cardsave/Cardsaveonlinepayments/controllers/PaymentController.php ADDED
@@ -0,0 +1,918 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once "app/code/local/Cardsave/Cardsaveonlinepayments/Model/Common/PaymentFormHelper.php";
4
+
5
+ /**
6
+ * Standard Checkout Controller
7
+ *
8
+ */
9
+ class Cardsave_Cardsaveonlinepayments_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
+ //$this->_redirect('checkout/cart');
23
+ $this->_redirect('checkout/onepage/failure');
24
+ #$this->loadLayout();
25
+ #$this->renderLayout();
26
+ }
27
+
28
+ /**
29
+ * When a customer cancel payment from paypal.
30
+ */
31
+ public function cancelAction()
32
+ {
33
+ $session = Mage::getSingleton('checkout/session');
34
+ $session->setQuoteId($session->getPaypalStandardQuoteId(true));
35
+
36
+ $this->_redirect('checkout/cart');
37
+ }
38
+
39
+ /**
40
+ * Action logic for Hosted Payment mode
41
+ *
42
+ */
43
+ public function redirectAction()
44
+ {
45
+ $nVersion = Mage::getModel('cardsaveonlinepayments/direct')->getVersion();
46
+
47
+ if($nVersion >= 1410)
48
+ {
49
+ // need to re-add the ordered item quantity to stock as per not completed 3DS transaction
50
+ if(!Mage::getSingleton('checkout/session')->getPares())
51
+ {
52
+ $order = Mage::getModel('sales/order')->load(Mage::getSingleton('checkout/session')->getLastOrderId());
53
+ $this->_addOrderedItemsToStock($order);
54
+ }
55
+ }
56
+ $this->getResponse()->setBody($this->getLayout()->createBlock('cardsaveonlinepayments/redirect')->toHtml());
57
+ }
58
+
59
+ /**
60
+ * Action logic for 3D Secure redirection
61
+ *
62
+ */
63
+ public function threedsecureAction()
64
+ {
65
+ $nVersion = Mage::getModel('cardsaveonlinepayments/direct')->getVersion();
66
+
67
+ if($nVersion >= 1410)
68
+ {
69
+ $mode = Mage::getModel('cardsaveonlinepayments/direct')->getConfigData('mode');
70
+
71
+ // need to re-add the ordered item quantity to stock as per not completed 3DS transaction
72
+ if($mode != Cardsave_Cardsaveonlinepayments_Model_Source_PaymentMode::PAYMENT_MODE_TRANSPARENT_REDIRECT)
73
+ {
74
+ $order = Mage::getModel('sales/order')->load(Mage::getSingleton('checkout/session')->getLastOrderId());
75
+ $this->_addOrderedItemsToStock($order);
76
+ }
77
+ }
78
+
79
+ $this->getResponse()->setBody($this->getLayout()->createBlock('cardsaveonlinepayments/threedsecure')->toHtml());
80
+ }
81
+
82
+ /**
83
+ * Action logic for handling the reception of the 3D Secure authentication result (PaRes)
84
+ *
85
+ * @return unknown
86
+ */
87
+ public function callback3dAction()
88
+ {
89
+ $boError = false;
90
+ $szMessage = '';
91
+ $checkout = Mage::getSingleton('checkout/type_onepage');
92
+ $session = Mage::getSingleton('checkout/session');
93
+ $szPaymentProcessorResponse = '';
94
+ $nVersion = Mage::getModel('cardsaveonlinepayments/direct')->getVersion();
95
+
96
+ try
97
+ {
98
+ $szPaRes = $this->getRequest()->getPost('PaRes');
99
+ $szMD = $this->getRequest()->getPost('MD');
100
+
101
+ // complete the 3D Secure transaction with the 3D Authorization result
102
+ $checkout->saveOrderAfter3dSecure($szPaRes, $szMD);
103
+ }
104
+ catch (Exception $exc)
105
+ {
106
+ $boError = true;
107
+ Mage::logException($exc);
108
+
109
+ if( isset($_SESSION['cardsaveonlinepayments_message']) )
110
+ {
111
+ $szMessage = $_SESSION['cardsaveonlinepayments_message'];
112
+ unset($_SESSION['cardsaveonlinepayments_message']);
113
+ }
114
+ else
115
+ {
116
+ $szMessage = Cardsave_Cardsaveonlinepayments_Model_Common_GlobalErrors::ERROR_7655;
117
+ }
118
+ }
119
+
120
+ $szPaymentProcessorResponse = $session->getPaymentprocessorresponse();
121
+ $order = Mage::getModel('sales/order');
122
+ $order->load(Mage::getSingleton('checkout/session')->getLastOrderId());
123
+
124
+ if ($boError)
125
+ {
126
+ if($szPaymentProcessorResponse != null &&
127
+ $szPaymentProcessorResponse != '')
128
+ {
129
+ $szMessage .= '<br/>'.$szPaymentProcessorResponse;
130
+ }
131
+
132
+ if($nVersion >= 1410)
133
+ {
134
+ if($order)
135
+ {
136
+ $orderState = 'pending_payment';
137
+ $orderStatus = 'csv_failed_threed_secure';
138
+ $order->setCustomerNote(Mage::helper('cardsaveonlinepayments')->__('3D Secure Authentication Failed'));
139
+ $order->setState($orderState, $orderStatus, $szPaymentProcessorResponse, false);
140
+ $order->save();
141
+ }
142
+ }
143
+ if($nVersion == 1324 || $nVersion == 1330)
144
+ {
145
+ Mage::getSingleton('checkout/session')->addError($szMessage);
146
+ }
147
+ else
148
+ {
149
+ Mage::getSingleton('core/session')->addError($szMessage);
150
+ }
151
+
152
+ $this->_clearSessionVariables();
153
+ // report out an fatal error
154
+ $this->_redirect('checkout/onepage/failure');
155
+ }
156
+ else
157
+ {
158
+ // set the quote as inactive after back from paypal
159
+ Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
160
+
161
+ // send confirmation email to customer
162
+ if($order->getId())
163
+ {
164
+ $order->sendNewOrderEmail();
165
+ }
166
+
167
+ if($nVersion >= 1410)
168
+ {
169
+ $this->_subtractOrderedItemsFromStock($order);
170
+ $this->_updateInvoices($order, $szPaymentProcessorResponse);
171
+ }
172
+
173
+ if($nVersion != 1324 && $nVersion != 1330)
174
+ {
175
+ if($szPaymentProcessorResponse != '')
176
+ {
177
+ Mage::getSingleton('core/session')->addSuccess($szPaymentProcessorResponse);
178
+ }
179
+ }
180
+
181
+ $this->_redirect('checkout/onepage/success', array('_secure' => true));
182
+ }
183
+ }
184
+
185
+ /**
186
+ * Action logic for handling the result from the Hosted Payment page
187
+ *
188
+ */
189
+ public function callbackhostedpaymentAction()
190
+ {
191
+ $boError = false;
192
+ $formVariables = array();
193
+ $model = Mage::getModel('cardsaveonlinepayments/direct');
194
+ $szOrderID = $this->getRequest()->getPost('OrderID');
195
+ $checkout = Mage::getSingleton('checkout/type_onepage');
196
+ $session = Mage::getSingleton('checkout/session');
197
+ $szPaymentProcessorResponse = '';
198
+ $order = Mage::getModel('sales/order');
199
+ $order->load(Mage::getSingleton('checkout/session')->getLastOrderId());
200
+ $nVersion = Mage::getModel('cardsaveonlinepayments/direct')->getVersion();
201
+
202
+ try
203
+ {
204
+ $hmHashMethod = $model->getConfigData('hashmethod');
205
+ $szPassword = $model->getConfigData('password');
206
+ $szPreSharedKey = $model->getConfigData('presharedkey');
207
+
208
+ $formVariables['HashDigest'] = $this->getRequest()->getPost('HashDigest');
209
+ $formVariables['MerchantID'] = $this->getRequest()->getPost('MerchantID');
210
+ $formVariables['StatusCode'] = $this->getRequest()->getPost('StatusCode');
211
+ $formVariables['Message'] = $this->getRequest()->getPost('Message');
212
+ $formVariables['PreviousStatusCode'] = $this->getRequest()->getPost('PreviousStatusCode');
213
+ $formVariables['PreviousMessage'] = $this->getRequest()->getPost('PreviousMessage');
214
+ $formVariables['CrossReference'] = $this->getRequest()->getPost('CrossReference');
215
+ $formVariables['Amount'] = $this->getRequest()->getPost('Amount');
216
+ $formVariables['CurrencyCode'] = $this->getRequest()->getPost('CurrencyCode');
217
+ $formVariables['OrderID'] = $this->getRequest()->getPost('OrderID');
218
+ $formVariables['TransactionType'] = $this->getRequest()->getPost('TransactionType');
219
+ $formVariables['TransactionDateTime'] = $this->getRequest()->getPost('TransactionDateTime');
220
+ $formVariables['OrderDescription'] = $this->getRequest()->getPost('OrderDescription');
221
+ $formVariables['CustomerName'] = $this->getRequest()->getPost('CustomerName');
222
+ $formVariables['Address1'] = $this->getRequest()->getPost('Address1');
223
+ $formVariables['Address2'] = $this->getRequest()->getPost('Address2');
224
+ $formVariables['Address3'] = $this->getRequest()->getPost('Address3');
225
+ $formVariables['Address4'] = $this->getRequest()->getPost('Address4');
226
+ $formVariables['City'] = $this->getRequest()->getPost('City');
227
+ $formVariables['State'] = $this->getRequest()->getPost('State');
228
+ $formVariables['PostCode'] = $this->getRequest()->getPost('PostCode');
229
+ $formVariables['CountryCode'] = $this->getRequest()->getPost('CountryCode');
230
+
231
+ if(!CSV_PaymentFormHelper::compareHostedPaymentFormHashDigest($formVariables, $szPassword, $hmHashMethod, $szPreSharedKey))
232
+ {
233
+ $boError = true;
234
+ $szNotificationMessage = "The payment was rejected for a SECURITY reason: the incoming payment data was tampered with.";
235
+ Mage::log("The Hosted Payment Form transaction couldn't be completed for the following reason: [".$szNotificationMessage. "]. Form variables: ".print_r($formVariables, 1));
236
+ }
237
+ else
238
+ {
239
+ $checkout->saveOrderAfterRedirectedPaymentAction(true,
240
+ $this->getRequest()->getPost('StatusCode'),
241
+ $this->getRequest()->getPost('Message'),
242
+ $this->getRequest()->getPost('PreviousStatusCode'),
243
+ $this->getRequest()->getPost('PreviousMessage'),
244
+ $this->getRequest()->getPost('OrderID'),
245
+ $this->getRequest()->getPost('CrossReference'));
246
+ }
247
+ }
248
+ catch (Exception $exc)
249
+ {
250
+ $boError = true;
251
+ $szNotificationMessage = Cardsave_Cardsaveonlinepayments_Model_Common_GlobalErrors::ERROR_183;
252
+ Mage::logException($exc);
253
+ }
254
+
255
+ $szPaymentProcessorResponse = $session->getPaymentprocessorresponse();
256
+ if($boError)
257
+ {
258
+ if($szPaymentProcessorResponse != null &&
259
+ $szPaymentProcessorResponse != '')
260
+ {
261
+ $szNotificationMessage = $szNotificationMessage.'<br/>'.$szPaymentProcessorResponse;
262
+ }
263
+
264
+ $order->getPayment()->setAdditionalData("CrossReference=".$this->getRequest()->getPost('CrossReference'));
265
+
266
+ if($nVersion >= 1410)
267
+ {
268
+ if($order)
269
+ {
270
+ $orderState = 'pending_payment';
271
+ $orderStatus = 'csv_failed_hosted_payment';
272
+ $order->setCustomerNote(Mage::helper('cardsaveonlinepayments')->__('Hosted Payment Failed'));
273
+ $order->setState($orderState, $orderStatus, $szPaymentProcessorResponse, false);
274
+ $order->save();
275
+ }
276
+ }
277
+ if($nVersion == 1324 || $nVersion == 1330)
278
+ {
279
+ Mage::getSingleton('checkout/session')->addError($szNotificationMessage);
280
+ }
281
+ else
282
+ {
283
+ Mage::getSingleton('core/session')->addError($szNotificationMessage);
284
+ }
285
+ $order->save();
286
+
287
+ $this->_clearSessionVariables();
288
+ $this->_redirect('checkout/onepage/failure');
289
+ }
290
+ else
291
+ {
292
+ // set the quote as inactive after back from paypal
293
+ Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
294
+
295
+ // send confirmation email to customer
296
+ if($order->getId())
297
+ {
298
+ $order->sendNewOrderEmail();
299
+ }
300
+
301
+ if($nVersion >= 1410)
302
+ {
303
+ $this->_subtractOrderedItemsFromStock($order);
304
+ $this->_updateInvoices($order, $szPaymentProcessorResponse);
305
+ }
306
+
307
+ if($nVersion != 1324 && $nVersion != 1330)
308
+ {
309
+ if($szPaymentProcessorResponse != '')
310
+ {
311
+ Mage::getSingleton('core/session')->addSuccess($szPaymentProcessorResponse);
312
+ }
313
+ }
314
+ $this->_redirect('checkout/onepage/success', array('_secure' => true));
315
+ }
316
+ }
317
+
318
+ /**
319
+ * Action logic for handling the server to server communication in case of Result Delivery Method = SERVER
320
+ *
321
+ */
322
+ public function serverresultAction()
323
+ {
324
+ $boError = false;
325
+ $model = Mage::getModel('cardsaveonlinepayments/direct');
326
+ $checkout = Mage::getSingleton('checkout/type_onepage');
327
+ $szOrderID = $this->getRequest()->getPost('OrderID');
328
+ $szMessage = $this->getRequest()->getPost('Message');
329
+ $nVersion = Mage::getModel('cardsaveonlinepayments/direct')->getVersion();
330
+
331
+ try
332
+ {
333
+ // finish off the transaction: if StatusCode = 0 create an order otherwise do nothing
334
+ $checkout->saveOrderAfterRedirectedPaymentAction(true,
335
+ $this->getRequest()->getPost('StatusCode'),
336
+ $szMessage,
337
+ $this->getRequest()->getPost('PreviousStatusCode'),
338
+ $this->getRequest()->getPost('PreviousMessage'),
339
+ $this->getRequest()->getPost('OrderID'),
340
+ $this->getRequest()->getPost('CrossReference'));
341
+ }
342
+ catch (Exception $exc)
343
+ {
344
+ $boError = true;
345
+ $szErrorMessage = $exc->getMessage();
346
+ $szNotificationMessage = Cardsave_Cardsaveonlinepayments_Model_Common_GlobalErrors::ERROR_183;
347
+ Mage::logException($exc);
348
+ }
349
+
350
+ if($boError == true)
351
+ {
352
+ $this->getResponse()->setBody('StatusCode=30&Message='.$szErrorMessage);
353
+ }
354
+ else
355
+ {
356
+ $order = Mage::getModel('sales/order');
357
+ $order->load(Mage::getSingleton('checkout/session')->getLastOrderId());
358
+ // set the quote as inactive after back from paypal
359
+ Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
360
+
361
+ // send confirmation email to customer
362
+ if($order->getId())
363
+ {
364
+ $order->sendNewOrderEmail();
365
+ }
366
+
367
+ // if the payment was successful clear the session so that if the customer navigates back to the Magento store
368
+ // the shopping cart will be emptied rather than 'uncomplete'
369
+ if($this->getRequest()->getPost('StatusCode') == '0')
370
+ {
371
+ Mage::getSingleton('checkout/session')->clear();
372
+
373
+ if($nVersion >= 1410)
374
+ {
375
+ $this->_subtractOrderedItemsFromStock($order);
376
+ $this->_updateInvoices($order, $szMessage);
377
+ }
378
+ }
379
+
380
+ $this->getResponse()->setBody('StatusCode=0');
381
+ }
382
+ }
383
+
384
+ /*
385
+ * Action logic to handle the SERVER_PUSH web request to the PaymentFormResultHandler.ashx to get the transaction result details
386
+ */
387
+ public function serverpullresultAction()
388
+ {
389
+ $boError = false;
390
+ $nStartIndex = false;
391
+ //
392
+ $szHashDigest = false;
393
+ $szMerchantID = false;
394
+ $szCrossReference = false;
395
+ $szOrderID = false;
396
+ //
397
+ $nErrorNumber = false;
398
+ $szErrorMessage = false;
399
+ $model = Mage::getModel('cardsaveonlinepayments/direct');
400
+ $checkout = Mage::getSingleton('checkout/type_onepage');
401
+ $szServerPullURL = $model->getConfigData('serverpullresultactionurl');
402
+ $szMerchantID = $model->getConfigData('merchantid');
403
+ $szPassword = $model->getConfigData('password');
404
+ $hmHashMethod = $model->getConfigData('hashmethod');
405
+ $szPreSharedKey = $model->getConfigData('presharedkey');
406
+ $szURLVariableString = $this->getRequest()->getRequestUri();
407
+ $nStartIndex = strpos($szURLVariableString, "?");
408
+ $order = Mage::getModel('sales/order');
409
+ $order->load(Mage::getSingleton('checkout/session')->getLastOrderId());
410
+ $nVersion = Mage::getModel('cardsaveonlinepayments/direct')->getVersion();
411
+
412
+ if(!is_int($nStartIndex))
413
+ {
414
+ $szErrorMessage = Cardsave_Cardsaveonlinepayments_Model_Common_GlobalErrors::ERROR_309;
415
+ Mage::log(Cardsave_Cardsaveonlinepayments_Model_Common_GlobalErrors::ERROR_309." Request URI: ".$szURLVariableString);
416
+ }
417
+ else
418
+ {
419
+ $szURLVariableString = substr($szURLVariableString, $nStartIndex + 1);
420
+ $arFormVariables = CSV_PaymentFormHelper::getVariableCollectionFromString($szURLVariableString);
421
+
422
+ if(!CSV_PaymentFormHelper::compareServerHashDigest($arFormVariables, $szPassword, $hmHashMethod, $szPreSharedKey))
423
+ {
424
+ // report an error message
425
+ $szErrorMessage = Cardsave_Cardsaveonlinepayments_Model_Common_GlobalErrors::ERROR_304;
426
+ }
427
+ else
428
+ {
429
+ $szOrderID = $arFormVariables["OrderID"];
430
+ $szCrossReference = $arFormVariables["CrossReference"];
431
+ $szPostFields = "MerchantID=".$szMerchantID."&Password=".$szPassword."&CrossReference=".$szCrossReference;
432
+
433
+ $cCurl = curl_init();
434
+ curl_setopt($cCurl, CURLOPT_URL, $szServerPullURL);
435
+ curl_setopt($cCurl, CURLOPT_POST, true);
436
+ curl_setopt($cCurl, CURLOPT_POSTFIELDS, $szPostFields);
437
+ curl_setopt($cCurl, CURLOPT_RETURNTRANSFER, 1);
438
+ curl_setopt($cCurl, CURLOPT_ENCODING, "UTF-8");
439
+ curl_setopt($cCurl, CURLOPT_SSL_VERIFYPEER, false);
440
+ curl_setopt($cCurl, CURLOPT_SSL_VERIFYHOST, false);
441
+
442
+ $response = curl_exec($cCurl);
443
+ $nErrorNumber = curl_errno($cCurl);
444
+ $szErrorMessage = curl_error($cCurl);
445
+ curl_close($cCurl);
446
+
447
+ if(is_int($nErrorNumber) &&
448
+ $nErrorNumber > 0)
449
+ {
450
+ Mage::log("Error happened while trying to retrieve the transaction result details for a SERVER_PULL method for CrossReference: ".$szCrossReference.". Error code: ".$nErrorNumber.", message: ".$szErrorMessage);
451
+ // suppress the message and use customer friendly instead
452
+ $szErrorMessage = Cardsave_Cardsaveonlinepayments_Model_Common_GlobalErrors::ERROR_329." Message: ".$szErrorMessage;
453
+ }
454
+ else
455
+ {
456
+ // synchronize of the Magento backend with the transcation result
457
+ try
458
+ {
459
+ // get the response items
460
+ $responseItems = CSV_PaymentFormHelper::getVariableCollectionFromString($response);
461
+
462
+ $szStatusCode = $responseItems["StatusCode"];
463
+ $szMessage = $responseItems["Message"];
464
+ $transactionResult = $responseItems["TransactionResult"];
465
+
466
+ if($szStatusCode !== '0')
467
+ {
468
+ $szErrorMessage = Cardsave_Cardsaveonlinepayments_Model_Common_GlobalErrors::ERROR_381;
469
+ $szErrorMessage .= " Message: ".$szMessage;
470
+ }
471
+ else
472
+ {
473
+ // URL decode the transaction result variable and get the transaction result sub variables
474
+ $transactionResult = urldecode($transactionResult);
475
+ $transactionResult = CSV_PaymentFormHelper::getVariableCollectionFromString($transactionResult);
476
+ // create the order item in the Magento backend
477
+ $szStatusCode = isset($transactionResult["StatusCode"]) ? $transactionResult["StatusCode"] : false;
478
+ $szMessage = isset($transactionResult["Message"]) ? $transactionResult["Message"] : false;
479
+ $szPreviousStatusCode = $szStatusCode;
480
+ $szPreviousMessage = $szMessage;
481
+
482
+ $checkout->saveOrderAfterRedirectedPaymentAction(true,
483
+ $szStatusCode,
484
+ $szMessage,
485
+ $szPreviousStatusCode,
486
+ $szPreviousMessage,
487
+ $szOrderID,
488
+ $szCrossReference);
489
+ }
490
+ }
491
+ catch(Exception $exc)
492
+ {
493
+ $boError = true;
494
+ $szErrorMessage = $exc->getMessage();
495
+ Mage::logException($exc);
496
+ }
497
+ }
498
+ }
499
+ }
500
+
501
+ if($szErrorMessage)
502
+ {
503
+ $order->getPayment()->setAdditionalData("CrossReference=".$szCrossReference);
504
+
505
+ if($nVersion >= 1410)
506
+ {
507
+ if($order)
508
+ {
509
+ $orderState = 'pending_payment';
510
+ $orderStatus = 'csv_failed_hosted_payment';
511
+ $order->setCustomerNote(Mage::helper('cardsaveonlinepayments')->__('Hosted Payment Failed'));
512
+ $order->setState($orderState, $orderStatus, $szErrorMessage, false);
513
+ $order->save();
514
+ }
515
+ }
516
+ if($nVersion == 1324 || $nVersion == 1330)
517
+ {
518
+ Mage::getSingleton('checkout/session')->addError($szErrorMessage);
519
+ }
520
+ else
521
+ {
522
+ Mage::getSingleton('core/session')->addError($szErrorMessage);
523
+ }
524
+ $order->save();
525
+
526
+ $this->_clearSessionVariables();
527
+ $this->_redirect('checkout/onepage/failure');
528
+ }
529
+ else
530
+ {
531
+ // set the quote as inactive after back from paypal
532
+ Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
533
+
534
+ // send confirmation email to customer
535
+ if($order->getId())
536
+ {
537
+ $order->sendNewOrderEmail();
538
+ }
539
+
540
+ if($nVersion >= 1410)
541
+ {
542
+ $this->_subtractOrderedItemsFromStock($order);
543
+ $this->_updateInvoices($order, $szMessage);
544
+ }
545
+
546
+ if($nVersion != 1324 && $nVersion != 1330)
547
+ {
548
+ Mage::getSingleton('core/session')->addSuccess('Payment Processor Response: '.$szMessage);
549
+ }
550
+ $this->_redirect('checkout/onepage/success', array('_secure' => true));
551
+ }
552
+ }
553
+
554
+ /**
555
+ * Action logic for handling the result set from the Transparent Redirect page
556
+ *
557
+ */
558
+ public function callbacktransparentredirectAction()
559
+ {
560
+ $model = Mage::getModel('cardsaveonlinepayments/direct');
561
+ $order = Mage::getModel('sales/order');
562
+ $order->load(Mage::getSingleton('checkout/session')->getLastOrderId());
563
+ $nVersion = Mage::getModel('cardsaveonlinepayments/direct')->getVersion();
564
+
565
+ try
566
+ {
567
+ $hmHashMethod = $model->getConfigData('hashmethod');
568
+ $szPassword = $model->getConfigData('password');
569
+ $szPreSharedKey = $model->getConfigData('presharedkey');
570
+
571
+ $szPaREQ = $this->getRequest()->getPost('PaREQ');
572
+ $szPaRES = $this->getRequest()->getPost('PaRes');
573
+ $nStatusCode = $this->getRequest()->getPost('StatusCode');
574
+
575
+ if(isset($szPaREQ))
576
+ {
577
+ // 3D Secure authentication required
578
+ self::_threeDSecureAuthenticationRequired($szPassword, $hmHashMethod, $szPreSharedKey);
579
+ }
580
+ else if(isset($szPaRES))
581
+ {
582
+ // 3D Secure post authentication
583
+ self::_postThreeDSecureAuthentication($szPassword, $hmHashMethod, $szPreSharedKey);
584
+ }
585
+ else
586
+ {
587
+ // payment complete
588
+ self::_paymentComplete($szPassword, $hmHashMethod, $szPreSharedKey);
589
+ }
590
+
591
+ }
592
+ catch (Exception $exc)
593
+ {
594
+ $error = Cardsave_Cardsaveonlinepayments_Model_Common_GlobalErrors::ERROR_260;
595
+ Mage::logException($exc);
596
+
597
+ if($nVersion >= 1410)
598
+ {
599
+ if($order)
600
+ {
601
+ $orderState = 'pending_payment';
602
+ $orderStatus = 'csv_failed_hosted_payment';
603
+ $order->setCustomerNote(Mage::helper('cardsaveonlinepayments')->__('Transparent Redirect Payment Failed'));
604
+ $order->setState($orderState, $orderStatus, $exc->getMessage(), false);
605
+ $order->save();
606
+ }
607
+ }
608
+ if($nVersion == 1324 || $nVersion == 1330)
609
+ {
610
+ Mage::getSingleton('checkout/session')->addError($error);
611
+ }
612
+ else
613
+ {
614
+ Mage::getSingleton('core/session')->addError($error);
615
+ }
616
+
617
+ $this->_clearSessionVariables();
618
+ $this->_redirect('checkout/onepage/failure');
619
+ }
620
+ }
621
+
622
+ private function _threeDSecureAuthenticationRequired($szPassword, $hmHashMethod, $szPreSharedKey)
623
+ {
624
+ $error = false;
625
+ $formVariables = array();
626
+
627
+ $formVariables['HashDigest'] = $this->getRequest()->getPost('HashDigest');
628
+ $formVariables['MerchantID'] = $this->getRequest()->getPost('MerchantID');
629
+ $formVariables['StatusCode'] = $this->getRequest()->getPost('StatusCode');
630
+ $formVariables['Message'] = $this->getRequest()->getPost('Message');
631
+ $formVariables['CrossReference'] = $this->getRequest()->getPost('CrossReference');
632
+ $formVariables['OrderID'] = $this->getRequest()->getPost('OrderID');
633
+ $formVariables['TransactionDateTime'] = $this->getRequest()->getPost('TransactionDateTime');
634
+ $formVariables['ACSURL'] = $this->getRequest()->getPost('ACSURL');
635
+ $formVariables['PaREQ'] = $this->getRequest()->getPost('PaREQ');
636
+
637
+ if(!CSV_PaymentFormHelper::compareThreeDSecureAuthenticationRequiredHashDigest($formVariables, $szPassword, $hmHashMethod, $szPreSharedKey))
638
+ {
639
+ $error = "The payment was rejected for a SECURITY reason: the incoming payment data was tampered with.";
640
+ Mage::log("The Transparent Redirect transaction couldn't be completed for the following reason: ".$error. " Form variables: ".print_r($formVariables, 1));
641
+ }
642
+
643
+ if($error)
644
+ {
645
+ $this->_clearSessionVariables();
646
+ //Mage::getSingleton('core/session')->addError($error);
647
+ //$this->_redirect('checkout/onepage/failure');
648
+ Mage::throwException($error);
649
+ }
650
+ else
651
+ {
652
+ // redirect to a secure 3DS authentication page
653
+ Mage::getSingleton('checkout/session')->setMd($formVariables['CrossReference'])
654
+ ->setAcsurl($formVariables['ACSURL'])
655
+ ->setPareq($formVariables['PaREQ'])
656
+ ->setTermurl('cardsaveonlinepayments/payment/callbacktransparentredirect');
657
+
658
+ // redirect to a 3D Secure page
659
+ $this->_redirect('cardsaveonlinepayments/payment/threedsecure');
660
+ }
661
+ }
662
+
663
+ private function _postThreeDSecureAuthentication($szPassword, $hmHashMethod, $szPreSharedKey)
664
+ {
665
+ $error = false;
666
+ $formVariables = array();
667
+ $model = Mage::getModel('cardsaveonlinepayments/direct');
668
+
669
+ $szPaRES = $this->getRequest()->getPost('PaRes');
670
+ $szCrossReference = $this->getRequest()->getPost('MD');
671
+ $szMerchantID = $model->getConfigData('merchantid');
672
+ $szTransactionDateTime = date('Y-m-d H:i:s P');
673
+ $szCallbackURL = Mage::getUrl('cardsaveonlinepayments/payment/callbacktransparentredirect', array('_secure' => true));
674
+ $szHashDigest = CSV_PaymentFormHelper::calculatePostThreeDSecureAuthenticationHashDigest($szMerchantID, $szPassword, $hmHashMethod, $szPreSharedKey, $szPaRES, $szCrossReference, $szTransactionDateTime, $szCallbackURL);
675
+
676
+ Mage::getSingleton('checkout/session')->setHashdigest($szHashDigest)
677
+ ->setMerchantid($szMerchantID)
678
+ ->setCrossreference($szCrossReference)
679
+ ->setTransactiondatetime($szTransactionDateTime)
680
+ ->setCallbackurl($szCallbackURL)
681
+ ->setPares($szPaRES);
682
+
683
+ // redirect to the redirection bridge page
684
+ $this->_redirect('cardsaveonlinepayments/payment/redirect');
685
+ }
686
+
687
+ private function _paymentComplete($szPassword, $hmHashMethod, $szPreSharedKey)
688
+ {
689
+ $boError = false;
690
+ $formVariables = array();
691
+ $model = Mage::getModel('cardsaveonlinepayments/direct');
692
+ $szOrderID = $this->getRequest()->getPost('OrderID');
693
+ $checkout = Mage::getSingleton('checkout/type_onepage');
694
+ $session = Mage::getSingleton('checkout/session');
695
+ $szPaymentProcessorResponse = '';
696
+ $order = Mage::getModel('sales/order');
697
+ $order->load(Mage::getSingleton('checkout/session')->getLastOrderId());
698
+ $nVersion = Mage::getModel('cardsaveonlinepayments/direct')->getVersion();
699
+
700
+ try
701
+ {
702
+ $formVariables['HashDigest'] = $this->getRequest()->getPost('HashDigest');
703
+ $formVariables['MerchantID'] = $this->getRequest()->getPost('MerchantID');
704
+ $formVariables['StatusCode'] = $this->getRequest()->getPost('StatusCode');
705
+ $formVariables['Message'] = $this->getRequest()->getPost('Message');
706
+ $formVariables['PreviousStatusCode'] = $this->getRequest()->getPost('PreviousStatusCode');
707
+ $formVariables['PreviousMessage'] = $this->getRequest()->getPost('PreviousMessage');
708
+ $formVariables['CrossReference'] = $this->getRequest()->getPost('CrossReference');
709
+ $formVariables['Amount'] = $this->getRequest()->getPost('Amount');
710
+ $formVariables['CurrencyCode'] = $this->getRequest()->getPost('CurrencyCode');
711
+ $formVariables['OrderID'] = $this->getRequest()->getPost('OrderID');
712
+ $formVariables['TransactionType'] = $this->getRequest()->getPost('TransactionType');
713
+ $formVariables['TransactionDateTime'] = $this->getRequest()->getPost('TransactionDateTime');
714
+ $formVariables['OrderDescription'] = $this->getRequest()->getPost('OrderDescription');
715
+ $formVariables['Address1'] = $this->getRequest()->getPost('Address1');
716
+ $formVariables['Address2'] = $this->getRequest()->getPost('Address2');
717
+ $formVariables['Address3'] = $this->getRequest()->getPost('Address3');
718
+ $formVariables['Address4'] = $this->getRequest()->getPost('Address4');
719
+ $formVariables['City'] = $this->getRequest()->getPost('City');
720
+ $formVariables['State'] = $this->getRequest()->getPost('State');
721
+ $formVariables['PostCode'] = $this->getRequest()->getPost('PostCode');
722
+ $formVariables['CountryCode'] = $this->getRequest()->getPost('CountryCode');
723
+
724
+ if(!CSV_PaymentFormHelper::comparePaymentCompleteHashDigest($formVariables, $szPassword, $hmHashMethod, $szPreSharedKey))
725
+ {
726
+ $boError = true;
727
+ $szNotificationMessage = "The payment was rejected for a SECURITY reason: the incoming payment data was tampered with.";
728
+ Mage::log("The Transparent Redirect transaction couldn't be completed for the following reason: [".$szNotificationMessage."] Form variables: ".print_r($formVariables, 1));
729
+ }
730
+ else
731
+ {
732
+ $checkout->saveOrderAfterRedirectedPaymentAction(false,
733
+ $this->getRequest()->getPost('StatusCode'),
734
+ $this->getRequest()->getPost('Message'),
735
+ $this->getRequest()->getPost('PreviousStatusCode'),
736
+ $this->getRequest()->getPost('PreviousMessage'),
737
+ $this->getRequest()->getPost('OrderID'),
738
+ $this->getRequest()->getPost('CrossReference'));
739
+ }
740
+ }
741
+ catch(Exception $exc)
742
+ {
743
+ $boError = true;
744
+ $szNotificationMessage = Cardsave_Cardsaveonlinepayments_Model_Common_GlobalErrors::ERROR_183;
745
+ Mage::logException($exc);
746
+ }
747
+
748
+ $szPaymentProcessorResponse = $session->getPaymentprocessorresponse();
749
+ if($boError == true)
750
+ {
751
+ if($szPaymentProcessorResponse != null &&
752
+ $szPaymentProcessorResponse != '')
753
+ {
754
+ $szNotificationMessage = $szNotificationMessage.'<br/>'.$szPaymentProcessorResponse;
755
+ }
756
+
757
+ $order->getPayment()->setAdditionalData("CrossReference=".$this->getRequest()->getPost('CrossReference'));
758
+
759
+ if($nVersion >= 1410)
760
+ {
761
+ if($order)
762
+ {
763
+ $orderState = 'pending_payment';
764
+ $orderStatus = 'csv_failed_hosted_payment';
765
+ $order->setCustomerNote(Mage::helper('cardsaveonlinepayments')->__('Transparent Redirect Payment Failed'));
766
+ $order->setState($orderState, $orderStatus, $szPaymentProcessorResponse, false);
767
+ }
768
+ }
769
+ if($nVersion == 1324 || $nVersion == 1330)
770
+ {
771
+ Mage::getSingleton('checkout/session')->addError($szNotificationMessage);
772
+ }
773
+ else
774
+ {
775
+ Mage::getSingleton('core/session')->addError($szNotificationMessage);
776
+ }
777
+ $order->save();
778
+
779
+ $this->_clearSessionVariables();
780
+ $this->_redirect('checkout/onepage/failure');
781
+ }
782
+ else
783
+ {
784
+ // set the quote as inactive after back from paypal
785
+ Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
786
+ // send confirmation email to customer
787
+ if($order->getId())
788
+ {
789
+ $order->sendNewOrderEmail();
790
+ }
791
+
792
+ if($nVersion >= 1410)
793
+ {
794
+ $this->_subtractOrderedItemsFromStock($order);
795
+ $this->_updateInvoices($order, $szPaymentProcessorResponse);
796
+ }
797
+
798
+ if($nVersion != 1324 && $nVersion != 1330)
799
+ {
800
+ if($szPaymentProcessorResponse != '')
801
+ {
802
+ Mage::getSingleton('core/session')->addSuccess($szPaymentProcessorResponse);
803
+ }
804
+ }
805
+ $this->_redirect('checkout/onepage/success', array('_secure' => true));
806
+ }
807
+ }
808
+
809
+ /**
810
+ * Deduct the order items from the stock
811
+ *
812
+ * @param unknown_type $order
813
+ */
814
+ private function _subtractOrderedItemsFromStock($order)
815
+ {
816
+ $nVersion = Mage::getModel('cardsaveonlinepayments/direct')->getVersion();
817
+ $isCustomStockManagementEnabled = Mage::getModel('cardsaveonlinepayments/direct')->getConfigData('customstockmanagementenabled');
818
+
819
+ if($nVersion >= 1410 &&
820
+ $isCustomStockManagementEnabled)
821
+ {
822
+ $items = $order->getAllItems();
823
+ foreach ($items as $itemId => $item)
824
+ {
825
+ // ordered quantity of the item from stock
826
+ $quantity = $item->getQtyOrdered();
827
+ $productId = $item->getProductId();
828
+
829
+ $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($productId);
830
+ $stockManagement = $stock->getManageStock();
831
+
832
+ if($stockManagement)
833
+ {
834
+ $stock->setQty($stock->getQty() - $quantity);
835
+ $stock->save();
836
+ }
837
+ }
838
+ }
839
+ }
840
+
841
+ /**
842
+ * Re-add the order items to the stock to balance the incorrect stock management before a payment is completed
843
+ *
844
+ * @param unknown_type $order
845
+ */
846
+ private function _addOrderedItemsToStock($order)
847
+ {
848
+ $nVersion = Mage::getModel('cardsaveonlinepayments/direct')->getVersion();
849
+ $isCustomStockManagementEnabled = Mage::getModel('cardsaveonlinepayments/direct')->getConfigData('customstockmanagementenabled');
850
+
851
+ if($nVersion >= 1410 &&
852
+ $isCustomStockManagementEnabled)
853
+ {
854
+ $items = $order->getAllItems();
855
+ foreach ($items as $itemId => $item)
856
+ {
857
+ // ordered quantity of the item from stock
858
+ $quantity = $item->getQtyOrdered();
859
+ $productId = $item->getProductId();
860
+
861
+ $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($productId);
862
+ $stockManagement = $stock->getManageStock();
863
+
864
+ if($stockManagement)
865
+ {
866
+ $stock->setQty($stock->getQty() + $quantity);
867
+ $stock->save();
868
+ }
869
+ }
870
+ }
871
+ }
872
+
873
+
874
+ private function _clearSessionVariables()
875
+ {
876
+ // clear all the custom session variables used in the payment module in case of a failed payment
877
+ Mage::getSingleton('checkout/session')->setHashdigest(null)
878
+ ->setMerchantid(null)
879
+ ->setCrossreference(null)
880
+ ->setTransactiondatetime(null)
881
+ ->setCallbackurl(null)
882
+ ->setPareq(null)
883
+ ->setPares(null)
884
+ ->setMd(null)
885
+ ->setAcsurl(null)
886
+ ->setTermurl(null)
887
+ ->setThreedsecurerequired(null)
888
+ ->setIshostedpayment(null)
889
+ ->setStatuscode(null)
890
+ ->setMessage(null)
891
+ ->setPreviousstatuscode(null)
892
+ ->setPreviousmessage(null)
893
+ ->setOrderid(null)
894
+ ->setRedirectedpayment(null)
895
+ ->setCardsaveonlinepaymentsOrderId(null);
896
+ }
897
+
898
+ /**
899
+ * Set the invoice status to "Paid" after a successful payment
900
+ *
901
+ * @param unknown_type $order
902
+ */
903
+ private function _updateInvoices($order, $message)
904
+ {
905
+ $invoices = $order->getInvoiceCollection();
906
+ $status = Mage_Sales_Model_Order::STATE_PROCESSING;
907
+
908
+ foreach ($invoices as $invoice)
909
+ {
910
+ // set the invoice state to be "Paid"
911
+ $invoice->pay()->save();
912
+ }
913
+ // add a comment to the order comments
914
+ //$order->addStatusToHistory($status, $message, false);
915
+ $order->setState($status, 'csv_paid', $message, false);
916
+ $order->save();
917
+ }
918
+ }
app/code/local/Cardsave/Cardsaveonlinepayments/etc/config.xml ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Cardsave_Cardsaveonlinepayments>
5
+ <version>0.1.0</version>
6
+ </Cardsave_Cardsaveonlinepayments>
7
+ </modules>
8
+
9
+ <global>
10
+ <models>
11
+ <cardsaveonlinepayments>
12
+ <class>Cardsave_Cardsaveonlinepayments_Model</class>
13
+ </cardsaveonlinepayments>
14
+ </models>
15
+ <resources>
16
+ <cardsaveonlinepayments_setup>
17
+ <setup>
18
+ <module>Cardsave_Cardsaveonlinepayments</module>
19
+ <class>Cardsave_Cardsaveonlinepayments_Model_Resource_Eav_Mysql4_Setup</class>
20
+ </setup>
21
+ <connection>
22
+ <use>core_setup</use>
23
+ </connection>
24
+ </cardsaveonlinepayments_setup>
25
+ <cardsaveonlinepayments_write>
26
+ <connection>
27
+ <use>core_write</use>
28
+ </connection>
29
+ </cardsaveonlinepayments_write>
30
+ <cardsaveonlinepayments_read>
31
+ <connection>
32
+ <use>core_read</use>
33
+ </connection>
34
+ </cardsaveonlinepayments_read>
35
+ </resources>
36
+ <blocks>
37
+ <cardsaveonlinepayments>
38
+ <class>Cardsave_Cardsaveonlinepayments_Block</class>
39
+ </cardsaveonlinepayments>
40
+ </blocks>
41
+ <!-- Define the helper class type -->
42
+ <helpers>
43
+ <Cardsaveonlinepayments>
44
+ <class>Cardsave_Cardsaveonlinepayments_Helper</class>
45
+ </Cardsaveonlinepayments>
46
+ <cardsaveonlinepayments>
47
+ <rewrite>
48
+ <data>Cardsave_Cardsaveonlinepayments_Helper_Data</data>
49
+ </rewrite>
50
+ </cardsaveonlinepayments>
51
+ </helpers>
52
+ </global>
53
+
54
+ <frontend>
55
+ <secure_url>
56
+ <cardsaveonlinepayments>/cardsaveonlinepayments/standard</cardsaveonlinepayments>
57
+ </secure_url>
58
+ <routers>
59
+ <cardsaveonlinepayments>
60
+ <use>standard</use>
61
+ <args>
62
+ <module>Cardsave_Cardsaveonlinepayments</module>
63
+ <frontName>cardsaveonlinepayments</frontName>
64
+ </args>
65
+ </cardsaveonlinepayments>
66
+ </routers>
67
+ <translate>
68
+ <modules>
69
+ <Cardsave_Cardsaveonlinepayments>
70
+ <files>
71
+ <default>Cardsave_Cardsaveonlinepayments.csv</default>
72
+ </files>
73
+ </Cardsave_Cardsaveonlinepayments>
74
+ </modules>
75
+ </translate>
76
+ </frontend>
77
+
78
+ <!-- declare default configuration values for this module -->
79
+ <default>
80
+ <payment>
81
+ <cardsaveonlinepayments>
82
+ <active>1</active>
83
+ <model>cardsaveonlinepayments/direct</model>
84
+ <title>CardSave</title>
85
+ <hashmethod>sha1</hashmethod>
86
+ <paymentprocessordomain>cardsaveonlinepayments.com</paymentprocessordomain>
87
+ <paymentprocessorport>4430</paymentprocessorport>
88
+ <hostedpaymentactionurl>https://mms.cardsaveonlinepayments.com/Pages/PublicPages/PaymentForm.aspx</hostedpaymentactionurl>
89
+ <transparentredirectactionurl>https://mms.cardsaveonlinepayments.com/Pages/PublicPages/TransparentRedirect.aspx</transparentredirectactionurl>
90
+ <serverpullresultactionurl>https://mms.cardsaveonlinepayments.com/Pages/PublicPages/PaymentFormResultHandler.ashx</serverpullresultactionurl>
91
+ <payment_action>capture</payment_action>
92
+ <mode>direct</mode>
93
+ <cv2mandatory>1</cv2mandatory>
94
+ <address1mandatory>1</address1mandatory>
95
+ <citymandatory>1</citymandatory>
96
+ <statemandatory>1</statemandatory>
97
+ <postcodemandatory>1</postcodemandatory>
98
+ <countrymandatory>1</countrymandatory>
99
+ <resultdeliverymethod>POST</resultdeliverymethod>
100
+ <allowspecific>0</allowspecific>
101
+ <customstockmanagementenabled>1</customstockmanagementenabled>
102
+ </cardsaveonlinepayments>
103
+ </payment>
104
+ </default>
105
+ </config>
app/code/local/Cardsave/Cardsaveonlinepayments/etc/system.xml ADDED
@@ -0,0 +1,246 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <payment>
5
+ <groups>
6
+ <cardsaveonlinepayments translate="label">
7
+ <label>CardSave</label>
8
+ <comment>
9
+ <![CDATA[
10
+ <div style="color:Blue;font-weight:bold;">
11
+ Merchant Management System (MMS) <a href="https://mms.cardsaveonlinepayments.com" 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>cardsaveonlinepayments/source_orderStatus</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>cardsaveonlinepayments/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>label</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>label</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>cardsaveonlinepayments/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>cardsaveonlinepayments/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
+ <serverpullresultactionurl>
140
+ <label>Server Pull Result Action URL</label>
141
+ <frontend_type>label</frontend_type>
142
+ <sort_order>133</sort_order>
143
+ <show_in_default>1</show_in_default>
144
+ <show_in_website>1</show_in_website>
145
+ <show_in_store>0</show_in_store>
146
+ </serverpullresultactionurl>
147
+ <cv2mandatory>
148
+ <label>CV2 Mandatory <![CDATA[<span style="color:Red;font-weight:bold;font-size:12px;">(ON FORM ONLY)</span>]]></label>
149
+ <sort_order>140</sort_order>
150
+ <frontend_type>select</frontend_type>
151
+ <source_model>adminhtml/system_config_source_yesno</source_model>
152
+ <show_in_default>1</show_in_default>
153
+ <show_in_website>1</show_in_website>
154
+ <show_in_store>0</show_in_store>
155
+ <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>
156
+ </cv2mandatory>
157
+ <address1mandatory>
158
+ <label>Address1 Mandatory</label>
159
+ <sort_order>150</sort_order>
160
+ <frontend_type>select</frontend_type>
161
+ <source_model>adminhtml/system_config_source_yesno</source_model>
162
+ <show_in_default>1</show_in_default>
163
+ <show_in_website>1</show_in_website>
164
+ <show_in_store>0</show_in_store>
165
+ <comment>
166
+ <![CDATA[<strong>Please note</strong>: The above value is only applicable to Hosted Payment Form payment mode]]>
167
+ </comment>
168
+ </address1mandatory>
169
+ <citymandatory>
170
+ <label>City Mandatory</label>
171
+ <sort_order>160</sort_order>
172
+ <frontend_type>select</frontend_type>
173
+ <source_model>adminhtml/system_config_source_yesno</source_model>
174
+ <show_in_default>1</show_in_default>
175
+ <show_in_website>1</show_in_website>
176
+ <show_in_store>0</show_in_store>
177
+ <comment>
178
+ <![CDATA[<strong>Please note</strong>: The above value is only applicable to Hosted Payment Form payment mode]]>
179
+ </comment>
180
+ </citymandatory>
181
+ <postcodemandatory>
182
+ <label>PostCode Mandatory</label>
183
+ <sort_order>170</sort_order>
184
+ <frontend_type>select</frontend_type>
185
+ <source_model>adminhtml/system_config_source_yesno</source_model>
186
+ <show_in_default>1</show_in_default>
187
+ <show_in_website>1</show_in_website>
188
+ <show_in_store>0</show_in_store>
189
+ <comment>
190
+ <![CDATA[<strong>Please note</strong>: The above value is only applicable to Hosted Payment Form payment mode]]>
191
+ </comment>
192
+ </postcodemandatory>
193
+ <statemandatory>
194
+ <label>State Mandatory</label>
195
+ <sort_order>180</sort_order>
196
+ <frontend_type>select</frontend_type>
197
+ <source_model>adminhtml/system_config_source_yesno</source_model>
198
+ <show_in_default>1</show_in_default>
199
+ <show_in_website>1</show_in_website>
200
+ <show_in_store>0</show_in_store>
201
+ <comment>
202
+ <![CDATA[<strong>Please note</strong>: The above value is only applicable to Hosted Payment Form payment mode]]>
203
+ </comment>
204
+ </statemandatory>
205
+ <countrymandatory>
206
+ <label>Country Mandatory</label>
207
+ <sort_order>190</sort_order>
208
+ <frontend_type>select</frontend_type>
209
+ <source_model>adminhtml/system_config_source_yesno</source_model>
210
+ <show_in_default>1</show_in_default>
211
+ <show_in_website>1</show_in_website>
212
+ <show_in_store>0</show_in_store>
213
+ <comment>
214
+ <![CDATA[<strong>Please note</strong>: The above value is only applicable to Hosted Payment Form payment mode]]>
215
+ </comment>
216
+ </countrymandatory>
217
+ <resultdeliverymethod>
218
+ <label>Result Delivery Method</label>
219
+ <sort_order>200</sort_order>
220
+ <frontend_type>select</frontend_type>
221
+ <source_model>cardsaveonlinepayments/source_resultDeliveryMethod</source_model>
222
+ <show_in_default>1</show_in_default>
223
+ <show_in_website>1</show_in_website>
224
+ <show_in_store>0</show_in_store>
225
+ <comment>
226
+ <![CDATA[<strong>Please note</strong>: The above value is only applicable to Hosted Payment Form payment mode]]>
227
+ </comment>
228
+ </resultdeliverymethod>
229
+ <customstockmanagementenabled>
230
+ <label>Custom Stock Management Enabled</label>
231
+ <sort_order>210</sort_order>
232
+ <frontend_type>select</frontend_type>
233
+ <source_model>adminhtml/system_config_source_yesno</source_model>
234
+ <show_in_default>1</show_in_default>
235
+ <show_in_website>1</show_in_website>
236
+ <show_in_store>0</show_in_store>
237
+ <comment>
238
+ <![CDATA[<strong>Please note</strong>: The above setting is only applicable to Magento version 1.4.1.0 and above]]>
239
+ </comment>
240
+ </customstockmanagementenabled>
241
+ </fields>
242
+ </cardsaveonlinepayments>
243
+ </groups>
244
+ </payment>
245
+ </sections>
246
+ </config>
app/code/local/Cardsave/Cardsaveonlinepayments/sql/cardsaveonlinepayments_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ /* @var $installer Mage_Core_Model_Resource_Setup */
5
+ $installer->startSetup();
6
+
7
+ Mage::log('cardsave installer script started');
8
+
9
+ $installer->run("
10
+ DELETE FROM `{$installer->getTable('sales_order_status')}` WHERE (`status`='csv_failed_hosted_payment');
11
+ DELETE FROM `{$installer->getTable('sales_order_status')}` WHERE (`status`='csv_failed_threed_secure');
12
+ DELETE FROM `{$installer->getTable('sales_order_status')}` WHERE (`status`='csv_paid');
13
+ DELETE FROM `{$installer->getTable('sales_order_status')}` WHERE (`status`='csv_pending');
14
+ DELETE FROM `{$installer->getTable('sales_order_status')}` WHERE (`status`='csv_pending_hosted_payment');
15
+ DELETE FROM `{$installer->getTable('sales_order_status')}` WHERE (`status`='csv_pending_threed_secure');
16
+
17
+ INSERT INTO `{$installer->getTable('sales_order_status')}` (`status`, `label`) VALUES ('csv_failed_hosted_payment', 'CardSave - Failed Payment');
18
+ INSERT INTO `{$installer->getTable('sales_order_status')}` (`status`, `label`) VALUES ('csv_failed_threed_secure', 'CardSave - Failed 3D Secure');
19
+ INSERT INTO `{$installer->getTable('sales_order_status')}` (`status`, `label`) VALUES ('csv_paid', 'CardSave - Successful Payment');
20
+ INSERT INTO `{$installer->getTable('sales_order_status')}` (`status`, `label`) VALUES ('csv_pending', 'CardSave - Pending Payment');
21
+ INSERT INTO `{$installer->getTable('sales_order_status')}` (`status`, `label`) VALUES ('csv_pending_hosted_payment', 'CardSave - Pending Hosted Payment');
22
+ INSERT INTO `{$installer->getTable('sales_order_status')}` (`status`, `label`) VALUES ('csv_pending_threed_secure', 'CardSave - Pending 3D Secure');
23
+ ");
24
+
25
+ Mage::log('cardsave installer script ended');
26
+
27
+ $installer->endSetup();
app/code/local/Cardsave/Checkout/Block/Onepage/Payment/Methods.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One page checkout status
5
+ *
6
+ * @category Mage
7
+ * @category Mage
8
+ * @package Mage_Checkout
9
+ * @author Magento Core Team <core@magentocommerce.com>
10
+ */
11
+ class Cardsave_Checkout_Block_Onepage_Payment_Methods extends Mage_Checkout_Block_Onepage_Payment_Methods
12
+ {
13
+ /**
14
+ * Override the base function - by default the CardSave payment option will be selected
15
+ *
16
+ * @return mixed
17
+ */
18
+ public function getSelectedMethodCode()
19
+ {
20
+ $method = false;
21
+ $model = Mage::getModel('cardsaveonlinepayments/direct');
22
+
23
+ if ($this->getQuote()->getPayment()->getMethod())
24
+ {
25
+ $method = $this->getQuote()->getPayment()->getMethod();
26
+ }
27
+ /*else
28
+ {
29
+ // force the current payment to be selected
30
+ if($model)
31
+ {
32
+ $method = 'cardsaveonlinepayments';
33
+ }
34
+ }*/
35
+
36
+ return $method;
37
+ }
38
+ }
app/code/local/Cardsave/Checkout/Model/Type/Onepage.php ADDED
@@ -0,0 +1,1001 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Cardsave_Checkout_Model_Type_Onepage extends Mage_Checkout_Model_Type_Onepage
4
+ {
5
+ /**
6
+ * Create an order
7
+ *
8
+ * @return Mage_Checkout_Model_Type_Onepage
9
+ */
10
+ public function saveOrder()
11
+ {
12
+ $nVersion = Mage::getModel('cardsaveonlinepayments/direct')->getVersion();
13
+
14
+ if($nVersion >= 1410)
15
+ {
16
+ // logic for version 1.4.1.0 and above
17
+ $this->validate();
18
+ $isNewCustomer = false;
19
+
20
+ switch ($this->getCheckoutMethod())
21
+ {
22
+ case self::METHOD_GUEST:
23
+ $this->_prepareGuestQuote();
24
+ break;
25
+ case self::METHOD_REGISTER:
26
+ $this->_prepareNewCustomerQuote();
27
+ $isNewCustomer = true;
28
+ break;
29
+ default:
30
+ $this->_prepareCustomerQuote();
31
+ break;
32
+ }
33
+
34
+ $service = Mage::getModel('sales/service_quote', $this->getQuote());
35
+ $redirectUrl = $this->getQuote()->getPayment()->getOrderPlaceRedirectUrl();
36
+
37
+ if(!$redirectUrl ||
38
+ $this->getQuote()->getPayment()->getMethodInstance()->getCode() != 'cardsaveonlinepayments')
39
+ {
40
+ $service->submitAll();
41
+ }
42
+
43
+ if ($isNewCustomer)
44
+ {
45
+ try
46
+ {
47
+ $this->_involveNewCustomer();
48
+ }
49
+ catch (Exception $e)
50
+ {
51
+ Mage::logException($e);
52
+ }
53
+ }
54
+
55
+ $this->_checkoutSession->setLastQuoteId($this->getQuote()->getId())
56
+ ->setLastSuccessQuoteId($this->getQuote()->getId());
57
+ #->clearHelperData();
58
+
59
+ $order = $service->getOrder();
60
+ if ($order)
61
+ {
62
+ Mage::dispatchEvent('checkout_type_onepage_save_order_after', array('order'=>$order, 'quote'=>$this->getQuote()));
63
+
64
+ /**
65
+ * a flag to set that there will be redirect to third party after confirmation
66
+ * eg: paypal standard ipn
67
+ */
68
+ $redirectUrl = $this->getQuote()->getPayment()->getOrderPlaceRedirectUrl();
69
+ /**
70
+ * we only want to send to customer about new order when there is no redirect to third party
71
+ */
72
+ if(!$redirectUrl)
73
+ {
74
+ try
75
+ {
76
+ $order->sendNewOrderEmail();
77
+ }
78
+ catch (Exception $e)
79
+ {
80
+ Mage::logException($e);
81
+ }
82
+ }
83
+
84
+ // add order information to the session
85
+ $this->_checkoutSession->setLastOrderId($order->getId())
86
+ ->setRedirectUrl($redirectUrl)
87
+ ->setLastRealOrderId($order->getIncrementId());
88
+
89
+ // as well a billing agreement can be created
90
+ $agreement = $order->getPayment()->getBillingAgreement();
91
+ if ($agreement)
92
+ {
93
+ $this->_checkoutSession->setLastBillingAgreementId($agreement->getId());
94
+ }
95
+ }
96
+
97
+ // add recurring profiles information to the session
98
+ $profiles = $service->getRecurringPaymentProfiles();
99
+ if ($profiles)
100
+ {
101
+ $ids = array();
102
+ foreach($profiles as $profile)
103
+ {
104
+ $ids[] = $profile->getId();
105
+ }
106
+ $this->_checkoutSession->setLastRecurringProfileIds($ids);
107
+ // TODO: send recurring profile emails
108
+ }
109
+ }
110
+ else if($nVersion == 1400 || $nVersion == 1401)
111
+ {
112
+ // logic for version below 1.4.0.1 and below
113
+ $this->validateOrder();
114
+ $billing = $this->getQuote()->getBillingAddress();
115
+
116
+ if (!$this->getQuote()->isVirtual())
117
+ {
118
+ $shipping = $this->getQuote()->getShippingAddress();
119
+ }
120
+
121
+ switch ($this->getQuote()->getCheckoutMethod())
122
+ {
123
+ case Mage_Sales_Model_Quote::CHECKOUT_METHOD_GUEST:
124
+ if (!$this->getQuote()->isAllowedGuestCheckout())
125
+ {
126
+ Mage::throwException(Mage::helper('checkout')->__('Sorry, guest checkout is not enabled. Please try again or contact store owner.'));
127
+ }
128
+ $this->getQuote()->setCustomerId(null)
129
+ ->setCustomerEmail($billing->getEmail())
130
+ ->setCustomerIsGuest(true)
131
+ ->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
132
+ break;
133
+
134
+ case Mage_Sales_Model_Quote::CHECKOUT_METHOD_REGISTER:
135
+ $customer = Mage::getModel('customer/customer');
136
+
137
+ $customerBilling = $billing->exportCustomerAddress();
138
+ $customer->addAddress($customerBilling);
139
+
140
+ if (!$this->getQuote()->isVirtual() &&
141
+ !$shipping->getSameAsBilling())
142
+ {
143
+ $customerShipping = $shipping->exportCustomerAddress();
144
+ $customer->addAddress($customerShipping);
145
+ }
146
+
147
+ if ($this->getQuote()->getCustomerDob() &&
148
+ !$billing->getCustomerDob())
149
+ {
150
+ $billing->setCustomerDob($this->getQuote()->getCustomerDob());
151
+ }
152
+
153
+ Mage::helper('core')->copyFieldset('checkout_onepage_billing', 'to_customer', $billing, $customer);
154
+
155
+ $customer->setPassword($customer->decryptPassword($this->getQuote()->getPasswordHash()));
156
+ $customer->setPasswordHash($customer->hashPassword($customer->getPassword()));
157
+
158
+ $this->getQuote()->setCustomer($customer);
159
+ Mage::log(time());
160
+ break;
161
+
162
+ default:
163
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
164
+
165
+ if (!$billing->getCustomerId() ||
166
+ $billing->getSaveInAddressBook())
167
+ {
168
+ $customerBilling = $billing->exportCustomerAddress();
169
+ $customer->addAddress($customerBilling);
170
+ }
171
+ if (!$this->getQuote()->isVirtual() &&
172
+ ((!$shipping->getCustomerId() && !$shipping->getSameAsBilling()) ||
173
+ (!$shipping->getSameAsBilling() && $shipping->getSaveInAddressBook())))
174
+ {
175
+ $customerShipping = $shipping->exportCustomerAddress();
176
+ $customer->addAddress($customerShipping);
177
+ }
178
+ $customer->setSavedFromQuote(true);
179
+ $customer->save();
180
+
181
+ $changed = false;
182
+ if (isset($customerBilling) &&
183
+ !$customer->getDefaultBilling())
184
+ {
185
+ $customer->setDefaultBilling($customerBilling->getId());
186
+ $changed = true;
187
+ }
188
+ if (!$this->getQuote()->isVirtual() &&
189
+ isset($customerBilling) &&
190
+ !$customer->getDefaultShipping() &&
191
+ $shipping->getSameAsBilling())
192
+ {
193
+ $customer->setDefaultShipping($customerBilling->getId());
194
+ $changed = true;
195
+ }
196
+ elseif (!$this->getQuote()->isVirtual() &&
197
+ isset($customerShipping) &&
198
+ !$customer->getDefaultShipping())
199
+ {
200
+ $customer->setDefaultShipping($customerShipping->getId());
201
+ $changed = true;
202
+ }
203
+
204
+ if ($changed)
205
+ {
206
+ $customer->save();
207
+ }
208
+ }
209
+
210
+ $this->getQuote()->reserveOrderId();
211
+ $convertQuote = Mage::getModel('sales/convert_quote');
212
+ // @var $convertQuote Mage_Sales_Model_Convert_Quote
213
+ if ($this->getQuote()->isVirtual())
214
+ {
215
+ $order = $convertQuote->addressToOrder($billing);
216
+ }
217
+ else
218
+ {
219
+ $order = $convertQuote->addressToOrder($shipping);
220
+ }
221
+ // @var $order Mage_Sales_Model_Order
222
+ $order->setBillingAddress($convertQuote->addressToOrderAddress($billing));
223
+
224
+ if (!$this->getQuote()->isVirtual())
225
+ {
226
+ $order->setShippingAddress($convertQuote->addressToOrderAddress($shipping));
227
+ }
228
+
229
+ $order->setPayment($convertQuote->paymentToOrderPayment($this->getQuote()->getPayment()));
230
+
231
+ foreach ($this->getQuote()->getAllItems() as $item)
232
+ {
233
+ $orderItem = $convertQuote->itemToOrderItem($item);
234
+ if ($item->getParentItem())
235
+ {
236
+ $orderItem->setParentItem($order->getItemByQuoteItemId($item->getParentItem()->getId()));
237
+ }
238
+ $order->addItem($orderItem);
239
+ }
240
+
241
+ // We can use configuration data for declare new order status
242
+ Mage::dispatchEvent('checkout_type_onepage_save_order', array('order'=>$order, 'quote'=>$this->getQuote()));
243
+ // check again, if customer exists
244
+ if ($this->getQuote()->getCheckoutMethod() == Mage_Sales_Model_Quote::CHECKOUT_METHOD_REGISTER)
245
+ {
246
+ if ($this->_customerEmailExists($customer->getEmail(), Mage::app()->getWebsite()->getId()))
247
+ {
248
+ Mage::throwException(Mage::helper('checkout')->__('There is already a customer registered using this email address'));
249
+ }
250
+ }
251
+
252
+ // clear 3dSecure session variables
253
+ Mage::getSingleton('checkout/session')->setThreedsecurerequired(null)
254
+ ->setMd(null)
255
+ ->setPares(null)
256
+ ->setAcsurl(null);
257
+
258
+ $order->place();
259
+
260
+ if ($this->getQuote()->getCheckoutMethod()==Mage_Sales_Model_Quote::CHECKOUT_METHOD_REGISTER)
261
+ {
262
+ $customer->save();
263
+ $customerBillingId = $customerBilling->getId();
264
+ if (!$this->getQuote()->isVirtual())
265
+ {
266
+ $customerShippingId = isset($customerShipping) ? $customerShipping->getId() : $customerBillingId;
267
+ $customer->setDefaultShipping($customerShippingId);
268
+ }
269
+ $customer->setDefaultBilling($customerBillingId);
270
+ $customer->save();
271
+
272
+ $this->getQuote()->setCustomerId($customer->getId());
273
+
274
+ $order->setCustomerId($customer->getId());
275
+ Mage::helper('core')->copyFieldset('customer_account', 'to_order', $customer, $order);
276
+
277
+ $billing->setCustomerId($customer->getId())->setCustomerAddressId($customerBillingId);
278
+ if (!$this->getQuote()->isVirtual())
279
+ {
280
+ $shipping->setCustomerId($customer->getId())->setCustomerAddressId($customerShippingId);
281
+ }
282
+
283
+ if ($customer->isConfirmationRequired())
284
+ {
285
+ $customer->sendNewAccountEmail('confirmation');
286
+ }
287
+ else
288
+ {
289
+ $customer->sendNewAccountEmail();
290
+ }
291
+ }
292
+
293
+ /**
294
+ * a flag to set that there will be redirect to third party after confirmation
295
+ * eg: paypal standard ipn
296
+ */
297
+ $redirectUrl = $this->getQuote()->getPayment()->getOrderPlaceRedirectUrl();
298
+ if(!$redirectUrl)
299
+ {
300
+ $order->setEmailSent(true);
301
+ }
302
+
303
+ if(!$redirectUrl ||
304
+ $this->getQuote()->getPayment()->getMethodInstance()->getCode() != 'cardsaveonlinepayments')
305
+ {
306
+ $order->save();
307
+ }
308
+
309
+ Mage::dispatchEvent('checkout_type_onepage_save_order_after', array('order'=>$order, 'quote'=>$this->getQuote()));
310
+
311
+
312
+ /**
313
+ * need to have some logic to set order as new status to make sure order is not finished yet
314
+ * quote will be still active when we send the customer to paypal
315
+ */
316
+
317
+ $orderId = $order->getIncrementId();
318
+ $this->getCheckout()->setLastQuoteId($this->getQuote()->getId());
319
+ $this->getCheckout()->setLastOrderId($order->getId());
320
+ $this->getCheckout()->setLastRealOrderId($order->getIncrementId());
321
+ $this->getCheckout()->setRedirectUrl($redirectUrl);
322
+
323
+ /**
324
+ * we only want to send to customer about new order when there is no redirect to third party
325
+ */
326
+ if(!$redirectUrl)
327
+ {
328
+ $order->sendNewOrderEmail();
329
+ }
330
+
331
+ if ($this->getQuote()->getCheckoutMethod(true) == Mage_Sales_Model_Quote::CHECKOUT_METHOD_REGISTER &&
332
+ !Mage::getSingleton('customer/session')->isLoggedIn())
333
+ {
334
+ /**
335
+ * we need to save quote here to have it saved with Customer Id.
336
+ * so when loginById() executes checkout/session method loadCustomerQuote
337
+ * it would not create new quotes and merge it with old one.
338
+ */
339
+ $this->getQuote()->save();
340
+ if ($customer->isConfirmationRequired())
341
+ {
342
+ Mage::getSingleton('checkout/session')->addSuccess(Mage::helper('customer')->__('Account confirmation is required. Please, check your e-mail for confirmation link. To resend confirmation email please <a href="%s">click here</a>.',
343
+ Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail())
344
+ ));
345
+ }
346
+ else
347
+ {
348
+ Mage::getSingleton('customer/session')->loginById($customer->getId());
349
+ }
350
+ }
351
+
352
+ //Setting this one more time like control flag that we haves saved order
353
+ //Must be checkout on success page to show it or not.
354
+ $this->getCheckout()->setLastSuccessQuoteId($this->getQuote()->getId());
355
+
356
+ /*
357
+ * Fix for v1.4.1.0 and above - need to comment the below lines
358
+ */
359
+ //$this->getQuote()->setIsActive(false);
360
+ //$this->getQuote()->save();
361
+ }
362
+ else if($nVersion == 1324 || $nVersion == 1330)
363
+ {
364
+ $this->validateOrder();
365
+ $billing = $this->getQuote()->getBillingAddress();
366
+
367
+ if (!$this->getQuote()->isVirtual())
368
+ {
369
+ $shipping = $this->getQuote()->getShippingAddress();
370
+ }
371
+
372
+ switch ($this->getQuote()->getCheckoutMethod())
373
+ {
374
+ case Mage_Sales_Model_Quote::CHECKOUT_METHOD_GUEST:
375
+ if (!$this->getQuote()->isAllowedGuestCheckout())
376
+ {
377
+ Mage::throwException(Mage::helper('checkout')->__('Sorry, guest checkout is not enabled. Please try again or contact store owner.'));
378
+ }
379
+ $this->getQuote()->setCustomerId(null)
380
+ ->setCustomerEmail($billing->getEmail())
381
+ ->setCustomerIsGuest(true)
382
+ ->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
383
+ break;
384
+
385
+ case Mage_Sales_Model_Quote::CHECKOUT_METHOD_REGISTER:
386
+ $customer = Mage::getModel('customer/customer');
387
+
388
+ $customerBilling = $billing->exportCustomerAddress();
389
+ $customer->addAddress($customerBilling);
390
+
391
+ if (!$this->getQuote()->isVirtual() &&
392
+ !$shipping->getSameAsBilling())
393
+ {
394
+ $customerShipping = $shipping->exportCustomerAddress();
395
+ $customer->addAddress($customerShipping);
396
+ }
397
+
398
+ if ($this->getQuote()->getCustomerDob() &&
399
+ !$billing->getCustomerDob())
400
+ {
401
+ $billing->setCustomerDob($this->getQuote()->getCustomerDob());
402
+ }
403
+
404
+ if ($this->getQuote()->getCustomerTaxvat() && !$billing->getCustomerTaxvat())
405
+ {
406
+ $billing->setCustomerTaxvat($this->getQuote()->getCustomerTaxvat());
407
+ }
408
+
409
+ Mage::helper('core')->copyFieldset('checkout_onepage_billing', 'to_customer', $billing, $customer);
410
+
411
+ $customer->setPassword($customer->decryptPassword($this->getQuote()->getPasswordHash()));
412
+ $customer->setPasswordHash($customer->hashPassword($customer->getPassword()));
413
+
414
+ $this->getQuote()->setCustomer($customer);
415
+ Mage::log(time());
416
+ break;
417
+
418
+ default:
419
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
420
+
421
+ if (!$billing->getCustomerId() ||
422
+ $billing->getSaveInAddressBook())
423
+ {
424
+ $customerBilling = $billing->exportCustomerAddress();
425
+ $customer->addAddress($customerBilling);
426
+ }
427
+ if (!$this->getQuote()->isVirtual() &&
428
+ ((!$shipping->getCustomerId() && !$shipping->getSameAsBilling()) ||
429
+ (!$shipping->getSameAsBilling() && $shipping->getSaveInAddressBook())))
430
+ {
431
+ $customerShipping = $shipping->exportCustomerAddress();
432
+ $customer->addAddress($customerShipping);
433
+ }
434
+ $customer->setSavedFromQuote(true);
435
+ $customer->save();
436
+
437
+ $changed = false;
438
+ if (isset($customerBilling) &&
439
+ !$customer->getDefaultBilling())
440
+ {
441
+ $customer->setDefaultBilling($customerBilling->getId());
442
+ $changed = true;
443
+ }
444
+ if (!$this->getQuote()->isVirtual() &&
445
+ isset($customerBilling) &&
446
+ !$customer->getDefaultShipping() &&
447
+ $shipping->getSameAsBilling())
448
+ {
449
+ $customer->setDefaultShipping($customerBilling->getId());
450
+ $changed = true;
451
+ }
452
+ elseif (!$this->getQuote()->isVirtual() &&
453
+ isset($customerShipping) &&
454
+ !$customer->getDefaultShipping())
455
+ {
456
+ $customer->setDefaultShipping($customerShipping->getId());
457
+ $changed = true;
458
+ }
459
+
460
+ if ($changed)
461
+ {
462
+ $customer->save();
463
+ }
464
+ }
465
+
466
+ $this->getQuote()->reserveOrderId();
467
+ $convertQuote = Mage::getModel('sales/convert_quote');
468
+ // @var $convertQuote Mage_Sales_Model_Convert_Quote
469
+ if ($this->getQuote()->isVirtual())
470
+ {
471
+ $order = $convertQuote->addressToOrder($billing);
472
+ }
473
+ else
474
+ {
475
+ $order = $convertQuote->addressToOrder($shipping);
476
+ }
477
+ // @var $order Mage_Sales_Model_Order
478
+ $order->setBillingAddress($convertQuote->addressToOrderAddress($billing));
479
+
480
+ if (!$this->getQuote()->isVirtual())
481
+ {
482
+ $order->setShippingAddress($convertQuote->addressToOrderAddress($shipping));
483
+ }
484
+
485
+ $order->setPayment($convertQuote->paymentToOrderPayment($this->getQuote()->getPayment()));
486
+
487
+ foreach ($this->getQuote()->getAllItems() as $item)
488
+ {
489
+ $orderItem = $convertQuote->itemToOrderItem($item);
490
+ if ($item->getParentItem())
491
+ {
492
+ $orderItem->setParentItem($order->getItemByQuoteItemId($item->getParentItem()->getId()));
493
+ }
494
+ $order->addItem($orderItem);
495
+ }
496
+
497
+ // We can use configuration data for declare new order status
498
+ Mage::dispatchEvent('checkout_type_onepage_save_order', array('order'=>$order, 'quote'=>$this->getQuote()));
499
+ // check again, if customer exists
500
+ if ($this->getQuote()->getCheckoutMethod() == Mage_Sales_Model_Quote::CHECKOUT_METHOD_REGISTER)
501
+ {
502
+ if ($this->_customerEmailExists($customer->getEmail(), Mage::app()->getWebsite()->getId()))
503
+ {
504
+ Mage::throwException(Mage::helper('checkout')->__('There is already a customer registered using this email address'));
505
+ }
506
+ }
507
+
508
+ // clear 3dSecure session variables
509
+ Mage::getSingleton('checkout/session')->setThreedsecurerequired(null);
510
+ Mage::getSingleton('checkout/session')->setMd(null);
511
+ Mage::getSingleton('checkout/session')->setPares(null);
512
+ Mage::getSingleton('checkout/session')->setAcsurl(null);
513
+
514
+ $order->place();
515
+
516
+ if ($this->getQuote()->getCheckoutMethod()==Mage_Sales_Model_Quote::CHECKOUT_METHOD_REGISTER)
517
+ {
518
+ $customer->save();
519
+ $customerBillingId = $customerBilling->getId();
520
+ if (!$this->getQuote()->isVirtual())
521
+ {
522
+ $customerShippingId = isset($customerShipping) ? $customerShipping->getId() : $customerBillingId;
523
+ $customer->setDefaultShipping($customerShippingId);
524
+ }
525
+ $customer->setDefaultBilling($customerBillingId);
526
+ $customer->save();
527
+
528
+ $this->getQuote()->setCustomerId($customer->getId());
529
+
530
+ $order->setCustomerId($customer->getId());
531
+ Mage::helper('core')->copyFieldset('customer_account', 'to_order', $customer, $order);
532
+
533
+ $billing->setCustomerId($customer->getId())->setCustomerAddressId($customerBillingId);
534
+ if (!$this->getQuote()->isVirtual())
535
+ {
536
+ $shipping->setCustomerId($customer->getId())->setCustomerAddressId($customerShippingId);
537
+ }
538
+
539
+ if ($customer->isConfirmationRequired())
540
+ {
541
+ $customer->sendNewAccountEmail('confirmation');
542
+ }
543
+ else
544
+ {
545
+ $customer->sendNewAccountEmail();
546
+ }
547
+ }
548
+
549
+ /**
550
+ * a flag to set that there will be redirect to third party after confirmation
551
+ * eg: paypal standard ipn
552
+ */
553
+ $redirectUrl = $this->getQuote()->getPayment()->getOrderPlaceRedirectUrl();
554
+ if(!$redirectUrl)
555
+ {
556
+ $order->setEmailSent(true);
557
+ }
558
+
559
+ if(!$redirectUrl ||
560
+ $this->getQuote()->getPayment()->getMethodInstance()->getCode() != 'cardsaveonlinepayments')
561
+ {
562
+ $order->save();
563
+ }
564
+
565
+ Mage::dispatchEvent('checkout_type_onepage_save_order_after', array('order'=>$order, 'quote'=>$this->getQuote()));
566
+
567
+
568
+ /**
569
+ * need to have somelogic to set order as new status to make sure order is not finished yet
570
+ * quote will be still active when we send the customer to paypal
571
+ */
572
+
573
+ $orderId = $order->getIncrementId();
574
+ $this->getCheckout()->setLastQuoteId($this->getQuote()->getId());
575
+ $this->getCheckout()->setLastOrderId($order->getId());
576
+ $this->getCheckout()->setLastRealOrderId($order->getIncrementId());
577
+ $this->getCheckout()->setRedirectUrl($redirectUrl);
578
+
579
+ /**
580
+ * we only want to send to customer about new order when there is no redirect to third party
581
+ */
582
+ if(!$redirectUrl)
583
+ {
584
+ $order->sendNewOrderEmail();
585
+ }
586
+
587
+ if ($this->getQuote()->getCheckoutMethod(true) == Mage_Sales_Model_Quote::CHECKOUT_METHOD_REGISTER &&
588
+ !Mage::getSingleton('customer/session')->isLoggedIn())
589
+ {
590
+ /**
591
+ * we need to save quote here to have it saved with Customer Id.
592
+ * so when loginById() executes checkout/session method loadCustomerQuote
593
+ * it would not create new quotes and merge it with old one.
594
+ */
595
+ $this->getQuote()->save();
596
+ if ($customer->isConfirmationRequired())
597
+ {
598
+ Mage::getSingleton('checkout/session')->addSuccess(Mage::helper('customer')->__('Account confirmation is required. Please, check your e-mail for confirmation link. To resend confirmation email please <a href="%s">click here</a>.',
599
+ Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail())
600
+ ));
601
+ }
602
+ else
603
+ {
604
+ Mage::getSingleton('customer/session')->loginById($customer->getId());
605
+ }
606
+ }
607
+
608
+ //Setting this one more time like control flag that we haves saved order
609
+ //Must be checkout on success page to show it or not.
610
+ $this->getCheckout()->setLastSuccessQuoteId($this->getQuote()->getId());
611
+
612
+ $this->getQuote()->setIsActive(false);
613
+ $this->getQuote()->save();
614
+ }
615
+
616
+ return $this;
617
+ }
618
+
619
+ /**
620
+ * Create an order for a Direct (API) 3D Secure enabled payment on the callback
621
+ *
622
+ * @param unknown_type $pares
623
+ * @param unknown_type $md
624
+ * @return unknown
625
+ */
626
+ public function saveOrderAfter3dSecure($pares, $md)
627
+ {
628
+ $nVersion = Mage::getModel('cardsaveonlinepayments/direct')->getVersion();
629
+
630
+ if($nVersion >= 1410)
631
+ {
632
+ $_order = Mage::getModel('sales/order')->load(Mage::getSingleton('checkout/session')->getCardsaveonlinepaymentsOrderId());
633
+
634
+ if(!$_order->getId())
635
+ {
636
+ Mage::throwException('Could not load order.');
637
+ }
638
+
639
+ Mage::getSingleton('checkout/session')->setThreedsecurerequired(true)
640
+ ->setMd($md)
641
+ ->setPares($pares);
642
+
643
+ $method = Mage::getSingleton('checkout/session')->getRedirectionmethod();
644
+ $_order->getPayment()->getMethodInstance()->{$method}($_order->getPayment(), $pares, $md);
645
+
646
+ if ($_order->getFailedThreed() !== true &&
647
+ $_order->getPayment()->getMethodInstance()->getCode() == 'cardsaveonlinepayments' &&
648
+ $_order->getStatus() != 'pending')
649
+ {
650
+ $order_status = Mage::getStoreConfig('payment/cardsaveonlinepayments/order_status', Mage::app()->getStore()->getId());
651
+ $_order->addStatusToHistory($order_status);
652
+ $_order->setStatus($order_status);
653
+ }
654
+
655
+ $_order->save();
656
+
657
+ Mage::getSingleton('checkout/session')->setThreedsecurerequired(null)
658
+ ->setMd(null)
659
+ ->setPareq(null)
660
+ ->setAcsurl(null)
661
+ ->setCardsaveonlinepaymentsOrderId(null);
662
+ }
663
+ else if($nVersion == 1400 || $nVersion == 1401 || $nVersion == 1324 || $nVersion == 1330)
664
+ {
665
+ $this->validateOrder();
666
+ $billing = $this->getQuote()->getBillingAddress();
667
+ if (!$this->getQuote()->isVirtual())
668
+ {
669
+ $shipping = $this->getQuote()->getShippingAddress();
670
+ }
671
+
672
+ switch ($this->getQuote()->getCheckoutMethod())
673
+ {
674
+ case 'guest':
675
+ $this->getQuote()->setCustomerEmail($billing->getEmail())
676
+ ->setCustomerIsGuest(true)
677
+ ->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
678
+ break;
679
+
680
+ default:
681
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
682
+
683
+ if (!$billing->getCustomerId() ||
684
+ $billing->getSaveInAddressBook())
685
+ {
686
+ $customerBilling = $billing->exportCustomerAddress();
687
+ $customer->addAddress($customerBilling);
688
+ }
689
+ if (!$this->getQuote()->isVirtual() &&
690
+ ((!$shipping->getCustomerId() && !$shipping->getSameAsBilling()) ||
691
+ (!$shipping->getSameAsBilling() && $shipping->getSaveInAddressBook())))
692
+ {
693
+ $customerShipping = $shipping->exportCustomerAddress();
694
+ $customer->addAddress($customerShipping);
695
+ }
696
+ $customer->setSavedFromQuote(true);
697
+ $customer->save();
698
+
699
+ $changed = false;
700
+ if (isset($customerBilling) &&
701
+ !$customer->getDefaultBilling())
702
+ {
703
+ $customer->setDefaultBilling($customerBilling->getId());
704
+ $changed = true;
705
+ }
706
+ if (!$this->getQuote()->isVirtual() &&
707
+ isset($customerBilling) &&
708
+ !$customer->getDefaultShipping() &&
709
+ $shipping->getSameAsBilling())
710
+ {
711
+ $customer->setDefaultShipping($customerBilling->getId());
712
+ $changed = true;
713
+ }
714
+ elseif (!$this->getQuote()->isVirtual() &&
715
+ isset($customerShipping) &&
716
+ !$customer->getDefaultShipping())
717
+ {
718
+ $customer->setDefaultShipping($customerShipping->getId());
719
+ $changed = true;
720
+ }
721
+
722
+ if ($changed)
723
+ {
724
+ $customer->save();
725
+ }
726
+ }
727
+
728
+ $this->getQuote()->reserveOrderId();
729
+ $convertQuote = Mage::getModel('sales/convert_quote');
730
+ // @var $convertQuote Mage_Sales_Model_Convert_Quote
731
+ if ($this->getQuote()->isVirtual())
732
+ {
733
+ $order = $convertQuote->addressToOrder($billing);
734
+ }
735
+ else
736
+ {
737
+ $order = $convertQuote->addressToOrder($shipping);
738
+ }
739
+ /* @var $order Mage_Sales_Model_Order */
740
+ $order->setBillingAddress($convertQuote->addressToOrderAddress($billing));
741
+
742
+ if (!$this->getQuote()->isVirtual())
743
+ {
744
+ $order->setShippingAddress($convertQuote->addressToOrderAddress($shipping));
745
+ }
746
+
747
+ $order->setPayment($convertQuote->paymentToOrderPayment($this->getQuote()->getPayment()));
748
+
749
+ foreach ($this->getQuote()->getAllItems() as $item)
750
+ {
751
+ $order->addItem($convertQuote->itemToOrderItem($item));
752
+ }
753
+
754
+ /**
755
+ * We can use configuration data for declare new order status
756
+ */
757
+ Mage::dispatchEvent('checkout_type_onepage_save_order', array('order'=>$order, 'quote'=>$this->getQuote()));
758
+
759
+ Mage::getSingleton('checkout/session')->setThreedsecurerequired(true)
760
+ ->setMd($md)
761
+ ->setPares($pares);
762
+
763
+ $order->place();
764
+
765
+ if ( $order->getPayment()->getMethodInstance()->getCode() == 'cardsaveonlinepayments' &&
766
+ $order->getStatus() != 'pending' )
767
+ {
768
+ $order_status = Mage::getStoreConfig('payment/cardsaveonlinepayments/order_status', Mage::app()->getStore()->getId());
769
+
770
+ $order->addStatusToHistory($order_status);
771
+ $order->setStatus($order_status);
772
+ }
773
+
774
+ $order->save();
775
+
776
+ Mage::dispatchEvent('checkout_type_onepage_save_order_after', array('order'=>$order, 'quote'=>$this->getQuote()));
777
+
778
+
779
+ $this->getQuote()->setIsActive(false);
780
+ $this->getQuote()->save();
781
+
782
+ $orderId = $order->getIncrementId();
783
+ $this->getCheckout()->setLastQuoteId($this->getQuote()->getId());
784
+ $this->getCheckout()->setLastOrderId($order->getId());
785
+ $this->getCheckout()->setLastRealOrderId($order->getIncrementId());
786
+ // $this->getCheckout()->setRedirectUrl($redirectUrl);
787
+
788
+ /**
789
+ * we only want to send to customer about new order when there is no redirect to third party
790
+ */
791
+ /*if(!$redirectUrl){
792
+ $order->sendNewOrderEmail();
793
+ }*/
794
+
795
+ if ($this->getQuote()->getCheckoutMethod() == 'register')
796
+ {
797
+ Mage::getSingleton('customer/session')->loginById($customer->getId());
798
+ }
799
+ }
800
+ return $this;
801
+ }
802
+
803
+ /**
804
+ * Create an order for a Hosted Payment Form/Transparent Redirect payment on the callback
805
+ *
806
+ * @param unknown_type $boIsHostedPaymentAction
807
+ * @param unknown_type $szStatusCode
808
+ * @param unknown_type $szMessage
809
+ * @param unknown_type $szPreviousStatusCode
810
+ * @param unknown_type $szPreviousMessage
811
+ * @param unknown_type $szOrderID
812
+ * @return unknown
813
+ */
814
+ public function saveOrderAfterRedirectedPaymentAction($boIsHostedPaymentAction, $szStatusCode, $szMessage, $szPreviousStatusCode, $szPreviousMessage, $szOrderID, $szCrossReference)
815
+ {
816
+ $nVersion = Mage::getModel('cardsaveonlinepayments/direct')->getVersion();
817
+
818
+ if($nVersion >= 1410)
819
+ {
820
+ $_order = Mage::getModel('sales/order')->load(Mage::getSingleton('checkout/session')->getCardsaveonlinepaymentsOrderId());
821
+
822
+ if(!$_order->getId())
823
+ {
824
+ Mage::throwException('Could not load order.');
825
+ }
826
+
827
+ Mage::getSingleton('checkout/session')->setRedirectedpayment(true)
828
+ ->setIshostedpayment($boIsHostedPaymentAction)
829
+ ->setStatuscode($szStatusCode)
830
+ ->setMessage($szMessage)
831
+ ->setPreviousstatuscode($szPreviousStatusCode)
832
+ ->setPreviousmessage($szPreviousMessage)
833
+ ->setOrderid($szOrderID);
834
+
835
+ $method = Mage::getSingleton('checkout/session')->getRedirectionmethod();
836
+ $_order->getPayment()->getMethodInstance()->{$method}($_order->getPayment(), $boIsHostedPaymentAction, $szStatusCode, $szMessage, $szPreviousStatusCode, $szPreviousMessage, $szOrderID, $szCrossReference);
837
+
838
+ if ($_order->getFailedThreed() !== true &&
839
+ $_order->getPayment()->getMethodInstance()->getCode() == 'cardsaveonlinepayments' &&
840
+ $_order->getStatus() != 'pending')
841
+ {
842
+ $order_status = Mage::getStoreConfig('payment/cardsaveonlinepayments/order_status', Mage::app()->getStore()->getId());
843
+ $_order->addStatusToHistory($order_status);
844
+ $_order->setStatus($order_status);
845
+ }
846
+
847
+ $_order->save();
848
+
849
+ Mage::getSingleton('checkout/session')->setRedirectedpayment(null)
850
+ ->setIshostedpayment(null)
851
+ ->setStatuscode(null)
852
+ ->setMessage(null)
853
+ ->setPreviousstatuscode(null)
854
+ ->setPreviousmessage(null)
855
+ ->setOrderid(null)
856
+ ->setCardsaveonlinepaymentsOrderId(null);
857
+ }
858
+ else if($nVersion == 1400 || $nVersion == 1401 || $nVersion == 1324 || $nVersion == 1330)
859
+ {
860
+ $this->validateOrder();
861
+ $billing = $this->getQuote()->getBillingAddress();
862
+
863
+ if (!$this->getQuote()->isVirtual())
864
+ {
865
+ $shipping = $this->getQuote()->getShippingAddress();
866
+ }
867
+
868
+ switch ($this->getQuote()->getCheckoutMethod())
869
+ {
870
+ case 'guest':
871
+ $this->getQuote()->setCustomerEmail($billing->getEmail())
872
+ ->setCustomerIsGuest(true)
873
+ ->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
874
+ break;
875
+
876
+ default:
877
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
878
+
879
+ if (!$billing->getCustomerId() ||
880
+ $billing->getSaveInAddressBook())
881
+ {
882
+ $customerBilling = $billing->exportCustomerAddress();
883
+ $customer->addAddress($customerBilling);
884
+ }
885
+ if (!$this->getQuote()->isVirtual() &&
886
+ ((!$shipping->getCustomerId() && !$shipping->getSameAsBilling()) ||
887
+ (!$shipping->getSameAsBilling() && $shipping->getSaveInAddressBook())))
888
+ {
889
+ $customerShipping = $shipping->exportCustomerAddress();
890
+ $customer->addAddress($customerShipping);
891
+ }
892
+ $customer->setSavedFromQuote(true);
893
+ $customer->save();
894
+
895
+ $changed = false;
896
+ if (isset($customerBilling) &&
897
+ !$customer->getDefaultBilling())
898
+ {
899
+ $customer->setDefaultBilling($customerBilling->getId());
900
+ $changed = true;
901
+ }
902
+ if (!$this->getQuote()->isVirtual() &&
903
+ isset($customerBilling) &&
904
+ !$customer->getDefaultShipping() &&
905
+ $shipping->getSameAsBilling())
906
+ {
907
+ $customer->setDefaultShipping($customerBilling->getId());
908
+ $changed = true;
909
+ }
910
+ elseif (!$this->getQuote()->isVirtual() &&
911
+ isset($customerShipping) &&
912
+ !$customer->getDefaultShipping())
913
+ {
914
+ $customer->setDefaultShipping($customerShipping->getId());
915
+ $changed = true;
916
+ }
917
+
918
+ if ($changed)
919
+ {
920
+ $customer->save();
921
+ }
922
+ }
923
+
924
+ $this->getQuote()->reserveOrderId();
925
+ $convertQuote = Mage::getModel('sales/convert_quote');
926
+ // @var $convertQuote Mage_Sales_Model_Convert_Quote
927
+ if ($this->getQuote()->isVirtual())
928
+ {
929
+ $order = $convertQuote->addressToOrder($billing);
930
+ }
931
+ else
932
+ {
933
+ $order = $convertQuote->addressToOrder($shipping);
934
+ }
935
+ /* @var $order Mage_Sales_Model_Order */
936
+ $order->setBillingAddress($convertQuote->addressToOrderAddress($billing));
937
+
938
+ if (!$this->getQuote()->isVirtual())
939
+ {
940
+ $order->setShippingAddress($convertQuote->addressToOrderAddress($shipping));
941
+ }
942
+
943
+ $order->setPayment($convertQuote->paymentToOrderPayment($this->getQuote()->getPayment()));
944
+
945
+ foreach ($this->getQuote()->getAllItems() as $item)
946
+ {
947
+ $order->addItem($convertQuote->itemToOrderItem($item));
948
+ }
949
+
950
+ /**
951
+ * We can use configuration data for declare new order status
952
+ */
953
+ Mage::dispatchEvent('checkout_type_onepage_save_order', array('order'=>$order, 'quote'=>$this->getQuote()));
954
+
955
+ Mage::getSingleton('checkout/session')->setRedirectedpayment(true)
956
+ ->setIshostedpayment($boIsHostedPaymentAction)
957
+ ->setStatuscode($szStatusCode)
958
+ ->setMessage($szMessage)
959
+ ->setPreviousstatuscode($szPreviousStatusCode)
960
+ ->setPreviousmessage($szPreviousMessage)
961
+ ->setOrderid($szOrderID);
962
+
963
+ $order->place();
964
+
965
+ if ( $order->getPayment()->getMethodInstance()->getCode() == 'cardsaveonlinepayments' &&
966
+ $order->getStatus() != 'pending' )
967
+ {
968
+ $order_status = Mage::getStoreConfig('payment/cardsaveonlinepayments/order_status', Mage::app()->getStore()->getId());
969
+
970
+ $order->addStatusToHistory($order_status);
971
+ $order->setStatus($order_status);
972
+ }
973
+
974
+ $order->save();
975
+
976
+ Mage::dispatchEvent('checkout_type_onepage_save_order_after', array('order'=>$order, 'quote'=>$this->getQuote()));
977
+
978
+ $this->getQuote()->setIsActive(false);
979
+ $this->getQuote()->save();
980
+
981
+ $orderId = $order->getIncrementId();
982
+ $this->getCheckout()->setLastQuoteId($this->getQuote()->getId());
983
+ $this->getCheckout()->setLastOrderId($order->getId());
984
+ $this->getCheckout()->setLastRealOrderId($order->getIncrementId());
985
+
986
+ /**
987
+ * we only want to send to customer about new order when there is no redirect to third party
988
+ */
989
+ //if(!$redirectUrl){
990
+ $order->sendNewOrderEmail();
991
+ //}
992
+
993
+ if ($this->getQuote()->getCheckoutMethod()=='register')
994
+ {
995
+ Mage::getSingleton('customer/session')->loginById($customer->getId());
996
+ }
997
+ }
998
+
999
+ return $this;
1000
+ }
1001
+ }
app/code/local/Cardsave/Checkout/etc/config.xml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Cardsave_Checkout>
5
+ <version>0.0.1</version>
6
+ </Cardsave_Checkout>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <checkout>
11
+ <rewrite>
12
+ <type_onepage>Cardsave_Checkout_Model_Type_Onepage</type_onepage>
13
+ </rewrite>
14
+ </checkout>
15
+ </models>
16
+ <blocks>
17
+ <checkout>
18
+ <rewrite>
19
+ <onepage_payment_methods>Cardsave_Checkout_Block_Onepage_Payment_Methods</onepage_payment_methods>
20
+ </rewrite>
21
+ </checkout>
22
+ </blocks>
23
+ </global>
24
+ </config>
app/code/local/Cardsave/Sales/Model/Order.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Cardsave_Sales_Model_Order extends Mage_Sales_Model_Order
4
+ {
5
+ protected function _setState($state, $status = false, $comment = '', $isCustomerNotified = null, $shouldProtectState = false)
6
+ {
7
+ // attempt to set the specified state
8
+ if ($shouldProtectState)
9
+ {
10
+ if ($this->isStateProtected($state))
11
+ {
12
+ Mage::throwException(Mage::helper('sales')->__('The Order State "%s" must not be set manually.', $state));
13
+ }
14
+ }
15
+
16
+ $this->setData('state', $state);
17
+
18
+ // add status history
19
+ if ($status)
20
+ {
21
+ if ($status === true)
22
+ {
23
+ $status = $this->getConfig()->getStateDefaultStatus($state);
24
+ }
25
+
26
+ $this->setStatus($status);
27
+ $history = $this->addStatusHistoryComment($comment, false); // no sense to set $status again
28
+ $history->setIsCustomerNotified($isCustomerNotified); // for backwards compatibility
29
+ }
30
+ return $this;
31
+ }
32
+ }
app/code/local/Cardsave/Sales/Model/Order/Invoice.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Cardsave_Sales_Model_Order_Invoice extends Mage_Sales_Model_Order_Invoice
4
+ {
5
+ /**
6
+ * Capture invoice
7
+ *
8
+ * @return Mage_Sales_Model_Order_Invoice
9
+ */
10
+ public function capture()
11
+ {
12
+ $this->getOrder()->getPayment()->capture($this);
13
+
14
+ if ($this->getIsPaid())
15
+ {
16
+ $this->pay();
17
+ }
18
+ return $this;
19
+ }
20
+
21
+ public function pay()
22
+ {
23
+ $nVersion = Mage::getModel('cardsaveonlinepayments/direct')->getVersion();
24
+
25
+ if($nVersion >= 1400)
26
+ {
27
+ if ($this->_wasPayCalled)
28
+ {
29
+ return $this;
30
+ }
31
+
32
+ if(!$this->getOrder()->getIsThreeDSecurePending() &&
33
+ !$this->getOrder()->getIsHostedPaymentPending())
34
+ {
35
+ $this->_wasPayCalled = true;
36
+
37
+ $invoiceState = self::STATE_PAID;
38
+ if ($this->getOrder()->getPayment()->hasForcedState())
39
+ {
40
+ $invoiceState = $this->getOrder()->getPayment()->getForcedState();
41
+ }
42
+
43
+ $this->setState($invoiceState);
44
+
45
+ $this->getOrder()->getPayment()->pay($this);
46
+ $this->getOrder()->setTotalPaid(
47
+ $this->getOrder()->getTotalPaid()+$this->getGrandTotal()
48
+ );
49
+ $this->getOrder()->setBaseTotalPaid(
50
+ $this->getOrder()->getBaseTotalPaid()+$this->getBaseGrandTotal()
51
+ );
52
+ Mage::dispatchEvent('sales_order_invoice_pay', array($this->_eventObject=>$this));
53
+ }
54
+ }
55
+ else if($nVersion == 1324 || $nVersion == 1330)
56
+ {
57
+ $invoiceState = self::STATE_PAID;
58
+ if ($this->getOrder()->getPayment()->hasForcedState())
59
+ {
60
+ $invoiceState = $this->getOrder()->getPayment()->getForcedState();
61
+ }
62
+ $this->setState($invoiceState);
63
+
64
+ $this->getOrder()->getPayment()->pay($this);
65
+ $this->getOrder()->setTotalPaid(
66
+ $this->getOrder()->getTotalPaid()+$this->getGrandTotal()
67
+ );
68
+ $this->getOrder()->setBaseTotalPaid(
69
+ $this->getOrder()->getBaseTotalPaid()+$this->getBaseGrandTotal()
70
+ );
71
+ Mage::dispatchEvent('sales_order_invoice_pay', array($this->_eventObject=>$this));
72
+ }
73
+
74
+ return $this;
75
+ }
76
+ }
app/code/local/Cardsave/Sales/Model/Order/Payment.php ADDED
@@ -0,0 +1,403 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Cardsave_Sales_Model_Order_Payment extends Mage_Sales_Model_Order_Payment
4
+ {
5
+ /**
6
+ * Capture payment
7
+ *
8
+ * @return Mage_Sales_Model_Order_Payment
9
+ */
10
+ public function capture($invoice)
11
+ {
12
+ $nVersion = Mage::getModel('cardsaveonlinepayments/direct')->getVersion();
13
+
14
+ if($nVersion >= 1411 || $nVersion == 1410)
15
+ {
16
+ if (is_null($invoice))
17
+ {
18
+ $invoice = $this->_invoice();
19
+ $this->setCreatedInvoice($invoice);
20
+ return $this; // @see Mage_Sales_Model_Order_Invoice::capture()
21
+ }
22
+ $amountToCapture = $this->_formatAmount($invoice->getBaseGrandTotal());
23
+ $order = $this->getOrder();
24
+
25
+ // prepare parent transaction and its amount
26
+ $paidWorkaround = 0;
27
+ if (!$invoice->wasPayCalled())
28
+ {
29
+ $paidWorkaround = (float)$amountToCapture;
30
+ }
31
+ $this->_isCaptureFinal($paidWorkaround);
32
+
33
+ $this->_generateTransactionId(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE, $this->getAuthorizationTransaction());
34
+
35
+ Mage::dispatchEvent('sales_order_payment_capture', array('payment' => $this, 'invoice' => $invoice));
36
+
37
+ /**
38
+ * Fetch an update about existing transaction. It can determine whether the transaction can be paid
39
+ * Capture attempt will happen only when invoice is not yet paid and the transaction can be paid
40
+ */
41
+ if ($invoice->getTransactionId())
42
+ {
43
+ $this->getMethodInstance()->setStore($order->getStoreId())->fetchTransactionInfo($this, $invoice->getTransactionId());
44
+ }
45
+ $status = true;
46
+ if (!$invoice->getIsPaid() && !$this->getIsTransactionPending())
47
+ {
48
+ // attempt to capture: this can trigger "is_transaction_pending"
49
+ $this->getMethodInstance()->setStore($order->getStoreId())->capture($this, $amountToCapture);
50
+
51
+ $transaction = $this->_addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE, $invoice, true);
52
+
53
+ if ($this->getIsTransactionPending())
54
+ {
55
+ $message = Mage::helper('sales')->__('Capturing amount of %s is pending approval on gateway.', $this->_formatPrice($amountToCapture));
56
+ $state = Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW;
57
+ if ($this->getIsFraudDetected())
58
+ {
59
+ $status = 'fraud';
60
+ }
61
+ $invoice->setIsPaid(false);
62
+ }
63
+ else
64
+ { // normal online capture: invoice is marked as "paid"
65
+ $message = Mage::helper('sales')->__('Captured amount of %s online.', $this->_formatPrice($amountToCapture));
66
+ $state = Mage_Sales_Model_Order::STATE_PROCESSING;
67
+ $invoice->setIsPaid(true);
68
+ $this->_updateTotals(array('base_amount_paid_online' => $amountToCapture));
69
+ }
70
+ if ($order->isNominal())
71
+ {
72
+ $message = $this->_prependMessage(Mage::helper('sales')->__('Nominal order registered.'));
73
+ }
74
+ else
75
+ {
76
+ $message = $this->_prependMessage($message);
77
+ $message = $this->_appendTransactionToMessage($transaction, $message);
78
+ }
79
+ $order->setState($state, $status, $message);
80
+ $this->getMethodInstance()->processInvoice($invoice, $this); // should be deprecated
81
+ return $this;
82
+ }
83
+ Mage::throwException(Mage::helper('sales')->__('The transaction "%s" cannot be captured yet.', $invoice->getTransactionId()));
84
+ }
85
+ if($nVersion == 1400 || $nVersion == 1401)
86
+ {
87
+ if (is_null($invoice))
88
+ {
89
+ $invoice = $this->_invoice();
90
+ $this->setCreatedInvoice($invoice);
91
+ return $this; // @see Mage_Sales_Model_Order_Invoice::capture()
92
+ }
93
+ $amountToCapture = $this->_formatAmount($invoice->getBaseGrandTotal());
94
+
95
+ $paidWorkaround = 0;
96
+ if (!$invoice->wasPayCalled())
97
+ {
98
+ $paidWorkaround = (float)$amountToCapture;
99
+ }
100
+ $this->_isCaptureFinal($paidWorkaround);
101
+ $baseTransaction = false;
102
+ if ($invoice->getTransactionId())
103
+ {
104
+ $baseTransaction = $this->_lookupTransaction($invoice->getTransactionId());
105
+ }
106
+ else
107
+ {
108
+ $baseTransaction = $this->getAuthorizationTransaction();
109
+ }
110
+ $this->_generateTransactionId(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE, $baseTransaction);
111
+
112
+ Mage::dispatchEvent('sales_order_payment_capture', array('payment' => $this, 'invoice' => $invoice));
113
+
114
+ $this->getMethodInstance()
115
+ ->setStore($this->getOrder()->getStoreId())
116
+ ->capture($this, $amountToCapture);
117
+
118
+ // update transactions, set order state (order will close itself if required)
119
+ $transaction = $this->_addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE, $invoice, true);
120
+ /**
121
+ * Check if payment transaction is under pending state.
122
+ * Gateway can accept peyment transaction but mark it as pending.
123
+ * We need hold such kind of orders
124
+ */
125
+ if ($this->getIsTransactionPending())
126
+ {
127
+ $message = Mage::helper('sales')->__('Amount of %s pending approval on gateway.', $this->_formatPrice($amountToCapture));
128
+ $message = $this->_prependMessage($message);
129
+ $message = $this->_appendTransactionToMessage($transaction, $message);
130
+ $status = $this->getTransactionPendingStatus() ? $this->getTransactionPendingStatus() : true;
131
+ $this->getOrder()->setState(Mage_Sales_Model_Order::STATE_HOLDED, $status, $message);
132
+ $invoice->setIsPaid(false);
133
+ }
134
+ else
135
+ {
136
+ $this->_updateTotals(array('base_amount_paid_online' => $amountToCapture));
137
+ $message = Mage::helper('sales')->__('Captured amount of %s online.', $this->_formatPrice($amountToCapture));
138
+ $message = $this->_prependMessage($message);
139
+ $message = $this->_appendTransactionToMessage($transaction, $message);
140
+ $this->getOrder()->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, $message);
141
+ $invoice->setIsPaid(true);
142
+ }
143
+
144
+ $this->getMethodInstance()->processInvoice($invoice, $this); // should be deprecated
145
+ return $this;
146
+ }
147
+ if($nVersion == 1324 || $nVersion == 1330)
148
+ {
149
+ if (is_null($invoice))
150
+ {
151
+ $invoice = $this->_invoice();
152
+ }
153
+
154
+ Mage::dispatchEvent('sales_order_payment_capture', array('payment' => $this, 'invoice' => $invoice));
155
+
156
+ $this->getMethodInstance()
157
+ ->setStore($this->getOrder()->getStoreId())
158
+ ->capture($this, sprintf('%.2f', $invoice->getBaseGrandTotal()));
159
+ if($this->getIsInvoicePaid())
160
+ {
161
+ $invoice->setIsPaid(true);
162
+ }
163
+ $this->getMethodInstance()->processInvoice($invoice, $this);
164
+
165
+ return $this;
166
+ }
167
+ }
168
+
169
+ /**
170
+ * Authorize or authorize and capture payment on gateway, if applicable
171
+ * This method is supposed to be called only when order is placed
172
+ *
173
+ * @return Mage_Sales_Model_Order_Payment
174
+ */
175
+ public function place()
176
+ {
177
+ $nVersion = Mage::getModel('cardsaveonlinepayments/direct')->getVersion();
178
+
179
+ if($nVersion >= 1411 || $nVersion == 1410 || $nVersion == 1401 || $nVersion == 1400)
180
+ {
181
+ Mage::dispatchEvent('sales_order_payment_place_start', array('payment' => $this));
182
+ $order = $this->getOrder();
183
+
184
+ $this->setAmountOrdered($order->getTotalDue());
185
+ $this->setBaseAmountOrdered($order->getBaseTotalDue());
186
+ $this->setShippingAmount($order->getShippingAmount());
187
+ $this->setBaseShippingAmount($order->getBaseShippingAmount());
188
+
189
+ $methodInstance = $this->getMethodInstance();
190
+ $methodInstance->setStore($order->getStoreId());
191
+
192
+ $orderState = Mage_Sales_Model_Order::STATE_NEW;
193
+ $orderStatus= false;
194
+
195
+ $stateObject = new Varien_Object();
196
+
197
+ /**
198
+ * Do order payment validation on payment method level
199
+ */
200
+ $methodInstance->validate();
201
+ $action = $methodInstance->getConfigPaymentAction();
202
+ if ($action)
203
+ {
204
+ if ($methodInstance->isInitializeNeeded())
205
+ {
206
+ /**
207
+ * For method initialization we have to use original config value for payment action
208
+ */
209
+ $methodInstance->initialize($methodInstance->getConfigData('payment_action'), $stateObject);
210
+ }
211
+ else
212
+ {
213
+ $orderState = Mage_Sales_Model_Order::STATE_PROCESSING;
214
+ switch ($action)
215
+ {
216
+ case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE:
217
+ $this->_authorize(true, $order->getBaseTotalDue()); // base amount will be set inside
218
+ $this->setAmountAuthorized($order->getTotalDue());
219
+ break;
220
+ case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE:
221
+ $this->setAmountAuthorized($order->getTotalDue());
222
+ $this->setBaseAmountAuthorized($order->getBaseTotalDue());
223
+ $this->capture(null);
224
+ break;
225
+ default:
226
+ break;
227
+ }
228
+ }
229
+ }
230
+
231
+ if($nVersion >= 1411 || $nVersion == 1410)
232
+ {
233
+ $this->_createBillingAgreement();
234
+ $orderStateHelper = Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW;
235
+ }
236
+ else
237
+ {
238
+ $orderStateHelper = Mage_Sales_Model_Order::STATE_HOLDED;
239
+ }
240
+
241
+ $orderIsNotified = null;
242
+ if ($stateObject->getState() && $stateObject->getStatus())
243
+ {
244
+ $orderState = $stateObject->getState();
245
+ $orderStatus = $stateObject->getStatus();
246
+ $orderIsNotified = $stateObject->getIsNotified();
247
+ }
248
+ else if($order->getIsThreeDSecurePending())
249
+ {
250
+ $orderState = 'pending_payment';
251
+ $orderStatus = 'csv_pending_threed_secure';
252
+ $message = '3D Secure authentication need to be completed';
253
+ $orderIsNotified = false;
254
+ }
255
+ else if($order->getIsHostedPaymentPending())
256
+ {
257
+ $order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true)->save();
258
+ $orderStateHelper = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
259
+ $orderState = 'pending_payment';
260
+ $orderStatus = 'csv_pending_hosted_payment';
261
+ $message = 'Hosted Payment need to be completed';
262
+ $orderIsNotified = false;
263
+ }
264
+ else
265
+ {
266
+ $orderStatus = $methodInstance->getConfigData('order_status');
267
+ if (!$orderStatus || $order->getIsVirtual())
268
+ {
269
+ $orderStatus = $order->getConfig()->getStateDefaultStatus($orderState);
270
+ }
271
+ }
272
+
273
+ $isCustomerNotified = (null !== $orderIsNotified) ? $orderIsNotified : $order->getCustomerNoteNotify();
274
+ //$message = $order->getCustomerNote();
275
+ if(!$order->getIsThreeDSecurePending() &&
276
+ !$order->getIsHostedPaymentPending())
277
+ {
278
+ $message = $order->getCustomerNote();
279
+ }
280
+
281
+ // add message if order was put into review during authorization or capture
282
+ //if ($order->getState() == Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW)$orderState
283
+ if ($order->getState() == $orderStateHelper)
284
+ {
285
+ if ($message)
286
+ {
287
+ $order->addStatusToHistory($order->getStatus(), $message, $isCustomerNotified);
288
+ }
289
+
290
+ if($nVersion >= 1400 || $nVersion == 1401)
291
+ {
292
+ $order->setHoldBeforeState($orderState);
293
+ $order->setHoldBeforeStatus($orderStatus);
294
+ }
295
+ }
296
+ // add message to history if order state already declared
297
+ elseif ($order->getState() && ($orderStatus !== $order->getStatus() || $message))
298
+ {
299
+ $order->setState($orderState, $orderStatus, $message, $isCustomerNotified);
300
+ }
301
+ // set order state
302
+ elseif (($order->getState() != $orderState) || ($order->getStatus() != $orderStatus) || $message)
303
+ {
304
+ $order->setState($orderState, $orderStatus, $message, $isCustomerNotified);
305
+ }
306
+
307
+ Mage::dispatchEvent('sales_order_payment_place_end', array('payment' => $this));
308
+
309
+ return $this;
310
+ }
311
+ if($nVersion == 1324 || $nVersion == 1330)
312
+ {
313
+ Mage::dispatchEvent('sales_order_payment_place_start', array('payment' => $this));
314
+
315
+ $this->setAmountOrdered($this->getOrder()->getTotalDue());
316
+ $this->setBaseAmountOrdered($this->getOrder()->getBaseTotalDue());
317
+
318
+ $this->setShippingAmount($this->getOrder()->getShippingAmount());
319
+ $this->setBaseShippingAmount($this->getOrder()->getBaseShippingAmount());
320
+
321
+ $methodInstance = $this->getMethodInstance()->setStore($this->getOrder()->getStoreId());
322
+
323
+ $orderState = Mage_Sales_Model_Order::STATE_NEW;
324
+ $orderStatus= false;
325
+
326
+ $stateObject = new Varien_Object();
327
+
328
+ /**
329
+ * validating payment method again
330
+ */
331
+ $methodInstance->validate();
332
+ if ($action = $methodInstance->getConfigData('payment_action')) {
333
+ /**
334
+ * Run action declared for payment method in configuration
335
+ */
336
+
337
+ if ($methodInstance->isInitializeNeeded()) {
338
+ $methodInstance->initialize($action, $stateObject);
339
+ } else {
340
+ switch ($action) {
341
+ case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE:
342
+ case Mage_Paypal_Model_Api_Abstract::PAYMENT_TYPE_AUTH:
343
+ $methodInstance->authorize($this, $this->getOrder()->getBaseTotalDue());
344
+
345
+ $this->setAmountAuthorized($this->getOrder()->getTotalDue());
346
+ $this->setBaseAmountAuthorized($this->getOrder()->getBaseTotalDue());
347
+
348
+ $orderState = Mage_Sales_Model_Order::STATE_PROCESSING;
349
+ break;
350
+ case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE:
351
+ case Mage_Paypal_Model_Api_Abstract::PAYMENT_TYPE_SALE:
352
+ $invoice = $this->_invoice();
353
+
354
+ $this->setAmountAuthorized($this->getOrder()->getTotalDue());
355
+ $this->setBaseAmountAuthorized($this->getOrder()->getBaseTotalDue());
356
+
357
+ $orderState = $this->getOrder()->getIsVirtual()
358
+ ? Mage_Sales_Model_Order::STATE_COMPLETE
359
+ : Mage_Sales_Model_Order::STATE_PROCESSING;
360
+ break;
361
+ default:
362
+ break;
363
+ }
364
+ }
365
+ }
366
+
367
+ $orderIsNotified = null;
368
+ if ($stateObject->getState() && $stateObject->getStatus()) {
369
+ $orderState = $stateObject->getState();
370
+ $orderStatus = $stateObject->getStatus();
371
+ $orderIsNotified = $stateObject->getIsNotified();
372
+ } else {
373
+ /*
374
+ * this flag will set if the order went to as authorization under fraud service for payflowpro
375
+ */
376
+ if ($this->getFraudFlag()) {
377
+ $orderStatus = $methodInstance->getConfigData('fraud_order_status');
378
+ $orderState = Mage_Sales_Model_Order::STATE_HOLDED;
379
+ } else {
380
+ /**
381
+ * Change order status if it specified
382
+ */
383
+ $orderStatus = $methodInstance->getConfigData('order_status');
384
+ }
385
+
386
+ if (!$orderStatus || $this->getOrder()->getIsVirtual()) {
387
+ $orderStatus = $this->getOrder()->getConfig()->getStateDefaultStatus($orderState);
388
+ }
389
+ }
390
+
391
+ $this->getOrder()->setState($orderState);
392
+ $this->getOrder()->addStatusToHistory(
393
+ $orderStatus,
394
+ $this->getOrder()->getCustomerNote(),
395
+ (null !== $orderIsNotified ? $orderIsNotified : $this->getOrder()->getCustomerNoteNotify())
396
+ );
397
+
398
+ Mage::dispatchEvent('sales_order_payment_place_end', array('payment' => $this));
399
+
400
+ return $this;
401
+ }
402
+ }
403
+ }
app/code/local/Cardsave/Sales/Model/Service/Quote.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Cardsave_Sales_Model_Service_Quote extends Mage_Sales_Model_Service_Quote
4
+ {
5
+ public function submitOrder()
6
+ {
7
+ $nVersion = Mage::getModel('cardsaveonlinepayments/direct')->getVersion();
8
+
9
+ if($nVersion >= 1410)
10
+ {
11
+ if ($this->_quote->getPayment()->getMethodInstance()->getCode() != 'cardsaveonlinepayments')
12
+ {
13
+ return parent::submitOrder();
14
+ }
15
+
16
+ $this->_deleteNominalItems();
17
+ $this->_validate();
18
+ $quote = $this->_quote;
19
+ $isVirtual = $quote->isVirtual();
20
+
21
+ $transaction = Mage::getModel('core/resource_transaction');
22
+ if ($quote->getCustomerId())
23
+ {
24
+ $transaction->addObject($quote->getCustomer());
25
+ }
26
+ $transaction->addObject($quote);
27
+
28
+ $quote->reserveOrderId();
29
+ if ($isVirtual)
30
+ {
31
+ $order = $this->_convertor->addressToOrder($quote->getBillingAddress());
32
+ }
33
+ else
34
+ {
35
+ $order = $this->_convertor->addressToOrder($quote->getShippingAddress());
36
+ }
37
+ $order->setBillingAddress($this->_convertor->addressToOrderAddress($quote->getBillingAddress()));
38
+
39
+ if (!$isVirtual)
40
+ {
41
+ $order->setShippingAddress($this->_convertor->addressToOrderAddress($quote->getShippingAddress()));
42
+ }
43
+ $order->setPayment($this->_convertor->paymentToOrderPayment($quote->getPayment()));
44
+
45
+ foreach ($this->_orderData as $key => $value)
46
+ {
47
+ $order->setData($key, $value);
48
+ }
49
+
50
+ foreach ($quote->getAllItems() as $item)
51
+ {
52
+ $orderItem = $this->_convertor->itemToOrderItem($item);
53
+ if ($item->getParentItem())
54
+ {
55
+ $orderItem->setParentItem($order->getItemByQuoteItemId($item->getParentItem()->getId()));
56
+ }
57
+ $order->addItem($orderItem);
58
+ }
59
+ // make sure the customer can still use the quote if payment is failed
60
+ //$quote->setIsActive(false);
61
+
62
+ $transaction->addObject($order);
63
+ $transaction->addCommitCallback(array($order, 'place'));
64
+ $transaction->addCommitCallback(array($order, 'save'));
65
+
66
+ /**
67
+ * We can use configuration data for declare new order status
68
+ */
69
+ Mage::dispatchEvent('checkout_type_onepage_save_order', array('order'=>$order, 'quote'=>$quote));
70
+ Mage::dispatchEvent('sales_model_service_quote_submit_before', array('order'=>$order, 'quote'=>$quote));
71
+ try
72
+ {
73
+ $transaction->save();
74
+ Mage::dispatchEvent('sales_model_service_quote_submit_success', array('order'=>$order, 'quote'=>$quote));
75
+
76
+ // need to store the orderID in the session for the callback from an external page
77
+ Mage::getSingleton('checkout/session')->setCardsaveonlinepaymentsOrderId($order->getId());
78
+
79
+ }
80
+ catch (Exception $e)
81
+ {
82
+ Mage::logException($e);
83
+ Mage::dispatchEvent('sales_model_service_quote_submit_failure', array('order'=>$order, 'quote'=>$quote));
84
+ throw $e;
85
+ }
86
+ Mage::dispatchEvent('sales_model_service_quote_submit_after', array('order'=>$order, 'quote'=>$quote));
87
+ $this->_order = $order;
88
+
89
+ return $order;
90
+ }
91
+ }
92
+ }
app/code/local/Cardsave/Sales/etc/config.xml ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Cardsave_Sales>
5
+ <version>0.0.1</version>
6
+ </Cardsave_Sales>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <sales>
11
+ <rewrite>
12
+ <order>Cardsave_Sales_Model_Order</order>
13
+ <order_invoice>Cardsave_Sales_Model_Order_Invoice</order_invoice>
14
+ <order_payment>Cardsave_Sales_Model_Order_Payment</order_payment>
15
+ <service_quote>Cardsave_Sales_Model_Service_Quote</service_quote>
16
+ </rewrite>
17
+ </sales>
18
+ </models>
19
+ <sales>
20
+ <order>
21
+ <statuses>
22
+ <csv_paid translate="label">
23
+ <label>CardSave - Successful Payment</label>
24
+ </csv_paid>
25
+ <csv_pending_threed_secure translate="label">
26
+ <label>CardSave - Pending 3D Secure</label>
27
+ </csv_pending_threed_secure>
28
+ <csv_failed_threed_secure translate="label">
29
+ <label>CardSave - Failed 3D Secure</label>
30
+ </csv_failed_threed_secure>
31
+ <csv_pending translate="label">
32
+ <label>CardSave - Pending Hosted Payment</label>
33
+ </csv_pending>
34
+ <csv_pending_hosted_payment translate="label">
35
+ <label>CardSave - Pending Hosted Payment</label>
36
+ </csv_pending_hosted_payment>
37
+ <csv_failed_hosted_payment translate="label">
38
+ <label>CardSave - Failed Payment</label>
39
+ </csv_failed_hosted_payment>
40
+ </statuses>
41
+ </order>
42
+ </sales>
43
+ </global>
44
+ </config>
app/design/adminhtml/base/default/template/cardsaveonlinepayments/form.phtml ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $direct = Mage::getModel('cardsaveonlinepayments/direct'); ?>
2
+ <?php $_code = $this->getMethodCode() ?>
3
+ <?php $route = $this->getRequest()->getRequestedRouteName(); if($route == 'onestepcheckout'){ $fieldCode = '['.$_code.']'; } else { $fieldCode = ''; }?>
4
+
5
+ <?php if ($direct->getConfigData('mode') == Cardsave_Cardsaveonlinepayments_Model_Source_PaymentMode::PAYMENT_MODE_HOSTED_PAYMENT_FORM) {?>
6
+ <fieldset class="form-list">
7
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
8
+ <li>
9
+ <?php echo $this->__('You will be redirected to a secure page where you can complete your payment.') ?>
10
+ </li>
11
+ </ul>
12
+ </fieldset>
13
+ <?php } else {?>
14
+ <fieldset class="form-list">
15
+ <ul id="payment_form_<?php echo $_code; ?>" style="display:none">
16
+ <li>
17
+ <div class="input-box">
18
+ <label for="<?php echo $_code; ?>_cc_owner"><?php echo $this->__('Name On Card') ?> <span class="required">*</span></label><br/>
19
+ <input type="text" title="<?php echo $this->__('Name On Card') ?>" class="input-text required-entry validate-length maximum-length-100" id="<?php echo $_code; ?>_cc_owner" name="payment<?php echo $fieldCode; ?>[cc_owner]" value="<?php echo $this->htmlEscape($this->getInfoData('cc_owner')) ?>"/>
20
+ </div>
21
+ </li>
22
+ <li>
23
+ <div class="input-box">
24
+ <label for="<?php echo $_code; ?>_cc_number"><?php echo $this->__('Card Number') ?> <span class="required">*</span></label><br/>
25
+ <input type="text" id="<?php echo $_code; ?>_cc_number" name="payment<?php echo $fieldCode; ?>[cc_number]" title="<?php echo $this->__('Card Number') ?>" class="input-text required-entry validate-digits validate-length maximum-length-20" value=""/>
26
+ </div>
27
+ </li>
28
+ <li>
29
+ <label for="<?php echo $_code; ?>_expiration"><?php echo $this->__('Expiration Date') ?> <span class="required">*</span></label><br/>
30
+ <div class="input-box">
31
+ <div class="v-fix">
32
+ <select id="<?php echo $_code; ?>_expiration" name="payment<?php echo $fieldCode; ?>[cc_exp_month]" class="month validate-cc-exp required-entry">
33
+ <?php $_ccExpMonth = $this->getInfoData('cc_exp_month') ?>
34
+ <?php foreach ($this->getCcMonths() as $k=>$v): ?>
35
+ <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
36
+ <?php endforeach ?>
37
+ </select>
38
+ </div>
39
+
40
+ <div class="v-fix">
41
+ <?php $_ccExpYear = $this->getInfoData('cc_exp_year') ?>
42
+ <select id="<?php echo $_code; ?>_expiration_yr" name="payment<?php echo $fieldCode; ?>[cc_exp_year]" class="year required-entry">
43
+ <?php foreach ($this->getCcYears() as $k=>$v): ?>
44
+ <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
45
+ <?php endforeach ?>
46
+ </select>
47
+ </div>
48
+ </div>
49
+ </li>
50
+ <li>
51
+ <label for="<?php echo $_code; ?>_cc_ss_start_month"><?php echo $this->__('Start Date') ?></label><br />
52
+ <div class="input-box">
53
+ <div class="v-fix">
54
+ <select id="<?php echo $_code; ?>_cc_ss_start_month" name="payment<?php echo $fieldCode; ?>[cc_ss_start_month]" class="month">
55
+ <?php $_ccStartMonth = $this->getInfoData('cc_ss_start_month') ?>
56
+ <?php foreach ($this->getCcStartMonths() as $k=>$v): ?>
57
+ <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccStartMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
58
+ <?php endforeach ?>
59
+ </select>
60
+ </div>
61
+ <div class="v-fix">
62
+ <?php $_ccStartYear = $this->getInfoData('cc_ss_start_year') ?>
63
+ <select id="<?php echo $_code ?>_cc_ss_start_year" name="payment<?php echo $fieldCode; ?>[cc_ss_start_year]" class="year">
64
+ <?php foreach ($this->getCcStartYears() as $k=>$v): ?>
65
+ <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccStartYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
66
+ <?php endforeach ?>
67
+ </select>
68
+ </div>
69
+ </div>
70
+ </li>
71
+ <li>
72
+ <div class="input-box">
73
+ <label for="<?php echo $_code; ?>_cc_ss_issue"><?php echo $this->__('Issue Number') ?></label><br />
74
+ <div class="v-fix"><input type="text" title="<?php echo $this->__('Issue Number') ?>" class="input-text validate-digits validate-length maximum-length-2" style="width:50px;" id="<?php echo $_code ?>_cc_ss_issue" name="payment<?php echo $fieldCode; ?>[cc_ss_issue]" value="" /></div>
75
+ </div>
76
+ </li>
77
+ <li>
78
+ <div class="input-box">
79
+ <label for="<?php echo $_code; ?>_cc_cid"><?php echo $this->__('CV2') ?> <span class="required">*</span></label><br/>
80
+ <div class="v-fix"><input type="text" title="<?php echo $this->__('CV2') ?>" class="input-text required-entry validate-digits validate-length maximum-length-4" id="<?php echo $_code; ?>_cc_cid" name="payment<?php echo $fieldCode; ?>[cc_cid]" style="width:50px;" value=""/></div>
81
+ &nbsp;
82
+ <a href="#" class="cvv-what-is-this"><?php echo $this->__('What is this?') ?></a>
83
+ </div>
84
+ </li>
85
+ </ul>
86
+ </fieldset>
87
+ <?php }?>
app/design/adminhtml/base/default/template/cardsaveonlinepayments/info.phtml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $direct = Mage::getModel('cardsaveonlinepayments/direct'); ?>
2
+ <?php if ($direct->getConfigData('mode') != Cardsave_Cardsaveonlinepayments_Model_Source_PaymentMode::PAYMENT_MODE_DIRECT_API) {?>
3
+ <?php if ($direct->getConfigData('mode') == Cardsave_Cardsaveonlinepayments_Model_Source_PaymentMode::PAYMENT_MODE_HOSTED_PAYMENT_FORM) {?>
4
+ <?php echo $this->__('CardSave Hosted Payment'); ?>
5
+ <?php } else {?>
6
+ <?php echo $this->__('CardSave Transparent Redirect'); ?>
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/adminhtml/default/default/template/cardsaveonlinepayments/form.phtml ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $direct = Mage::getModel('cardsaveonlinepayments/direct'); ?>
2
+ <?php $_code = $this->getMethodCode() ?>
3
+ <?php $route = $this->getRequest()->getRequestedRouteName(); if($route == 'onestepcheckout'){ $fieldCode = '['.$_code.']'; } else { $fieldCode = ''; }?>
4
+
5
+ <?php if ($direct->getConfigData('mode') == Cardsave_Cardsaveonlinepayments_Model_Source_PaymentMode::PAYMENT_MODE_HOSTED_PAYMENT_FORM) {?>
6
+ <fieldset class="form-list">
7
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
8
+ <li>
9
+ <?php echo $this->__('You will be redirected to a secure page where you can complete your payment.') ?>
10
+ </li>
11
+ </ul>
12
+ </fieldset>
13
+ <?php } else {?>
14
+ <fieldset class="form-list">
15
+ <ul id="payment_form_<?php echo $_code; ?>" style="display:none">
16
+ <li>
17
+ <div class="input-box">
18
+ <label for="<?php echo $_code; ?>_cc_owner"><?php echo $this->__('Name On Card') ?> <span class="required">*</span></label><br/>
19
+ <input type="text" title="<?php echo $this->__('Name On Card') ?>" class="input-text required-entry validate-length maximum-length-100" id="<?php echo $_code; ?>_cc_owner" name="payment<?php echo $fieldCode; ?>[cc_owner]" value="<?php echo $this->htmlEscape($this->getInfoData('cc_owner')) ?>"/>
20
+ </div>
21
+ </li>
22
+ <li>
23
+ <div class="input-box">
24
+ <label for="<?php echo $_code; ?>_cc_number"><?php echo $this->__('Card Number') ?> <span class="required">*</span></label><br/>
25
+ <input type="text" id="<?php echo $_code; ?>_cc_number" name="payment<?php echo $fieldCode; ?>[cc_number]" title="<?php echo $this->__('Card Number') ?>" class="input-text required-entry validate-digits validate-length maximum-length-20" value=""/>
26
+ </div>
27
+ </li>
28
+ <li>
29
+ <label for="<?php echo $_code; ?>_expiration"><?php echo $this->__('Expiration Date') ?> <span class="required">*</span></label><br/>
30
+ <div class="input-box">
31
+ <div class="v-fix">
32
+ <select id="<?php echo $_code; ?>_expiration" name="payment<?php echo $fieldCode; ?>[cc_exp_month]" class="month validate-cc-exp required-entry">
33
+ <?php $_ccExpMonth = $this->getInfoData('cc_exp_month') ?>
34
+ <?php foreach ($this->getCcMonths() as $k=>$v): ?>
35
+ <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
36
+ <?php endforeach ?>
37
+ </select>
38
+ </div>
39
+
40
+ <div class="v-fix">
41
+ <?php $_ccExpYear = $this->getInfoData('cc_exp_year') ?>
42
+ <select id="<?php echo $_code; ?>_expiration_yr" name="payment<?php echo $fieldCode; ?>[cc_exp_year]" class="year required-entry">
43
+ <?php foreach ($this->getCcYears() as $k=>$v): ?>
44
+ <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
45
+ <?php endforeach ?>
46
+ </select>
47
+ </div>
48
+ </div>
49
+ </li>
50
+ <li>
51
+ <label for="<?php echo $_code; ?>_cc_ss_start_month"><?php echo $this->__('Start Date') ?></label><br />
52
+ <div class="input-box">
53
+ <div class="v-fix">
54
+ <select id="<?php echo $_code; ?>_cc_ss_start_month" name="payment<?php echo $fieldCode; ?>[cc_ss_start_month]" class="month">
55
+ <?php $_ccStartMonth = $this->getInfoData('cc_ss_start_month') ?>
56
+ <?php foreach ($this->getCcStartMonths() as $k=>$v): ?>
57
+ <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccStartMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
58
+ <?php endforeach ?>
59
+ </select>
60
+ </div>
61
+ <div class="v-fix">
62
+ <?php $_ccStartYear = $this->getInfoData('cc_ss_start_year') ?>
63
+ <select id="<?php echo $_code ?>_cc_ss_start_year" name="payment<?php echo $fieldCode; ?>[cc_ss_start_year]" class="year">
64
+ <?php foreach ($this->getCcStartYears() as $k=>$v): ?>
65
+ <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccStartYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
66
+ <?php endforeach ?>
67
+ </select>
68
+ </div>
69
+ </div>
70
+ </li>
71
+ <li>
72
+ <div class="input-box">
73
+ <label for="<?php echo $_code; ?>_cc_ss_issue"><?php echo $this->__('Issue Number') ?></label><br />
74
+ <div class="v-fix"><input type="text" title="<?php echo $this->__('Issue Number') ?>" class="input-text validate-digits validate-length maximum-length-2" id="<?php echo $_code ?>_cc_ss_issue" name="payment<?php echo $fieldCode; ?>[cc_ss_issue]" style="width:50px;" value="" /></div>
75
+ </div>
76
+ </li>
77
+ <li>
78
+ <div class="input-box">
79
+ <label for="<?php echo $_code; ?>_cc_cid"><?php echo $this->__('CV2') ?> <span class="required">*</span></label><br/>
80
+ <div class="v-fix"><input type="text" title="<?php echo $this->__('CV2') ?>" class="input-text required-entry validate-digits validate-length maximum-length-4" id="<?php echo $_code; ?>_cc_cid" name="payment<?php echo $fieldCode; ?>[cc_cid]" style="width:50px;" value=""/></div>
81
+ &nbsp;
82
+ <a href="#" class="cvv-what-is-this"><?php echo $this->__('What is this?') ?></a>
83
+ </div>
84
+ </li>
85
+ </ul>
86
+ </fieldset>
87
+ <?php }?>
app/design/adminhtml/default/default/template/cardsaveonlinepayments/info.phtml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $direct = Mage::getModel('cardsaveonlinepayments/direct'); ?>
2
+ <?php if ($direct->getConfigData('mode') != Cardsave_Cardsaveonlinepayments_Model_Source_PaymentMode::PAYMENT_MODE_DIRECT_API) {?>
3
+ <?php if ($direct->getConfigData('mode') == Cardsave_Cardsaveonlinepayments_Model_Source_PaymentMode::PAYMENT_MODE_HOSTED_PAYMENT_FORM) {?>
4
+ <?php echo $this->__('CardSave Hosted Payment'); ?>
5
+ <?php } else {?>
6
+ <?php echo $this->__('CardSave Transparent Redirect'); ?>
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/base/default/template/cardsaveonlinepayments/form.phtml ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $direct = Mage::getModel('cardsaveonlinepayments/direct'); ?>
2
+ <?php $_code = $this->getMethodCode() ?>
3
+ <?php $route = $this->getRequest()->getRequestedRouteName(); if($route == 'onestepcheckout'){ $fieldCode = '['.$_code.']'; } else { $fieldCode = ''; }?>
4
+
5
+ <?php if ($direct->getConfigData('mode') == Cardsave_Cardsaveonlinepayments_Model_Source_PaymentMode::PAYMENT_MODE_HOSTED_PAYMENT_FORM) {?>
6
+ <fieldset class="form-list">
7
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
8
+ <li>
9
+ <img alt="<?php echo $this->__('CardSave Online Payment Logo'); ?>" src="<?php echo $this->getSkinUrl('images/cardsave_online.jpg'); ?>">
10
+ </li>
11
+ <li>
12
+ <?php echo $this->__('You will be redirected to a secure page where you can complete your payment.') ?>
13
+ </li>
14
+ </ul>
15
+ </fieldset>
16
+ <?php } else {?>
17
+ <fieldset class="form-list">
18
+ <ul id="payment_form_<?php echo $_code; ?>" style="display:none">
19
+ <li>
20
+ <img alt="<?php echo $this->__('CardSave Online Payment Logo'); ?>" src="<?php echo $this->getSkinUrl('images/cardsave_online.jpg'); ?>">
21
+ </li>
22
+ <li>
23
+ <div class="input-box">
24
+ <label for="<?php echo $_code; ?>_cc_owner"><?php echo $this->__('Name On Card') ?> <span class="required">*</span></label><br/>
25
+ <input type="text" title="<?php echo $this->__('Name On Card') ?>" class="input-text required-entry validate-length maximum-length-100" id="<?php echo $_code; ?>_cc_owner" name="payment<?php echo $fieldCode; ?>[cc_owner]" value="<?php echo $this->htmlEscape($this->getInfoData('cc_owner')) ?>"/>
26
+ </div>
27
+ </li>
28
+ <li>
29
+ <div class="input-box">
30
+ <label for="<?php echo $_code; ?>_cc_number"><?php echo $this->__('Card Number') ?> <span class="required">*</span></label><br/>
31
+ <input type="text" id="<?php echo $_code; ?>_cc_number" name="payment<?php echo $fieldCode; ?>[cc_number]" title="<?php echo $this->__('Card Number') ?>" class="input-text required-entry validate-digits validate-length maximum-length-20" value=""/>
32
+ </div>
33
+ </li>
34
+ <li>
35
+ <label for="<?php echo $_code; ?>_expiration"><?php echo $this->__('Expiry Date') ?> <span class="required">*</span></label><br/>
36
+ <div class="input-box">
37
+ <div class="v-fix">
38
+ <select id="<?php echo $_code; ?>_expiration" name="payment<?php echo $fieldCode; ?>[cc_exp_month]" class="month validate-cc-exp required-entry">
39
+ <?php $_ccExpMonth = $this->getInfoData('cc_exp_month') ?>
40
+ <?php foreach ($this->getCcMonths() as $k=>$v): ?>
41
+ <option value="<?php echo $k?$k:'' ?>" <?php if($k==$_ccExpMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
42
+ <?php endforeach ?>
43
+ </select>
44
+ </div>
45
+
46
+ <div class="v-fix">
47
+ <?php $_ccExpYear = $this->getInfoData('cc_exp_year') ?>
48
+ <select id="<?php echo $_code; ?>_expiration_yr" name="payment<?php echo $fieldCode; ?>[cc_exp_year]" class="year required-entry">
49
+ <?php foreach ($this->getCcYears() as $k=>$v): ?>
50
+ <option value="<?php echo $k?$k:'' ?>" <?php if($k==$_ccExpYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
51
+ <?php endforeach ?>
52
+ </select>
53
+ </div>
54
+ </div>
55
+ </li>
56
+ <li>
57
+ <label for="<?php echo $_code; ?>_cc_ss_start_month"><?php echo $this->__('Start Date') ?></label><br />
58
+ <div class="input-box">
59
+ <div class="v-fix">
60
+ <select id="<?php echo $_code; ?>_cc_ss_start_month" name="payment<?php echo $fieldCode; ?>[cc_ss_start_month]" class="month">
61
+ <?php $_ccStartMonth = $this->getInfoData('cc_ss_start_month') ?>
62
+ <?php foreach ($this->getCcStartMonths() as $k=>$v): ?>
63
+ <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccStartMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
64
+ <?php endforeach ?>
65
+ </select>
66
+ </div>
67
+ <div class="v-fix">
68
+ <?php $_ccStartYear = $this->getInfoData('cc_ss_start_year') ?>
69
+ <select id="<?php echo $_code ?>_cc_ss_start_year" name="payment<?php echo $fieldCode; ?>[cc_ss_start_year]" class="year">
70
+ <?php foreach ($this->getCcStartYears() as $k=>$v): ?>
71
+ <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccStartYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
72
+ <?php endforeach ?>
73
+ </select>
74
+ </div>
75
+ </div>
76
+ </li>
77
+ <li>
78
+ <div class="input-box">
79
+ <label for="<?php echo $_code; ?>_cc_ss_issue"><?php echo $this->__('Issue Number') ?></label><br />
80
+ <div class="v-fix"><input type="text" title="<?php echo $this->__('Issue Number') ?>" class="input-text validate-digits validate-length maximum-length-2" id="<?php echo $_code ?>_cc_ss_issue" name="payment<?php echo $fieldCode; ?>[cc_ss_issue]" style="width:50px;" value="" /></div>
81
+ </div>
82
+ </li>
83
+ <li>
84
+ <div class="input-box">
85
+ <label for="<?php echo $_code; ?>_cc_cid"><?php echo $this->__('CV2') ?> <span class="required">*</span></label><br/>
86
+ <div class="v-fix"><input type="text" title="<?php echo $this->__('CV2') ?>" class="input-text required-entry validate-digits validate-length maximum-length-4" id="<?php echo $_code; ?>_cc_cid" name="payment<?php echo $fieldCode; ?>[cc_cid]" style="width:50px;" value=""/></div>
87
+ &nbsp;
88
+ <a href="#" class="cvv-what-is-this"><?php echo $this->__('What is this?') ?></a>
89
+ </div>
90
+ </li>
91
+ </ul>
92
+ </fieldset>
93
+ <?php }?>
app/design/frontend/base/default/template/cardsaveonlinepayments/info.phtml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $direct = Mage::getModel('cardsaveonlinepayments/direct'); ?>
2
+ <?php if ($direct->getConfigData('mode') != Cardsave_Cardsaveonlinepayments_Model_Source_PaymentMode::PAYMENT_MODE_DIRECT_API) {?>
3
+ <?php if ($direct->getConfigData('mode') == Cardsave_Cardsaveonlinepayments_Model_Source_PaymentMode::PAYMENT_MODE_HOSTED_PAYMENT_FORM) {?>
4
+ <?php echo $this->__('CardSave Hosted Payment'); ?>
5
+ <?php } else {?>
6
+ <?php echo $this->__('CardSave Transparent Redirect'); ?>
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/design/frontend/default/default/template/cardsaveonlinepayments/form.phtml ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $direct = Mage::getModel('cardsaveonlinepayments/direct'); ?>
2
+ <?php $_code=$this->getMethodCode(); ?>
3
+ <?php $route = $this->getRequest()->getRequestedRouteName(); if($route == 'onestepcheckout'){ $fieldCode = '['.$_code.']'; } else { $fieldCode = ''; }?>
4
+
5
+ <?php if ($direct->getConfigData('mode') == Cardsave_Cardsaveonlinepayments_Model_Source_PaymentMode::PAYMENT_MODE_HOSTED_PAYMENT_FORM) {?>
6
+ <fieldset class="form-list">
7
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
8
+ <li>
9
+ <img alt="<?php echo $this->__('CardSave Online Payment Logo'); ?>" src="<?php echo $this->getSkinUrl('images/cardsave_online.jpg'); ?>">
10
+ </li>
11
+ <li>
12
+ <?php echo $this->__('You will be redirected to a secure page where you can complete your payment.') ?>
13
+ </li>
14
+ </ul>
15
+ </fieldset>
16
+ <?php } else {?>
17
+ <fieldset class="form-list">
18
+ <ul id="payment_form_<?php echo $_code; ?>" style="display:none">
19
+ <li>
20
+ <img alt="<?php echo $this->__('CardSave Online Payment Logo'); ?>" src="<?php echo $this->getSkinUrl('images/cardsave_online.jpg'); ?>">
21
+ </li>
22
+ <li>
23
+ <div class="input-box">
24
+ <label for="<?php echo $_code; ?>_cc_owner"><?php echo $this->__('Name On Card') ?> <span class="required">*</span></label><br/>
25
+ <input type="text" title="<?php echo $this->__('Name On Card') ?>" class="input-text required-entry validate-length maximum-length-100" id="<?php echo $_code; ?>_cc_owner" name="payment<?php echo $fieldCode; ?>[cc_owner]" value="<?php echo $this->htmlEscape($this->getInfoData('cc_owner')) ?>"/>
26
+ </div>
27
+ </li>
28
+ <li>
29
+ <div class="input-box">
30
+ <label for="<?php echo $_code; ?>_cc_number"><?php echo $this->__('Card Number') ?> <span class="required">*</span></label><br/>
31
+ <input type="text" id="<?php echo $_code; ?>_cc_number" name="payment<?php echo $fieldCode; ?>[cc_number]" title="<?php echo $this->__('Card Number') ?>" class="input-text required-entry validate-digits validate-length maximum-length-20" value=""/>
32
+ </div>
33
+ </li>
34
+ <li>
35
+ <label for="<?php echo $_code; ?>_expiration"><?php echo $this->__('Expiry Date') ?> <span class="required">*</span></label><br/>
36
+ <div class="input-box">
37
+ <div class="v-fix">
38
+ <select id="<?php echo $_code; ?>_expiration" name="payment<?php echo $fieldCode; ?>[cc_exp_month]" class="month validate-cc-exp required-entry">
39
+ <?php $_ccExpMonth = $this->getInfoData('cc_exp_month') ?>
40
+ <?php foreach ($this->getCcMonths() as $k=>$v): ?>
41
+ <option value="<?php echo $k?$k:'' ?>" <?php if($k==$_ccExpMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
42
+ <?php endforeach ?>
43
+ </select>
44
+ </div>
45
+
46
+ <div class="v-fix">
47
+ <?php $_ccExpYear = $this->getInfoData('cc_exp_year') ?>
48
+ <select id="<?php echo $_code; ?>_expiration_yr" name="payment<?php echo $fieldCode; ?>[cc_exp_year]" class="year required-entry">
49
+ <?php foreach ($this->getCcYears() as $k=>$v): ?>
50
+ <option value="<?php echo $k?$k:'' ?>" <?php if($k==$_ccExpYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
51
+ <?php endforeach ?>
52
+ </select>
53
+ </div>
54
+ </div>
55
+ </li>
56
+ <li>
57
+ <label for="<?php echo $_code; ?>_cc_ss_start_month"><?php echo $this->__('Start Date') ?></label><br />
58
+ <div class="input-box">
59
+ <div class="v-fix">
60
+ <select id="<?php echo $_code; ?>_cc_ss_start_month" name="payment<?php echo $fieldCode; ?>[cc_ss_start_month]" class="month">
61
+ <?php $_ccStartMonth = $this->getInfoData('cc_ss_start_month') ?>
62
+ <?php foreach ($this->getCcStartMonths() as $k=>$v): ?>
63
+ <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccStartMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
64
+ <?php endforeach ?>
65
+ </select>
66
+ </div>
67
+ <div class="v-fix">
68
+ <?php $_ccStartYear = $this->getInfoData('cc_ss_start_year') ?>
69
+ <select id="<?php echo $_code ?>_cc_ss_start_year" name="payment<?php echo $fieldCode; ?>[cc_ss_start_year]" class="year">
70
+ <?php foreach ($this->getCcStartYears() as $k=>$v): ?>
71
+ <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccStartYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
72
+ <?php endforeach ?>
73
+ </select>
74
+ </div>
75
+ </div>
76
+ </li>
77
+ <li>
78
+ <div class="input-box">
79
+ <label for="<?php echo $_code; ?>_cc_ss_issue"><?php echo $this->__('Issue Number') ?></label><br />
80
+ <div class="v-fix"><input type="text" title="<?php echo $this->__('Issue Number') ?>" class="input-text validate-digits validate-length maximum-length-2" id="<?php echo $_code ?>_cc_ss_issue" name="payment<?php echo $fieldCode; ?>[cc_ss_issue]" style="width:50px;" value="" /></div>
81
+ </div>
82
+ </li>
83
+ <li>
84
+ <div class="input-box">
85
+ <label for="<?php echo $_code; ?>_cc_cid"><?php echo $this->__('CV2') ?> <span class="required">*</span></label><br/>
86
+ <div class="v-fix"><input type="text" title="<?php echo $this->__('CV2') ?>" class="input-text required-entry validate-digits validate-length maximum-length-4" id="<?php echo $_code; ?>_cc_cid" name="payment<?php echo $fieldCode; ?>[cc_cid]" style="width:50px;" value=""/></div>
87
+ &nbsp;
88
+ <a href="#" class="cvv-what-is-this"><?php echo $this->__('What is this?') ?></a>
89
+ </div>
90
+ </li>
91
+ </ul>
92
+ </fieldset>
93
+ <?php }?>
app/design/frontend/default/default/template/cardsaveonlinepayments/info.phtml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $direct = Mage::getModel('cardsaveonlinepayments/direct'); ?>
2
+ <?php if ($direct->getConfigData('mode') != Cardsave_Cardsaveonlinepayments_Model_Source_PaymentMode::PAYMENT_MODE_DIRECT_API) {?>
3
+ <?php if ($direct->getConfigData('mode') == Cardsave_Cardsaveonlinepayments_Model_Source_PaymentMode::PAYMENT_MODE_HOSTED_PAYMENT_FORM) {?>
4
+ <?php echo $this->__('CardSave Hosted Payment'); ?>
5
+ <?php } else {?>
6
+ <?php echo $this->__('CardSave Transparent Redirect'); ?>
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/Cardsave_All.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <modules>
3
+ <Cardsave_Cardsaveonlinepayments>
4
+ <active>true</active>
5
+ <codePool>local</codePool>
6
+ <depends>
7
+ <Mage_Payment />
8
+ </depends>
9
+ </Cardsave_Cardsaveonlinepayments>
10
+ <Cardsave_Checkout>
11
+ <active>true</active>
12
+ <codePool>local</codePool>
13
+ </Cardsave_Checkout>
14
+ <Cardsave_Sales>
15
+ <active>true</active>
16
+ <codePool>local</codePool>
17
+ </Cardsave_Sales>
18
+ </modules>
19
+ </config>
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Cardsave_Cardsaveonlinepayments</name>
4
- <version>1.10.0</version>
5
  <stability>stable</stability>
6
  <license>OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>CardSave payment extension compatible with Magento v 1.3, 1.4 and 1.5</summary>
10
- <description>Fully supports 3D secure transactions. Also supports all of the integration methods provided by CardSave</description>
11
- <notes>Fixed sql script resource issues</notes>
12
  <authors><author><name>Cardsave</name><user>auto-converted</user><email>integrationsupport@cardsaveonlinepayments.com</email></author></authors>
13
- <date>2011-06-08</date>
14
- <time>17:41:18</time>
15
- <contents><target name="mageskin"><dir name="frontend"><dir name="default"><dir name="default"><dir name="images"><file name="cardsave_online.jpg" hash=""/></dir></dir></dir><dir name="base"><dir name="default"><dir name="images"><file name="cardsave_online.jpg" hash=""/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="cardsaveonlinepayments"><file name="form.phtml" hash=""/><file name="info.phtml" hash=""/></dir></dir></dir></dir><dir name="base"><dir name="default"><dir name="template"><dir name="cardsaveonlinepayments"><file name="form.phtml" hash=""/><file name="info.phtml" hash=""/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="cardsaveonlinepayments"><file name="form.phtml" hash=""/><file name="info.phtml" hash=""/></dir></dir></dir></dir><dir name="base"><dir name="default"><dir name="template"><dir name="cardsaveonlinepayments"><file name="form.phtml" hash=""/><file name="info.phtml" hash=""/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Cardsave_All.xml" hash=""/></dir></target><target name="magelocal"><dir name="Cardsave"><dir name="Cardsaveonlinepayments"><dir name="Block"><file name="Error.php" hash=""/><file name="Form.php" hash=""/><file name="Info.php" hash=""/><file name="Redirect.php" hash=""/><file name="Threedsecure.php" hash=""/></dir><dir name="controllers"><file name="PaymentController.php" hash=""/></dir><dir name="etc"><file name="config.xml" hash=""/><file name="system.xml" hash=""/></dir><dir name="Helper"><file name="Data.php" hash=""/></dir><dir name="Model"><dir name="Common"><dir name="ThePaymentGateway"><file name="PaymentSystem.php" hash=""/><file name="SOAP.php" hash=""/><file name="TPG_Common.php" hash=""/></dir><file name="GlobalErrors.php" hash=""/><file name="ISOCountries.php" hash=""/><file name="ISOCurrencies.php" hash=""/><file name="PaymentFormHelper.php" hash=""/></dir><dir name="Source"><file name="HashMethod.php" hash=""/><file name="OrderStatus.php" hash=""/><file name="PaymentAction.php" hash=""/><file name="PaymentMode.php" hash=""/><file name="ResultDeliveryMethod.php" hash=""/></dir><dir name="Resource"><dir name="Eav"><dir name="Mysql4"><file name="Setup.php" hash=""/></dir></dir></dir><file name="Direct.php" hash=""/><file name="Request.php" hash=""/></dir><dir name="sql"><dir name="cardsaveonlinepayments_setup"><file name="mysql4-install-0.1.0.php" hash=""/></dir></dir></dir><dir name="Checkout"><dir name="Block"><dir name="Onepage"><dir name="Payment"><file name="Methods.php" hash=""/></dir></dir></dir><dir name="etc"><file name="config.xml" hash=""/></dir><dir name="Model"><dir name="Type"><file name="Onepage.php" hash=""/></dir></dir></dir><dir name="Sales"><dir name="etc"><file name="config.xml" hash=""/></dir><dir name="Model"><dir name="Order"><file name="Invoice.php" hash=""/><file name="Payment.php" hash=""/></dir><dir name="Service"><file name="Quote.php" hash=""/></dir><file name="Order.php" hash=""/></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies/>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Cardsave_Cardsaveonlinepayments</name>
4
+ <version>1.10.1</version>
5
  <stability>stable</stability>
6
  <license>OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>Cardsave payment extension compatible with Magento v 1.3, 1.4 and 1.5</summary>
10
+ <description>Fully supports 3D secure transactions. Also supports all of the integration methods provided by CardSave.</description>
11
+ <notes>Fixed sql script</notes>
12
  <authors><author><name>Cardsave</name><user>auto-converted</user><email>integrationsupport@cardsaveonlinepayments.com</email></author></authors>
13
+ <date>2011-06-09</date>
14
+ <time>09:32:46</time>
15
+ <contents><target name="mageskin"><dir name="frontend"><dir name="default"><dir name="default"><dir name="images"><file name="cardsave_online.jpg" hash="abb239c81edb9ae8df8cf891e914e2aa"/></dir></dir></dir><dir name="base"><dir name="default"><dir name="images"><file name="cardsave_online.jpg" hash="abb239c81edb9ae8df8cf891e914e2aa"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="cardsaveonlinepayments"><file name="form.phtml" hash="bf8cf94001d912f6d1e77b1d2b03cf6e"/><file name="info.phtml" hash="9765a5eae50cb6fa21dcec22e7767e79"/></dir></dir></dir></dir><dir name="base"><dir name="default"><dir name="template"><dir name="cardsaveonlinepayments"><file name="form.phtml" hash="ad3f2b6304ce7e83e82195aa16fdb43a"/><file name="info.phtml" hash="9765a5eae50cb6fa21dcec22e7767e79"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="cardsaveonlinepayments"><file name="form.phtml" hash="7f67d94e80b469997a5c1ca2f61a4e47"/><file name="info.phtml" hash="c378bb59f085df95a4a6a5d866fc512d"/></dir></dir></dir></dir><dir name="base"><dir name="default"><dir name="template"><dir name="cardsaveonlinepayments"><file name="form.phtml" hash="34e9854beb8479eef68f452efa803ec1"/><file name="info.phtml" hash="c378bb59f085df95a4a6a5d866fc512d"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Cardsave_All.xml" hash="e1d59fd8c4d4b5d87607f43fecf47e59"/></dir></target><target name="magelocal"><dir name="Cardsave"><dir name="Cardsaveonlinepayments"><dir name="Block"><file name="Error.php" hash="660d3cbde48910ef271df9e05130a6d7"/><file name="Form.php" hash="ea5b3817c9607a94f4685d53d0b18569"/><file name="Info.php" hash="57a4bfec1a1c769de063be2b922f4a97"/><file name="Redirect.php" hash="b5a1f7af807dc9a41ec5b9db5c74e87e"/><file name="Threedsecure.php" hash="9d75776f34c5acaf6ea265f35f302c69"/></dir><dir name="controllers"><file name="PaymentController.php" hash="8bfece31f856e90f0cdadf3bca067ccf"/></dir><dir name="etc"><file name="config.xml" hash="d42560b62660323b2139db8201c3205f"/><file name="system.xml" hash="946f07b53a3e5e321cdacb1bad97a469"/></dir><dir name="Helper"><file name="Data.php" hash="e024ec0479d1e8e7efcf4751b05194d6"/></dir><dir name="Model"><dir name="Common"><dir name="ThePaymentGateway"><file name="PaymentSystem.php" hash="e4d4df170c21b7e3571b3ba1205ca979"/><file name="SOAP.php" hash="a0e5474dce51dc90ba4d37b5de3cdd84"/><file name="TPG_Common.php" hash="d86997c977cfd55b8ab577a514ab149c"/></dir><file name="GlobalErrors.php" hash="04d277d4a763efa508bf36d29c7dc8c4"/><file name="ISOCountries.php" hash="78dc558da68ca9a6ef44898a3980ecf2"/><file name="ISOCurrencies.php" hash="a32bc47b2d9896c293ecdcbf847144f9"/><file name="PaymentFormHelper.php" hash="41e22f61e8b71b8e8b6ca78b90da44e5"/></dir><dir name="Source"><file name="HashMethod.php" hash="997928579b69d21ae9eebec698c715c6"/><file name="OrderStatus.php" hash="4c44f8ba1652f20d934aa200ed4c8d00"/><file name="PaymentAction.php" hash="fa94be37c18bbb2f6301bdad1db3698d"/><file name="PaymentMode.php" hash="ea8af602bd09d54a123af64bc4b680d0"/><file name="ResultDeliveryMethod.php" hash="afb838319df715e604173d6aa143feab"/></dir><dir name="Resource"><dir name="Eav"><dir name="Mysql4"><file name="Setup.php" hash="b2a7e887464ff91517dbb4fd62f13c66"/></dir></dir></dir><file name="Direct.php" hash="e35e88bd1c4dd94dc59adb6cb5061321"/><file name="Request.php" hash="370f028086d13ae1df470e93a67dea66"/></dir><dir name="sql"><dir name="cardsaveonlinepayments_setup"><file name="mysql4-install-0.1.0.php" hash="9a720dbd1752c9651733b068730e686a"/></dir></dir></dir><dir name="Checkout"><dir name="Block"><dir name="Onepage"><dir name="Payment"><file name="Methods.php" hash="695d628564f6e1e0c85e3821699e6b45"/></dir></dir></dir><dir name="etc"><file name="config.xml" hash="9dbd58b6b32491d65e5c7d5850aa3420"/></dir><dir name="Model"><dir name="Type"><file name="Onepage.php" hash="7d1b93be12eebd5e317d72655ba1d8e1"/></dir></dir></dir><dir name="Sales"><dir name="etc"><file name="config.xml" hash="9c884b19d80ee19e12bed268bb15e4ab"/></dir><dir name="Model"><dir name="Order"><file name="Invoice.php" hash="9be99f3fbe1c4fe98fb110d3daa8afe6"/><file name="Payment.php" hash="14f5fc7b55d07707e252f031f64cf18c"/></dir><dir name="Service"><file name="Quote.php" hash="a514922157b5690772d716c29f4a653e"/></dir><file name="Order.php" hash="9ffa9e06b0d5d8d2d810ab50017e81fa"/></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies/>
18
  </package>
skin/frontend/base/default/images/cardsave_online.jpg ADDED
Binary file
skin/frontend/default/default/images/cardsave_online.jpg ADDED
Binary file