OnTechnology_Test3 - Version 1.0.0.0

Version Notes

Mobile version

Download this release

Release Info

Developer Ontechnology
Extension OnTechnology_Test3
Version 1.0.0.0
Comparing to
See all releases


Version 1.0.0.0

Files changed (22) hide show
  1. app/code/community/OnTechnology/Checkout/controllers/Checkout/CartController.php +92 -0
  2. app/code/community/OnTechnology/Checkout/controllers/Checkout/OnepageController.php +1262 -0
  3. app/code/community/OnTechnology/Checkout/controllers/Checkout/simple_html_dom.php +975 -0
  4. app/code/community/OnTechnology/Checkout/controllers/Checkout/system.xml +154 -0
  5. app/code/community/OnTechnology/Checkout/etc/config.xml +36 -0
  6. app/code/community/OnTechnology/Ezimerchant/Block/Paystep/Form.php +12 -0
  7. app/code/community/OnTechnology/Ezimerchant/Helper/Data.php +28 -0
  8. app/code/community/OnTechnology/Ezimerchant/Model/Config/CustomerGroupAccess.php +38 -0
  9. app/code/community/OnTechnology/Ezimerchant/Model/Config/CustomerGroups.php +42 -0
  10. app/code/community/OnTechnology/Ezimerchant/Model/Paystep.php +283 -0
  11. app/code/community/OnTechnology/Ezimerchant/Model/Paystep/PaymentAction.php +40 -0
  12. app/code/community/OnTechnology/Ezimerchant/controllers/PaystepController.php +104 -0
  13. app/code/community/OnTechnology/Ezimerchant/etc/config.xml +84 -0
  14. app/code/community/OnTechnology/Ezimerchant/etc/system.xml +154 -0
  15. app/code/community/OnTechnology/Mobile/Controller/Varien/Router/Standard.php +236 -0
  16. app/code/community/OnTechnology/Mobile/etc/config.xml +38 -0
  17. app/code/community/OnTechnology/Paypal/controllers/Paypal/ExpressController.php +159 -0
  18. app/code/community/OnTechnology/Paypal/etc/config.xml +36 -0
  19. app/code/community/OnTechnology/Sales/Model/Order/Creditmemo.php +130 -0
  20. app/code/community/OnTechnology/Sales/etc/config.xml +39 -0
  21. app/etc/modules/OnTechnology_All.xml +63 -0
  22. package.xml +18 -0
app/code/community/OnTechnology/Checkout/controllers/Checkout/CartController.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Checkout
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Shopping cart controller
29
+ */
30
+
31
+ include_once('Mage/Checkout/controllers/CartController.php');
32
+
33
+ class OnTechnology_Checkout_Checkout_CartController extends Mage_Checkout_CartController
34
+ {
35
+
36
+ /**
37
+ * Shopping cart display action
38
+ */
39
+ public function indexAction()
40
+ {
41
+ $cart = $this->_getCart();
42
+ if ($cart->getQuote()->getItemsCount()) {
43
+ $cart->init();
44
+ $cart->save();
45
+
46
+ if (!$this->_getQuote()->validateMinimumAmount()) {
47
+ $warning = Mage::getStoreConfig('sales/minimum_order/description');
48
+ $cart->getCheckoutSession()->addNotice($warning);
49
+ }
50
+ }
51
+
52
+ foreach ($cart->getQuote()->getMessages() as $message) {
53
+ if ($message) {
54
+ $cart->getCheckoutSession()->addMessage($message);
55
+ }
56
+ }
57
+
58
+ /**
59
+ * if customer enteres shopping cart we should mark quote
60
+ * as modified bc he can has checkout page in another window.
61
+ */
62
+ $this->_getSession()->setCartWasUpdated(true);
63
+
64
+ Varien_Profiler::start(__METHOD__ . 'cart_display');
65
+ $this
66
+ ->loadLayout()
67
+ ->_initLayoutMessages('checkout/session')
68
+ ->_initLayoutMessages('catalog/session')
69
+ ->getLayout()->getBlock('head')->setTitle($this->__('Shopping Cart'));
70
+ $this->renderLayout();
71
+ Varien_Profiler::stop(__METHOD__ . 'cart_display');
72
+
73
+ if(!($this->_getQuote()->getShippingAddress()->getShippingMethod()) && $cart->getQuote()->getItemsCount() > 0)
74
+ {
75
+ $this->_redirect('checkout/cart/estimateUpdatePost');
76
+ }
77
+ }
78
+
79
+
80
+ /**
81
+ * Initialize shipping information
82
+ */
83
+ public function estimateUpdatePostAction()
84
+ {
85
+ $this->_getQuote()->getShippingAddress()
86
+ ->setCountryId('AU');
87
+ $this->_getQuote()->getShippingAddress()->setShippingMethod('flatrate_flatrate')/*->collectTotals()*/->save();
88
+ $this->_goBack();
89
+ }
90
+
91
+
92
+ }
app/code/community/OnTechnology/Checkout/controllers/Checkout/OnepageController.php ADDED
@@ -0,0 +1,1262 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Checkout
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ include_once('Mage/Checkout/controllers/OnepageController.php');
28
+
29
+ class OnTechnology_Checkout_Checkout_OnepageController extends Mage_Checkout_OnepageController
30
+ {
31
+
32
+
33
+ /**
34
+ * Checkout page
35
+ */
36
+ public function indexAction()
37
+ {
38
+ if (!Mage::helper('checkout')->canOnepageCheckout()) {
39
+ Mage::getSingleton('checkout/session')->addError($this->__('The onepage checkout is disabled.'));
40
+ $this->_redirect('checkout/cart');
41
+ return;
42
+ }
43
+ $quote = $this->getOnepage()->getQuote();
44
+ if (!$quote->hasItems() || $quote->getHasError()) {
45
+ $this->_redirect('checkout/cart');
46
+ return;
47
+ }
48
+
49
+ if (!$quote->validateMinimumAmount()) {
50
+ $error = Mage::getStoreConfig('sales/minimum_order/error_message');
51
+ Mage::getSingleton('checkout/session')->addError($error);
52
+ $this->_redirect('checkout/cart');
53
+ return;
54
+ }
55
+
56
+ $this->createtemplateAction();
57
+ $redirectUrl = $this->sendEziAction();
58
+ if ($redirectUrl) {
59
+ $this->getResponse()->setRedirect($redirectUrl);
60
+ return;
61
+ }
62
+ parent::indexAction();
63
+ }
64
+
65
+ /* FUNCTION TO CALL THE URL */
66
+
67
+ public function sendEziAction(){
68
+ $quote = $this->getOnepage()->getQuote();
69
+ $items = $quote->getAllVisibleItems();
70
+ $billingAddress = $quote->getBillingAddress();
71
+ $shippingAddress = $quote->getShippingAddress();
72
+ $model = Mage::getModel('catalog/product'); //getting product model
73
+ $itemidx = 0;
74
+ $discount_amount = 0;
75
+ $paramhash = array();
76
+
77
+ foreach ($items as $ite)
78
+ {
79
+ $item = $ite->toArray();
80
+
81
+ $helper = Mage::helper('catalog/product_configuration');
82
+ if($item['product_type'] == 'configurable')
83
+ $options = $helper->getConfigurableOptions($ite);
84
+ else
85
+ $options = $helper->getCustomOptions($ite);
86
+
87
+
88
+ $_product = $model->load($item['product_id']); //getting product object for particular product id
89
+
90
+ $paramhash["PRODUCTQUANTITY(" . $itemidx . ")"] = $item['qty'];
91
+ $paramhash["PRODUCTCODE(" . $itemidx . ")"] = $item['sku'];
92
+ $paramhash["PRODUCTNAME(" . $itemidx . ")"] = $item['name'];
93
+ $paramhash["PRODUCTPRICEINCTAX(" . $itemidx . ")"] = $item['price_incl_tax'];
94
+ $paramhash["PRODUCTID(" . $itemidx . ")"] = $item['product_id'];
95
+ $paramhash["PRODUCTIMAGEURL(" . $itemidx . ")"] = $_product->getImageUrl();
96
+ $attridx = 0;
97
+ foreach($options as $option)
98
+ {
99
+ $paramhash["PRODUCTATTRIBUTE(".$itemidx.")(".$attridx.")"] = $option['label'];
100
+ $paramhash["PRODUCTATTRIBUTEVALUE(".$itemidx.")(".$attridx.")"] = $option['value'];
101
+ $attridx++;
102
+ }
103
+
104
+ if($item['discount_amount'])
105
+ {
106
+ $discount_amount += $item['discount_amount'];
107
+ }
108
+
109
+ $itemidx = $itemidx + 1;
110
+ }
111
+ if($discount_amount > 0)
112
+ {
113
+ $paramhash["PRODUCTQUANTITY(" . $itemidx . ")"] = 1;
114
+ $paramhash["PRODUCTNAME(" . $itemidx . ")"] = 'Discounts';
115
+ $paramhash["PRODUCTCODE(" . $itemidx . ")"] = 'Discounts';
116
+ $paramhash["PRODUCTPRICEINCTAX(" . $itemidx . ")"] = -$discount_amount;
117
+ }
118
+ $paramhash["COUPONACTIVE"] = 1;
119
+ $couponCode = (string) $quote->getCouponCode();
120
+
121
+ if ($couponCode) {
122
+ $paramhash["COUPONCODE"] = $couponCode;
123
+ }
124
+
125
+
126
+
127
+ $paramhash["CURRENCY"] = Mage::app()->getStore()-> getCurrentCurrencyCode();
128
+ $paramhash["PRODUCTTAX"] = 'GST';
129
+ $paramhash["CUSTOM"] = $quote->getId();
130
+
131
+
132
+ // Check if costomer is logged in
133
+ if(Mage::getSingleton('customer/session')->isLoggedIn())
134
+ {
135
+ $customer_staff = 0;
136
+ // Get group Id
137
+ $groupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
138
+ $group = Mage::getModel('customer/group')->load($groupId);
139
+ if($group->getCustomerGroupCode() == 'Staff')
140
+ {
141
+ foreach (Mage::getSingleton('customer/session')->getCustomer()->getAddresses() as $address) {
142
+ $paramhash["BILLNAME(".$customer_staff.")"] = $address->getName();
143
+ $paramhash["BILLCOMPANY(".$customer_staff.")"] = $address->getCompany();
144
+ $paramhash["BILLEMAIL(".$customer_staff.")"] = $quote->getCustomer()->getEmail();
145
+ $paramhash["BILLPHONE(".$customer_staff.")"] = $address->getTelephone();
146
+ $paramhash["BILLFAX(".$customer_staff.")"] = $address->getFax();
147
+ $paramhash["BILLADDRESS1(".$customer_staff.")"] = $address->getStreet1();
148
+ $paramhash["BILLADDRESS2(".$customer_staff.")"] = $address->getStreet2();
149
+ $paramhash["BILLADDRESS3(".$customer_staff.")"] = $address->getStreet3();
150
+ $paramhash["BILLPLACE(".$customer_staff.")"] = $address->getCity();
151
+ $paramhash["BILLDIVISION(".$customer_staff.")"] = $address->getRegion();
152
+ $paramhash["BILLPOSTALCODE(".$customer_staff.")"] = $address->getPostcode();
153
+ $paramhash["BILLCOUNTRYCODE(".$customer_staff.")"] = $address->getCountry();
154
+ $customer_staff++;
155
+ }
156
+ }
157
+ }
158
+
159
+
160
+
161
+
162
+ if($billingAddress->getEmail())
163
+ {
164
+ $paramhash["BILLNAME"] = $billingAddress->getName();
165
+ $paramhash["BILLCOMPANY"] = $billingAddress->getCompany();
166
+ $paramhash["BILLEMAIL"] = $billingAddress->getEmail();
167
+ $paramhash["BILLPHONE"] = $billingAddress->getTelephone();
168
+ $paramhash["BILLFAX"] = $billingAddress->getFax();
169
+ $paramhash["BILLADDRESS1"] = $billingAddress->getStreet1();
170
+ $paramhash["BILLADDRESS2"] = $billingAddress->getStreet2();
171
+ $paramhash["BILLADDRESS3"] = $billingAddress->getStreet3();
172
+ $paramhash["BILLPLACE"] = $billingAddress->getCity();
173
+ $paramhash["BILLDIVISION"] = $billingAddress->getRegion();
174
+ $paramhash["BILLPOSTALCODE"] = $billingAddress->getPostcode();
175
+ $paramhash["BILLCOUNTRYCODE"] = $billingAddress->getCountry();
176
+ }
177
+ if($shippingAddress->getEmail())
178
+ {
179
+ $paramhash["SHIPNAME"] = $shippingAddress->getName();
180
+ $paramhash["SHIPCOMPANY"] = $shippingAddress->getCompany();
181
+ $paramhash["SHIPEMAIL"] = $shippingAddress->getEmail();
182
+ $paramhash["SHIPPHONE"] = $shippingAddress->getTelephone();
183
+ $paramhash["SHIPADDRESS1"] = $shippingAddress->getStreet1();
184
+ $paramhash["SHIPADDRESS2"] = $shippingAddress->getStreet2();
185
+ $paramhash["SHIPADDRESS3"] = $shippingAddress->getStreet3();
186
+ $paramhash["SHIPPLACE"] = $shippingAddress->getCity();
187
+ $paramhash["SHIPDIVISION"] = $shippingAddress->getRegion();
188
+ $paramhash["SHIPPOSTALCODE"] = $shippingAddress->getPostcode();
189
+ $paramhash["SHIPCOUNTRYCODE"] = $shippingAddress->getCountry();
190
+ }
191
+ $paramhash["ACTION"] = "CreateOrder";
192
+ $paramhash["READONLY"] = 1;
193
+ $paramhash["CANCELURL"] = Mage::getUrl('checkout/cart');
194
+ $paramhash["RETURNURL"] = Mage::getUrl('checkout/onepage/return/o/{orderid}');
195
+ $paramhash["NOTIFYURL"] = Mage::getUrl('checkout/onepage/notify');
196
+ $paramhash["CALCULATECALLBACKURL"] = Mage::getUrl('checkout/onepage/calculateshipping');
197
+ $paramhash["TEMPLATEURL"] = preg_replace('/index.php\//', '', Mage::getBaseURL()).'checkout_template.php';
198
+
199
+ $merchantid = Mage::getStoreConfig('payment/ezimerchant/merchantid');
200
+ $apikey = Mage::getStoreConfig('payment/ezimerchant/apikey');
201
+
202
+ $ch = curl_init();
203
+ curl_setopt($ch, CURLOPT_URL, "https://api.ezimerchant.com/".$merchantid."/orders/");
204
+ curl_setopt($ch, CURLOPT_HEADER, 0);
205
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
206
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array( "Content-Type: application/x-www-form-urlencoded", "X-APIKEY:".$apikey ));
207
+ curl_setopt($ch, CURLOPT_POST, 1);
208
+ curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($paramhash));
209
+
210
+
211
+ $apiresponse = curl_exec($ch);
212
+ curl_close($ch);
213
+
214
+ $xml = simplexml_load_string($apiresponse);
215
+ $redirectUrl = (string)$xml->entry->link["href"];
216
+ $this->LogToFile('test.txt', 'check');
217
+ return $redirectUrl;
218
+ }
219
+
220
+ /**
221
+ * Get region collection
222
+ * @param string $countryCode
223
+ * @return array
224
+ */
225
+ public function getRegionCollection($countryCode)
226
+ {
227
+ $regionCollection = Mage::getModel('directory/region_api')->items($countryCode);
228
+ return $regionCollection;
229
+ }
230
+
231
+
232
+ /* FUNCTION AFTER RETURNING FROM EZIMERCHANT. */
233
+ public function returnAction()
234
+ {
235
+ $orderid = $this->getRequest()->getParam('o');
236
+
237
+ $merchantid = Mage::getStoreConfig('payment/ezimerchant/merchantid');
238
+ $apikey = Mage::getStoreConfig('payment/ezimerchant/apikey');
239
+
240
+ $ch = curl_init();
241
+ curl_setopt($ch, CURLOPT_URL, "https://api.ezimerchant.com/".$merchantid."/orders/".$orderid."/");
242
+ curl_setopt($ch, CURLOPT_HEADER, 0);
243
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
244
+ curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
245
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array( "Content-Type: application/x-www-form-urlencoded", "X-APIKEY:".$apikey ));
246
+
247
+
248
+ $apiresponse = curl_exec($ch);
249
+ curl_close($ch);
250
+
251
+ $xml = simplexml_load_string($apiresponse);
252
+ $ordercontent = $xml->entry->content->children('http://api.ezimerchant.com/schemas/2009/');
253
+
254
+ $billing_address = $ordercontent->orderaddresses->orderaddress[0];
255
+ $name_billing_address = explode(" ", $billing_address->name);
256
+ $shipping_address = $ordercontent->orderaddresses->orderaddress[1];
257
+ $name_shipping_address = explode(" ", $shipping_address->name);
258
+
259
+ if($name_billing_address[1] == '')
260
+ $name_billing_address[1] = $name_billing_address[0];
261
+
262
+ if($name_shipping_address[1] == '')
263
+ $name_shipping_address[1] = $name_shipping_address[0];
264
+
265
+ $customer = Mage::getModel('customer/customer');
266
+ $password = '123456';
267
+
268
+ $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
269
+ $customer->loadByEmail($billing_address->email);
270
+
271
+
272
+ $regionCollection = $this->getRegionCollection($billing_address->countrycode);
273
+ foreach($regionCollection as $region)
274
+ {
275
+ if($region['code'] == $billing_address->division)
276
+ {
277
+ $regionsel_id = $region['region_id'];
278
+ }
279
+ }
280
+
281
+ $regionCollection_ship = $this->getRegionCollection($shipping_address->countrycode);
282
+ foreach($regionCollection_ship as $region_ship)
283
+ {
284
+ if($region_ship['code'] == $shipping_address->division)
285
+ {
286
+ $regionsel_id_ship = $region_ship['region_id'];
287
+ }
288
+ }
289
+
290
+ $addressData_billing = array(
291
+ 'firstname' => $name_billing_address[0],
292
+ 'lastname' => $name_billing_address[1]." ".$name_billing_address[2],
293
+ 'street' => $billing_address->address1.','.$billing_address->address2,
294
+ 'city' => $billing_address->place,
295
+ 'postcode' => $billing_address->postalcode,
296
+ 'telephone' => $billing_address->phone,
297
+ 'country_id' => $billing_address->countrycode,
298
+ 'region_id' => $regionsel_id, // id from directory_country_region table// id from directory_country_region table
299
+ );
300
+
301
+ $addressData_shipping = array(
302
+ 'firstname' => $name_shipping_address[0],
303
+ 'lastname' => $name_shipping_address[1]." ".$name_shipping_address[2],
304
+ 'street' => $shipping_address->address1.','.$shipping_address->address2,
305
+ 'city' => $shipping_address->place,
306
+ 'postcode' => $shipping_address->postalcode,
307
+ 'telephone' => $shipping_address->phone,
308
+ 'country_id' => $shipping_address->countrycode,
309
+ 'region_id' => $regionsel_id_ship, // id from directory_country_region table// id from directory_country_region table
310
+ );
311
+
312
+
313
+
314
+
315
+
316
+ $check = $ordercontent->custom;
317
+
318
+
319
+
320
+
321
+
322
+
323
+
324
+ $quoteId = $check;
325
+
326
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
327
+ $login = 0;
328
+
329
+ if ($customer->getId())
330
+ {
331
+ // for customer orders:
332
+ $quote->assignCustomer($customer);
333
+ Mage::getSingleton('customer/session')->loginById($customer->getId());
334
+ $login = 1;
335
+ }
336
+ else
337
+ {
338
+ // for guest orders only:
339
+
340
+ $websiteId = Mage::app()->getWebsite()->getId();
341
+ $storeId = Mage::app()->getStore()->getId();
342
+ $customer = Mage::getModel("customer/customer");
343
+ $customer->setWebsiteId($websiteId);
344
+ $customer->setStoreId($storeId);
345
+ $customer->setEmail($billing_address->email);
346
+ $customer->setFirstname($name_billing_address[0]);
347
+ $customer->setLastname($name_billing_address[1]);
348
+ $customer->setPassword($password);
349
+ try
350
+ {
351
+ $customer->save();
352
+ $customer->setConfirmation(null);
353
+ $customer->save();
354
+ $customerId = $customer->getId();
355
+
356
+
357
+ $customerAddress = Mage::getModel('customer/address');
358
+
359
+ $customerAddress->setData($addressData_billing)
360
+ ->setCustomerId($customer->getId())
361
+ ->setIsDefaultBilling('1')
362
+ ->setSaveInAddressBook('1');
363
+
364
+ $customerAddress->save();
365
+
366
+
367
+ $customerAddress->setData($addressData_shipping)
368
+ ->setCustomerId($customer->getId())
369
+ ->setIsDefaultShipping('1')
370
+ ->setSaveInAddressBook('1');
371
+
372
+ $customerAddress->save();
373
+
374
+ //Make a "login" of new customer
375
+
376
+ }
377
+ catch (Exception $ex)
378
+ {
379
+ //Zend_Debug::dump($ex->getMessage());
380
+ }
381
+ $customer_new = Mage::getModel('customer/customer')->load($customerId);
382
+ $quote->assignCustomer($customer_new);
383
+
384
+ }
385
+
386
+ $product_model = Mage::getModel('catalog/product');
387
+ $products = $ordercontent->orderlines->orderline;
388
+
389
+
390
+
391
+ foreach($products as $product)
392
+ {
393
+ if('FREIGHT' == $product->productcode)
394
+ {
395
+ $shipping_price = (float)$product->priceinctax;
396
+ $shipping_name = $product->productname;
397
+ }
398
+ }
399
+
400
+
401
+
402
+ $billingAddress = $quote->getBillingAddress()->addData($addressData_billing);
403
+ $shippingAddress = $quote->getShippingAddress()->addData($addressData_shipping);
404
+
405
+ if($ordercontent->coupons->couponcode)
406
+ {
407
+ $couponCode = $ordercontent->coupons->couponcode;
408
+ }
409
+ $quote->getShippingAddress()->setCollectShippingRates(true);
410
+ $quote->setCouponCode(strlen($couponCode) ? $couponCode : '')->collectTotals()->save();
411
+
412
+ $quote->getShippingAddress()->collectShippingRates();
413
+ $groups = $quote->getShippingAddress()->getGroupedAllShippingRates();
414
+
415
+ foreach ($groups as $code => $rates)
416
+ {
417
+ foreach ($rates as $rate)
418
+ {
419
+ if($rate->getCarrierTitle() == strip_tags(trim($shipping_name)))
420
+ {
421
+ $set_shipping_method = $rate->getCode();
422
+ $ship_price = $rate->getPrice();
423
+ }
424
+ }
425
+ }
426
+
427
+ $quote->setTotalsCollectedFlag(0);
428
+ // shipping method an collect
429
+ $quote->getShippingAddress()->setShippingMethod($set_shipping_method);
430
+ $quote->getShippingAddress()->setCollectShippingRates(true);
431
+ $quote->getShippingAddress()->collectShippingRates();
432
+ $quote->collectTotals()->save();
433
+
434
+ /*$ccTypeRegExpList = array(
435
+ //Solo, Switch or Maestro. International safe
436
+ 'SO' => '/(^(6334)[5-9](\d{11}$|\d{13,14}$))|(^(6767)(\d{12}$|\d{14,15}$))/', // Solo only
437
+ 'SM' => '/(^(5[0678])\d{11,18}$)|(^(6[^05])\d{11,18}$)|(^(601)[^1]\d{9,16}$)|(^(6011)\d{9,11}$)|(^(6011)\d{13,16}$)|(^(65)\d{11,13}$)|(^(65)\d{15,18}$)|(^(49030)[2-9](\d{10}$|\d{12,13}$))|(^(49033)[5-9](\d{10}$|\d{12,13}$))|(^(49110)[1-2](\d{10}$|\d{12,13}$))|(^(49117)[4-9](\d{10}$|\d{12,13}$))|(^(49118)[0-2](\d{10}$|\d{12,13}$))|(^(4936)(\d{12}$|\d{14,15}$))/',
438
+
439
+ 'SS' => '/^((6759[0-9]{12})|(6334|6767[0-9]{12})|(6334|6767[0-9]{14,15})|(5018|5020|5038|6304|6759|6761|6763[0-9]{12,19})|(49[013][1356][0-9]{12})|(633[34][0-9]{12})|(633110[0-9]{10})|(564182[0-9]{10}))([0-9]{2,3})?$/', // Maestro / Solo
440
+ 'VI' => '/^4[0-9]{12}([0-9]{3})?$/', // Visa
441
+ 'MC' => '/^5[1-5][0-9]{14}$/', // Master Card
442
+ 'AE' => '/^3[47][0-9]{13}$/', // American Express
443
+ 'DI' => '/^6011[0-9]{12}$/', // Discovery
444
+ 'JCB' => '/^(3[0-9]{15}|(2131|1800)[0-9]{11})$/', // JCB
445
+ ); */
446
+
447
+ $quoteId = $quote->getId();
448
+ $getquote = Mage::getModel('sales/quote')->load($quoteId);
449
+ $items = $getquote->getAllItems();
450
+ $getquote->reserveOrderId();
451
+ $quotePaymentObj = $getquote->getPayment(); // Mage_Sales_Model_Quote_Payment
452
+ $quotePaymentObj->setMethod('checkmo');
453
+
454
+ /* $enckey = (string)Mage::getConfig()->getNode('global/crypt/key');
455
+ $cc_number_enc = base64_encode(Varien_Crypt::factory()->init($enckey)->encrypt((string)$ordercontent->orderpayments->orderpayment->cardnumber));
456
+
457
+ $quotePaymentObj->setData('method', 'ccsave');
458
+ $quotePaymentObj->setData('cc_owner', (string)$ordercontent->orderpayments->orderpayment->cardname);
459
+ $quotePaymentObj->setData('cc_number', (string)$ordercontent->orderpayments->orderpayment->cardnumber);
460
+ $quotePaymentObj->setData('cc_number_enc', $cc_number_enc);
461
+ $quotePaymentObj->setData('cc_last4', substr((string)$ordercontent->orderpayments->orderpayment->cardnumber, -4));
462
+ $quotePaymentObj->setData('cc_exp_month', (int)$ordercontent->orderpayments->orderpayment->expirymonth);
463
+ $quotePaymentObj->setData('cc_exp_year', (int)$ordercontent->orderpayments->orderpayment->expiryyear); */
464
+
465
+
466
+ //$quotePaymentObj->importData(array('method' => 'ccsave',
467
+ // 'cc_owner' => 'ffffffffff',
468
+ // 'cc_number' => (string)$ordercontent->orderpayments->orderpaymnet->cardnumber,
469
+ // 'cc_type' => 'VI',
470
+ // 'cc_exp_month' => (int)$ordercontent->orderpayments->orderpayment->expirymonth,
471
+ // 'cc_exp_year' => (int)$ordercontent->orderpayments->orderpayment->expiryyear,
472
+ // 'cc_cid' => 'xxx'));
473
+
474
+
475
+
476
+ $getquote->setPayment($quotePaymentObj);
477
+
478
+ $convertquote=Mage::getSingleton('sales/convert_quote');
479
+ $orderObj = $convertquote->addressToOrder($getquote->getShippingAddress());
480
+ $orderPaymentObj=$convertquote->paymentToOrderPayment($quotePaymentObj);
481
+
482
+ $orderObj->setBillingAddress($convertquote->addressToOrderAddress($getquote->getBillingAddress()));
483
+ $orderObj->setShippingAddress($convertquote->addressToOrderAddress($getquote->getShippingAddress()));
484
+ $orderObj->setPayment($convertquote->paymentToOrderPayment($getquote->getPayment()));
485
+
486
+ foreach ($items as $item) {
487
+ //@var $item Mage_Sales_Model_Quote_Item
488
+
489
+ $item->setData('price_incl_tax', $item->getData('base_price_incl_tax'));
490
+ $item->setData('tax_amount', $item->getData('base_tax_amount'));
491
+ $item->setData('row_total_incl_tax', $item->getData('base_row_total_incl_tax'));
492
+
493
+
494
+ $orderItem = $convertquote->itemToOrderItem($item);
495
+
496
+ if ($item->getParentItem()) {
497
+ $orderItem->setParentItem($orderObj->getItemByQuoteItemId($item->getParentItem()->getId()));
498
+ }
499
+ $productId = $item->getProductId();
500
+ if ($productId) {
501
+ $stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($productId);
502
+ $stockItem->subtractQty($item->getQty());
503
+ $stockItem->save();
504
+ }
505
+ $orderObj->addItem($orderItem);
506
+ }
507
+
508
+
509
+ $orderObj->setData('subtotal', $orderObj->getData('base_subtotal'));
510
+ $orderObj->setData('tax_amount', $orderObj->getData('base_tax_amount'));
511
+ $orderObj->setData('grand_total', $orderObj->getData('base_grand_total'));
512
+
513
+
514
+
515
+ $orderObj->setCanShipPartiallyItem(false);
516
+ $orderObj->setIncrementId($orderid);
517
+ //$orderObj->collectTotals();
518
+ $totalDue=$orderObj->getTotalDue();
519
+
520
+ $orderObj->place();
521
+ $orderObj->save();
522
+ $orderObj->sendNewOrderEmail();
523
+ $orderId=$orderObj->getId();
524
+ /* IF PAYMENT DONE SUCCESSFULLY, INVOICE IS CREATED*/
525
+ if($ordercontent->paymentstatus == 'paid')
526
+ {
527
+ $invorderObj=Mage::getModel('sales/order')->load($orderId);
528
+ $convertOrderObj=Mage::getSingleton('sales/convert_order');
529
+ $invoiceObj=$convertOrderObj->toInvoice($invorderObj);
530
+
531
+ foreach ($invorderObj->getAllItems() as $item) {
532
+
533
+ $invoiceItem = $convertOrderObj->itemToInvoiceItem($item);
534
+
535
+ if ($item->getParentItem()) {
536
+ $invoiceItem->setParentItem($invoiceObj->getItemById($item->getParentItem()->getId()));
537
+ }
538
+
539
+ $invoiceItem->setQty($item->getQtyToInvoice());
540
+
541
+ $invoiceObj->addItem($invoiceItem);
542
+ }
543
+
544
+ $invoiceObj->collectTotals();
545
+ $invoiceObj->register();
546
+
547
+ $orderPaymentObj=$invorderObj->getPayment();
548
+ $orderPaymentObj->pay($invoiceObj);
549
+
550
+ $invoiceObj->getOrder()->setIsInProcess(true);
551
+ $transactionObj = Mage::getModel('core/resource_transaction');
552
+ $transactionObj->addObject($invoiceObj);
553
+ $transactionObj->addObject($invoiceObj->getOrder());
554
+ $transactionObj->save();
555
+
556
+ $invoiceObj->save();
557
+ $invoiceId=$invoiceObj->getId();
558
+ }
559
+ if(!$login)
560
+ Mage::getSingleton('customer/session')->loginById($customer->getId());
561
+ $this->_redirect('checkout/onepage/success/o/'.$orderObj->getIncrementId());
562
+
563
+
564
+ }
565
+
566
+
567
+ /* FUNCTION AFTER RETURNING FROM EZIMERCHANT. */
568
+ public function notifyAction()
569
+ {
570
+ //$data = $this->getRequest()->getPost();
571
+ //$orderid = $data['eziorderid'];
572
+ //$orderid = $this->getRequest()->getParam('o');
573
+
574
+ $merchantid = Mage::getStoreConfig('payment/ezimerchant/merchantid');
575
+ $apikey = Mage::getStoreConfig('payment/ezimerchant/apikey');
576
+ $xmlinput = file_get_contents("php://input");
577
+ if(strlen($xmlinput)>0)
578
+ {
579
+ $xml = simplexml_load_string($xmlinput);
580
+ }
581
+ else
582
+ {
583
+ $data = $this->getRequest()->getPost();
584
+ $orderid = $data['eziorderid'];
585
+ $ch = curl_init();
586
+ curl_setopt($ch, CURLOPT_URL, "https://api.ezimerchant.com/".$merchantid."/orders/".$orderid."/");
587
+ curl_setopt($ch, CURLOPT_HEADER, 0);
588
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
589
+ curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
590
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array( "Content-Type: application/x-www-form-urlencoded", "X-APIKEY:".$apikey ));
591
+
592
+
593
+ $apiresponse = curl_exec($ch);
594
+ curl_close($ch);
595
+ $xml = simplexml_load_string($apiresponse);
596
+ }
597
+
598
+
599
+
600
+ $ordercontent = $xml->entry->content->children('http://api.ezimerchant.com/schemas/2009/');
601
+ $orderid = (string)$ordercontent->orderid;
602
+ $billing_address = $ordercontent->orderaddresses->orderaddress[0];
603
+ $name_billing_address = explode(" ", $billing_address->name);
604
+ $shipping_address = $ordercontent->orderaddresses->orderaddress[1];
605
+ $name_shipping_address = explode(" ", $shipping_address->name);
606
+
607
+ if($name_billing_address[1] == '')
608
+ $name_billing_address[1] = $name_billing_address[0];
609
+
610
+ if($name_shipping_address[1] == '')
611
+ $name_shipping_address[1] = $name_shipping_address[0];
612
+
613
+ $customer = Mage::getModel('customer/customer');
614
+ $password = '123456';
615
+
616
+ $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
617
+ $customer->loadByEmail($billing_address->email);
618
+
619
+
620
+ $regionCollection = $this->getRegionCollection($billing_address->countrycode);
621
+ foreach($regionCollection as $region)
622
+ {
623
+ if($region['code'] == $billing_address->division)
624
+ {
625
+ $regionsel_id = $region['region_id'];
626
+ }
627
+ }
628
+
629
+ $regionCollection_ship = $this->getRegionCollection($shipping_address->countrycode);
630
+ foreach($regionCollection_ship as $region_ship)
631
+ {
632
+ if($region_ship['code'] == $shipping_address->division)
633
+ {
634
+ $regionsel_id_ship = $region_ship['region_id'];
635
+ }
636
+ }
637
+
638
+ $addressData_billing = array(
639
+ 'firstname' => $name_billing_address[0],
640
+ 'lastname' => $name_billing_address[1]." ".$name_billing_address[2],
641
+ 'street' => $billing_address->address1.','.$billing_address->address2,
642
+ 'city' => $billing_address->place,
643
+ 'postcode' => $billing_address->postalcode,
644
+ 'telephone' => $billing_address->phone,
645
+ 'country_id' => $billing_address->countrycode,
646
+ 'region_id' => $regionsel_id, // id from directory_country_region table// id from directory_country_region table
647
+ );
648
+
649
+ $addressData_shipping = array(
650
+ 'firstname' => $name_shipping_address[0],
651
+ 'lastname' => $name_shipping_address[1]." ".$name_shipping_address[2],
652
+ 'street' => $shipping_address->address1.','.$shipping_address->address2,
653
+ 'city' => $shipping_address->place,
654
+ 'postcode' => $shipping_address->postalcode,
655
+ 'telephone' => $shipping_address->phone,
656
+ 'country_id' => $shipping_address->countrycode,
657
+ 'region_id' => $regionsel_id_ship, // id from directory_country_region table// id from directory_country_region table
658
+ );
659
+
660
+
661
+
662
+
663
+ if($ordercontent->custom)
664
+ {
665
+ $check = $ordercontent->custom;
666
+
667
+ $quoteId = $check;
668
+
669
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
670
+ $login = 0;
671
+ }
672
+ else
673
+ {
674
+ $quote = Mage::getModel('sales/quote');
675
+
676
+ $storeObj = $quote->getStore()->load(1);
677
+ $quote->setStore($storeObj);
678
+ $productModel=Mage::getModel('catalog/product');
679
+
680
+
681
+ /*$quote->assignCustomer($customer);*/
682
+ $quote->setIsMultiShipping(false);
683
+ /*$customer_billing_address = $customer ->getDefaultBillingAddress();
684
+ $customer_shipping_address = $customer ->getDefaultShippingAddress();
685
+ $quote_billing_address = Mage::getModel('sales/quote_address')
686
+ ->importCustomerAddress($customer_billing_address);
687
+ $quote_shipping_address = Mage::getModel('sales/quote_address')
688
+ ->importCustomerAddress($customer_shipping_address);
689
+ $quote->setBillingAddress ($quote_billing_address);
690
+ $quote->setBillingAddress ($quote_shipping_address);*/
691
+ $products = $ordercontent->orderlines->orderline;
692
+
693
+
694
+
695
+ foreach($products as $product)
696
+ {
697
+ if('FREIGHT' != $product->productcode)
698
+ {
699
+ $productObj=$productModel->load($product->productid);
700
+ $quoteItem=Mage::getModel('sales/quote_item')->setProduct($productObj);
701
+ $quoteItem->setQuote($quote);
702
+ $quoteItem->setQty($product->quantity);
703
+ $quote->addItem($quoteItem);
704
+ }
705
+ }
706
+ $quote->collectTotals();
707
+ $quote->save();
708
+ $quoteId = $quote->getId();
709
+ }
710
+ if ($customer->getId())
711
+ {
712
+ // for customer orders:
713
+ $quote->assignCustomer($customer);
714
+ Mage::getSingleton('customer/session')->loginById($customer->getId());
715
+ $login = 1;
716
+ }
717
+ else
718
+ {
719
+ // for guest orders only:
720
+
721
+ $websiteId = Mage::app()->getWebsite()->getId();
722
+ $storeId = Mage::app()->getStore()->getId();
723
+ $customer = Mage::getModel("customer/customer");
724
+ $customer->setWebsiteId($websiteId);
725
+ $customer->setStoreId($storeId);
726
+ $customer->setEmail($billing_address->email);
727
+ $customer->setFirstname($name_billing_address[0]);
728
+ $customer->setLastname($name_billing_address[1]);
729
+ $customer->setPassword($password);
730
+ try
731
+ {
732
+ $customer->save();
733
+ $customer->setConfirmation(null);
734
+ $customer->save();
735
+ $customerId = $customer->getId();
736
+
737
+
738
+ $customerAddress = Mage::getModel('customer/address');
739
+
740
+ $customerAddress->setData($addressData_billing)
741
+ ->setCustomerId($customer->getId())
742
+ ->setIsDefaultBilling('1')
743
+ ->setSaveInAddressBook('1');
744
+
745
+ $customerAddress->save();
746
+
747
+
748
+ $customerAddress->setData($addressData_shipping)
749
+ ->setCustomerId($customer->getId())
750
+ ->setIsDefaultShipping('1')
751
+ ->setSaveInAddressBook('1');
752
+
753
+ $customerAddress->save();
754
+
755
+ //Make a "login" of new customer
756
+
757
+ }
758
+ catch (Exception $ex)
759
+ {
760
+ //Zend_Debug::dump($ex->getMessage());
761
+ }
762
+ $customer_new = Mage::getModel('customer/customer')->load($customerId);
763
+ $quote->assignCustomer($customer_new);
764
+
765
+ }
766
+
767
+ //$product_model = Mage::getModel('catalog/product');
768
+ //$products = $ordercontent->orderlines->orderline;
769
+
770
+
771
+
772
+ foreach($products as $product)
773
+ {
774
+ if('FREIGHT' == $product->productcode)
775
+ {
776
+ $shipping_price = (float)$product->priceinctax;
777
+ $shipping_name = $product->productname;
778
+ }
779
+ }
780
+
781
+
782
+
783
+ $billingAddress = $quote->getBillingAddress()->addData($addressData_billing);
784
+ $shippingAddress = $quote->getShippingAddress()->addData($addressData_shipping);
785
+
786
+ if($ordercontent->coupons->couponcode)
787
+ {
788
+ $couponCode = $ordercontent->coupons->couponcode;
789
+ }
790
+ $quote->getShippingAddress()->setCollectShippingRates(true);
791
+ $quote->setCouponCode(strlen($couponCode) ? $couponCode : '')->collectTotals()->save();
792
+
793
+ $quote->getShippingAddress()->collectShippingRates();
794
+ $groups = $quote->getShippingAddress()->getGroupedAllShippingRates();
795
+
796
+ foreach ($groups as $code => $rates)
797
+ {
798
+ foreach ($rates as $rate)
799
+ {
800
+ if($rate->getCarrierTitle() == strip_tags(trim($shipping_name)))
801
+ {
802
+ $set_shipping_method = $rate->getCode();
803
+ $ship_price = $rate->getPrice();
804
+ }
805
+ }
806
+ }
807
+
808
+ $quote->setTotalsCollectedFlag(0);
809
+ // shipping method an collect
810
+ $quote->getShippingAddress()->setShippingMethod($set_shipping_method);
811
+ $quote->getShippingAddress()->setCollectShippingRates(true);
812
+ $quote->getShippingAddress()->collectShippingRates();
813
+ $quote->collectTotals()->save();
814
+
815
+ /*$ccTypeRegExpList = array(
816
+ //Solo, Switch or Maestro. International safe
817
+ 'SO' => '/(^(6334)[5-9](\d{11}$|\d{13,14}$))|(^(6767)(\d{12}$|\d{14,15}$))/', // Solo only
818
+ 'SM' => '/(^(5[0678])\d{11,18}$)|(^(6[^05])\d{11,18}$)|(^(601)[^1]\d{9,16}$)|(^(6011)\d{9,11}$)|(^(6011)\d{13,16}$)|(^(65)\d{11,13}$)|(^(65)\d{15,18}$)|(^(49030)[2-9](\d{10}$|\d{12,13}$))|(^(49033)[5-9](\d{10}$|\d{12,13}$))|(^(49110)[1-2](\d{10}$|\d{12,13}$))|(^(49117)[4-9](\d{10}$|\d{12,13}$))|(^(49118)[0-2](\d{10}$|\d{12,13}$))|(^(4936)(\d{12}$|\d{14,15}$))/',
819
+
820
+ 'SS' => '/^((6759[0-9]{12})|(6334|6767[0-9]{12})|(6334|6767[0-9]{14,15})|(5018|5020|5038|6304|6759|6761|6763[0-9]{12,19})|(49[013][1356][0-9]{12})|(633[34][0-9]{12})|(633110[0-9]{10})|(564182[0-9]{10}))([0-9]{2,3})?$/', // Maestro / Solo
821
+ 'VI' => '/^4[0-9]{12}([0-9]{3})?$/', // Visa
822
+ 'MC' => '/^5[1-5][0-9]{14}$/', // Master Card
823
+ 'AE' => '/^3[47][0-9]{13}$/', // American Express
824
+ 'DI' => '/^6011[0-9]{12}$/', // Discovery
825
+ 'JCB' => '/^(3[0-9]{15}|(2131|1800)[0-9]{11})$/', // JCB
826
+ ); */
827
+
828
+ $quoteId = $quote->getId();
829
+ $getquote = Mage::getModel('sales/quote')->load($quoteId);
830
+ $items = $getquote->getAllItems();
831
+ $getquote->reserveOrderId();
832
+ $quotePaymentObj = $getquote->getPayment(); // Mage_Sales_Model_Quote_Payment
833
+ $quotePaymentObj->setMethod('checkmo');
834
+
835
+ /* $enckey = (string)Mage::getConfig()->getNode('global/crypt/key');
836
+ $cc_number_enc = base64_encode(Varien_Crypt::factory()->init($enckey)->encrypt((string)$ordercontent->orderpayments->orderpayment->cardnumber));
837
+
838
+ $quotePaymentObj->setData('method', 'ccsave');
839
+ $quotePaymentObj->setData('cc_owner', (string)$ordercontent->orderpayments->orderpayment->cardname);
840
+ $quotePaymentObj->setData('cc_number', (string)$ordercontent->orderpayments->orderpayment->cardnumber);
841
+ $quotePaymentObj->setData('cc_number_enc', $cc_number_enc);
842
+ $quotePaymentObj->setData('cc_last4', substr((string)$ordercontent->orderpayments->orderpayment->cardnumber, -4));
843
+ $quotePaymentObj->setData('cc_exp_month', (int)$ordercontent->orderpayments->orderpayment->expirymonth);
844
+ $quotePaymentObj->setData('cc_exp_year', (int)$ordercontent->orderpayments->orderpayment->expiryyear); */
845
+
846
+
847
+ //$quotePaymentObj->importData(array('method' => 'ccsave',
848
+ // 'cc_owner' => 'ffffffffff',
849
+ // 'cc_number' => (string)$ordercontent->orderpayments->orderpaymnet->cardnumber,
850
+ // 'cc_type' => 'VI',
851
+ // 'cc_exp_month' => (int)$ordercontent->orderpayments->orderpayment->expirymonth,
852
+ // 'cc_exp_year' => (int)$ordercontent->orderpayments->orderpayment->expiryyear,
853
+ // 'cc_cid' => 'xxx'));
854
+
855
+
856
+
857
+ $getquote->setPayment($quotePaymentObj);
858
+
859
+ $convertquote=Mage::getSingleton('sales/convert_quote');
860
+ $orderObj = $convertquote->addressToOrder($getquote->getShippingAddress());
861
+ $orderPaymentObj=$convertquote->paymentToOrderPayment($quotePaymentObj);
862
+
863
+ $orderObj->setBillingAddress($convertquote->addressToOrderAddress($getquote->getBillingAddress()));
864
+ $orderObj->setShippingAddress($convertquote->addressToOrderAddress($getquote->getShippingAddress()));
865
+ $orderObj->setPayment($convertquote->paymentToOrderPayment($getquote->getPayment()));
866
+
867
+ foreach ($items as $item) {
868
+ //@var $item Mage_Sales_Model_Quote_Item
869
+
870
+ $item->setData('price_incl_tax', $item->getData('base_price_incl_tax'));
871
+ $item->setData('tax_amount', $item->getData('base_tax_amount'));
872
+ $item->setData('row_total_incl_tax', $item->getData('base_row_total_incl_tax'));
873
+
874
+
875
+ $orderItem = $convertquote->itemToOrderItem($item);
876
+
877
+ if ($item->getParentItem()) {
878
+ $orderItem->setParentItem($orderObj->getItemByQuoteItemId($item->getParentItem()->getId()));
879
+ }
880
+ $productId = $item->getProductId();
881
+ if ($productId) {
882
+ $stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($productId);
883
+ $stockItem->subtractQty($item->getQty());
884
+ $stockItem->save();
885
+ }
886
+ $orderObj->addItem($orderItem);
887
+ }
888
+
889
+
890
+ $orderObj->setData('subtotal', $orderObj->getData('base_subtotal'));
891
+ $orderObj->setData('tax_amount', $orderObj->getData('base_tax_amount'));
892
+ $orderObj->setData('grand_total', $orderObj->getData('base_grand_total'));
893
+
894
+
895
+
896
+ $orderObj->setCanShipPartiallyItem(false);
897
+ $orderObj->setIncrementId($orderid);
898
+ //$orderObj->collectTotals();
899
+ $totalDue=$orderObj->getTotalDue();
900
+
901
+ $orderObj->place();
902
+ $orderObj->save();
903
+ $orderObj->sendNewOrderEmail();
904
+ $orderId=$orderObj->getId();
905
+ /* IF PAYMENT DONE SUCCESSFULLY, INVOICE IS CREATED*/
906
+ if($ordercontent->paymentstatus == 'paid')
907
+ {
908
+ $invorderObj=Mage::getModel('sales/order')->load($orderId);
909
+ $convertOrderObj=Mage::getSingleton('sales/convert_order');
910
+ $invoiceObj=$convertOrderObj->toInvoice($invorderObj);
911
+
912
+ foreach ($invorderObj->getAllItems() as $item) {
913
+
914
+ $invoiceItem = $convertOrderObj->itemToInvoiceItem($item);
915
+
916
+ if ($item->getParentItem()) {
917
+ $invoiceItem->setParentItem($invoiceObj->getItemById($item->getParentItem()->getId()));
918
+ }
919
+
920
+ $invoiceItem->setQty($item->getQtyToInvoice());
921
+
922
+ $invoiceObj->addItem($invoiceItem);
923
+ }
924
+
925
+ $invoiceObj->collectTotals();
926
+ $invoiceObj->register();
927
+
928
+ $orderPaymentObj=$invorderObj->getPayment();
929
+ $orderPaymentObj->pay($invoiceObj);
930
+
931
+ $invoiceObj->getOrder()->setIsInProcess(true);
932
+ $transactionObj = Mage::getModel('core/resource_transaction');
933
+ $transactionObj->addObject($invoiceObj);
934
+ $transactionObj->addObject($invoiceObj->getOrder());
935
+ $transactionObj->save();
936
+
937
+ $invoiceObj->save();
938
+ $invoiceId=$invoiceObj->getId();
939
+ }
940
+
941
+ }
942
+
943
+ function LogToFile($logfile, $message)
944
+ {
945
+ //$fp = fopen($logfile, 'w+');
946
+ $fp = fopen(Mage::getBaseDir() . DS. $logfile, "a+");
947
+ fwrite($fp, $message);
948
+ fclose($fp);
949
+ }
950
+
951
+
952
+ public function calculateshippingAction()
953
+ {
954
+
955
+ try {
956
+ $data = $this->getRequest()->getPost();
957
+ } catch (Exception $e) {
958
+ Mage::logException($e);
959
+ }
960
+
961
+ if($data['COUPONCODE'])
962
+ $couponCode = $data['COUPONCODE'];
963
+ else
964
+ $couponCode = '';
965
+ if(!$data['CUSTOM'])
966
+ {
967
+ /*$customer = Mage::getModel('customer/customer')
968
+ ->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
969
+ ->loadByEmail($data['EMAIL']);*/
970
+ foreach ($data as $key => $value)
971
+ {
972
+ $this->LogToFile('test.txt', $key);
973
+ $this->LogToFile('test.txt', $value);
974
+ preg_match_all('/PRODUCTNAME\((.+?)\)/is', $key, $new);
975
+ if($new[1][0] >= "0" && $new[1][0] > $prod_count)$prod_count = $new[1][0];
976
+ }
977
+
978
+
979
+ $quote = Mage::getModel('sales/quote');
980
+
981
+ $storeObj = $quote->getStore()->load(1);
982
+ $quote->setStore($storeObj);
983
+ $productModel=Mage::getModel('catalog/product');
984
+
985
+
986
+ /*$quote->assignCustomer($customer);*/
987
+ $quote->setIsMultiShipping(false);
988
+ /*$customer_billing_address = $customer ->getDefaultBillingAddress();
989
+ $customer_shipping_address = $customer ->getDefaultShippingAddress();
990
+ $quote_billing_address = Mage::getModel('sales/quote_address')
991
+ ->importCustomerAddress($customer_billing_address);
992
+ $quote_shipping_address = Mage::getModel('sales/quote_address')
993
+ ->importCustomerAddress($customer_shipping_address);
994
+ $quote->setBillingAddress ($quote_billing_address);
995
+ $quote->setBillingAddress ($quote_shipping_address);*/
996
+
997
+ for($i=0;$i<=$prod_count;$i++)
998
+ {
999
+ $productObj=$productModel->load($data['PRODUCTID('.$i.')']);
1000
+ $quoteItem=Mage::getModel('sales/quote_item')->setProduct($productObj);
1001
+ $quoteItem->setQuote($quote);
1002
+ $quoteItem->setQty($data['PRODUCTQUANTITY('.$i.')']);
1003
+ $quote->addItem($quoteItem);
1004
+ }
1005
+ $quote->collectTotals();
1006
+ $quote->save();
1007
+ $quoteId = $quote->getId();
1008
+ }
1009
+ else
1010
+ {
1011
+ $quoteId = $data['CUSTOM'];
1012
+ }
1013
+
1014
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
1015
+
1016
+ $model = Mage::getModel('catalog/product'); //getting product model
1017
+ $customer = Mage::getModel('customer/customer');
1018
+ if($data['EMAIL'])
1019
+ {
1020
+
1021
+ $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
1022
+ $customer->loadByEmail($data['EMAIL']);
1023
+ if ($customer->getId()) {
1024
+ $quote->assignCustomer($customer);
1025
+ Mage::getSingleton('customer/session')->loginById($customer->getId());
1026
+ }
1027
+ }
1028
+
1029
+ $regionCollection = $this->getRegionCollection($data['COUNTRYCODE']);
1030
+ foreach($regionCollection as $region) {
1031
+ if($region['code'] == $data['DIVISION'])
1032
+ {
1033
+ $regionsel_id = $region['region_id'];
1034
+ }
1035
+ }
1036
+
1037
+ $addressData_shipping = array(
1038
+ 'postcode' => $data['POSTALCODE'],
1039
+ 'country_id' => $data['COUNTRYCODE'],
1040
+ 'region_id' => $regionsel_id, // id from directory_country_region table// id from directory_country_region table
1041
+ );
1042
+ $shippingAddress = $quote->getShippingAddress()->addData($addressData_shipping);
1043
+
1044
+ $quote->getShippingAddress()->setCollectShippingRates(true);
1045
+ $quote->setCouponCode($couponCode)
1046
+ ->collectTotals()
1047
+ ->save();
1048
+ $quote->getShippingAddress()->collectShippingRates();
1049
+ $groups = $quote->getShippingAddress()->getGroupedAllShippingRates();
1050
+ $i=0;
1051
+ $paramhash = array();
1052
+ foreach ($groups as $code => $rates) {
1053
+ foreach ($rates as $rate) {
1054
+ $paramhash["FREIGHTNAME(".$i.")"] = $rate->getCarrierTitle();
1055
+ $paramhash["FREIGHTCHARGEINCTAX(".$i.")"] = $rate->getPrice();
1056
+ $i++;
1057
+ } }
1058
+
1059
+
1060
+
1061
+
1062
+
1063
+ $items = $quote->getAllVisibleItems();
1064
+ $itemidx = 0;
1065
+ $discount_amount = 0;
1066
+
1067
+ foreach ($items as $ite)
1068
+ {
1069
+ $item = $ite->toArray();
1070
+
1071
+ $helper = Mage::helper('catalog/product_configuration');
1072
+ if($item['product_type'] == 'configurable')
1073
+ $options = $helper->getConfigurableOptions($ite);
1074
+ else
1075
+ $options = $helper->getCustomOptions($ite);
1076
+
1077
+
1078
+ $_product = $model->load($item['product_id']); //getting product object for particular product id
1079
+
1080
+ $paramhash["PRODUCTQUANTITY(" . $itemidx . ")"] = $item['qty'];
1081
+ $paramhash["PRODUCTCODE(" . $itemidx . ")"] = $item['sku'];
1082
+ $paramhash["PRODUCTNAME(" . $itemidx . ")"] = $item['name'];
1083
+ $paramhash["PRODUCTPRICEINCTAX(" . $itemidx . ")"] = $item['price_incl_tax'];
1084
+ $paramhash["PRODUCTID(" . $itemidx . ")"] = $item['product_id'];
1085
+ $paramhash["PRODUCTIMAGEURL(" . $itemidx . ")"] = $_product->getImageUrl();
1086
+ $attridx = 0;
1087
+ foreach($options as $option)
1088
+ {
1089
+ $paramhash["PRODUCTATTRIBUTE(".$itemidx.")(".$attridx.")"] = $option['label'];
1090
+ $paramhash["PRODUCTATTRIBUTEVALUE(".$itemidx.")(".$attridx.")"] = $option['value'];
1091
+ $attridx++;
1092
+ }
1093
+
1094
+ if($item['discount_amount'])
1095
+ {
1096
+ $discount_amount += $item['discount_amount'];
1097
+ }
1098
+
1099
+ $itemidx = $itemidx + 1;
1100
+ }
1101
+ if($discount_amount > 0)
1102
+ {
1103
+ $paramhash["PRODUCTQUANTITY(" . $itemidx . ")"] = 1;
1104
+ $paramhash["PRODUCTNAME(" . $itemidx . ")"] = 'Discounts';
1105
+ $paramhash["PRODUCTCODE(" . $itemidx . ")"] = 'Discounts';
1106
+ $paramhash["PRODUCTPRICEINCTAX(" . $itemidx . ")"] = -$discount_amount;
1107
+ }
1108
+ if($data['CUSTOM'])
1109
+ $paramhash["CUSTOM"] = $quote->getId();
1110
+ echo http_build_query($paramhash);
1111
+
1112
+ }
1113
+ /*public function paypalreturnAction()
1114
+ {
1115
+
1116
+ //echo '<pre>';
1117
+ $orderid = $this->getRequest()->getParam('o');
1118
+
1119
+
1120
+ $username = Mage::getStoreConfig('payment/ezimerchant/username');
1121
+ $merchantid = Mage::getStoreConfig('payment/ezimerchant/merchantid');
1122
+ $password = Mage::getStoreConfig('payment/ezimerchant/password');
1123
+
1124
+ $ch = curl_init();
1125
+ curl_setopt($ch, CURLOPT_URL, "https://api.ezimerchant.com/".$merchantid."/orders/".$orderid."/");
1126
+ curl_setopt($ch, CURLOPT_HEADER, 0);
1127
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1128
+ curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
1129
+ curl_setopt($ch, CURL_HTTPHEADER, array( "Content-Type: application/x-www-form-urlencoded" ));
1130
+ curl_setopt($ch, CURLOPT_USERPWD, $username.":".$password);
1131
+
1132
+ $apiresponse = curl_exec($ch);
1133
+ curl_close($ch);
1134
+
1135
+ preg_match_all('/<content type=\"application\/xml\">(.+?)<\/content>/is', $apiresponse, $matches);
1136
+
1137
+ preg_match_all('/<ezi:(.+?)<\/ezi/is', $matches[1][0], $new);
1138
+ //print_r($matches[1][0]);
1139
+
1140
+ foreach($new[1] as $val)
1141
+ {
1142
+ $valuene = explode('>',$val);
1143
+ //print_r($valuene);
1144
+ if($valuene[0] != 'orderaddresses')
1145
+ $newval[$valuene[0]] = $valuene[1];
1146
+ }
1147
+
1148
+ //$xml = simplexml_load_string($matches[1]);
1149
+
1150
+
1151
+ $cart = Mage::helper('checkout/cart')->getCart();
1152
+
1153
+
1154
+
1155
+
1156
+ $quote = Mage::getModel('sales/quote')
1157
+ ->setStoreId(Mage::app()->getStore('default')->getId());
1158
+
1159
+ if ('do customer orders') {
1160
+ // for customer orders:
1161
+ $customer = Mage::getModel('customer/customer')
1162
+ ->setWebsiteId(1)
1163
+ ->loadByEmail($newval['email']);
1164
+ $quote->assignCustomer($customer);
1165
+ } else {
1166
+ // for guest orders only:
1167
+ $quote->setCustomerEmail($newval['email']);
1168
+ }
1169
+
1170
+ foreach ($cart->getQuote()->getAllItems() as $item)
1171
+ {
1172
+
1173
+ $product = Mage::getModel('catalog/product')->load($item->product_id);
1174
+ $buyInfo = array(
1175
+ 'qty' => $item->qty,
1176
+ );
1177
+
1178
+ $quote->addProduct($product, new Varien_Object($buyInfo));
1179
+
1180
+ }
1181
+
1182
+
1183
+ $addressData = array(
1184
+ 'firstname' => $newval['name'],
1185
+ 'lastname' => $newval['name'],
1186
+ 'street' => $newval['address1'].','.$newval['place'],
1187
+ 'city' => $newval['division'],
1188
+ 'postcode' => $newval['postalcode'],
1189
+ 'telephone' => $newval['phone'],
1190
+ 'country_id' => $newval['countrycode'],
1191
+ 'region_id' => 12, // id from directory_country_region table// id from directory_country_region table
1192
+ );
1193
+
1194
+ $billingAddress = $quote->getBillingAddress()->addData($addressData);
1195
+ $shippingAddress = $quote->getShippingAddress()->addData($addressData);
1196
+
1197
+ $shippingAddress->setCollectShippingRates(true)->collectShippingRates()
1198
+ ->setShippingMethod('freeshipping_freeshipping')
1199
+ ->setPaymentMethod('ezimerchant');
1200
+
1201
+ $quote->getPayment()->importData(array('method' => 'checkmo'));
1202
+
1203
+ $quote->collectTotals()->save();
1204
+
1205
+ $service = Mage::getModel('sales/service_quote', $quote);
1206
+ $service->submitAll();
1207
+ $order = $service->getOrder();
1208
+
1209
+ $this->_redirect('checkout/onepage/success/o/'.$order->getIncrementId());
1210
+
1211
+
1212
+ } */
1213
+
1214
+ /*Function for creating template*/
1215
+
1216
+ public function createtemplateAction()
1217
+ {
1218
+ include('simple_html_dom.php');
1219
+ $url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
1220
+
1221
+ $html = file_get_html($url);
1222
+
1223
+ foreach($html->find('.col-main') as $element) {
1224
+ $element->outertext = '{Main}';
1225
+ }
1226
+ $fp = fopen(Mage::getBaseDir() . DS. "checkout_template.php", "w+");
1227
+ fwrite($fp, $html);
1228
+ fclose($fp);
1229
+ }
1230
+
1231
+
1232
+ /**
1233
+ * Order success action
1234
+ */
1235
+ public function successAction()
1236
+ {
1237
+ if(!$this->getRequest()->getParam('o'))
1238
+ {
1239
+ $this->_redirect('checkout/cart');
1240
+ }
1241
+ $cart = Mage::getSingleton('checkout/cart');
1242
+
1243
+ $cart->truncate();
1244
+ $cart->save();
1245
+ $cart->getItems()->clear()->save();
1246
+
1247
+ //$session->clear();
1248
+ $this->loadLayout();
1249
+ $this->_initLayoutMessages('checkout/session');
1250
+ Mage::dispatchEvent('checkout_onepage_controller_success_action', array('order_ids' => array($this->getRequest()->getParam('o'))));
1251
+ $this->renderLayout();
1252
+ }
1253
+
1254
+
1255
+
1256
+
1257
+
1258
+
1259
+
1260
+
1261
+
1262
+ }
app/code/community/OnTechnology/Checkout/controllers/Checkout/simple_html_dom.php ADDED
@@ -0,0 +1,975 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*******************************************************************************
3
+ Version: 1.11 ($Rev: 175 $)
4
+ Website: http://sourceforge.net/projects/simplehtmldom/
5
+ Author: S.C. Chen <me578022@gmail.com>
6
+ Acknowledge: Jose Solorzano (https://sourceforge.net/projects/php-html/)
7
+ Contributions by:
8
+ Yousuke Kumakura (Attribute filters)
9
+ Vadim Voituk (Negative indexes supports of "find" method)
10
+ Antcs (Constructor with automatically load contents either text or file/url)
11
+ Licensed under The MIT License
12
+ Redistributions of files must retain the above copyright notice.
13
+ *******************************************************************************/
14
+
15
+ define('HDOM_TYPE_ELEMENT', 1);
16
+ define('HDOM_TYPE_COMMENT', 2);
17
+ define('HDOM_TYPE_TEXT', 3);
18
+ define('HDOM_TYPE_ENDTAG', 4);
19
+ define('HDOM_TYPE_ROOT', 5);
20
+ define('HDOM_TYPE_UNKNOWN', 6);
21
+ define('HDOM_QUOTE_DOUBLE', 0);
22
+ define('HDOM_QUOTE_SINGLE', 1);
23
+ define('HDOM_QUOTE_NO', 3);
24
+ define('HDOM_INFO_BEGIN', 0);
25
+ define('HDOM_INFO_END', 1);
26
+ define('HDOM_INFO_QUOTE', 2);
27
+ define('HDOM_INFO_SPACE', 3);
28
+ define('HDOM_INFO_TEXT', 4);
29
+ define('HDOM_INFO_INNER', 5);
30
+ define('HDOM_INFO_OUTER', 6);
31
+ define('HDOM_INFO_ENDSPACE',7);
32
+
33
+ // helper functions
34
+ // -----------------------------------------------------------------------------
35
+ // get html dom form file
36
+ function file_get_html() {
37
+ $dom = new simple_html_dom;
38
+ $args = func_get_args();
39
+ $dom->load(call_user_func_array('file_get_contents', $args), true);
40
+ return $dom;
41
+ }
42
+
43
+ // get html dom form string
44
+ function str_get_html($str, $lowercase=true) {
45
+ $dom = new simple_html_dom;
46
+ $dom->load($str, $lowercase);
47
+ return $dom;
48
+ }
49
+
50
+ // dump html dom tree
51
+ function dump_html_tree($node, $show_attr=true, $deep=0) {
52
+ $lead = str_repeat(' ', $deep);
53
+ echo $lead.$node->tag;
54
+ if ($show_attr && count($node->attr)>0) {
55
+ echo '(';
56
+ foreach($node->attr as $k=>$v)
57
+ echo "[$k]=>\"".$node->$k.'", ';
58
+ echo ')';
59
+ }
60
+ echo "\n";
61
+
62
+ foreach($node->nodes as $c)
63
+ dump_html_tree($c, $show_attr, $deep+1);
64
+ }
65
+
66
+ // get dom form file (deprecated)
67
+ function file_get_dom() {
68
+ $dom = new simple_html_dom;
69
+ $args = func_get_args();
70
+ $dom->load(call_user_func_array('file_get_contents', $args), true);
71
+ return $dom;
72
+ }
73
+
74
+ // get dom form string (deprecated)
75
+ function str_get_dom($str, $lowercase=true) {
76
+ $dom = new simple_html_dom;
77
+ $dom->load($str, $lowercase);
78
+ return $dom;
79
+ }
80
+
81
+ // simple html dom node
82
+ // -----------------------------------------------------------------------------
83
+ class simple_html_dom_node {
84
+ public $nodetype = HDOM_TYPE_TEXT;
85
+ public $tag = 'text';
86
+ public $attr = array();
87
+ public $children = array();
88
+ public $nodes = array();
89
+ public $parent = null;
90
+ public $_ = array();
91
+ private $dom = null;
92
+
93
+ function __construct($dom) {
94
+ $this->dom = $dom;
95
+ $dom->nodes[] = $this;
96
+ }
97
+
98
+ function __destruct() {
99
+ $this->clear();
100
+ }
101
+
102
+ function __toString() {
103
+ return $this->outertext();
104
+ }
105
+
106
+ // clean up memory due to php5 circular references memory leak...
107
+ function clear() {
108
+ $this->dom = null;
109
+ $this->nodes = null;
110
+ $this->parent = null;
111
+ $this->children = null;
112
+ }
113
+
114
+ // dump node's tree
115
+ function dump($show_attr=true) {
116
+ dump_html_tree($this, $show_attr);
117
+ }
118
+
119
+ // returns the parent of node
120
+ function parent() {
121
+ return $this->parent;
122
+ }
123
+
124
+ // returns children of node
125
+ function children($idx=-1) {
126
+ if ($idx===-1) return $this->children;
127
+ if (isset($this->children[$idx])) return $this->children[$idx];
128
+ return null;
129
+ }
130
+
131
+ // returns the first child of node
132
+ function first_child() {
133
+ if (count($this->children)>0) return $this->children[0];
134
+ return null;
135
+ }
136
+
137
+ // returns the last child of node
138
+ function last_child() {
139
+ if (($count=count($this->children))>0) return $this->children[$count-1];
140
+ return null;
141
+ }
142
+
143
+ // returns the next sibling of node
144
+ function next_sibling() {
145
+ if ($this->parent===null) return null;
146
+ $idx = 0;
147
+ $count = count($this->parent->children);
148
+ while ($idx<$count && $this!==$this->parent->children[$idx])
149
+ ++$idx;
150
+ if (++$idx>=$count) return null;
151
+ return $this->parent->children[$idx];
152
+ }
153
+
154
+ // returns the previous sibling of node
155
+ function prev_sibling() {
156
+ if ($this->parent===null) return null;
157
+ $idx = 0;
158
+ $count = count($this->parent->children);
159
+ while ($idx<$count && $this!==$this->parent->children[$idx])
160
+ ++$idx;
161
+ if (--$idx<0) return null;
162
+ return $this->parent->children[$idx];
163
+ }
164
+
165
+ // get dom node's inner html
166
+ function innertext() {
167
+ if (isset($this->_[HDOM_INFO_INNER])) return $this->_[HDOM_INFO_INNER];
168
+ if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
169
+
170
+ $ret = '';
171
+ foreach($this->nodes as $n)
172
+ $ret .= $n->outertext();
173
+ return $ret;
174
+ }
175
+
176
+ // get dom node's outer text (with tag)
177
+ function outertext() {
178
+ if ($this->tag==='root') return $this->innertext();
179
+
180
+ // trigger callback
181
+ if ($this->dom->callback!==null)
182
+ call_user_func_array($this->dom->callback, array($this));
183
+
184
+ if (isset($this->_[HDOM_INFO_OUTER])) return $this->_[HDOM_INFO_OUTER];
185
+ if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
186
+
187
+ // render begin tag
188
+ $ret = $this->dom->nodes[$this->_[HDOM_INFO_BEGIN]]->makeup();
189
+
190
+ // render inner text
191
+ if (isset($this->_[HDOM_INFO_INNER]))
192
+ $ret .= $this->_[HDOM_INFO_INNER];
193
+ else {
194
+ foreach($this->nodes as $n)
195
+ $ret .= $n->outertext();
196
+ }
197
+
198
+ // render end tag
199
+ if(isset($this->_[HDOM_INFO_END]) && $this->_[HDOM_INFO_END]!=0)
200
+ $ret .= '</'.$this->tag.'>';
201
+ return $ret;
202
+ }
203
+
204
+ // get dom node's plain text
205
+ function text() {
206
+ if (isset($this->_[HDOM_INFO_INNER])) return $this->_[HDOM_INFO_INNER];
207
+ switch ($this->nodetype) {
208
+ case HDOM_TYPE_TEXT: return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
209
+ case HDOM_TYPE_COMMENT: return '';
210
+ case HDOM_TYPE_UNKNOWN: return '';
211
+ }
212
+ if (strcasecmp($this->tag, 'script')===0) return '';
213
+ if (strcasecmp($this->tag, 'style')===0) return '';
214
+
215
+ $ret = '';
216
+ foreach($this->nodes as $n)
217
+ $ret .= $n->text();
218
+ return $ret;
219
+ }
220
+
221
+ function xmltext() {
222
+ $ret = $this->innertext();
223
+ $ret = str_ireplace('<![CDATA[', '', $ret);
224
+ $ret = str_replace(']]>', '', $ret);
225
+ return $ret;
226
+ }
227
+
228
+ // build node's text with tag
229
+ function makeup() {
230
+ // text, comment, unknown
231
+ if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
232
+
233
+ $ret = '<'.$this->tag;
234
+ $i = -1;
235
+
236
+ foreach($this->attr as $key=>$val) {
237
+ ++$i;
238
+
239
+ // skip removed attribute
240
+ if ($val===null || $val===false)
241
+ continue;
242
+
243
+ $ret .= $this->_[HDOM_INFO_SPACE][$i][0];
244
+ //no value attr: nowrap, checked selected...
245
+ if ($val===true)
246
+ $ret .= $key;
247
+ else {
248
+ switch($this->_[HDOM_INFO_QUOTE][$i]) {
249
+ case HDOM_QUOTE_DOUBLE: $quote = '"'; break;
250
+ case HDOM_QUOTE_SINGLE: $quote = '\''; break;
251
+ default: $quote = '';
252
+ }
253
+ $ret .= $key.$this->_[HDOM_INFO_SPACE][$i][1].'='.$this->_[HDOM_INFO_SPACE][$i][2].$quote.$val.$quote;
254
+ }
255
+ }
256
+ $ret = $this->dom->restore_noise($ret);
257
+ return $ret . $this->_[HDOM_INFO_ENDSPACE] . '>';
258
+ }
259
+
260
+ // find elements by css selector
261
+ function find($selector, $idx=null) {
262
+ $selectors = $this->parse_selector($selector);
263
+ if (($count=count($selectors))===0) return array();
264
+ $found_keys = array();
265
+
266
+ // find each selector
267
+ for ($c=0; $c<$count; ++$c) {
268
+ if (($levle=count($selectors[0]))===0) return array();
269
+ if (!isset($this->_[HDOM_INFO_BEGIN])) return array();
270
+
271
+ $head = array($this->_[HDOM_INFO_BEGIN]=>1);
272
+
273
+ // handle descendant selectors, no recursive!
274
+ for ($l=0; $l<$levle; ++$l) {
275
+ $ret = array();
276
+ foreach($head as $k=>$v) {
277
+ $n = ($k===-1) ? $this->dom->root : $this->dom->nodes[$k];
278
+ $n->seek($selectors[$c][$l], $ret);
279
+ }
280
+ $head = $ret;
281
+ }
282
+
283
+ foreach($head as $k=>$v) {
284
+ if (!isset($found_keys[$k]))
285
+ $found_keys[$k] = 1;
286
+ }
287
+ }
288
+
289
+ // sort keys
290
+ ksort($found_keys);
291
+
292
+ $found = array();
293
+ foreach($found_keys as $k=>$v)
294
+ $found[] = $this->dom->nodes[$k];
295
+
296
+ // return nth-element or array
297
+ if (is_null($idx)) return $found;
298
+ else if ($idx<0) $idx = count($found) + $idx;
299
+ return (isset($found[$idx])) ? $found[$idx] : null;
300
+ }
301
+
302
+ // seek for given conditions
303
+ protected function seek($selector, &$ret) {
304
+ list($tag, $key, $val, $exp, $no_key) = $selector;
305
+
306
+ // xpath index
307
+ if ($tag && $key && is_numeric($key)) {
308
+ $count = 0;
309
+ foreach ($this->children as $c) {
310
+ if ($tag==='*' || $tag===$c->tag) {
311
+ if (++$count==$key) {
312
+ $ret[$c->_[HDOM_INFO_BEGIN]] = 1;
313
+ return;
314
+ }
315
+ }
316
+ }
317
+ return;
318
+ }
319
+
320
+ $end = (!empty($this->_[HDOM_INFO_END])) ? $this->_[HDOM_INFO_END] : 0;
321
+ if ($end==0) {
322
+ $parent = $this->parent;
323
+ while (!isset($parent->_[HDOM_INFO_END]) && $parent!==null) {
324
+ $end -= 1;
325
+ $parent = $parent->parent;
326
+ }
327
+ $end += $parent->_[HDOM_INFO_END];
328
+ }
329
+
330
+ for($i=$this->_[HDOM_INFO_BEGIN]+1; $i<$end; ++$i) {
331
+ $node = $this->dom->nodes[$i];
332
+ $pass = true;
333
+
334
+ if ($tag==='*' && !$key) {
335
+ if (in_array($node, $this->children, true))
336
+ $ret[$i] = 1;
337
+ continue;
338
+ }
339
+
340
+ // compare tag
341
+ if ($tag && $tag!=$node->tag && $tag!=='*') {$pass=false;}
342
+ // compare key
343
+ if ($pass && $key) {
344
+ if ($no_key) {
345
+ if (isset($node->attr[$key])) $pass=false;
346
+ }
347
+ else if (!isset($node->attr[$key])) $pass=false;
348
+ }
349
+ // compare value
350
+ if ($pass && $key && $val && $val!=='*') {
351
+ $check = $this->match($exp, $val, $node->attr[$key]);
352
+ // handle multiple class
353
+ if (!$check && strcasecmp($key, 'class')===0) {
354
+ foreach(explode(' ',$node->attr[$key]) as $k) {
355
+ $check = $this->match($exp, $val, $k);
356
+ if ($check) break;
357
+ }
358
+ }
359
+ if (!$check) $pass = false;
360
+ }
361
+ if ($pass) $ret[$i] = 1;
362
+ unset($node);
363
+ }
364
+ }
365
+
366
+ protected function match($exp, $pattern, $value) {
367
+ switch ($exp) {
368
+ case '=':
369
+ return ($value===$pattern);
370
+ case '!=':
371
+ return ($value!==$pattern);
372
+ case '^=':
373
+ return preg_match("/^".preg_quote($pattern,'/')."/", $value);
374
+ case '$=':
375
+ return preg_match("/".preg_quote($pattern,'/')."$/", $value);
376
+ case '*=':
377
+ if ($pattern[0]=='/')
378
+ return preg_match($pattern, $value);
379
+ return preg_match("/".$pattern."/i", $value);
380
+ }
381
+ return false;
382
+ }
383
+
384
+ protected function parse_selector($selector_string) {
385
+ // pattern of CSS selectors, modified from mootools
386
+ $pattern = "/([\w-:\*]*)(?:\#([\w-]+)|\.([\w-]+))?(?:\[@?(!?[\w-]+)(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ]+)/is";
387
+ preg_match_all($pattern, trim($selector_string).' ', $matches, PREG_SET_ORDER);
388
+ $selectors = array();
389
+ $result = array();
390
+ //print_r($matches);
391
+
392
+ foreach ($matches as $m) {
393
+ $m[0] = trim($m[0]);
394
+ if ($m[0]==='' || $m[0]==='/' || $m[0]==='//') continue;
395
+ // for borwser grnreated xpath
396
+ if ($m[1]==='tbody') continue;
397
+
398
+ list($tag, $key, $val, $exp, $no_key) = array($m[1], null, null, '=', false);
399
+ if(!empty($m[2])) {$key='id'; $val=$m[2];}
400
+ if(!empty($m[3])) {$key='class'; $val=$m[3];}
401
+ if(!empty($m[4])) {$key=$m[4];}
402
+ if(!empty($m[5])) {$exp=$m[5];}
403
+ if(!empty($m[6])) {$val=$m[6];}
404
+
405
+ // convert to lowercase
406
+ if ($this->dom->lowercase) {$tag=strtolower($tag); $key=strtolower($key);}
407
+ //elements that do NOT have the specified attribute
408
+ if (isset($key[0]) && $key[0]==='!') {$key=substr($key, 1); $no_key=true;}
409
+
410
+ $result[] = array($tag, $key, $val, $exp, $no_key);
411
+ if (trim($m[7])===',') {
412
+ $selectors[] = $result;
413
+ $result = array();
414
+ }
415
+ }
416
+ if (count($result)>0)
417
+ $selectors[] = $result;
418
+ return $selectors;
419
+ }
420
+
421
+ function __get($name) {
422
+ if (isset($this->attr[$name])) return $this->attr[$name];
423
+ switch($name) {
424
+ case 'outertext': return $this->outertext();
425
+ case 'innertext': return $this->innertext();
426
+ case 'plaintext': return $this->text();
427
+ case 'xmltext': return $this->xmltext();
428
+ default: return array_key_exists($name, $this->attr);
429
+ }
430
+ }
431
+
432
+ function __set($name, $value) {
433
+ switch($name) {
434
+ case 'outertext': return $this->_[HDOM_INFO_OUTER] = $value;
435
+ case 'innertext':
436
+ if (isset($this->_[HDOM_INFO_TEXT])) return $this->_[HDOM_INFO_TEXT] = $value;
437
+ return $this->_[HDOM_INFO_INNER] = $value;
438
+ }
439
+ if (!isset($this->attr[$name])) {
440
+ $this->_[HDOM_INFO_SPACE][] = array(' ', '', '');
441
+ $this->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_DOUBLE;
442
+ }
443
+ $this->attr[$name] = $value;
444
+ }
445
+
446
+ function __isset($name) {
447
+ switch($name) {
448
+ case 'outertext': return true;
449
+ case 'innertext': return true;
450
+ case 'plaintext': return true;
451
+ }
452
+ //no value attr: nowrap, checked selected...
453
+ return (array_key_exists($name, $this->attr)) ? true : isset($this->attr[$name]);
454
+ }
455
+
456
+ function __unset($name) {
457
+ if (isset($this->attr[$name]))
458
+ unset($this->attr[$name]);
459
+ }
460
+
461
+ // camel naming conventions
462
+ function getAllAttributes() {return $this->attr;}
463
+ function getAttribute($name) {return $this->__get($name);}
464
+ function setAttribute($name, $value) {$this->__set($name, $value);}
465
+ function hasAttribute($name) {return $this->__isset($name);}
466
+ function removeAttribute($name) {$this->__set($name, null);}
467
+ function getElementById($id) {return $this->find("#$id", 0);}
468
+ function getElementsById($id, $idx=null) {return $this->find("#$id", $idx);}
469
+ function getElementByTagName($name) {return $this->find($name, 0);}
470
+ function getElementsByTagName($name, $idx=null) {return $this->find($name, $idx);}
471
+ function parentNode() {return $this->parent();}
472
+ function childNodes($idx=-1) {return $this->children($idx);}
473
+ function firstChild() {return $this->first_child();}
474
+ function lastChild() {return $this->last_child();}
475
+ function nextSibling() {return $this->next_sibling();}
476
+ function previousSibling() {return $this->prev_sibling();}
477
+ }
478
+
479
+ // simple html dom parser
480
+ // -----------------------------------------------------------------------------
481
+ class simple_html_dom {
482
+ public $root = null;
483
+ public $nodes = array();
484
+ public $callback = null;
485
+ public $lowercase = false;
486
+ protected $pos;
487
+ protected $doc;
488
+ protected $char;
489
+ protected $size;
490
+ protected $cursor;
491
+ protected $parent;
492
+ protected $noise = array();
493
+ protected $token_blank = " \t\r\n";
494
+ protected $token_equal = ' =/>';
495
+ protected $token_slash = " />\r\n\t";
496
+ protected $token_attr = ' >';
497
+ // use isset instead of in_array, performance boost about 30%...
498
+ protected $self_closing_tags = array('img'=>1, 'br'=>1, 'input'=>1, 'meta'=>1, 'link'=>1, 'hr'=>1, 'base'=>1, 'embed'=>1, 'spacer'=>1);
499
+ protected $block_tags = array('root'=>1, 'body'=>1, 'form'=>1, 'div'=>1, 'span'=>1, 'table'=>1);
500
+ protected $optional_closing_tags = array(
501
+ 'tr'=>array('tr'=>1, 'td'=>1, 'th'=>1),
502
+ 'th'=>array('th'=>1),
503
+ 'td'=>array('td'=>1),
504
+ 'li'=>array('li'=>1),
505
+ 'dt'=>array('dt'=>1, 'dd'=>1),
506
+ 'dd'=>array('dd'=>1, 'dt'=>1),
507
+ 'dl'=>array('dd'=>1, 'dt'=>1),
508
+ 'p'=>array('p'=>1),
509
+ 'nobr'=>array('nobr'=>1),
510
+ );
511
+
512
+ function __construct($str=null) {
513
+ if ($str) {
514
+ if (preg_match("/^http:\/\//i",$str) || is_file($str))
515
+ $this->load_file($str);
516
+ else
517
+ $this->load($str);
518
+ }
519
+ }
520
+
521
+ function __destruct() {
522
+ $this->clear();
523
+ }
524
+
525
+ // load html from string
526
+ function load($str, $lowercase=true) {
527
+ // prepare
528
+ $this->prepare($str, $lowercase);
529
+ // strip out comments
530
+ $this->remove_noise("'<!--(.*?)-->'is");
531
+ // strip out cdata
532
+ $this->remove_noise("'<!\[CDATA\[(.*?)\]\]>'is", true);
533
+ // strip out <style> tags
534
+ $this->remove_noise("'<\s*style[^>]*[^/]>(.*?)<\s*/\s*style\s*>'is");
535
+ $this->remove_noise("'<\s*style\s*>(.*?)<\s*/\s*style\s*>'is");
536
+ // strip out <script> tags
537
+ $this->remove_noise("'<\s*script[^>]*[^/]>(.*?)<\s*/\s*script\s*>'is");
538
+ $this->remove_noise("'<\s*script\s*>(.*?)<\s*/\s*script\s*>'is");
539
+ // strip out preformatted tags
540
+ $this->remove_noise("'<\s*(?:code)[^>]*>(.*?)<\s*/\s*(?:code)\s*>'is");
541
+ // strip out server side scripts
542
+ $this->remove_noise("'(<\?)(.*?)(\?>)'s", true);
543
+ // strip smarty scripts
544
+ $this->remove_noise("'(\{\w)(.*?)(\})'s", true);
545
+
546
+ // parsing
547
+ while ($this->parse());
548
+ // end
549
+ $this->root->_[HDOM_INFO_END] = $this->cursor;
550
+ }
551
+
552
+ // load html from file
553
+ function load_file() {
554
+ $args = func_get_args();
555
+ $this->load(call_user_func_array('file_get_contents', $args), true);
556
+ }
557
+
558
+ // set callback function
559
+ function set_callback($function_name) {
560
+ $this->callback = $function_name;
561
+ }
562
+
563
+ // remove callback function
564
+ function remove_callback() {
565
+ $this->callback = null;
566
+ }
567
+
568
+ // save dom as string
569
+ function save($filepath='') {
570
+ $ret = $this->root->innertext();
571
+ if ($filepath!=='') file_put_contents($filepath, $ret);
572
+ return $ret;
573
+ }
574
+
575
+ // find dom node by css selector
576
+ function find($selector, $idx=null) {
577
+ return $this->root->find($selector, $idx);
578
+ }
579
+
580
+ // clean up memory due to php5 circular references memory leak...
581
+ function clear() {
582
+ foreach($this->nodes as $n) {$n->clear(); $n = null;}
583
+ if (isset($this->parent)) {$this->parent->clear(); unset($this->parent);}
584
+ if (isset($this->root)) {$this->root->clear(); unset($this->root);}
585
+ unset($this->doc);
586
+ unset($this->noise);
587
+ }
588
+
589
+ function dump($show_attr=true) {
590
+ $this->root->dump($show_attr);
591
+ }
592
+
593
+ // prepare HTML data and init everything
594
+ protected function prepare($str, $lowercase=true) {
595
+ $this->clear();
596
+ $this->doc = $str;
597
+ $this->pos = 0;
598
+ $this->cursor = 1;
599
+ $this->noise = array();
600
+ $this->nodes = array();
601
+ $this->lowercase = $lowercase;
602
+ $this->root = new simple_html_dom_node($this);
603
+ $this->root->tag = 'root';
604
+ $this->root->_[HDOM_INFO_BEGIN] = -1;
605
+ $this->root->nodetype = HDOM_TYPE_ROOT;
606
+ $this->parent = $this->root;
607
+ // set the length of content
608
+ $this->size = strlen($str);
609
+ if ($this->size>0) $this->char = $this->doc[0];
610
+ }
611
+
612
+ // parse html content
613
+ protected function parse() {
614
+ if (($s = $this->copy_until_char('<'))==='')
615
+ return $this->read_tag();
616
+
617
+ // text
618
+ $node = new simple_html_dom_node($this);
619
+ ++$this->cursor;
620
+ $node->_[HDOM_INFO_TEXT] = $s;
621
+ $this->link_nodes($node, false);
622
+ return true;
623
+ }
624
+
625
+ // read tag info
626
+ protected function read_tag() {
627
+ if ($this->char!=='<') {
628
+ $this->root->_[HDOM_INFO_END] = $this->cursor;
629
+ return false;
630
+ }
631
+ $begin_tag_pos = $this->pos;
632
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
633
+
634
+ // end tag
635
+ if ($this->char==='/') {
636
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
637
+ $this->skip($this->token_blank_t);
638
+ $tag = $this->copy_until_char('>');
639
+
640
+ // skip attributes in end tag
641
+ if (($pos = strpos($tag, ' '))!==false)
642
+ $tag = substr($tag, 0, $pos);
643
+
644
+ $parent_lower = strtolower($this->parent->tag);
645
+ $tag_lower = strtolower($tag);
646
+
647
+ if ($parent_lower!==$tag_lower) {
648
+ if (isset($this->optional_closing_tags[$parent_lower]) && isset($this->block_tags[$tag_lower])) {
649
+ $this->parent->_[HDOM_INFO_END] = 0;
650
+ $org_parent = $this->parent;
651
+
652
+ while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower)
653
+ $this->parent = $this->parent->parent;
654
+
655
+ if (strtolower($this->parent->tag)!==$tag_lower) {
656
+ $this->parent = $org_parent; // restore origonal parent
657
+ if ($this->parent->parent) $this->parent = $this->parent->parent;
658
+ $this->parent->_[HDOM_INFO_END] = $this->cursor;
659
+ return $this->as_text_node($tag);
660
+ }
661
+ }
662
+ else if (($this->parent->parent) && isset($this->block_tags[$tag_lower])) {
663
+ $this->parent->_[HDOM_INFO_END] = 0;
664
+ $org_parent = $this->parent;
665
+
666
+ while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower)
667
+ $this->parent = $this->parent->parent;
668
+
669
+ if (strtolower($this->parent->tag)!==$tag_lower) {
670
+ $this->parent = $org_parent; // restore origonal parent
671
+ $this->parent->_[HDOM_INFO_END] = $this->cursor;
672
+ return $this->as_text_node($tag);
673
+ }
674
+ }
675
+ else if (($this->parent->parent) && strtolower($this->parent->parent->tag)===$tag_lower) {
676
+ $this->parent->_[HDOM_INFO_END] = 0;
677
+ $this->parent = $this->parent->parent;
678
+ }
679
+ else
680
+ return $this->as_text_node($tag);
681
+ }
682
+
683
+ $this->parent->_[HDOM_INFO_END] = $this->cursor;
684
+ if ($this->parent->parent) $this->parent = $this->parent->parent;
685
+
686
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
687
+ return true;
688
+ }
689
+
690
+ $node = new simple_html_dom_node($this);
691
+ $node->_[HDOM_INFO_BEGIN] = $this->cursor;
692
+ ++$this->cursor;
693
+ $tag = $this->copy_until($this->token_slash);
694
+
695
+ // doctype, cdata & comments...
696
+ if (isset($tag[0]) && $tag[0]==='!') {
697
+ $node->_[HDOM_INFO_TEXT] = '<' . $tag . $this->copy_until_char('>');
698
+
699
+ if (isset($tag[2]) && $tag[1]==='-' && $tag[2]==='-') {
700
+ $node->nodetype = HDOM_TYPE_COMMENT;
701
+ $node->tag = 'comment';
702
+ } else {
703
+ $node->nodetype = HDOM_TYPE_UNKNOWN;
704
+ $node->tag = 'unknown';
705
+ }
706
+
707
+ if ($this->char==='>') $node->_[HDOM_INFO_TEXT].='>';
708
+ $this->link_nodes($node, true);
709
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
710
+ return true;
711
+ }
712
+
713
+ // text
714
+ if ($pos=strpos($tag, '<')!==false) {
715
+ $tag = '<' . substr($tag, 0, -1);
716
+ $node->_[HDOM_INFO_TEXT] = $tag;
717
+ $this->link_nodes($node, false);
718
+ $this->char = $this->doc[--$this->pos]; // prev
719
+ return true;
720
+ }
721
+
722
+ if (!preg_match("/^[\w-:]+$/", $tag)) {
723
+ $node->_[HDOM_INFO_TEXT] = '<' . $tag . $this->copy_until('<>');
724
+ if ($this->char==='<') {
725
+ $this->link_nodes($node, false);
726
+ return true;
727
+ }
728
+
729
+ if ($this->char==='>') $node->_[HDOM_INFO_TEXT].='>';
730
+ $this->link_nodes($node, false);
731
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
732
+ return true;
733
+ }
734
+
735
+ // begin tag
736
+ $node->nodetype = HDOM_TYPE_ELEMENT;
737
+ $tag_lower = strtolower($tag);
738
+ $node->tag = ($this->lowercase) ? $tag_lower : $tag;
739
+
740
+ // handle optional closing tags
741
+ if (isset($this->optional_closing_tags[$tag_lower]) ) {
742
+ while (isset($this->optional_closing_tags[$tag_lower][strtolower($this->parent->tag)])) {
743
+ $this->parent->_[HDOM_INFO_END] = 0;
744
+ $this->parent = $this->parent->parent;
745
+ }
746
+ $node->parent = $this->parent;
747
+ }
748
+
749
+ $guard = 0; // prevent infinity loop
750
+ $space = array($this->copy_skip($this->token_blank), '', '');
751
+
752
+ // attributes
753
+ do {
754
+ if ($this->char!==null && $space[0]==='') break;
755
+ $name = $this->copy_until($this->token_equal);
756
+ if($guard===$this->pos) {
757
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
758
+ continue;
759
+ }
760
+ $guard = $this->pos;
761
+
762
+ // handle endless '<'
763
+ if($this->pos>=$this->size-1 && $this->char!=='>') {
764
+ $node->nodetype = HDOM_TYPE_TEXT;
765
+ $node->_[HDOM_INFO_END] = 0;
766
+ $node->_[HDOM_INFO_TEXT] = '<'.$tag . $space[0] . $name;
767
+ $node->tag = 'text';
768
+ $this->link_nodes($node, false);
769
+ return true;
770
+ }
771
+
772
+ // handle mismatch '<'
773
+ if($this->doc[$this->pos-1]=='<') {
774
+ $node->nodetype = HDOM_TYPE_TEXT;
775
+ $node->tag = 'text';
776
+ $node->attr = array();
777
+ $node->_[HDOM_INFO_END] = 0;
778
+ $node->_[HDOM_INFO_TEXT] = substr($this->doc, $begin_tag_pos, $this->pos-$begin_tag_pos-1);
779
+ $this->pos -= 2;
780
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
781
+ $this->link_nodes($node, false);
782
+ return true;
783
+ }
784
+
785
+ if ($name!=='/' && $name!=='') {
786
+ $space[1] = $this->copy_skip($this->token_blank);
787
+ $name = $this->restore_noise($name);
788
+ if ($this->lowercase) $name = strtolower($name);
789
+ if ($this->char==='=') {
790
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
791
+ $this->parse_attr($node, $name, $space);
792
+ }
793
+ else {
794
+ //no value attr: nowrap, checked selected...
795
+ $node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_NO;
796
+ $node->attr[$name] = true;
797
+ if ($this->char!='>') $this->char = $this->doc[--$this->pos]; // prev
798
+ }
799
+ $node->_[HDOM_INFO_SPACE][] = $space;
800
+ $space = array($this->copy_skip($this->token_blank), '', '');
801
+ }
802
+ else
803
+ break;
804
+ } while($this->char!=='>' && $this->char!=='/');
805
+
806
+ $this->link_nodes($node, true);
807
+ $node->_[HDOM_INFO_ENDSPACE] = $space[0];
808
+
809
+ // check self closing
810
+ if ($this->copy_until_char_escape('>')==='/') {
811
+ $node->_[HDOM_INFO_ENDSPACE] .= '/';
812
+ $node->_[HDOM_INFO_END] = 0;
813
+ }
814
+ else {
815
+ // reset parent
816
+ if (!isset($this->self_closing_tags[strtolower($node->tag)])) $this->parent = $node;
817
+ }
818
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
819
+ return true;
820
+ }
821
+
822
+ // parse attributes
823
+ protected function parse_attr($node, $name, &$space) {
824
+ $space[2] = $this->copy_skip($this->token_blank);
825
+ switch($this->char) {
826
+ case '"':
827
+ $node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_DOUBLE;
828
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
829
+ $node->attr[$name] = $this->restore_noise($this->copy_until_char_escape('"'));
830
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
831
+ break;
832
+ case '\'':
833
+ $node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_SINGLE;
834
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
835
+ $node->attr[$name] = $this->restore_noise($this->copy_until_char_escape('\''));
836
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
837
+ break;
838
+ default:
839
+ $node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_NO;
840
+ $node->attr[$name] = $this->restore_noise($this->copy_until($this->token_attr));
841
+ }
842
+ }
843
+
844
+ // link node's parent
845
+ protected function link_nodes(&$node, $is_child) {
846
+ $node->parent = $this->parent;
847
+ $this->parent->nodes[] = $node;
848
+ if ($is_child)
849
+ $this->parent->children[] = $node;
850
+ }
851
+
852
+ // as a text node
853
+ protected function as_text_node($tag) {
854
+ $node = new simple_html_dom_node($this);
855
+ ++$this->cursor;
856
+ $node->_[HDOM_INFO_TEXT] = '</' . $tag . '>';
857
+ $this->link_nodes($node, false);
858
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
859
+ return true;
860
+ }
861
+
862
+ protected function skip($chars) {
863
+ $this->pos += strspn($this->doc, $chars, $this->pos);
864
+ $this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
865
+ }
866
+
867
+ protected function copy_skip($chars) {
868
+ $pos = $this->pos;
869
+ $len = strspn($this->doc, $chars, $pos);
870
+ $this->pos += $len;
871
+ $this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
872
+ if ($len===0) return '';
873
+ return substr($this->doc, $pos, $len);
874
+ }
875
+
876
+ protected function copy_until($chars) {
877
+ $pos = $this->pos;
878
+ $len = strcspn($this->doc, $chars, $pos);
879
+ $this->pos += $len;
880
+ $this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
881
+ return substr($this->doc, $pos, $len);
882
+ }
883
+
884
+ protected function copy_until_char($char) {
885
+ if ($this->char===null) return '';
886
+
887
+ if (($pos = strpos($this->doc, $char, $this->pos))===false) {
888
+ $ret = substr($this->doc, $this->pos, $this->size-$this->pos);
889
+ $this->char = null;
890
+ $this->pos = $this->size;
891
+ return $ret;
892
+ }
893
+
894
+ if ($pos===$this->pos) return '';
895
+ $pos_old = $this->pos;
896
+ $this->char = $this->doc[$pos];
897
+ $this->pos = $pos;
898
+ return substr($this->doc, $pos_old, $pos-$pos_old);
899
+ }
900
+
901
+ protected function copy_until_char_escape($char) {
902
+ if ($this->char===null) return '';
903
+
904
+ $start = $this->pos;
905
+ while(1) {
906
+ if (($pos = strpos($this->doc, $char, $start))===false) {
907
+ $ret = substr($this->doc, $this->pos, $this->size-$this->pos);
908
+ $this->char = null;
909
+ $this->pos = $this->size;
910
+ return $ret;
911
+ }
912
+
913
+ if ($pos===$this->pos) return '';
914
+
915
+ if ($this->doc[$pos-1]==='\\') {
916
+ $start = $pos+1;
917
+ continue;
918
+ }
919
+
920
+ $pos_old = $this->pos;
921
+ $this->char = $this->doc[$pos];
922
+ $this->pos = $pos;
923
+ return substr($this->doc, $pos_old, $pos-$pos_old);
924
+ }
925
+ }
926
+
927
+ // remove noise from html content
928
+ protected function remove_noise($pattern, $remove_tag=false) {
929
+ $count = preg_match_all($pattern, $this->doc, $matches, PREG_SET_ORDER|PREG_OFFSET_CAPTURE);
930
+
931
+ for ($i=$count-1; $i>-1; --$i) {
932
+ $key = '___noise___'.sprintf('% 3d', count($this->noise)+100);
933
+ $idx = ($remove_tag) ? 0 : 1;
934
+ $this->noise[$key] = $matches[$i][$idx][0];
935
+ $this->doc = substr_replace($this->doc, $key, $matches[$i][$idx][1], strlen($matches[$i][$idx][0]));
936
+ }
937
+
938
+ // reset the length of content
939
+ $this->size = strlen($this->doc);
940
+ if ($this->size>0) $this->char = $this->doc[0];
941
+ }
942
+
943
+ // restore noise to html content
944
+ function restore_noise($text) {
945
+ while(($pos=strpos($text, '___noise___'))!==false) {
946
+ $key = '___noise___'.$text[$pos+11].$text[$pos+12].$text[$pos+13];
947
+ if (isset($this->noise[$key]))
948
+ $text = substr($text, 0, $pos).$this->noise[$key].substr($text, $pos+14);
949
+ }
950
+ return $text;
951
+ }
952
+
953
+ function __toString() {
954
+ return $this->root->innertext();
955
+ }
956
+
957
+ function __get($name) {
958
+ switch($name) {
959
+ case 'outertext': return $this->root->innertext();
960
+ case 'innertext': return $this->root->innertext();
961
+ case 'plaintext': return $this->root->text();
962
+ }
963
+ }
964
+
965
+ // camel naming conventions
966
+ function childNodes($idx=-1) {return $this->root->childNodes($idx);}
967
+ function firstChild() {return $this->root->first_child();}
968
+ function lastChild() {return $this->root->last_child();}
969
+ function getElementById($id) {return $this->find("#$id", 0);}
970
+ function getElementsById($id, $idx=null) {return $this->find("#$id", $idx);}
971
+ function getElementByTagName($name) {return $this->find($name, 0);}
972
+ function getElementsByTagName($name, $idx=-1) {return $this->find($name, $idx);}
973
+ function loadFile() {$args = func_get_args();$this->load(call_user_func_array('file_get_contents', $args), true);}
974
+ }
975
+ ?>
app/code/community/OnTechnology/Checkout/controllers/Checkout/system.xml ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * ezimerchant Payment Extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @category ezimerchant
17
+ * @package OnTechnology_Ezimerchant
18
+ * @author On Technology
19
+ * @copyright Copyright (c) 2010 On Technology Pty. Ltd. (http://www.ezimerchant.com/)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ -->
23
+ <config>
24
+ <sections>
25
+ <payment translate="label" module="payment">
26
+ <groups>
27
+ <ezimerchant translate="label">
28
+ <label>ezimerchant</label>
29
+ <frontend_type>text</frontend_type>
30
+ <sort_order>2</sort_order>
31
+ <show_in_default>1</show_in_default>
32
+ <show_in_website>1</show_in_website>
33
+ <show_in_store>0</show_in_store>
34
+ <fields>
35
+ <active translate="label">
36
+ <label>Enabled</label>
37
+ <frontend_type>select</frontend_type>
38
+ <source_model>adminhtml/system_config_source_yesno</source_model>
39
+ <sort_order>1</sort_order>
40
+ <show_in_default>1</show_in_default>
41
+ <show_in_website>1</show_in_website>
42
+ <show_in_store>0</show_in_store>
43
+ </active>
44
+ <order_status translate="label">
45
+ <label>New order status</label>
46
+ <frontend_type>select</frontend_type>
47
+ <source_model>adminhtml/system_config_source_order_status</source_model>
48
+ <sort_order>9</sort_order>
49
+ <show_in_default>1</show_in_default>
50
+ <show_in_website>1</show_in_website>
51
+ <show_in_store>0</show_in_store>
52
+ </order_status>
53
+ <customer_group_access translate="label">
54
+ <label>Customer Group Access</label>
55
+ <frontend_type>select</frontend_type>
56
+ <source_model>ezimerchant/config_customerGroupAccess</source_model>
57
+ <sort_order>3</sort_order>
58
+ <show_in_default>1</show_in_default>
59
+ <show_in_website>1</show_in_website>
60
+ <show_in_store>0</show_in_store>
61
+ </customer_group_access>
62
+ <customer_group translate="label">
63
+ <label>Customer Group</label>
64
+ <frontend_type>select</frontend_type>
65
+ <source_model>mage_adminhtml_model_system_config_source_customer_group</source_model>
66
+ <sort_order>4</sort_order>
67
+ <show_in_default>1</show_in_default>
68
+ <show_in_website>1</show_in_website>
69
+ <show_in_store>0</show_in_store>
70
+ </customer_group>
71
+ <sort_order translate="label">
72
+ <label>Sort order</label>
73
+ <frontend_type>text</frontend_type>
74
+ <sort_order>100</sort_order>
75
+ <show_in_default>1</show_in_default>
76
+ <show_in_website>1</show_in_website>
77
+ <show_in_store>0</show_in_store>
78
+ </sort_order>
79
+ <title translate="label">
80
+ <label>Title</label>
81
+ <frontend_type>text</frontend_type>
82
+ <sort_order>1</sort_order>
83
+ <show_in_default>1</show_in_default>
84
+ <show_in_website>1</show_in_website>
85
+ <show_in_store>0</show_in_store>
86
+ </title>
87
+ <merchantid translate="label">
88
+ <label>Merchant ID</label>
89
+ <frontend_type>text</frontend_type>
90
+ <sort_order>20</sort_order>
91
+ <show_in_default>1</show_in_default>
92
+ <show_in_website>1</show_in_website>
93
+ <show_in_store>0</show_in_store>
94
+ </merchantid>
95
+ <apikey translate="label">
96
+ <label>API Key</label>
97
+ <frontend_type>password</frontend_type>
98
+ <sort_order>21</sort_order>
99
+ <show_in_default>1</show_in_default>
100
+ <show_in_website>1</show_in_website>
101
+ <show_in_store>0</show_in_store>
102
+ </apikey>
103
+ <payment_action translate="label">
104
+ <label>Action</label>
105
+ <frontend_type>select</frontend_type>
106
+ <source_model>ezimerchant/paystep_paymentAction</source_model>
107
+ <sort_order>22</sort_order>
108
+ <show_in_default>1</show_in_default>
109
+ <show_in_website>1</show_in_website>
110
+ <show_in_store>0</show_in_store>
111
+ </payment_action>
112
+ <cctypes translate="label">
113
+ <label>Credit Card Types</label>
114
+ <frontend_type>multiselect</frontend_type>
115
+ <source_model>adminhtml/system_config_source_payment_cctype</source_model>
116
+ <sort_order>30</sort_order>
117
+ <show_in_default>1</show_in_default>
118
+ <show_in_website>1</show_in_website>
119
+ <show_in_store>0</show_in_store>
120
+ </cctypes>
121
+ <debug translate="label">
122
+ <label>Debug</label>
123
+ <frontend_type>select</frontend_type>
124
+ <source_model>adminhtml/system_config_source_yesno</source_model>
125
+ <sort_order>40</sort_order>
126
+ <show_in_default>1</show_in_default>
127
+ <show_in_website>1</show_in_website>
128
+ <show_in_store>0</show_in_store>
129
+ </debug>
130
+ <allowspecific translate="label">
131
+ <label>Payment from applicable countries</label>
132
+ <frontend_type>allowspecific</frontend_type>
133
+ <sort_order>50</sort_order>
134
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
135
+ <show_in_default>1</show_in_default>
136
+ <show_in_website>1</show_in_website>
137
+ <show_in_store>1</show_in_store>
138
+ </allowspecific>
139
+ <specificcountry translate="label">
140
+ <label>Payment from Specific countries</label>
141
+ <frontend_type>multiselect</frontend_type>
142
+ <sort_order>51</sort_order>
143
+ <source_model>adminhtml/system_config_source_country</source_model>
144
+ <show_in_default>1</show_in_default>
145
+ <show_in_website>1</show_in_website>
146
+ <show_in_store>1</show_in_store>
147
+ </specificcountry>
148
+
149
+ </fields>
150
+ </ezimerchant>
151
+ </groups>
152
+ </payment>
153
+ </sections>
154
+ </config>
app/code/community/OnTechnology/Checkout/etc/config.xml ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * ezimerchant Payment Extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @category ezimerchant
17
+ * @package OnTechnology_Ezimerchant
18
+ * @author On Technology
19
+ * @copyright Copyright (c) 2011 On Technology Pty. Ltd. (http://www.ezimerchant.com/)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ -->
23
+ <config>
24
+ <frontend>
25
+ <routers>
26
+ <checkout>
27
+ <args>
28
+ <modules>
29
+ <OnTechnology_Checkout before="Mage_Checkout">OnTechnology_Checkout_Checkout</OnTechnology_Checkout>
30
+ </modules>
31
+ </args>
32
+ </checkout>
33
+ </routers>
34
+ </frontend>
35
+ </config>
36
+
app/code/community/OnTechnology/Ezimerchant/Block/Paystep/Form.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+
5
+ class OnTechnology_Ezimerchant_Block_Paystep_Form extends Mage_Payment_Block_Form
6
+ {
7
+ protected function _construct()
8
+ {
9
+ $this->setTemplate('ontechnology/ezimerchant/form.phtml');
10
+ parent::_construct();
11
+ }
12
+ }
app/code/community/OnTechnology/Ezimerchant/Helper/Data.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ezimerchant Payment Extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category ezimerchant
16
+ * @package OnTechnology_Ezimerchant
17
+ * @author On Technology
18
+ * @copyright Copyright (c) 2010 On Technology Pty. Ltd. (http://www.ezimerchant.com/)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Data helper
24
+ */
25
+ class OnTechnology_Ezimerchant_Helper_Data extends Mage_Core_Helper_Abstract
26
+ {
27
+
28
+ }
app/code/community/OnTechnology/Ezimerchant/Model/Config/CustomerGroupAccess.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ezimerchant Payment Extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category ezimerchant
16
+ * @package OnTechnology_ezimerchant
17
+ * @author On Technology
18
+ * @copyright Copyright (c) 2011 On Technology Pty. Ltd. (http://www.ezimerchant.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Listing of possible options for restricting access based on customer groups
24
+ *
25
+ * @category ezimerchant
26
+ * @package OnTechnology_ezimerchant
27
+ */
28
+ class OnTechnology_Ezimerchant_Model_Config_CustomerGroupAccess
29
+ {
30
+ public function toOptionArray()
31
+ {
32
+ return array(
33
+ array('value' => 0, 'label' => Mage::helper('adminhtml')->__('No restrictions')),
34
+ array('value' => 1, 'label' => Mage::helper('adminhtml')->__('Only allow group ...')),
35
+ array('value' => 2, 'label' => Mage::helper('adminhtml')->__('Allow all groups except ...'))
36
+ );
37
+ }
38
+ }
app/code/community/OnTechnology/Ezimerchant/Model/Config/CustomerGroups.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ezimerchant Payment Extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category ezimerchant
16
+ * @package OnTechnology_ezimerchant
17
+ * @author On Technology
18
+ * @copyright Copyright (c) 2011 On Technology Pty. Ltd. (http://www.ezimerchant.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Listing of customer groups available in the shop.
24
+ *
25
+ * @category ezimerchant
26
+ * @package OnTechnology_ezimerchant
27
+ */
28
+ class OnTechnology_Ezimerchant_Model_Config_CustomerGroups
29
+ {
30
+ public function toOptionArray()
31
+ {
32
+ $storeId = Mage::app()->getStore()->getId();
33
+ $collection = Mage::getModel('customer/group')->setStoreId($storeId)->getCollection();
34
+
35
+ foreach($collection as $group)
36
+ {
37
+ $options[] = array('value' => (int)$group->getCustomerGroupId(), 'label' => $group->getCustomerGroupCode());
38
+ }
39
+
40
+ return $options;
41
+ }
42
+ }
app/code/community/OnTechnology/Ezimerchant/Model/Paystep.php ADDED
@@ -0,0 +1,283 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ezimerchant Payment Extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Ezimerchant
16
+ * @package OnTechnology_Ezimerchant
17
+ * @author On Technology
18
+ * @copyright Copyright (c) 2010 On Technology Pty. Ltd. (http://www.ezimerchant.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ class OnTechnology_Ezimerchant_Model_Paystep extends Mage_Payment_Model_Method_Abstract
23
+ {
24
+ protected $logfile = null;
25
+
26
+ const REQUEST_AMOUNT_EDITABLE = 'N';
27
+
28
+ protected $_code = 'paystep';
29
+ protected $_formBlockType = 'ezimerchant/paystep_form';
30
+ protected $_allowCurrencyCode = array('AUD', 'EUR', 'GBP', 'NZD', 'USD');
31
+
32
+ public function assignData($data)
33
+ {
34
+ $details = array();
35
+ if ($this->getUsername())
36
+ {
37
+ $details['username'] = $this->getUsername();
38
+ }
39
+ if (!empty($details))
40
+ {
41
+ $this->getInfoInstance()->setAdditionalData(serialize($details));
42
+ }
43
+ return $this;
44
+ }
45
+
46
+ public function getUsername()
47
+ {
48
+ return $this->getConfigData('username');
49
+ }
50
+
51
+ public function getPassword()
52
+ {
53
+ return $this->getConfigData('password');
54
+ }
55
+
56
+ public function getCheckout()
57
+ {
58
+ return Mage::getSingleton('checkout/session');
59
+ }
60
+
61
+ public function getQuote()
62
+ {
63
+ return $this->getCheckout()->getQuote();
64
+ }
65
+
66
+ public function validate()
67
+ {
68
+ parent::validate();
69
+ $currency_code = $this->getQuote()->getBaseCurrencyCode();
70
+ if (!in_array($currency_code,$this->_allowCurrencyCode)) {
71
+ Mage::throwException(Mage::helper('dps')->__('Selected currency code ('.$currency_code.') is not compatible with Payment Express'));
72
+ }
73
+ return $this;
74
+ }
75
+
76
+ public function onOrderValidate(Mage_Sales_Model_Order_Payment $payment)
77
+ {
78
+ return $this;
79
+ }
80
+
81
+ public function onInvoiceCreate(Mage_Sales_Model_Invoice_Payment $payment)
82
+ {
83
+
84
+ }
85
+
86
+ public function canCapture()
87
+ {
88
+ return true;
89
+ }
90
+
91
+
92
+ public function getOrderPlaceRedirectUrl()
93
+ {
94
+
95
+ $logfile = fopen('/var/www/vhosts/jschiller.ezimerchant.biz/httpdocs/log.txt', 'a');
96
+
97
+ LogToFile($logfile, 'getOrderPlaceRedirectUrl()');
98
+
99
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
100
+
101
+ LogToFile($logfile, '1');
102
+
103
+ $billingAddress = $quote->getShippingAddress();
104
+
105
+ $shippingAddress = $quote->getShippingAddress();
106
+
107
+ $items = $quote->getAllVisibleItems();
108
+
109
+ if(isset($items))
110
+ LogToFile($logfile, 'WE HAVE IT');
111
+ else
112
+ LogToFile($logfile, 'WE DONT HAVE IT');
113
+
114
+ /*
115
+ LogToFile($logfile, 'Billing Name:'.$billingAddress->getName());
116
+ LogToFile($logfile, 'Billing Company:'.$billingAddress->getCompany());
117
+ LogToFile($logfile, 'Billing Street1:'.$billingAddress->getStreet1());
118
+ LogToFile($logfile, 'Billing Street2:'.$billingAddress->getStreet2());
119
+ LogToFile($logfile, 'Billing Street3:'.$billingAddress->getStreet3());
120
+ LogToFile($logfile, 'Billing Street4:'.$billingAddress->getStreet4());
121
+ LogToFile($logfile, 'Billing City:'.$billingAddress->getCity());
122
+ LogToFile($logfile, 'Billing Region ID:'.$billingAddress->getRegionId());
123
+ LogToFile($logfile, 'Billing Region Code:'.$billingAddress->getRegionCode());
124
+ LogToFile($logfile, 'Billing Region:'.$billingAddress->getRegion());
125
+ LogToFile($logfile, 'Billing Postal Code:'.$billingAddress->getPostcode());
126
+ LogToFile($logfile, 'Billing Country:'.$billingAddress->getCountry());
127
+ LogToFile($logfile, 'Billing Email:'.$billingAddress->getEmail());
128
+ LogToFile($logfile, 'Billing Phone:'.$billingAddress->getTelephone());
129
+ LogToFile($logfile, 'Billing Fax:'.$billingAddress->getFax());
130
+
131
+ LogToFile($logfile, 'Shipping Name:'.$shippingAddress->getName());
132
+ LogToFile($logfile, 'Shipping Company:'.$shippingAddress->getCompany());
133
+ LogToFile($logfile, 'Shipping Street1:'.$shippingAddress->getStreet1());
134
+ LogToFile($logfile, 'Shipping Street2:'.$shippingAddress->getStreet2());
135
+ LogToFile($logfile, 'Shipping Street3:'.$shippingAddress->getStreet3());
136
+ LogToFile($logfile, 'Shipping Street4:'.$shippingAddress->getStreet4());
137
+ LogToFile($logfile, 'Shipping City:'.$shippingAddress->getCity());
138
+ LogToFile($logfile, 'Shipping Region ID:'.$shippingAddress->getRegionId());
139
+ LogToFile($logfile, 'Shipping Region Code:'.$shippingAddress->getRegionCode());
140
+ LogToFile($logfile, 'Shipping Region:'.$shippingAddress->getRegion());
141
+ LogToFile($logfile, 'Shipping Postal Code:'.$shippingAddress->getPostcode());
142
+ LogToFile($logfile, 'Shipping Country:'.$shippingAddress->getCountry());
143
+ LogToFile($logfile, 'Shipping Email:'.$shippingAddress->getEmail());
144
+ LogToFile($logfile, 'Shipping Phone:'.$shippingAddress->getTelephone());
145
+ LogToFile($logfile, 'Shipping Fax:'.$shippingAddress->getFax());
146
+ */
147
+ $paramhash = array();
148
+
149
+ $paramhash["BILLNAME"] = $billingAddress->getName();
150
+ $paramhash["BILLCOMPANY"] = $billingAddress->getCompany();
151
+ $paramhash["BILLEMAIL"] = $billingAddress->getEmail();
152
+ $paramhash["BILLPHONE"] = $billingAddress->getTelephone();
153
+ $paramhash["BILLFAX"] = $billingAddress->getFax();
154
+ $paramhash["BILLADDRESS1"] = $billingAddress->getStreet1();
155
+ $paramhash["BILLADDRESS2"] = $billingAddress->getStreet2();
156
+ $paramhash["BILLADDRESS3"] = $billingAddress->getStreet3();
157
+ $paramhash["BILLPLACE"] = $billingAddress->getCity();
158
+ $paramhash["BILLDIVISION"] = $billingAddress->getRegion();
159
+ $paramhash["BILLPOSTALCODE"] = $billingAddress->getPostcode();
160
+ $paramhash["BILLCOUNTRYCODE"] = $billingAddress->getCountry();
161
+
162
+ $paramhash["SHIPNAME"] = $shippingAddress->getName();
163
+ $paramhash["SHIPCOMPANY"] = $shippingAddress->getCompany();
164
+ $paramhash["SHIPEMAIL"] = $shippingAddress->getEmail();
165
+ $paramhash["SHIPPHONE"] = $shippingAddress->getTelephone();
166
+ $paramhash["SHIPADDRESS1"] = $shippingAddress->getStreet1();
167
+ $paramhash["SHIPADDRESS2"] = $shippingAddress->getStreet2();
168
+ $paramhash["SHIPADDRESS3"] = $shippingAddress->getStreet3();
169
+ $paramhash["SHIPPLACE"] = $shippingAddress->getCity();
170
+ $paramhash["SHIPDIVISION"] = $shippingAddress->getRegion();
171
+ $paramhash["SHIPPOSTALCODE"] = $shippingAddress->getPostcode();
172
+ $paramhash["SHIPCOUNTRYCODE"] = $shippingAddress->getCountry();
173
+
174
+ $itemidx = 0;
175
+ $item = $items[0]->toArray();
176
+
177
+ foreach ($items as $item)
178
+ {
179
+ $item = $item->toArray();
180
+
181
+ LogToFile($logfile, print_r($item, true));
182
+
183
+ $paramhash["PRODUCTQUANTITY(" . $itemidx . ")"] = $item['qty'];
184
+ $paramhash["PRODUCTCODE(" . $itemidx . ")"] = $item['product']['sku'];
185
+ $paramhash["PRODUCTNAME(" . $itemidx . ")"] = $item['product']['name'];
186
+ $paramhash["PRODUCTPRICE(" . $itemidx . ")"] = $item['price'];
187
+
188
+ $itemidx = $itemidx + 1;
189
+ }
190
+
191
+ $paramhash["ACTION"] = "CreateOrder";
192
+ $paramhash["CANCELURL"] = Mage::getUrl('checkout/onepage/fail');
193
+ $paramhash["RETURNURL"] = Mage::getUrl('checkout/onepage/success');
194
+ $paramhash["NOTIFYURL"] = Mage::getUrl('checkout/onepage/notify');
195
+
196
+ LogToFile($logfile, print_r($paramhash, true));
197
+
198
+ fclose($logfile);
199
+
200
+ $username = Mage::getStoreConfig('payment/ezimerchant/username');
201
+ $merchantid = Mage::getStoreConfig('payment/ezimerchant/merchantid');
202
+ $password = Mage::getStoreConfig('payment/ezimerchant/password');
203
+
204
+ $ch = curl_init();
205
+ curl_setopt($ch, CURLOPT_URL, "https://api.ezimerchant.com/".$merchantid."/orders/");
206
+ curl_setopt($ch, CURLOPT_HEADER, 0);
207
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
208
+ curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
209
+ curl_setopt($ch, CURL_HTTPHEADER, array( "Content-Type: application/x-www-form-urlencoded" ));
210
+ curl_setopt($ch, CURLOPT_USERPWD, "".$username.":".$password);
211
+ curl_setopt($ch, CURLOPT_POST, 1);
212
+ curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($paramhash));
213
+
214
+ $apiresponse = curl_exec($ch);
215
+ curl_close($ch);
216
+
217
+ $xml = simplexml_load_string($apiresponse);
218
+
219
+ return (string)$xml->entry->link["href"];
220
+
221
+
222
+
223
+
224
+ // return 'http://www.google.com/';
225
+ }
226
+
227
+
228
+ public function isAvailable($quote = null)
229
+ {
230
+ if($this->getDebug())
231
+ {
232
+ $writer = new Zend_Log_Writer_Stream($this->getLogPath());
233
+ $logger = new Zend_Log($writer);
234
+ $logger->info("entering isAvailable()");
235
+ }
236
+
237
+ $groupAccess = $this->getConfigData('customer_group_access');
238
+ $group = $this->getConfigData('customer_group');
239
+
240
+ if($this->getDebug())
241
+ {
242
+ $logger->info("Customer Group Access: " . $groupAccess);
243
+ $logger->info("Customer Group: " . $group);
244
+ $logger->info("Quoted Customer Group: " . $quote->getCustomerGroupId());
245
+ }
246
+
247
+ if($groupAccess == 0 || $group === '')
248
+ {
249
+ // No restrictions on access
250
+ return true;
251
+ }
252
+ elseif($groupAccess == 1)
253
+ {
254
+ // Only allow customer to access this method if they are part of the
255
+ // specified group
256
+ if($quote->getCustomerGroupId() == $group)
257
+ {
258
+ return true;
259
+ }
260
+ }
261
+ elseif($groupAccess == 2)
262
+ {
263
+ // Only allow customer to access this method if they are NOT part
264
+ // of the specified group
265
+ if($quote->getCustomerGroupId() != $group)
266
+ {
267
+ return true;
268
+ }
269
+ }
270
+
271
+ // Default, restrict access
272
+ return false;
273
+ }
274
+
275
+ }
276
+
277
+
278
+ function LogToFile($logfile, $message)
279
+ {
280
+ fprintf($logfile, $message);
281
+ fflush($logfile);
282
+ }
283
+
app/code/community/OnTechnology/Ezimerchant/Model/Paystep/PaymentAction.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ezimerchant Payment Extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category ezimerchant
16
+ * @package OnTechnology_ezimerchant
17
+ * @author On Technology
18
+ * @copyright Copyright (c) 2011 On Technology Pty. Ltd. (http://www.ezimerchant.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ class OnTechnology_Ezimerchant_Model_Paystep_PaymentAction
23
+ {
24
+ public function toOptionArray()
25
+ {
26
+ return array(
27
+ array(
28
+ 'value' => 'authorize_capture',
29
+ 'label' => Mage::helper('ezimerchant')->__('Authorise and Capture')
30
+ ),
31
+ array(
32
+ 'value' => 'authorize',
33
+ 'label' => Mage::helper('ezimerchant')->__('Authorise')
34
+ )
35
+ );
36
+ }
37
+ }
38
+
39
+ ?>
40
+
app/code/community/OnTechnology/Ezimerchant/controllers/PaystepController.php ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ezimerchant Payment Extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category ezimerchant
16
+ * @package OnTechnology_ezimerchant
17
+ * @author On Technology
18
+ * @copyright Copyright (c) 2011 On Technology Pty. Ltd. (http://www.ezimerchant.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * ezimerchant Checkout Controller
24
+ *
25
+ */
26
+ class OnTechnology_Ezimerchant_PaystepController extends Mage_Core_Controller_Front_Action
27
+ {
28
+ protected function _expireAjax()
29
+ {
30
+ if (!Mage::getSingleton('checkout/session')->getQuote()->hasItems()) {
31
+ $this->getResponse()->setHeader('HTTP/1.1','403 Session Expired');
32
+ exit;
33
+ }
34
+ }
35
+
36
+ /**
37
+ * When a customer chooses DPS on Checkout/DPS page
38
+ */
39
+ public function redirectAction()
40
+ {
41
+ echo('did I get to redirect?');
42
+ die();
43
+ $session = Mage::getSingleton('checkout/session');
44
+ $session->setPxpayQuoteId($session->getQuoteId());
45
+ $this->getResponse()->setBody($this->getLayout()->createBlock('dps/pxpay_redirect')->toHtml());
46
+ $session->unsQuoteId();
47
+ }
48
+
49
+ /**
50
+ * When a customer cancels payment from DPS.
51
+ */
52
+ public function cancelAction()
53
+ {
54
+ echo('did I get to cancel?');
55
+ die();
56
+ $session = Mage::getSingleton('checkout/session');
57
+ $session->setQuoteId($session->getPxpayQuoteId(true));
58
+ $this->_redirect('checkout/cart');
59
+ }
60
+
61
+ /**
62
+ * Where ezimerchant returns with a success.
63
+ */
64
+ public function successAction()
65
+ {
66
+ echo('did I get to success?');
67
+ die();
68
+
69
+ $session = Mage::getSingleton('checkout/session');
70
+ $session->setQuoteId($session->getPxpayQuoteId(true));
71
+
72
+ // Set the quote as inactive after returning
73
+ Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
74
+
75
+ // Send a confirmation email to customer
76
+ $order = Mage::getModel('sales/order');
77
+ $order->load(Mage::getSingleton('checkout/session')->getLastOrderId());
78
+ if($order->getId()){
79
+ $order->setStatus('processing')->save();
80
+ $order->sendNewOrderEmail();
81
+ }
82
+
83
+ Mage::getSingleton('checkout/session')->unsQuoteId();
84
+
85
+ $this->_redirect('checkout/onepage/success');
86
+ }
87
+
88
+ /**
89
+ * Where ezimerchant returns with a failure.
90
+ */
91
+ public function failAction()
92
+ {
93
+ echo('did I get to fail?');
94
+ die();
95
+
96
+ $order = Mage::getModel('sales/order');
97
+ $order->load(Mage::getSingleton('checkout/session')->getLastOrderId());
98
+ if($order->getId()){
99
+ $order->setStatus('canceled')->save();
100
+ }
101
+
102
+ $this->_redirect('checkout/onepage/failure');
103
+ }
104
+ }
app/code/community/OnTechnology/Ezimerchant/etc/config.xml ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * ezimerchant Payment Extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @category ezimerchant
17
+ * @package OnTechnology_Ezimerchant
18
+ * @author On Technology
19
+ * @copyright Copyright (c) 2010 On Technology Pty. Ltd. (http://www.ezimerchant.com/)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ -->
23
+ <config>
24
+ <modules>
25
+ <OnTechnology_Ezimerchant>
26
+ <version>1.0</version>
27
+ <depends>
28
+ <Mage_Payment />
29
+ </depends>
30
+ </OnTechnology_Ezimerchant>
31
+ </modules>
32
+ <global>
33
+ <models>
34
+ <ezimerchant>
35
+ <class>OnTechnology_Ezimerchant_Model</class>
36
+ </ezimerchant>
37
+ </models>
38
+ <helpers>
39
+ <ezimerchant>
40
+ <class>OnTechnology_Ezimerchant_Helper</class>
41
+ </ezimerchant>
42
+ </helpers>
43
+ <blocks>
44
+ <ezimerchant>
45
+ <class>OnTechnology_Ezimerchant_Block</class>
46
+ </ezimerchant>
47
+ </blocks>
48
+ <resources>
49
+ <ezimerchant_setup>
50
+ <setup>
51
+ <module>OnTechnology_Ezimerchant</module>
52
+ </setup>
53
+ <connection>
54
+ <use>directory_setup</use>
55
+ </connection>
56
+ </ezimerchant_setup>
57
+ <ezimerchant_write>
58
+ <connection>
59
+ <use>local_write</use>
60
+ </connection>
61
+ </ezimerchant_write>
62
+ <ezimerchant_read>
63
+ <connection>
64
+ <use>local_read</use>
65
+ </connection>
66
+ </ezimerchant_read>
67
+ </resources>
68
+ </global>
69
+ <default>
70
+ <payment>
71
+ <paystep>
72
+ <active>0</active>
73
+ <model>ezimerchant/paystep</model>
74
+ <title>ezimerchant</title>
75
+ <customer_group_access>0</customer_group_access>
76
+ <customer_group>0</customer_group>
77
+ <allowspecific>0</allowspecific>
78
+ <debug>0</debug>
79
+ <cctypes>VI,MC</cctypes>
80
+ <payment_action>authorize_capture</payment_action>
81
+ </paystep>
82
+ </payment>
83
+ </default>
84
+ </config>
app/code/community/OnTechnology/Ezimerchant/etc/system.xml ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * ezimerchant Payment Extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @category ezimerchant
17
+ * @package OnTechnology_Ezimerchant
18
+ * @author On Technology
19
+ * @copyright Copyright (c) 2010 On Technology Pty. Ltd. (http://www.ezimerchant.com/)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ -->
23
+ <config>
24
+ <sections>
25
+ <payment translate="label" module="payment">
26
+ <groups>
27
+ <ezimerchant translate="label">
28
+ <label>ezimerchant</label>
29
+ <frontend_type>text</frontend_type>
30
+ <sort_order>2</sort_order>
31
+ <show_in_default>1</show_in_default>
32
+ <show_in_website>1</show_in_website>
33
+ <show_in_store>0</show_in_store>
34
+ <fields>
35
+ <active translate="label">
36
+ <label>Enabled</label>
37
+ <frontend_type>select</frontend_type>
38
+ <source_model>adminhtml/system_config_source_yesno</source_model>
39
+ <sort_order>1</sort_order>
40
+ <show_in_default>1</show_in_default>
41
+ <show_in_website>1</show_in_website>
42
+ <show_in_store>0</show_in_store>
43
+ </active>
44
+ <order_status translate="label">
45
+ <label>New order status</label>
46
+ <frontend_type>select</frontend_type>
47
+ <source_model>adminhtml/system_config_source_order_status</source_model>
48
+ <sort_order>9</sort_order>
49
+ <show_in_default>1</show_in_default>
50
+ <show_in_website>1</show_in_website>
51
+ <show_in_store>0</show_in_store>
52
+ </order_status>
53
+ <customer_group_access translate="label">
54
+ <label>Customer Group Access</label>
55
+ <frontend_type>select</frontend_type>
56
+ <source_model>ezimerchant/config_customerGroupAccess</source_model>
57
+ <sort_order>3</sort_order>
58
+ <show_in_default>1</show_in_default>
59
+ <show_in_website>1</show_in_website>
60
+ <show_in_store>0</show_in_store>
61
+ </customer_group_access>
62
+ <customer_group translate="label">
63
+ <label>Customer Group</label>
64
+ <frontend_type>select</frontend_type>
65
+ <source_model>mage_adminhtml_model_system_config_source_customer_group</source_model>
66
+ <sort_order>4</sort_order>
67
+ <show_in_default>1</show_in_default>
68
+ <show_in_website>1</show_in_website>
69
+ <show_in_store>0</show_in_store>
70
+ </customer_group>
71
+ <sort_order translate="label">
72
+ <label>Sort order</label>
73
+ <frontend_type>text</frontend_type>
74
+ <sort_order>100</sort_order>
75
+ <show_in_default>1</show_in_default>
76
+ <show_in_website>1</show_in_website>
77
+ <show_in_store>0</show_in_store>
78
+ </sort_order>
79
+ <title translate="label">
80
+ <label>Title</label>
81
+ <frontend_type>text</frontend_type>
82
+ <sort_order>1</sort_order>
83
+ <show_in_default>1</show_in_default>
84
+ <show_in_website>1</show_in_website>
85
+ <show_in_store>0</show_in_store>
86
+ </title>
87
+ <merchantid translate="label">
88
+ <label>Merchant ID</label>
89
+ <frontend_type>text</frontend_type>
90
+ <sort_order>20</sort_order>
91
+ <show_in_default>1</show_in_default>
92
+ <show_in_website>1</show_in_website>
93
+ <show_in_store>0</show_in_store>
94
+ </merchantid>
95
+ <apikey translate="label">
96
+ <label>API Key</label>
97
+ <frontend_type>password</frontend_type>
98
+ <sort_order>21</sort_order>
99
+ <show_in_default>1</show_in_default>
100
+ <show_in_website>1</show_in_website>
101
+ <show_in_store>0</show_in_store>
102
+ </apikey>
103
+ <payment_action translate="label">
104
+ <label>Action</label>
105
+ <frontend_type>select</frontend_type>
106
+ <source_model>ezimerchant/paystep_paymentAction</source_model>
107
+ <sort_order>22</sort_order>
108
+ <show_in_default>1</show_in_default>
109
+ <show_in_website>1</show_in_website>
110
+ <show_in_store>0</show_in_store>
111
+ </payment_action>
112
+ <cctypes translate="label">
113
+ <label>Credit Card Types</label>
114
+ <frontend_type>multiselect</frontend_type>
115
+ <source_model>adminhtml/system_config_source_payment_cctype</source_model>
116
+ <sort_order>30</sort_order>
117
+ <show_in_default>1</show_in_default>
118
+ <show_in_website>1</show_in_website>
119
+ <show_in_store>0</show_in_store>
120
+ </cctypes>
121
+ <debug translate="label">
122
+ <label>Debug</label>
123
+ <frontend_type>select</frontend_type>
124
+ <source_model>adminhtml/system_config_source_yesno</source_model>
125
+ <sort_order>40</sort_order>
126
+ <show_in_default>1</show_in_default>
127
+ <show_in_website>1</show_in_website>
128
+ <show_in_store>0</show_in_store>
129
+ </debug>
130
+ <allowspecific translate="label">
131
+ <label>Payment from applicable countries</label>
132
+ <frontend_type>allowspecific</frontend_type>
133
+ <sort_order>50</sort_order>
134
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
135
+ <show_in_default>1</show_in_default>
136
+ <show_in_website>1</show_in_website>
137
+ <show_in_store>1</show_in_store>
138
+ </allowspecific>
139
+ <specificcountry translate="label">
140
+ <label>Payment from Specific countries</label>
141
+ <frontend_type>multiselect</frontend_type>
142
+ <sort_order>51</sort_order>
143
+ <source_model>adminhtml/system_config_source_country</source_model>
144
+ <show_in_default>1</show_in_default>
145
+ <show_in_website>1</show_in_website>
146
+ <show_in_store>1</show_in_store>
147
+ </specificcountry>
148
+
149
+ </fields>
150
+ </ezimerchant>
151
+ </groups>
152
+ </payment>
153
+ </sections>
154
+ </config>
app/code/community/OnTechnology/Mobile/Controller/Varien/Router/Standard.php ADDED
@@ -0,0 +1,236 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function header_callback($ch, $header)
4
+ {
5
+ header($header, false);
6
+
7
+ return strlen($header);
8
+ }
9
+
10
+ function write_callback($ch, $data)
11
+ {
12
+ echo $data;
13
+
14
+ return strlen($data);
15
+ }
16
+
17
+ class OnTechnology_Mobile_Controller_Varien_Router_Standard extends Mage_Core_Controller_Varien_Router_Standard
18
+ {
19
+
20
+ /**
21
+ * Match the request
22
+ *
23
+ * @param Zend_Controller_Request_Http $request
24
+ * @return boolean
25
+ */
26
+ public function match(Zend_Controller_Request_Http $request)
27
+ {
28
+ //checking before even try to find out that current module
29
+ //should use this router
30
+ if (!$this->_beforeModuleMatch()) {
31
+ return false;
32
+ }
33
+
34
+ if(strstr($_SERVER['HTTP_USER_AGENT'],'iPhone') || strstr($_SERVER['HTTP_USER_AGENT'],'iPod') || strstr($_SERVER['HTTP_USER_AGENT'],'Mobile') || strstr($_SERVER['HTTP_USER_AGENT'],'PlayBook'))
35
+ {
36
+
37
+ $HostKey = 'magic';
38
+ $HostURL = 'https://beta.ezimerchant.com/21617/proxy/1';
39
+
40
+ $headers = array();
41
+
42
+ foreach ($_SERVER as $k => $v)
43
+ {
44
+ if(substr($k, 0, 5) == "HTTP_")
45
+ {
46
+ $k = str_replace('_', ' ', substr($k, 5));
47
+ $k = str_replace(' ', '-', ucwords(strtolower($k)));
48
+
49
+ if($k <> "Host" && $k <> "Connection")
50
+ array_push($headers, $k.": ".$v);
51
+ }
52
+ }
53
+
54
+ array_push($headers,
55
+ "X-HostKey: ".$HostKey,
56
+ "X-Original-Remote-Addr: ".@$_SERVER["REMOTE_ADDR"],
57
+ "X-Original-Host: ".@$_SERVER["HTTP_HOST"],
58
+ "X-Original-Https: ". ( !empty($_SERVER["HTTPS"])? $_SERVER['HTTPS'] :""));
59
+
60
+ $ch = curl_init();
61
+
62
+ curl_setopt($ch, CURLOPT_URL, $HostURL.$_SERVER["REQUEST_URI"]);
63
+ curl_setopt($ch, CURLOPT_HEADER, false);
64
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
65
+ curl_setopt($ch, CURLOPT_HEADERFUNCTION, 'header_callback');
66
+ curl_setopt($ch, CURLOPT_WRITEFUNCTION, 'write_callback');
67
+ curl_setopt($ch, CURLOPT_BUFFERSIZE, 65536);
68
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
69
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
70
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
71
+
72
+ if($_SERVER["REQUEST_METHOD"] == "HEAD")
73
+ {
74
+ curl_setopt($ch, CURLOPT_NOBODY, true);
75
+ }
76
+
77
+ else if($_SERVER["REQUEST_METHOD"] == "POST")
78
+ {
79
+ curl_setopt($ch, CURLOPT_POST, true);
80
+ curl_setopt($ch, CURLOPT_POSTFIELDS, file_get_contents("php://input"));
81
+ }
82
+
83
+
84
+ $output = curl_exec($ch);
85
+
86
+ if(curl_getinfo($ch, CURLINFO_HTTP_CODE)=='404')
87
+ {
88
+ echo file_get_contents($HostURL.$_SERVER["REQUEST_URI"]);
89
+ }
90
+ else echo $output;
91
+
92
+
93
+ curl_close($ch);
94
+ die();
95
+
96
+ exit();
97
+ }
98
+
99
+ $this->fetchDefault();
100
+
101
+ $front = $this->getFront();
102
+ $path = trim($request->getPathInfo(), '/');
103
+
104
+ if ($path) {
105
+ $p = explode('/', $path);
106
+ } else {
107
+ $p = explode('/', $this->_getDefaultPath());
108
+ }
109
+
110
+ // get module name
111
+ if ($request->getModuleName()) {
112
+ $module = $request->getModuleName();
113
+ } else {
114
+ if (!empty($p[0])) {
115
+ $module = $p[0];
116
+ } else {
117
+ $module = $this->getFront()->getDefault('module');
118
+ $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, '');
119
+ }
120
+ }
121
+ if (!$module) {
122
+ if (Mage::app()->getStore()->isAdmin()) {
123
+ $module = 'admin';
124
+ } else {
125
+ return false;
126
+ }
127
+ }
128
+
129
+ /**
130
+ * Searching router args by module name from route using it as key
131
+ */
132
+ $modules = $this->getModuleByFrontName($module);
133
+
134
+ if ($modules === false) {
135
+ return false;
136
+ }
137
+
138
+ //checkings after we foundout that this router should be used for current module
139
+ if (!$this->_afterModuleMatch()) {
140
+ return false;
141
+ }
142
+
143
+ /**
144
+ * Going through modules to find appropriate controller
145
+ */
146
+ $found = false;
147
+ foreach ($modules as $realModule) {
148
+ $request->setRouteName($this->getRouteByFrontName($module));
149
+
150
+ // get controller name
151
+ if ($request->getControllerName()) {
152
+ $controller = $request->getControllerName();
153
+ } else {
154
+ if (!empty($p[1])) {
155
+ $controller = $p[1];
156
+ } else {
157
+ $controller = $front->getDefault('controller');
158
+ $request->setAlias(
159
+ Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS,
160
+ ltrim($request->getOriginalPathInfo(), '/')
161
+ );
162
+ }
163
+ }
164
+
165
+ // get action name
166
+ if (empty($action)) {
167
+ if ($request->getActionName()) {
168
+ $action = $request->getActionName();
169
+ } else {
170
+ $action = !empty($p[2]) ? $p[2] : $front->getDefault('action');
171
+ }
172
+ }
173
+
174
+ //checking if this place should be secure
175
+ $this->_checkShouldBeSecure($request, '/'.$module.'/'.$controller.'/'.$action);
176
+
177
+ $controllerClassName = $this->_validateControllerClassName($realModule, $controller);
178
+ if (!$controllerClassName) {
179
+ continue;
180
+ }
181
+
182
+ // instantiate controller class
183
+ $controllerInstance = Mage::getControllerInstance($controllerClassName, $request, $front->getResponse());
184
+
185
+ if (!$controllerInstance->hasAction($action)) {
186
+ continue;
187
+ }
188
+
189
+ $found = true;
190
+ break;
191
+ }
192
+
193
+ /**
194
+ * if we did not found any siutibul
195
+ */
196
+ if (!$found) {
197
+ if ($this->_noRouteShouldBeApplied()) {
198
+ $controller = 'index';
199
+ $action = 'noroute';
200
+
201
+ $controllerClassName = $this->_validateControllerClassName($realModule, $controller);
202
+ if (!$controllerClassName) {
203
+ return false;
204
+ }
205
+
206
+ // instantiate controller class
207
+ $controllerInstance = Mage::getControllerInstance($controllerClassName, $request,
208
+ $front->getResponse());
209
+
210
+ if (!$controllerInstance->hasAction($action)) {
211
+ return false;
212
+ }
213
+ } else {
214
+ return false;
215
+ }
216
+ }
217
+
218
+ // set values only after all the checks are done
219
+ $request->setModuleName($module);
220
+ $request->setControllerName($controller);
221
+ $request->setActionName($action);
222
+ $request->setControllerModule($realModule);
223
+
224
+ // set parameters from pathinfo
225
+ for ($i = 3, $l = sizeof($p); $i < $l; $i += 2) {
226
+ $request->setParam($p[$i], isset($p[$i+1]) ? urldecode($p[$i+1]) : '');
227
+ }
228
+
229
+ // dispatch action
230
+ $request->setDispatched(true);
231
+ $controllerInstance->dispatch($action);
232
+
233
+ return true;
234
+ }
235
+
236
+ }
app/code/community/OnTechnology/Mobile/etc/config.xml ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * ezimerchant Payment Extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @category ezimerchant
17
+ * @package OnTechnology_Ezimerchant
18
+ * @author On Technology
19
+ * @copyright Copyright (c) 2011 On Technology Pty. Ltd. (http://www.ezimerchant.com/)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ -->
23
+ <config>
24
+ <stores>
25
+ <default>
26
+ <web>
27
+ <routers>
28
+ <standard>
29
+ <area>frontend</area>
30
+ <class>OnTechnology_Mobile_Controller_Varien_Router_Standard</class>
31
+ </standard>
32
+ </routers>
33
+ </web>
34
+ </default>
35
+ </stores>
36
+ </config>
37
+
38
+
app/code/community/OnTechnology/Paypal/controllers/Paypal/ExpressController.php ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Checkout
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ include_once('Mage/Paypal/controllers/ExpressController.php');
28
+
29
+ class OnTechnology_Paypal_Paypal_ExpressController extends Mage_Paypal_ExpressController
30
+ {
31
+ /**
32
+ * Config mode type
33
+ *
34
+ * @var string
35
+ */
36
+ protected $_configType = 'paypal/config';
37
+
38
+ /**
39
+ * Config method type
40
+ *
41
+ * @var string
42
+ */
43
+ protected $_configMethod = Mage_Paypal_Model_Config::METHOD_WPP_EXPRESS;
44
+
45
+ /**
46
+ * Checkout mode type
47
+ *
48
+ * @var string
49
+ */
50
+ protected $_checkoutType = 'paypal/express_checkout';
51
+
52
+ /**
53
+ * Checkout page to redirect to paypal through ezimerchnt
54
+ */
55
+ public function startAction()
56
+ {
57
+
58
+
59
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
60
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
61
+
62
+
63
+ $items = $quote->getAllVisibleItems();
64
+ $billingAddress = $quote->getBillingAddress();
65
+ $shippingAddress = $quote->getShippingAddress();
66
+ $itemidx = 0;
67
+ $discount_amount = 0;
68
+ $paramhash = array();
69
+
70
+ foreach ($items as $item)
71
+ {
72
+ $item = $item->toArray();
73
+
74
+ $paramhash["PRODUCTQUANTITY(" . $itemidx . ")"] = $item['qty'];
75
+ $paramhash["PRODUCTCODE(" . $itemidx . ")"] = $item['sku'];
76
+ $paramhash["PRODUCTNAME(" . $itemidx . ")"] = $item['name'];
77
+ $paramhash["PRODUCTPRICE(" . $itemidx . ")"] = $item['price'];
78
+
79
+
80
+ if($item['discount_amount'])
81
+ {
82
+ $discount_amount += $item['discount_amount'];
83
+ }
84
+
85
+ $itemidx = $itemidx + 1;
86
+ }
87
+ if($discount_amount > 0)
88
+ {
89
+ $paramhash["PRODUCTQUANTITY(" . $itemidx . ")"] = 1;
90
+ $paramhash["PRODUCTNAME(" . $itemidx . ")"] = 'Discounts';
91
+ $paramhash["PRODUCTCODE(" . $itemidx . ")"] = 'Discounts';
92
+ $paramhash["PRODUCTPRICE(" . $itemidx . ")"] = -$discount_amount;
93
+ }
94
+ $paramhash["CURRENCY"] = Mage::app()->getStore()-> getCurrentCurrencyCode();
95
+ $paramhash["PRODUCTTAX"] = 'GST';
96
+ if($billingAddress->getEmail())
97
+ {
98
+ $paramhash["BILLNAME"] = $billingAddress->getName();
99
+ $paramhash["BILLCOMPANY"] = $billingAddress->getCompany();
100
+ $paramhash["BILLEMAIL"] = $billingAddress->getEmail();
101
+ $paramhash["BILLPHONE"] = $billingAddress->getTelephone();
102
+ $paramhash["BILLFAX"] = $billingAddress->getFax();
103
+ $paramhash["BILLADDRESS1"] = $billingAddress->getStreet1();
104
+ $paramhash["BILLADDRESS2"] = $billingAddress->getStreet2();
105
+ $paramhash["BILLADDRESS3"] = $billingAddress->getStreet3();
106
+ $paramhash["BILLPLACE"] = $billingAddress->getCity();
107
+ $paramhash["BILLDIVISION"] = $billingAddress->getRegion();
108
+ $paramhash["BILLPOSTALCODE"] = $billingAddress->getPostcode();
109
+ $paramhash["BILLCOUNTRYCODE"] = $billingAddress->getCountry();
110
+ }
111
+ if($shippingAddress->getEmail())
112
+ {
113
+ $paramhash["SHIPNAME"] = $shippingAddress->getName();
114
+ $paramhash["SHIPCOMPANY"] = $shippingAddress->getCompany();
115
+ $paramhash["SHIPEMAIL"] = $shippingAddress->getEmail();
116
+ $paramhash["SHIPPHONE"] = $shippingAddress->getTelephone();
117
+ $paramhash["SHIPADDRESS1"] = $shippingAddress->getStreet1();
118
+ $paramhash["SHIPADDRESS2"] = $shippingAddress->getStreet2();
119
+ $paramhash["SHIPADDRESS3"] = $shippingAddress->getStreet3();
120
+ $paramhash["SHIPPLACE"] = $shippingAddress->getCity();
121
+ $paramhash["SHIPDIVISION"] = $shippingAddress->getRegion();
122
+ $paramhash["SHIPPOSTALCODE"] = $shippingAddress->getPostcode();
123
+ $paramhash["SHIPCOUNTRYCODE"] = $shippingAddress->getCountry();
124
+ }
125
+ $paramhash["ACTION"] = "CreateOrder";
126
+ $paramhash["CANCELURL"] = Mage::getUrl('checkout/onepage/fail');
127
+ $paramhash["RETURNURL"] = Mage::getUrl('checkout/onepage/return/o/{orderid}');
128
+ $paramhash["NOTIFYURL"] = Mage::getUrl('checkout/onepage/notify');
129
+ $paramhash["CALCULATECALLBACKURL"] = Mage::getUrl('checkout/onepage/calculateshipping');
130
+ //$paramhash["TEMPLATEURL"] = preg_replace('/index.php\//', '', Mage::getBaseURL()).'checkout_template.php';
131
+
132
+ $username = Mage::getStoreConfig('payment/ezimerchant/username');
133
+ $merchantid = Mage::getStoreConfig('payment/ezimerchant/merchantid');
134
+ $password = Mage::getStoreConfig('payment/ezimerchant/password');
135
+
136
+
137
+
138
+ $ch = curl_init();
139
+ curl_setopt($ch, CURLOPT_URL, "https://api.ezimerchant.com/".$merchantid."/orders/");
140
+ curl_setopt($ch, CURLOPT_HEADER, 0);
141
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
142
+ curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
143
+ curl_setopt($ch, CURL_HTTPHEADER, array( "Content-Type: application/x-www-form-urlencoded" ));
144
+ curl_setopt($ch, CURLOPT_USERPWD, "".$username.":".$password);
145
+ curl_setopt($ch, CURLOPT_POST, 1);
146
+ curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($paramhash));
147
+
148
+ $apiresponse = curl_exec($ch);
149
+ curl_close($ch);
150
+
151
+ $xml = simplexml_load_string($apiresponse);
152
+
153
+ $redirectUrl = (string)$xml->entry->link["href"].'&pp=1';
154
+
155
+ $this->getResponse()->setRedirect($redirectUrl);
156
+ return;
157
+ }
158
+
159
+ }
app/code/community/OnTechnology/Paypal/etc/config.xml ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * ezimerchant Payment Extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @category ezimerchant
17
+ * @package OnTechnology_Ezimerchant
18
+ * @author On Technology
19
+ * @copyright Copyright (c) 2010 On Technology Pty. Ltd. (http://www.ezimerchant.com/)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ -->
23
+ <config>
24
+ <frontend>
25
+ <routers>
26
+ <paypal>
27
+ <args>
28
+ <modules>
29
+ <OnTechnology_Paypal before="Mage_Paypal">OnTechnology_Paypal_Paypal</OnTechnology_Paypal>
30
+ </modules>
31
+ </args>
32
+ </paypal>
33
+ </routers>
34
+ </frontend>
35
+ </config>
36
+
app/code/community/OnTechnology/Sales/Model/Order/Creditmemo.php ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Sales
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ class OnTechnology_Sales_Model_Order_Creditmemo extends Mage_Sales_Model_Order_Creditmemo
29
+ {
30
+
31
+
32
+
33
+ public function refund()
34
+ {
35
+
36
+ $this->setState(self::STATE_REFUNDED);
37
+ $orderRefund = Mage::app()->getStore()->roundPrice($this->getOrder()->getTotalRefunded()+$this->getGrandTotal());
38
+ $baseOrderRefund = Mage::app()->getStore()->roundPrice($this->getOrder()->getBaseTotalRefunded()+$this->getBaseGrandTotal());
39
+
40
+ if ($baseOrderRefund > Mage::app()->getStore()->roundPrice($this->getOrder()->getBaseTotalPaid())) {
41
+
42
+ $baseAvailableRefund = $this->getOrder()->getBaseTotalPaid()- $this->getOrder()->getBaseTotalRefunded();
43
+
44
+ Mage::throwException(
45
+ Mage::helper('sales')->__('Maximum amount available to refund is %s',
46
+ $this->getOrder()->formatBasePrice($baseAvailableRefund)
47
+ )
48
+ );
49
+ }
50
+ $order = $this->getOrder();
51
+ $order->setBaseTotalRefunded($baseOrderRefund);
52
+ $order->setTotalRefunded($orderRefund);
53
+
54
+ $order->setBaseSubtotalRefunded($order->getBaseSubtotalRefunded()+$this->getBaseSubtotal());
55
+ $order->setSubtotalRefunded($order->getSubtotalRefunded()+$this->getSubtotal());
56
+
57
+ $order->setBaseTaxRefunded($order->getBaseTaxRefunded()+$this->getBaseTaxAmount());
58
+ $order->setTaxRefunded($order->getTaxRefunded()+$this->getTaxAmount());
59
+ $order->setBaseHiddenTaxRefunded($order->getBaseHiddenTaxRefunded()+$this->getBaseHiddenTaxAmount());
60
+ $order->setHiddenTaxRefunded($order->getHiddenTaxRefunded()+$this->getHiddenTaxAmount());
61
+
62
+ $order->setBaseShippingRefunded($order->getBaseShippingRefunded()+$this->getBaseShippingAmount());
63
+ $order->setShippingRefunded($order->getShippingRefunded()+$this->getShippingAmount());
64
+
65
+ $order->setBaseShippingTaxRefunded($order->getBaseShippingTaxRefunded()+$this->getBaseShippingTaxAmount());
66
+ $order->setShippingTaxRefunded($order->getShippingTaxRefunded()+$this->getShippingTaxAmount());
67
+
68
+ $order->setAdjustmentPositive($order->getAdjustmentPositive()+$this->getAdjustmentPositive());
69
+ $order->setBaseAdjustmentPositive($order->getBaseAdjustmentPositive()+$this->getBaseAdjustmentPositive());
70
+
71
+ $order->setAdjustmentNegative($order->getAdjustmentNegative()+$this->getAdjustmentNegative());
72
+ $order->setBaseAdjustmentNegative($order->getBaseAdjustmentNegative()+$this->getBaseAdjustmentNegative());
73
+
74
+ $order->setDiscountRefunded($order->getDiscountRefunded()+$this->getDiscountAmount());
75
+ $order->setBaseDiscountRefunded($order->getBaseDiscountRefunded()+$this->getBaseDiscountAmount());
76
+
77
+ if ($this->getInvoice()) {
78
+ $this->getInvoice()->setIsUsedForRefund(true);
79
+ $this->getInvoice()->setBaseTotalRefunded(
80
+ $this->getInvoice()->getBaseTotalRefunded() + $this->getBaseGrandTotal()
81
+ );
82
+ $this->setInvoiceId($this->getInvoice()->getId());
83
+ }
84
+
85
+ if (!$this->getPaymentRefundDisallowed()) {
86
+ if($order->getExtOrderId())
87
+ {
88
+
89
+ $merchantid = Mage::getStoreConfig('payment/ezimerchant/merchantid');
90
+ $apikey = Mage::getStoreConfig('payment/ezimerchant/apikey');
91
+
92
+ $paramhash["ACTION"] = "RefundOrder";
93
+ $paramhash["AMOUNT"] = $orderRefund;
94
+
95
+ $ch = curl_init();
96
+ curl_setopt($ch, CURLOPT_URL, "https://api.ezimerchant.com/".$merchantid."/orders/".$order->getExtOrderId()."/");
97
+ curl_setopt($ch, CURLOPT_HEADER, 0);
98
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
99
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array( "Content-Type: application/x-www-form-urlencoded", "X-APIKEY:".$apikey ));
100
+ curl_setopt($ch, CURLOPT_POST, 1);
101
+ curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($paramhash));
102
+
103
+ $apiresponse = curl_exec($ch);
104
+ curl_close($ch);
105
+
106
+
107
+
108
+
109
+ $xml = simplexml_load_string($apiresponse);
110
+
111
+
112
+
113
+ $refundcontent = $xml->entry->children('http://api.ezimerchant.com/schemas/2009/');
114
+ if($refundcontent->success == 1)
115
+ {
116
+ $order->getPayment()->refund($this);
117
+ }
118
+ }
119
+ else
120
+ {
121
+ $order->getPayment()->refund($this);
122
+ }
123
+ }
124
+
125
+ Mage::dispatchEvent('sales_order_creditmemo_refund', array($this->_eventObject=>$this));
126
+ return $this;
127
+ }
128
+
129
+
130
+ }
app/code/community/OnTechnology/Sales/etc/config.xml ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * ezimerchant Payment Extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @category ezimerchant
17
+ * @package OnTechnology_Ezimerchant
18
+ * @author On Technology
19
+ * @copyright Copyright (c) 2010 On Technology Pty. Ltd. (http://www.ezimerchant.com/)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ -->
23
+ <config>
24
+ <modules>
25
+ <OnTechnology_Sales>
26
+ <version>1.0.0</version>
27
+ </OnTechnology_Sales>
28
+ </modules>
29
+ <global>
30
+ <models>
31
+ <sales>
32
+ <rewrite>
33
+ <order_creditmemo>OnTechnology_Sales_Model_Order_Creditmemo</order_creditmemo>
34
+ </rewrite>
35
+ </sales>
36
+ </models>
37
+ </global>
38
+ </config>
39
+
app/etc/modules/OnTechnology_All.xml ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * ezimerchant Payment Extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @category ezimerchant
17
+ * @package OnTechnology_ezimerchant
18
+ * @author On Technology
19
+ * @copyright Copyright (c) 2008 On Technology Pty. Ltd. (http://www.ezimerchant.com/)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ -->
23
+ <config>
24
+ <modules>
25
+ <OnTechnology_Mobile>
26
+ <active>true</active>
27
+ <codePool>community</codePool>
28
+ </OnTechnology_Mobile>
29
+
30
+ <OnTechnology_Ezimerchant>
31
+ <active>true</active>
32
+ <codePool>community</codePool>
33
+ </OnTechnology_Ezimerchant>
34
+
35
+ <OnTechnology_Checkout>
36
+ <active>true</active>
37
+ <codePool>community</codePool>
38
+ <depends>
39
+ <Mage_Core />
40
+ <Mage_Checkout />
41
+ </depends>
42
+ </OnTechnology_Checkout>
43
+
44
+ <OnTechnology_Paypal>
45
+ <active>true</active>
46
+ <codePool>community</codePool>
47
+ <depends>
48
+ <Mage_Core />
49
+ <Mage_Paypal />
50
+ </depends>
51
+ </OnTechnology_Paypal>
52
+
53
+ <OnTechnology_Sales>
54
+ <active>true</active>
55
+ <codePool>community</codePool>
56
+ <depends>
57
+ <Mage_Core />
58
+ <Mage_Sales />
59
+ </depends>
60
+ </OnTechnology_Sales>
61
+ </modules>
62
+ </config>
63
+
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>OnTechnology_Test3</name>
4
+ <version>1.0.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Mobile version</summary>
10
+ <description>Mobile version</description>
11
+ <notes>Mobile version</notes>
12
+ <authors><author><name>Ontechnology</name><user>falconcoupe</user><email>jlivas@ontech.com.au</email></author></authors>
13
+ <date>2012-05-04</date>
14
+ <time>11:40:44</time>
15
+ <contents><target name="magecommunity"><dir name="OnTechnology"><dir name="Checkout"><dir name="controllers"><dir name="Checkout"><file name="CartController.php" hash="0c2d03b00e8b796308decd532f0a7edd"/><file name="OnepageController.php" hash="30ef0b42987a1dfc4908456b0b3f350b"/><file name="simple_html_dom.php" hash="e956e77d0197afa28b8c054b9ed9a771"/><file name="system.xml" hash="b0b0765bc3627d785296a7053f167952"/></dir></dir><dir name="etc"><file name="config.xml" hash="1cfe7ea4c1febb8feca2eb718d899555"/></dir></dir><dir name="Ezimerchant"><dir name="Block"><dir name="Paystep"><file name="Form.php" hash="da582046e00055c963383aeef61cc472"/></dir></dir><dir name="Helper"><file name="Data.php" hash="dc2ac95acc26bde4e59cfd3bb0b66bdc"/></dir><dir name="Model"><dir name="Config"><file name="CustomerGroupAccess.php" hash="106115420e07b43fb8f661a4dbf1a0fc"/><file name="CustomerGroups.php" hash="9f99902a834106da10d8bd85dfca9585"/></dir><dir name="Paystep"><file name="PaymentAction.php" hash="854d96febec7b085fc01f1e78254cc87"/></dir><file name="Paystep.php" hash="02581fd927f4fec8cd6baf152ab2240d"/></dir><dir name="controllers"><file name="PaystepController.php" hash="a2a3c8fd2bc21c8b3066089daed30e51"/></dir><dir name="etc"><file name="config.xml" hash="fc2a8308071e517f0eedf90308489510"/><file name="system.xml" hash="cffdf1c89fee07377504a352a16d377d"/></dir></dir><dir name="Mobile"><dir name="Controller"><dir name="Varien"><dir name="Router"><file name="Standard.php" hash="2ccf4632f4f89be6943a5f93db3bf59d"/></dir></dir></dir><dir name="etc"><file name="config.xml" hash="c1465977bec8ccb4de3b0b472262537e"/></dir></dir><dir name="Paypal"><dir name="controllers"><dir name="Paypal"><file name="ExpressController.php" hash="aa18521ba779fbe0bbadbd8c21176f1b"/></dir></dir><dir name="etc"><file name="config.xml" hash="871f6bdd46135d7d53a70d2046062607"/></dir></dir><dir name="Sales"><dir name="Model"><dir name="Order"><file name="Creditmemo.php" hash="6a85a5efd7a8166a50939c7fe8040265"/></dir></dir><dir name="etc"><file name="config.xml" hash="de7659ab764533ac87c8a5fa2bd255f1"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="OnTechnology_All.xml" hash="3a5be25bf490af79a64e15d5c2518b7b"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>Community</channel><min>1.6.0.0</min><max>1.7</max></package></required></dependencies>
18
+ </package>