Macpain_Leetchi - Version 0.1.0

Version Notes

First release

Download this release

Release Info

Developer Marceli Podstawski
Extension Macpain_Leetchi
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

app/code/local/Macpain/Leetchi/Block/Cancel.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Macpain_Leetchi_Block_Cancel extends Mage_Core_Block_Template
4
+ {
5
+ protected function _construct()
6
+ {
7
+ parent::_construct();
8
+ }
9
+ }
10
+
11
+ ?>
app/code/local/Macpain/Leetchi/Block/Form/Leetchi.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Macpain_Leetchi_Block_Form_Leetchi extends Mage_Payment_Block_Form_Cc
4
+ {
5
+ protected function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->setTemplate('macpain/leetchi/form/leetchi.phtml');
9
+ }
10
+
11
+ /**
12
+ * Retrieve checkout session model object
13
+ *
14
+ * @return Mage_Checkout_Model_Session
15
+ */
16
+ protected function _getCheckout()
17
+ {
18
+ return Mage::getSingleton('checkout/session');
19
+ }
20
+ }
app/code/local/Macpain/Leetchi/Block/Redirect.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Macpain_Leetchi_Block_Redirect extends Mage_Core_Block_Template {
4
+
5
+ protected function _construct() {
6
+ parent::_construct();
7
+ }
8
+
9
+ protected function _toHtml() {
10
+ $leetchi = Mage::getModel('macpain_leetchi/method_leetchi');
11
+ $form = new Varien_Data_Form();
12
+ $form->setAction($leetchi->getLeetchiUrl())
13
+ ->setId('leetchi_payment_form')
14
+ ->setName('leetchi_payment_form')
15
+ ->setMethod('POST')
16
+ ->setUseContainer(true);
17
+
18
+ $form = $leetchi->addLeetchiFields($form);
19
+
20
+ $this->setLeetchiForm($form);
21
+
22
+ return parent::_toHtml();
23
+ }
24
+
25
+ }
26
+
27
+ ?>
app/code/local/Macpain/Leetchi/Helper/Data.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Macpain_Leetchi_Helper_Data extends Mage_Core_Helper_Data
4
+ {
5
+ public function getCart()
6
+ {
7
+ return Mage::getSingleton('checkout/cart');
8
+ }
9
+
10
+ public function getQuote()
11
+ {
12
+ return $this->getCart()->getQuote();
13
+ }
14
+ }
app/code/local/Macpain/Leetchi/Model/Entity/Setup.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ class Macpain_Leetchi_Model_Entity_Setup extends Mage_Eav_Model_Entity_Setup
4
+ {
5
+ }
app/code/local/Macpain/Leetchi/Model/Leetchi.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Macpain_Leetchi_Model_Leetchi extends Mage_Core_Model_Session_Abstract
4
+ {
5
+ protected function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->init('macpain_leetchi');
9
+ }
10
+ }
app/code/local/Macpain/Leetchi/Model/Method/Leetchi.php ADDED
@@ -0,0 +1,272 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Macpain_Leetchi_Model_Method_Leetchi extends Mage_Payment_Model_Method_Abstract {
4
+
5
+ protected $_code = 'leetchi';
6
+ protected $_formBlockType = 'macpain_leetchi/form_leetchi';
7
+ protected $_module_debug_mode;
8
+ protected $_order;
9
+ protected $_url;
10
+
11
+ # Leetchi redirect form fileds
12
+ protected $_leetchi_test_url;
13
+ protected $_leetchi_prod_url;
14
+ protected $_pay_to_email;
15
+ protected $_status_url;
16
+ protected $_return_url;
17
+ protected $_cancel_url;
18
+ protected $_transaction_amount;
19
+ protected $_transaction_id;
20
+
21
+ /**
22
+ * Is this payment method a gateway (online auth/charge) ?
23
+ */
24
+ protected $_isGateway = true;
25
+
26
+ /**
27
+ * Can authorize online?
28
+ */
29
+ protected $_canAuthorize = true;
30
+
31
+ /**
32
+ * Can capture funds online?
33
+ */
34
+ protected $_canCapture = true;
35
+
36
+ /**
37
+ * Can capture partial amounts online?
38
+ */
39
+ protected $_canCapturePartial = false;
40
+
41
+ /**
42
+ * Can refund online?
43
+ */
44
+ protected $_canRefund = false;
45
+
46
+ /**
47
+ * Can void transactions online?
48
+ */
49
+ protected $_canVoid = true;
50
+
51
+ /**
52
+ * Can use this payment method in administration panel?
53
+ */
54
+ protected $_canUseInternal = true;
55
+
56
+ /**
57
+ * Can show this payment method as an option on checkout payment page?
58
+ */
59
+ protected $_canUseCheckout = true;
60
+
61
+ /**
62
+ * Is this payment method suitable for multi-shipping checkout?
63
+ */
64
+ protected $_canUseForMultishipping = false;
65
+
66
+ /**
67
+ * Can save credit card information for future processing?
68
+ */
69
+ protected $_canSaveCc = false;
70
+
71
+ public function __construct() {
72
+ $this->_url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
73
+ $this->_leetchi_test_url = Mage::getStoreConfig("payment/leetchi/test_url");
74
+ $this->_leetchi_prod_url = Mage::getStoreConfig("payment/leetchi/prod_url");
75
+ }
76
+
77
+ /**
78
+ * Return Order Place Redirect URL
79
+ *
80
+ * @return string Order Redirect URL
81
+ */
82
+ public function getOrderPlaceRedirectUrl() {
83
+ return Mage::getUrl('leetchi/leetchi/redirect');
84
+ }
85
+
86
+ /**
87
+ * Return the url for the getaway
88
+ */
89
+ public function getLeetchiUrl() {
90
+ if ($this->getDebugMode())
91
+ return $this->_leetchi_test_url;
92
+ else
93
+ return $this->_leetchi_prod_url;
94
+ }
95
+
96
+ /**
97
+ * Get admin configuration for debug mode
98
+ * @return int
99
+ */
100
+ public function getDebugMode() {
101
+ if ($this->_module_debug_mode == null) {
102
+ $this->_module_debug_mode = Mage::getStoreConfig('payment/leetchi/test');
103
+ }
104
+
105
+ return $this->_module_debug_mode;
106
+ }
107
+
108
+ /**
109
+ * Get admin configuration for merchant id
110
+ * @return string
111
+ */
112
+ public function getPayToEmail() {
113
+
114
+ if ($this->_pay_to_email == null) {
115
+ $this->_pay_to_email = Mage::getStoreConfig('payment/leetchi/merchant_email');
116
+ }
117
+
118
+ return $this->_pay_to_email;
119
+ }
120
+
121
+ /**
122
+ *
123
+ * @return string
124
+ */
125
+ public function getStatusUrl() {
126
+
127
+ if ($this->_status_url == null) {
128
+ $this->_status_url = $this->_url . Mage::getStoreConfig('payment/leetchi/statusurl');
129
+ }
130
+
131
+ return $this->_status_url;
132
+ }
133
+
134
+ /**
135
+ *
136
+ * @return string
137
+ */
138
+ public function getReturnUrl() {
139
+
140
+ if ($this->_return_url == null) {
141
+ $this->_return_url = $this->_url . Mage::getStoreConfig('payment/leetchi/returnurl');
142
+ }
143
+
144
+ return $this->_return_url;
145
+ }
146
+
147
+ /**
148
+ * Get admin configuration for cancel url
149
+ * @return string
150
+ */
151
+ public function getCancelUrl() {
152
+
153
+ if ($this->_cancel_url == null) {
154
+ $this->_cancel_url = $this->_url . Mage::getStoreConfig('payment/leetchi/cancelurl');
155
+ }
156
+
157
+ return $this->_cancel_url;
158
+ }
159
+
160
+ /**
161
+ * Get transaction amount for redirect form
162
+ * @return string
163
+ */
164
+ public function getTransactionAmount() {
165
+
166
+ if ($this->_transaction_amount == null) {
167
+ $this->_transaction_amount = $this->getOrder()->getGrandTotal() * 100;
168
+ }
169
+
170
+ return $this->_transaction_amount;
171
+ }
172
+
173
+ /**
174
+ * Get transaction amount for redirect form
175
+ * @return string
176
+ */
177
+ public function getTransactionId() {
178
+
179
+ if ($this->_transaction_id == null) {
180
+ $order = Mage::getModel('sales/order');
181
+ $order->loadByIncrementId($this->getCheckout()->getLastRealOrderId());
182
+ $this->_transaction_id = $order['increment_id'];
183
+ }
184
+
185
+ return $this->_transaction_id;
186
+ }
187
+
188
+ /**
189
+ * Add all needed fields for leetchi payment
190
+ * @param $forms Object
191
+ */
192
+ public function addLeetchiFields($form) {
193
+ # add pay to email to redirect form
194
+ $form->addField(
195
+ "pay_to_email", 'hidden', array(
196
+ 'name' => 'pay_to_email',
197
+ 'value' => $this->getPayToEmail()
198
+ )
199
+ );
200
+
201
+ # add status url to redirect form
202
+ $form->addField(
203
+ "status_url", 'hidden', array(
204
+ 'name' => 'status_url',
205
+ 'value' => $this->getStatusUrl()
206
+ )
207
+ );
208
+
209
+ # add return url to redirect form
210
+ $form->addField(
211
+ "return_url", 'hidden', array(
212
+ 'name' => 'return_url',
213
+ 'value' => $this->getReturnUrl()
214
+ )
215
+ );
216
+
217
+ # add cancel url to redirect form
218
+ $form->addField(
219
+ "cancel_url", 'hidden', array(
220
+ 'name' => 'cancel_url',
221
+ 'value' => $this->getCancelUrl()
222
+ )
223
+ );
224
+
225
+ # add amount to redirect form
226
+ $form->addField(
227
+ "amount", 'hidden', array(
228
+ 'name' => 'amount',
229
+ 'value' => $this->getTransactionAmount()
230
+ )
231
+ );
232
+
233
+ # add amount to redirect form
234
+ $form->addField(
235
+ "transaction_id", 'hidden', array(
236
+ 'name' => 'transaction_id',
237
+ 'value' => $this->getTransactionId()
238
+ )
239
+ );
240
+
241
+ return $form;
242
+ }
243
+
244
+ /**
245
+ * Validate payment method information object
246
+ *
247
+ * @param Mage_Payment_Model_Info $info
248
+ * @return Mage_Payment_Model_Abstract
249
+ */
250
+ public function validate() {
251
+ parent::validate();
252
+
253
+ return $this;
254
+ }
255
+
256
+ public function getCheckout() {
257
+ if (empty($this->_checkout)) {
258
+ $this->_checkout = Mage::getSingleton('checkout/session');
259
+ }
260
+ return $this->_checkout;
261
+ }
262
+
263
+ public function getOrder() {
264
+ if (empty($this->_order)) {
265
+ $order = Mage::getModel('sales/order');
266
+ $order->loadByIncrementId($this->getCheckout()->getLastRealOrderId());
267
+ $this->_order = $order;
268
+ }
269
+ return $this->_order;
270
+ }
271
+
272
+ }
app/code/local/Macpain/Leetchi/controllers/LeetchiController.php ADDED
@@ -0,0 +1,249 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Macpain_Leetchi_LeetchiController extends Mage_Core_Controller_Front_Action
4
+ {
5
+ protected $_leetchi_response;
6
+ protected $_md5sig;
7
+
8
+ /**
9
+ *
10
+ * Back process status action to validate leetchi payment response inforamtion
11
+ */
12
+ public function statusAction()
13
+ {
14
+ if ($this->getRequest()->isPost()) {
15
+
16
+ try {
17
+
18
+ $this->_setResponse($this->getRequest()->getParams());
19
+
20
+ # TODO: Small piece of code to debug leetchi response
21
+ /*$response = '';
22
+ foreach ($this->getRequest()->getParams() as $key => $val) {
23
+ $response .= "'" . $key . "' => '" . $val . "', ";
24
+ }
25
+ Mage::log('Response form leetchi: ' . $response, null, 'leetchi_api.log');*/
26
+
27
+ $order = Mage::getModel('sales/order');
28
+ $order->loadByIncrementId($this->_leetchi_response['transaction_id'])
29
+ ->sendNewOrderEmail();
30
+
31
+ if ($this->_compareApiSigns()) {
32
+
33
+ $order->addStatusToHistory(
34
+ $this->_getTransactionStatus($this->_leetchi_response['status']),
35
+ $this->__('Customer successfully returned from Leetchi')
36
+ . "\n<br>Leetchi transaction ID: " . $this->_leetchi_response['lma_transaction_id']
37
+ . "\n<br>Pay to email: " . $this->_leetchi_response['pay_to_email']
38
+ . "\n<br>Pay from email: " . $this->_leetchi_response['pay_from_email']
39
+ );
40
+
41
+ $order->getPayment()
42
+ ->getMethodInstance()
43
+ ->setTransactionId($this->_leetchi_response['transaction_id']);
44
+
45
+ } else {
46
+
47
+ $comment = $this->__('Order canceled. Error while processing leetchi data!');
48
+ $order->cancel()
49
+ ->addStatusToHistory($order::STATE_CANCELED, $comment, true)
50
+ ->sendOrderUpdateEmail(true, $comment);
51
+
52
+ }
53
+
54
+ $order->save();
55
+
56
+ } catch (Exception $e) {
57
+ # Mage::log('Exception: ' . $e->getMessage(), null, 'leetchi_api.log');
58
+ }
59
+
60
+ }
61
+
62
+ }
63
+
64
+ /**
65
+ * Cancel action
66
+ */
67
+ public function cancelAction()
68
+ {
69
+ $session = $this->_getCheckout();
70
+
71
+ if ($session->getLastRealOrderId()) {
72
+
73
+ $order = Mage::getModel('sales/order')->loadByIncrementId($session->getLastRealOrderId());
74
+ if ($order->getId()) {
75
+
76
+ # Cancel order
77
+ if ($order->getState() != Mage_Sales_Model_Order::STATE_CANCELED) {
78
+ $comment = $this->__('Order was cancelled by customer.');
79
+ $order
80
+ ->registerCancellation($comment)
81
+ ->sendOrderUpdateEmail(true, $comment)
82
+ ->save();
83
+ }
84
+
85
+ # Get quote
86
+ $quote = Mage::getModel('sales/quote')
87
+ ->load($order->getQuoteId());
88
+
89
+ # Return quote
90
+ if ($quote->getId()) {
91
+ $quote->setIsActive(1)
92
+ ->setReservedOrderId(NULL)
93
+ ->save();
94
+ $session->replaceQuote($quote);
95
+ }
96
+
97
+ # Unset data
98
+ $this->_emptyShoppingCart();
99
+ $session->unsLastRealOrderId();
100
+ }
101
+ }
102
+
103
+ $this
104
+ ->loadLayout()
105
+ ->_initLayoutMessages('checkout/session')
106
+ ->_initLayoutMessages('catalog/session')
107
+ ->renderLayout();
108
+
109
+ }
110
+
111
+ /**
112
+ * Redirect to leetchi.com action
113
+ */
114
+ public function redirectAction()
115
+ {
116
+ $this
117
+ ->loadLayout()
118
+ ->renderLayout();
119
+ }
120
+
121
+ /**
122
+ * Empty customer's shopping cart
123
+ */
124
+ protected function _emptyShoppingCart()
125
+ {
126
+ try {
127
+ $this->_getCart()->truncate()->save();
128
+ $this->_getSession()->setCartWasUpdated(true);
129
+ } catch (Mage_Core_Exception $exception) {
130
+ $this->_getSession()->addError($exception->getMessage());
131
+ } catch (Exception $exception) {
132
+ $this->_getSession()->addException($exception, $this->__('Cannot update shopping cart.'));
133
+ }
134
+ }
135
+
136
+ /**
137
+ * Get frontend checkout session object
138
+ *
139
+ * @return Mage_Checkout_Model_Session
140
+ */
141
+ protected function _getCheckout()
142
+ {
143
+ return Mage::getSingleton('checkout/session');
144
+ }
145
+
146
+ /**
147
+ * Retrieve shopping cart model object
148
+ *
149
+ * @return Mage_Checkout_Model_Cart
150
+ */
151
+ protected function _getCart()
152
+ {
153
+ return Mage::getSingleton('checkout/cart');
154
+ }
155
+
156
+ /**
157
+ * Get checkout session model instance
158
+ *
159
+ * @return Mage_Checkout_Model_Session
160
+ */
161
+ protected function _getSession()
162
+ {
163
+ return Mage::getSingleton('checkout/session');
164
+ }
165
+
166
+ /**
167
+ *
168
+ * Gets transaction statuc by response transaction status code
169
+ * @param string $status
170
+ */
171
+ private function _getTransactionStatus($status)
172
+ {
173
+ $order_model = Mage::getModel('sales/order');
174
+ switch ($status) {
175
+ case -2: # "failed";
176
+ $status = $order_model::STATE_CANCELED; # TODO: Leetchi - this status is disabled for now
177
+ break;
178
+ case -1: # "cancelled";
179
+ $status = $order_model::STATE_CANCELED; # TODO: Leetchi - this status is disabled for now
180
+ break;
181
+ case 0: # "pending";
182
+ $status = $order_model::STATE_PENDING_PAYMENT; # TODO: Leetchi - this status is disabled for now
183
+ break;
184
+ case 2: # "complete";
185
+ $status = $order_model::STATE_PROCESSING;
186
+ break;
187
+ }
188
+ return $status;
189
+ }
190
+
191
+ /**
192
+ *
193
+ * Sets response data and generates api sign
194
+ * @param array $data
195
+ */
196
+ private function _setResponse($data)
197
+ {
198
+ if (count($data)) {
199
+ $this->_leetchi_response = $data;
200
+ $this->_setApiSign();
201
+ }
202
+ return $this;
203
+ }
204
+
205
+ /**
206
+ *
207
+ * Generate api sign from response and admin section secret word
208
+ * @return string
209
+ */
210
+ private function _setApiSign()
211
+ {
212
+ $this->_md5sig = strtoupper(
213
+ md5(
214
+ $this->_leetchi_response['merchant_id']
215
+ . $this->_leetchi_response['lma_transaction_id']
216
+ . strtoupper(
217
+ md5($this->_getSecretWord())
218
+ )
219
+ . $this->_leetchi_response['lma_amount']
220
+ . $this->_leetchi_response['status']
221
+ )
222
+ );
223
+ return $this->_md5sig;
224
+ }
225
+
226
+ /**
227
+ *
228
+ * Comapres generated sign with response md5sig
229
+ * @return boolean
230
+ */
231
+ private function _compareApiSigns()
232
+ {
233
+ if ($this->_md5sig == $this->_leetchi_response['md5sig']) {
234
+ return true;
235
+ }
236
+ return false;
237
+ }
238
+
239
+ /**
240
+ *
241
+ * Get secret word form admin section
242
+ * @return string
243
+ */
244
+ private function _getSecretWord()
245
+ {
246
+ return Mage::getStoreConfig('payment/leetchi/api_pwd');
247
+ }
248
+
249
+ }
app/code/local/Macpain/Leetchi/etc/config.xml ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <Macpain_Leetchi>
5
+ <version>0.1.0</version>
6
+ </Macpain_Leetchi>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <leetchi>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>Macpain_Leetchi</module>
14
+ <frontName>leetchi</frontName>
15
+ </args>
16
+ </leetchi>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <leetchi>
21
+ <file>macpain_leetchi.xml</file>
22
+ </leetchi>
23
+ </updates>
24
+ </layout>
25
+ </frontend>
26
+ <global>
27
+ <models>
28
+ <macpain_leetchi>
29
+ <class>Macpain_Leetchi_Model</class>
30
+ </macpain_leetchi>
31
+ <macpain_leetchi_mysql4>
32
+ <class>Macpain_Leetchi_Model_Mysql4</class>
33
+ <entities></entities>
34
+ </macpain_leetchi_mysql4>
35
+ </models>
36
+ <helpers>
37
+ <macpain_leetchi>
38
+ <class>Macpain_Leetchi_Helper</class>
39
+ </macpain_leetchi>
40
+ </helpers>
41
+ <blocks>
42
+ <macpain_leetchi>
43
+ <class>Macpain_Leetchi_Block</class>
44
+ </macpain_leetchi>
45
+ </blocks>
46
+ <resources>
47
+ <macpain_leetchi_setup>
48
+ <setup>
49
+ <module>Macpain_Leetchi</module>
50
+ <class>Macpain_Leetchi_Model_Entity_Setup</class>
51
+ </setup>
52
+ <connection>
53
+ <use>core_setup</use>
54
+ </connection>
55
+ </macpain_leetchi_setup>
56
+ </resources>
57
+ </global>
58
+ <default>
59
+ <payment>
60
+ <leetchi>
61
+ <model>macpain_leetchi/method_leetchi</model>
62
+ <order_status>new</order_status>
63
+ <payment_action>authorize</payment_action>
64
+ <allowspecific>0</allowspecific>
65
+ <active>0</active>
66
+ <test>1</test>
67
+ <test_url>https://www-preprod.leetchi.com/Payment</test_url>
68
+ <prod_url>https://www.leetchi.com/Payment</prod_url>
69
+ <title>Leetchi payment method</title>
70
+ <merchant_id></merchant_id>
71
+ <api_pwd></api_pwd>
72
+ <merchant_email></merchant_email>
73
+ <statusurl>leetchi/leetchi/status</statusurl>
74
+ <returnurl>checkout/onepage/success</returnurl>
75
+ <cancelurl>leetchi/leetchi/cancel</cancelurl>
76
+ <redirect_js>https://www.leetchi.com/Payment/MerchantFrame.js</redirect_js>
77
+ <redirect_css>https://www.leetchi.com/Payment/MerchantFrame.css</redirect_css>
78
+ <payment_description>Your payment description</payment_description>
79
+ </leetchi>
80
+ </payment>
81
+ </default>
82
+ </config>
app/code/local/Macpain/Leetchi/etc/system.xml ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <payment>
5
+ <groups>
6
+ <leetchi translate="label" module="macpain_leetchi">
7
+ <label>Leetchi</label>
8
+ <sort_order>666</sort_order>
9
+ <show_in_default>1</show_in_default>
10
+ <show_in_website>1</show_in_website>
11
+ <show_in_store>0</show_in_store>
12
+ <comment><![CDATA[<br /><b>IMPORTANT!</b> - <i style="color:red">In order to complete this configuration you have to contact <a href="http://leetchi.com" target="_blank">www.leetchi.com</a></i><br /><br />]]></comment>
13
+ <fields>
14
+ <active translate="label">
15
+ <label>Enabled</label>
16
+ <frontend_type>select</frontend_type>
17
+ <source_model>adminhtml/system_config_source_yesno</source_model>
18
+ <sort_order>1</sort_order>
19
+ <show_in_default>1</show_in_default>
20
+ <show_in_website>1</show_in_website>
21
+ <show_in_store>0</show_in_store>
22
+ <comment>Activate this payment method</comment>
23
+ </active>
24
+ <test translate="label">
25
+ <label>Activate test mode</label>
26
+ <frontend_type>select</frontend_type>
27
+ <source_model>adminhtml/system_config_source_yesno</source_model>
28
+ <sort_order>2</sort_order>
29
+ <show_in_default>1</show_in_default>
30
+ <show_in_website>1</show_in_website>
31
+ <show_in_store>0</show_in_store>
32
+ <comment>If activated test url will be used for payment process</comment>
33
+ </test>
34
+ <test_url translate="label">
35
+ <label>Leetchi test url</label>
36
+ <frontend_type>text</frontend_type>
37
+ <sort_order>3</sort_order>
38
+ <show_in_default>1</show_in_default>
39
+ <show_in_website>1</show_in_website>
40
+ <show_in_store>0</show_in_store>
41
+ <comment>This information should be provided by leetchi.com</comment>
42
+ </test_url>
43
+ <prod_url translate="label">
44
+ <label>Leetchi production url</label>
45
+ <frontend_type>text</frontend_type>
46
+ <sort_order>4</sort_order>
47
+ <show_in_default>1</show_in_default>
48
+ <show_in_website>1</show_in_website>
49
+ <show_in_store>0</show_in_store>
50
+ <comment>This information should be provided by leetchi.com</comment>
51
+ </prod_url>
52
+ <order_status translate="label">
53
+ <label>New order status</label>
54
+ <frontend_type>select</frontend_type>
55
+ <source_model>adminhtml/system_config_source_order_status_new</source_model>
56
+ <sort_order>5</sort_order>
57
+ <show_in_default>1</show_in_default>
58
+ <show_in_website>1</show_in_website>
59
+ <show_in_store>0</show_in_store>
60
+ <comment>Order status</comment>
61
+ </order_status>
62
+ <title translate="label">
63
+ <label>Title</label>
64
+ <frontend_type>text</frontend_type>
65
+ <sort_order>6</sort_order>
66
+ <show_in_default>1</show_in_default>
67
+ <show_in_website>1</show_in_website>
68
+ <show_in_store>0</show_in_store>
69
+ <comment>Payment method title visible on checkout page</comment>
70
+ </title>
71
+ <merchant_id translate="label">
72
+ <label>Merchant ID</label>
73
+ <frontend_type>text</frontend_type>
74
+ <sort_order>7</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
+ <comment>This information should be provided by leetchi.com</comment>
79
+ </merchant_id>
80
+ <api_pwd translate="label">
81
+ <label>API password</label>
82
+ <frontend_type>password</frontend_type>
83
+ <sort_order>8</sort_order>
84
+ <show_in_default>1</show_in_default>
85
+ <show_in_website>1</show_in_website>
86
+ <show_in_store>0</show_in_store>
87
+ <comment>This information should be provided by leetchi.com</comment>
88
+ </api_pwd>
89
+ <merchant_email translate="label">
90
+ <label>Merchant email</label>
91
+ <frontend_type>text</frontend_type>
92
+ <sort_order>9</sort_order>
93
+ <show_in_default>1</show_in_default>
94
+ <show_in_website>1</show_in_website>
95
+ <show_in_store>0</show_in_store>
96
+ <comment>This information should be provided by leetchi.com</comment>
97
+ </merchant_email>
98
+ <statusurl>
99
+ <label>Status url</label>
100
+ <frontend_type>text</frontend_type>
101
+ <sort_order>10</sort_order>
102
+ <show_in_default>1</show_in_default>
103
+ <show_in_website>1</show_in_website>
104
+ <show_in_store>0</show_in_store>
105
+ <comment>Back process url to validate leetchi.com response information</comment>
106
+ </statusurl>
107
+ <returnurl>
108
+ <label>Return url</label>
109
+ <frontend_type>text</frontend_type>
110
+ <sort_order>11</sort_order>
111
+ <show_in_default>1</show_in_default>
112
+ <show_in_website>1</show_in_website>
113
+ <show_in_store>0</show_in_store>
114
+ <comment>Customer will return to this url after payment on leetchi.com</comment>
115
+ </returnurl>
116
+ <cancelurl>
117
+ <label>Cancel url</label>
118
+ <frontend_type>text</frontend_type>
119
+ <sort_order>12</sort_order>
120
+ <show_in_default>1</show_in_default>
121
+ <show_in_website>1</show_in_website>
122
+ <show_in_store>0</show_in_store>
123
+ <comment>Cancel order url</comment>
124
+ </cancelurl>
125
+ <redirect_js>
126
+ <label>Redirect form javascript url</label>
127
+ <frontend_type>text</frontend_type>
128
+ <sort_order>13</sort_order>
129
+ <show_in_default>1</show_in_default>
130
+ <show_in_website>1</show_in_website>
131
+ <show_in_store>0</show_in_store>
132
+ <comment>This information should be provided by leetchi.com</comment>
133
+ </redirect_js>
134
+ <redirect_css>
135
+ <label>Redirect form css url</label>
136
+ <frontend_type>text</frontend_type>
137
+ <sort_order>14</sort_order>
138
+ <show_in_default>1</show_in_default>
139
+ <show_in_website>1</show_in_website>
140
+ <show_in_store>0</show_in_store>
141
+ <comment>This information should be provided by leetchi.com</comment>
142
+ </redirect_css>
143
+ <payment_description>
144
+ <label>Checkout page payment description</label>
145
+ <frontend_type>textarea</frontend_type>
146
+ <sort_order>15</sort_order>
147
+ <show_in_default>1</show_in_default>
148
+ <show_in_website>1</show_in_website>
149
+ <show_in_store>0</show_in_store>
150
+ <comment>Payment method description visible on checkout page</comment>
151
+ </payment_description>
152
+ </fields>
153
+ </leetchi>
154
+ </groups>
155
+ </payment>
156
+ </sections>
157
+ </config>
app/design/frontend/default/default/layout/macpain_leetchi.xml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <leetchi_leetchi_redirect>
4
+ <reference name="root">
5
+ <action method="setTemplate">
6
+ <template>page/1column.phtml</template>
7
+ </action>
8
+ </reference>
9
+ <reference name="root">
10
+ <block as="content" type="macpain_leetchi/redirect" name="redirectForm"
11
+ template="macpain/leetchi/redirect.phtml" />
12
+ </reference>
13
+ </leetchi_leetchi_redirect>
14
+ <leetchi_leetchi_cancel>
15
+ <reference name="root">
16
+ <action method="setTemplate">
17
+ <template>page/1column.phtml</template>
18
+ </action>
19
+ </reference>
20
+ <reference name="root">
21
+ <block as="content" type="macpain_leetchi/cancel" name="cancelPage"
22
+ template="macpain/leetchi/cancel.phtml" />
23
+ </reference>
24
+ </leetchi_leetchi_cancel>
25
+ </layout>
app/design/frontend/default/default/template/macpain/leetchi/cancel.phtml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <div class="page-title">
2
+ <h1><?php echo $this->__('Order details.') ?></h1>
3
+ </div>
4
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
5
+ <h2 class="sub-title"><?php echo $this->__('Your order has been cancelled.') ?></h2>
6
+ <p><?php echo $this->__('You will receive an order cancellation email with details of your order.') ?></p>
7
+ <div class="buttons-set">
8
+ <button type="button" class="button" title="<?php echo $this->__('Continue Shopping') ?>" onclick="window.location='<?php echo $this->getUrl() ?>'"><span><span><?php echo $this->__('Continue Shopping') ?></span></span></button>
9
+ </div>
app/design/frontend/default/default/template/macpain/leetchi/form/leetchi.phtml ADDED
@@ -0,0 +1 @@
 
1
+ <?php echo Mage::getStoreConfig('payment/leetchi/payment_description') ?>
app/design/frontend/default/default/template/macpain/leetchi/redirect.phtml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p id="helper-txt"><?php echo $this->__('In a moment you will be redirected to leetchi.com payment page') ?></p>
2
+ <script type="text/javascript" src="<?php echo Mage::getStoreConfig('payment/leetchi/redirect_js') ?>"></script>
3
+ <link href="<?php echo Mage::getStoreConfig('payment/leetchi/redirect_css') ?>" rel="stylesheet" type="text/css" />
4
+ <?php echo $this->getLeetchiForm()->toHtml(); ?>
5
+ <script type="text/javascript">
6
+ //<![CDATA[
7
+ leetchiJQuery(document).ready(function (leetchiJQuery) {
8
+ leetchiJQuery("#leetchi_payment_form").submit();
9
+ leetchiJQuery(".ui-icon-closethick").click(function(){
10
+ document.location.href = "<?php echo $this->getUrl(Mage::getStoreConfig('payment/leetchi/cancelurl')); ?>";
11
+ });
12
+ leetchiJQuery("#helper-txt").hide();
13
+ });
14
+ //]]>
15
+ </script>
app/etc/modules/Macpain_Leetchi.xml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Macpain_Leetchi>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ <depends>
8
+ <Mage_Payment />
9
+ </depends>
10
+ </Macpain_Leetchi>
11
+ </modules>
12
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Macpain_Leetchi</name>
4
+ <version>0.1.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>This extension provides new payment method with external paygate to leetchi.com</summary>
10
+ <description>This extension provides new payment method with external paygate to leetchi.com. In order to provide this payment method you have to conntact leetchi.com and obtain leetchi user and account information. To configure this extension simply go to System -&gt; Configuration -&gt; Sales (tab) -&gt; Payment Methods -&gt; Leetchi. This method is available only for one page checkout.</description>
11
+ <notes>First release</notes>
12
+ <authors><author><name>Marceli Podstawski</name><user>macpain</user><email>m.podstawski@centerkom.pl</email></author></authors>
13
+ <date>2012-12-29</date>
14
+ <time>22:22:11</time>
15
+ <contents><target name="magelocal"><dir name="Macpain"><dir name="Leetchi"><dir name="Block"><file name="Cancel.php" hash="65630eb6a079047bea2056fa6f76d711"/><dir name="Form"><file name="Leetchi.php" hash="bb050908d1087ea9cd06105de8022e2d"/></dir><file name="Redirect.php" hash="1eb7981367d885863d325b75056addee"/></dir><dir name="Helper"><file name="Data.php" hash="b6e83e77ec3e2f71b21b8146995971ef"/></dir><dir name="Model"><dir name="Entity"><file name="Setup.php" hash="a30703533df660f6583510db5af50ee2"/></dir><file name="Leetchi.php" hash="6ea873b1bb7664b05ade2bf32700ec9e"/><dir name="Method"><file name="Leetchi.php" hash="d3157ddf3ea0955994e202dd634a67ce"/></dir></dir><dir name="controllers"><file name="LeetchiController.php" hash="53b62c64193a457ac67f056930a82c27"/></dir><dir name="etc"><file name="config.xml" hash="67c4640979dc6c89ab606d8987b819de"/><file name="system.xml" hash="4922a2f37c4c0c84a320cde79f52669d"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Macpain_Leetchi.xml" hash="465f19bcf98f16c02b5249a65cef1566"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="macpain_leetchi.xml" hash="5fe26f74ff2548370b1ce5832051b746"/></dir><dir name="template"><dir name="macpain"><dir name="leetchi"><file name="cancel.phtml" hash="cc228cb64ecc71f50394535edddad57e"/><dir name="form"><file name="leetchi.phtml" hash="ef9f31a03a5c4ab88c48f12c26eeecdd"/></dir><file name="redirect.phtml" hash="9d8272f98eb08b0d01dbc0e0e59f3bb9"/></dir></dir></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>