payu_payment - Version 0.1.0

Version Notes

you can use this extension for integrating PayU payment gateway

Download this release

Release Info

Developer Ramakant
Extension payu_payment
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

Files changed (27) hide show
  1. app/code/community/Payu/PayuCheckout/Block/Shared/Canceled.php +25 -0
  2. app/code/community/Payu/PayuCheckout/Block/Shared/Failure.php +25 -0
  3. app/code/community/Payu/PayuCheckout/Block/Shared/Form.php +10 -0
  4. app/code/community/Payu/PayuCheckout/Block/Shared/Redirect.php +27 -0
  5. app/code/community/Payu/PayuCheckout/Controller/Abstract.php +58 -0
  6. app/code/community/Payu/PayuCheckout/Helper/Data.php +7 -0
  7. app/code/community/Payu/PayuCheckout/Model/Api/Debug.php +10 -0
  8. app/code/community/Payu/PayuCheckout/Model/Mysql4/Api/Debug.php +9 -0
  9. app/code/community/Payu/PayuCheckout/Model/Mysql4/Api/Debug/Collection.php +9 -0
  10. app/code/community/Payu/PayuCheckout/Model/Mysql4/Setup.php +6 -0
  11. app/code/community/Payu/PayuCheckout/Model/Shared.php +361 -0
  12. app/code/community/Payu/PayuCheckout/Model/Source/DemoModes.php +13 -0
  13. app/code/community/Payu/PayuCheckout/Model/Source/DirectReturn.php +13 -0
  14. app/code/community/Payu/PayuCheckout/Model/Source/PaymentRoutines.php +13 -0
  15. app/code/community/Payu/PayuCheckout/controllers/SharedController.php +47 -0
  16. app/code/community/Payu/PayuCheckout/controllers/SharedController26.php +49 -0
  17. app/code/community/Payu/PayuCheckout/etc/config.xml +116 -0
  18. app/code/community/Payu/PayuCheckout/etc/system.xml +92 -0
  19. app/code/community/Payu/PayuCheckout/sql/payucheckout_setup/mysql4-install-0.1.0.php +22 -0
  20. app/design/frontend/default/default/layout/payucheckout.xml +43 -0
  21. app/design/frontend/default/default/template/payucheckout/form.phtml +1 -0
  22. app/design/frontend/default/default/template/payucheckout/info.phtml +0 -0
  23. app/design/frontend/default/default/template/payucheckout/shared/canceled.phtml +6 -0
  24. app/design/frontend/default/default/template/payucheckout/shared/failure.phtml +6 -0
  25. app/design/frontend/default/default/template/payucheckout/shared/form.phtml +9 -0
  26. app/etc/modules/Payu_PayuCheckout.xml +12 -0
  27. package.xml +18 -0
app/code/community/Payu/PayuCheckout/Block/Shared/Canceled.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Payu_PayuCheckout_Block_Shared_Canceled extends Mage_Core_Block_Template
5
+ {
6
+ /**
7
+ * Return Error message
8
+ *
9
+ * @return string
10
+ */
11
+ public function getErrorMessage ()
12
+ {
13
+ $msg = Mage::getSingleton('checkout/session')->getPayuCheckoutErrorMessage();
14
+ Mage::getSingleton('checkout/session')->unsPayuCheckoutErrorMessage();
15
+ return $msg;
16
+ }
17
+
18
+ /**
19
+ * Get continue shopping url
20
+ */
21
+ public function getContinueShoppingUrl()
22
+ {
23
+ return Mage::getUrl('checkout/cart');
24
+ }
25
+ }
app/code/community/Payu/PayuCheckout/Block/Shared/Failure.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Payu_PayuCheckout_Block_Shared_Failure extends Mage_Core_Block_Template
5
+ {
6
+ /**
7
+ * Return Error message
8
+ *
9
+ * @return string
10
+ */
11
+ public function getErrorMessage ()
12
+ {
13
+ $msg = Mage::getSingleton('checkout/session')->getPayuCheckoutErrorMessage();
14
+ Mage::getSingleton('checkout/session')->unsPayuCheckoutErrorMessage();
15
+ return $msg;
16
+ }
17
+
18
+ /**
19
+ * Get continue shopping url
20
+ */
21
+ public function getContinueShoppingUrl()
22
+ {
23
+ return Mage::getUrl('checkout/cart');
24
+ }
25
+ }
app/code/community/Payu/PayuCheckout/Block/Shared/Form.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Payu_PayuCheckout_Block_Shared_Form extends Mage_Payment_Block_Form
4
+ {
5
+ protected function _construct()
6
+ {
7
+ $this->setTemplate('payucheckout/shared/form.phtml');
8
+ parent::_construct();
9
+ }
10
+ }
app/code/community/Payu/PayuCheckout/Block/Shared/Redirect.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Payu_PayuCheckout_Block_Shared_Redirect extends Mage_Core_Block_Abstract
4
+ {
5
+ protected function _toHtml()
6
+ {
7
+ $shared = $this->getOrder()->getPayment()->getMethodInstance();
8
+
9
+ $form = new Varien_Data_Form();
10
+ $form->setAction($shared->getPayuCheckoutSharedUrl())
11
+ ->setId('payucheckout_shared_checkout')
12
+ ->setName('payucheckout_shared_checkout')
13
+ ->setMethod('POST')
14
+ ->setUseContainer(true);
15
+ foreach ($shared->getFormFields() as $field=>$value) {
16
+ $form->addField($field, 'hidden', array('name'=>$field, 'value'=>$value));
17
+ }
18
+
19
+ $html = '<html><body>';
20
+ $html.= $this->__('You will be redirected to PayuCheckout in a few seconds.');
21
+ $html.= $form->toHtml();
22
+ $html.= '<script type="text/javascript">document.getElementById("payucheckout_shared_checkout").submit();</script>';
23
+ $html.= '</body></html>';
24
+
25
+ return $html;
26
+ }
27
+ }
app/code/community/Payu/PayuCheckout/Controller/Abstract.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Payu_PayuCheckout_Controller_Abstract extends Mage_Core_Controller_Front_Action
4
+ {
5
+ protected function _expireAjax()
6
+ {
7
+ if (!$this->getCheckout()->getQuote()->hasItems()) {
8
+ $this->getResponse()->setHeader('HTTP/1.1','403 Session Expired');
9
+ exit;
10
+ }
11
+ }
12
+
13
+ /**
14
+ * Redirect Block
15
+ * need to be redeclared
16
+ */
17
+ protected $_redirectBlockType;
18
+
19
+ /**
20
+ * Get singleton of Checkout Session Model
21
+ *
22
+ * @return Mage_Checkout_Model_Session
23
+ */
24
+ public function getCheckout()
25
+ {
26
+ return Mage::getSingleton('checkout/session');
27
+ }
28
+
29
+ /**
30
+ * when customer select 2CO payment method
31
+ */
32
+ public function redirectAction()
33
+ {
34
+
35
+
36
+ $session = $this->getCheckout();
37
+ $session->setPayuCheckoutQuoteId($session->getQuoteId());
38
+ $session->setPayuCheckoutRealOrderId($session->getLastRealOrderId());
39
+
40
+ $order = Mage::getModel('sales/order');
41
+ $order->loadByIncrementId($session->getLastRealOrderId());
42
+ $order->addStatusToHistory($order->getStatus(), Mage::helper('payucheckout')->__('Customer was redirected to payu.'));
43
+ $order->save();
44
+
45
+ $this->getResponse()->setBody(
46
+ $this->getLayout()
47
+ ->createBlock($this->_redirectBlockType)
48
+ ->setOrder($order)
49
+ ->toHtml()
50
+ );
51
+ $session->unsQuoteId();
52
+ $session->unsLastRealOrderId();
53
+ }
54
+
55
+
56
+
57
+
58
+ }
app/code/community/Payu/PayuCheckout/Helper/Data.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Payu_PayuCheckout_Helper_Data extends Mage_Core_Helper_Abstract
5
+ {
6
+
7
+ }
app/code/community/Payu/PayuCheckout/Model/Api/Debug.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Payu_PayuCheckout_Model_Api_Debug extends Mage_Core_Model_Abstract
4
+ {
5
+ protected function _construct()
6
+ {
7
+
8
+ $this->_init('payucheckout/api_debug');
9
+ }
10
+ }
app/code/community/Payu/PayuCheckout/Model/Mysql4/Api/Debug.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Payu_PayuCheckout_Model_Mysql4_Api_Debug extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ protected function _construct()
6
+ {
7
+ $this->_init('payucheckout/api_debug', 'debug_id');
8
+ }
9
+ }
app/code/community/Payu/PayuCheckout/Model/Mysql4/Api/Debug/Collection.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Payu_PayuCheckout_Model_Mysql4_Api_Debug_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ protected function _construct()
6
+ {
7
+ $this->_init('payucheckout/api_debug');
8
+ }
9
+ }
app/code/community/Payu/PayuCheckout/Model/Mysql4/Setup.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Payu_PayuCheckout_Model_Mysql4_Setup extends Mage_Sales_Model_Mysql4_Setup
4
+ {
5
+
6
+ }
app/code/community/Payu/PayuCheckout/Model/Shared.php ADDED
@@ -0,0 +1,361 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Payu_PayuCheckout_Model_Shared extends Mage_Payment_Model_Method_Abstract
4
+ {
5
+ protected $_code = 'payucheckout_shared';
6
+
7
+ protected $_isGateway = false;
8
+ protected $_canAuthorize = false;
9
+ protected $_canCapture = true;
10
+ protected $_canCapturePartial = false;
11
+ protected $_canRefund = false;
12
+ protected $_canVoid = false;
13
+ protected $_canUseInternal = false;
14
+ protected $_canUseCheckout = true;
15
+ protected $_canUseForMultishipping = false;
16
+
17
+ protected $_formBlockType = 'payucheckout/shared_form';
18
+ protected $_paymentMethod = 'shared';
19
+
20
+
21
+ protected $_order;
22
+
23
+
24
+ public function cleanString($string) {
25
+
26
+ $string_step1 = strip_tags($string);
27
+ $string_step2 = nl2br($string_step1);
28
+ $string_step3 = str_replace("<br />","<br>",$string_step2);
29
+ $cleaned_string = str_replace("\""," inch",$string_step3);
30
+ return $cleaned_string;
31
+ }
32
+
33
+
34
+ /**
35
+ * Get checkout session namespace
36
+ *
37
+ * @return Mage_Checkout_Model_Session
38
+ */
39
+ public function getCheckout()
40
+ {
41
+ return Mage::getSingleton('checkout/session');
42
+ }
43
+
44
+ /**
45
+ * Get current quote
46
+ *
47
+ * @return Mage_Sales_Model_Quote
48
+ */
49
+ public function getQuote()
50
+ {
51
+ return $this->getCheckout()->getQuote();
52
+ }
53
+
54
+
55
+ /**
56
+ * Get order model
57
+ *
58
+ * @return Mage_Sales_Model_Order
59
+ */
60
+ public function getOrder()
61
+ {
62
+ if (!$this->_order) {
63
+ $paymentInfo = $this->getInfoInstance();
64
+ $this->_order = Mage::getModel('sales/order')
65
+ ->loadByIncrementId($paymentInfo->getOrder()->getRealOrderId());
66
+ }
67
+ return $this->_order;
68
+ }
69
+
70
+
71
+ public function getCustomerId()
72
+ {
73
+ return Mage::getStoreConfig('payment/' . $this->getCode() . '/customer_id');
74
+ }
75
+
76
+ public function getAccepteCurrency()
77
+ {
78
+ return Mage::getStoreConfig('payment/' . $this->getCode() . '/currency');
79
+ }
80
+
81
+
82
+
83
+
84
+ public function getOrderPlaceRedirectUrl()
85
+ {
86
+ return Mage::getUrl('payucheckout/shared/redirect');
87
+ }
88
+
89
+ /**
90
+ * prepare params array to send it to gateway page via POST
91
+ *
92
+ * @return array
93
+ */
94
+ public function getFormFields()
95
+ {
96
+
97
+ $billing = $this->getOrder()->getBillingAddress();
98
+ $coFields = array();
99
+ $items = $this->getQuote()->getAllItems();
100
+
101
+ if ($items) {
102
+ $i = 1;
103
+ foreach($items as $item){
104
+ if ($item->getParentItem()) {
105
+ continue;
106
+ }
107
+ $coFields['c_prod_'.$i] = $this->cleanString($item->getSku());
108
+ $coFields['c_name_'.$i] = $this->cleanString($item->getName());
109
+ $coFields['c_description_'.$i] = $this->cleanString($item->getDescription());
110
+ $coFields['c_price_'.$i] = number_format($item->getPrice(), 2, '.', '');
111
+ $i++;
112
+ }
113
+ }
114
+
115
+ $request = '';
116
+ foreach ($coFields as $k=>$v) {
117
+ $request .= '<' . $k . '>' . $v . '</' . $k . '>';
118
+ }
119
+
120
+
121
+ $key=Mage::getStoreConfig('payment/payucheckout_shared/key');
122
+ $salt=Mage::getStoreConfig('payment/payucheckout_shared/salt');
123
+ $debug_mode=Mage::getStoreConfig('payment/payucheckout_shared/debug_mode');
124
+
125
+ $orderId = $this->getOrder()->getRealOrderId();
126
+ $txnid = $orderId;
127
+
128
+
129
+ $coFields['key'] = $key;
130
+ $coFields['txnid'] = $txnid;
131
+
132
+ $coFields['amount'] = number_format($this->getOrder()->getBaseGrandTotal(),0,'','');
133
+ $coFields['productinfo'] = 'Prpduct Information';
134
+ $coFields['firstname'] = $billing->getFirstname();
135
+ $coFields['Lastname'] = $billing->getLastname();
136
+ $coFields['City'] = $billing->getCity();
137
+ $coFields['State'] = $billing->getRegion();
138
+ $coFields['Country'] = $billing->getCountry();
139
+ $coFields['Zipcode'] = $billing->getPostcode();
140
+ $coFields['email'] = $this->getOrder()->getCustomerEmail();
141
+ $coFields['phone'] = $billing->getTelephone();
142
+
143
+ $coFields['surl'] = Mage::getBaseUrl().'payucheckout/shared/success/';
144
+ $coFields['furl'] = Mage::getBaseUrl().'payucheckout/shared/failure/';
145
+ $coFields['curl'] = Mage::getBaseUrl().'payucheckout/shared/canceled/id/'.$this->getOrder()->getRealOrderId();
146
+
147
+
148
+
149
+
150
+ $coFields['Pg'] = 'CC';
151
+ $debugId='';
152
+
153
+ if ($debug_mode==1) {
154
+ $requestInfo= $key.'|'.$coFields['txnid'].'|'.$coFields['amount'].'|'.
155
+ $coFields['productinfo'].'|'.$coFields['firstname'].'|'.$coFields['email'].'|'.$debugId.'||||||||||'.$salt;
156
+ $debug = Mage::getModel('payucheckout/api_debug')
157
+ ->setRequestBody($requestInfo)
158
+ ->save();
159
+
160
+ $debugId =$debug->getId();
161
+
162
+ $coFields['udf1']=$debugId;
163
+ $coFields['Hash'] = hash('sha512', $key.'|'.$coFields['txnid'].'|'.$coFields['amount'].'|'.
164
+ $coFields['productinfo'].'|'.$coFields['firstname'].'|'.$coFields['email'].'|'.$debugId.'||||||||||'.$salt);
165
+ }
166
+ else
167
+ {
168
+ $coFields['Hash'] = hash('sha512', $key.'|'.$coFields['txnid'].'|'.$coFields['amount'].'|'.
169
+ $coFields['productinfo'].'|'.$coFields['firstname'].'|'.$coFields['email'].'|||||||||||'.$salt);
170
+ }
171
+ return $coFields;
172
+ }
173
+
174
+ /**
175
+ * Get url of Payu payment
176
+ *
177
+ * @return string
178
+ */
179
+ public function getPayuCheckoutSharedUrl()
180
+ {
181
+ $mode=Mage::getStoreConfig('payment/payucheckout_shared/demo_mode');
182
+
183
+ $url='https://test.payu.in/_payment.php';
184
+
185
+ if($mode=='')
186
+ {
187
+ $url='https://secure.payu.in/_payment.php';
188
+ }
189
+
190
+ return $url;
191
+ }
192
+
193
+
194
+ /**
195
+ * Get debug flag
196
+ *
197
+ * @return string
198
+ */
199
+ public function getDebug()
200
+ {
201
+ return Mage::getStoreConfig('payment/' . $this->getCode() . '/debug_flag');
202
+ }
203
+
204
+ public function capture(Varien_Object $payment, $amount)
205
+ {
206
+ $payment->setStatus(self::STATUS_APPROVED)
207
+ ->setLastTransId($this->getTransactionId());
208
+
209
+ return $this;
210
+ }
211
+
212
+ public function cancel(Varien_Object $payment)
213
+ {
214
+ $payment->setStatus(self::STATUS_DECLINED)
215
+ ->setLastTransId($this->getTransactionId());
216
+
217
+ return $this;
218
+ }
219
+
220
+ /**
221
+ * parse response POST array from gateway page and return payment status
222
+ *
223
+ * @return bool
224
+ */
225
+ public function parseResponse()
226
+ {
227
+
228
+ return true;
229
+
230
+ }
231
+
232
+ /**
233
+ * Return redirect block type
234
+ *
235
+ * @return string
236
+ */
237
+ public function getRedirectBlockType()
238
+ {
239
+ return $this->_redirectBlockType;
240
+ }
241
+
242
+ /**
243
+ * Return payment method type string
244
+ *
245
+ * @return string
246
+ */
247
+ public function getPaymentMethodType()
248
+ {
249
+ return $this->_paymentMethod;
250
+ }
251
+
252
+
253
+ public function getResponseOperation($response)
254
+ {
255
+
256
+ $order = Mage::getModel('sales/order');
257
+ $debug_mode=Mage::getStoreConfig('payment/payucheckout_shared/debug_mode');
258
+ $key=Mage::getStoreConfig('payment/payucheckout_shared/key');
259
+ $salt=Mage::getStoreConfig('payment/payucheckout_shared/salt');
260
+ if(isset($response['status']))
261
+ {
262
+ $txnid=$response['txnid'];
263
+ $orderid=$txnid;
264
+
265
+ if($response['status']=='success')
266
+ {
267
+ $status='success';
268
+ $order->loadByIncrementId($txnid);
269
+ $billing = $order->getBillingAddress();
270
+ $amount = $response['amount'];
271
+ $productinfo = 'Prpduct Information';
272
+ $firstname = $billing->getFirstname();
273
+ $email = $order->getCustomerEmail();
274
+ $keyString='';
275
+ $Udf1 = $response['udf1'];
276
+ $Udf2 = $response['udf2'];
277
+ $Udf3 = $response['udf3'];
278
+ $Udf4 = $response['udf4'];
279
+ $Udf5 = $response['udf5'];
280
+ $Udf6 = $response['udf6'];
281
+ $Udf7 = $response['udf7'];
282
+ $Udf8 = $response['udf8'];
283
+ $Udf9 = $response['udf9'];
284
+ $Udf10 = $response['udf10'];
285
+ if($debug_mode==1)
286
+ {
287
+ $keyString = $key.'|'.$txnid.'|'.$amount.'|'.$productinfo.'|'.$firstname.'|'.$email.'|'.$Udf1.'|'.$Udf2.'|'.$Udf3.'|'.$Udf4.'|'.$Udf5.'|'.$Udf6.'|'.$Udf7.'|'.$Udf8.'|'.$Udf9.'|'.$Udf10;
288
+ }
289
+ else
290
+ {
291
+ $keyString = $key.'|'.$txnid.'|'.$amount.'|'.$productinfo.'|'.$firstname.'|'.$email.'|'.$Udf1.'|'.$Udf2.'|'.$Udf3.'|'.$Udf4.'|'.$Udf5.'|'.$Udf6.'|'.$Udf7.'|'.$Udf8.'|'.$Udf9.'|'.$Udf10;
292
+ }
293
+
294
+ $keyArray = explode("|",$keyString);
295
+ $reverseKeyArray = array_reverse($keyArray);
296
+ $reverseKeyString=implode("|",$reverseKeyArray);
297
+ $saltString = $salt.'|'.$status.'|'.$reverseKeyString;
298
+ $sentHashString = strtolower(hash('sha512', $saltString));
299
+ $responseHashString=$_REQUEST['hash'];
300
+ if($sentHashString==$responseHashString)
301
+ {
302
+ $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true);
303
+ $order->save();
304
+ $order->sendNewOrderEmail();
305
+
306
+ }
307
+ else
308
+ {
309
+ $order->setState(Mage_Sales_Model_Order::STATE_NEW, true);
310
+ $order->cancel()->save();
311
+ }
312
+
313
+ if ($debug_mode==1) {
314
+ $debugId=$response['udf1'];
315
+ $data = array('response_body'=>implode(",",$response));
316
+ $model = Mage::getModel('payucheckout/api_debug')->load($debugId)->addData($data);
317
+ $model->setId($id)->save();
318
+ }
319
+ }
320
+
321
+ if($response['status']=='failure')
322
+ {
323
+ $order->loadByIncrementId($orderid);
324
+ $order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true);
325
+ $order->cancel()->save();
326
+ if ($debug_mode==1) {
327
+ $debugId=$response['udf1'];
328
+ $data = array('response_body'=>implode(",",$response));
329
+ $model = Mage::getModel('payucheckout/api_debug')->load($debugId)->addData($data);
330
+ $model->setId($id)->save();
331
+ }
332
+
333
+ }
334
+ else if($response['status']=='pending')
335
+ {
336
+ $order->loadByIncrementId($orderid);
337
+ $order->setState(Mage_Sales_Model_Order::STATE_NEW, true);
338
+ $order->cancel()->save();
339
+ if ($debug_mode==1) {
340
+ $debugId=$response['udf1'];
341
+ $data = array('response_body'=>implode(",",$response));
342
+ $model = Mage::getModel('payucheckout/api_debug')->load($debugId)->addData($data);
343
+ $model->setId($id)->save();
344
+ }
345
+
346
+ }
347
+
348
+ }
349
+ else
350
+ {
351
+ $order->loadByIncrementId($response['id']);
352
+ $order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true);
353
+ $order->cancel()->save();
354
+
355
+ }
356
+
357
+
358
+
359
+
360
+ }
361
+ }
app/code/community/Payu/PayuCheckout/Model/Source/DemoModes.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Payu_PayuCheckout_Model_Source_DemoModes
5
+ {
6
+ public function toOptionArray()
7
+ {
8
+ return array(
9
+ array('value' => 'Y', 'label' => 'Demo Mode'),
10
+ array('value' => '', 'label' => 'Production Mode'),
11
+ );
12
+ }
13
+ }
app/code/community/Payu/PayuCheckout/Model/Source/DirectReturn.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Payu_PayuCheckout_Model_Source_DirectReturn
5
+ {
6
+ public function toOptionArray()
7
+ {
8
+ return array(
9
+ array('value' => 'redirect', 'label' => 'Immediately returned to my website '),
10
+ array('value' => 'link', 'label' => 'Given links only back to my website '),
11
+ );
12
+ }
13
+ }
app/code/community/Payu/PayuCheckout/Model/Source/PaymentRoutines.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Payu_PayuCheckout_Model_Source_PaymentRoutines
5
+ {
6
+ public function toOptionArray()
7
+ {
8
+ return array(
9
+ array('value' => 'multi', 'label' => 'Multi-page Payment Routine'),
10
+ array('value' => 'single', 'label' => 'Single Page Payment Routine'),
11
+ );
12
+ }
13
+ }
app/code/community/Payu/PayuCheckout/controllers/SharedController.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Payu_PayuCheckout_SharedController extends Payu_PayuCheckout_Controller_Abstract
4
+ {
5
+
6
+ protected $_redirectBlockType = 'payucheckout/shared_redirect';
7
+ protected $_paymentInst = NULL;
8
+
9
+
10
+ public function successAction()
11
+ {
12
+ $response = $this->getRequest()->getPost();
13
+ Mage::getModel('payucheckout/shared')->getResponseOperation($response);
14
+ $this->_redirect('checkout/onepage/success');
15
+ }
16
+
17
+
18
+
19
+ public function failureAction()
20
+ {
21
+
22
+ $arrParams = $this->getRequest()->getPost();
23
+ Mage::getModel('payucheckout/shared')->getResponseOperation($arrParams);
24
+ $this->getCheckout()->clear();
25
+ $this->_redirect('checkout/onepage/failure');
26
+ }
27
+
28
+
29
+ public function canceledAction()
30
+ {
31
+ $arrParams = $this->getRequest()->getParams();
32
+
33
+
34
+ Mage::getModel('payucheckout/shared')->getResponseOperation($arrParams);
35
+
36
+ $this->getCheckout()->clear();
37
+ $this->loadLayout();
38
+ $this->renderLayout();
39
+ }
40
+
41
+
42
+
43
+
44
+
45
+ }
46
+
47
+
app/code/community/Payu/PayuCheckout/controllers/SharedController26.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Payu_PayuCheckout_SharedController extends Payu_PayuCheckout_Controller_Abstract
4
+ {
5
+
6
+ protected $_redirectBlockType = 'payucheckout/shared_redirect';
7
+ protected $_paymentInst = NULL;
8
+
9
+
10
+ public function successAction()
11
+ {
12
+ $response = $this->getRequest()->getPost();
13
+ Mage::getModel('payucheckout/shared')->getResponseOperation($response);
14
+ $this->_redirect('checkout/onepage/success');
15
+ }
16
+
17
+
18
+
19
+ public function failureAction()
20
+ {
21
+ $response=$_REQUEST;
22
+ Mage::getModel('payucheckout/shared')->getResponseOperation($response);
23
+ $this->getCheckout()->clear();
24
+ //$this->_redirect('checkout/onepage/failure');
25
+
26
+ $this->loadLayout();
27
+ $this->renderLayout();
28
+ }
29
+
30
+
31
+ public function canceledAction()
32
+ {
33
+ $arrParams = $this->getRequest()->getParams();
34
+
35
+
36
+ Mage::getModel('payucheckout/shared')->getResponseOperation($arrParams);
37
+
38
+ $this->getCheckout()->clear();
39
+ $this->loadLayout();
40
+ $this->renderLayout();
41
+ }
42
+
43
+
44
+
45
+
46
+
47
+ }
48
+
49
+
app/code/community/Payu/PayuCheckout/etc/config.xml ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Payu_PayuCheckout>
5
+ <version>0.1.0</version>
6
+ </Payu_PayuCheckout>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <payucheckout>
11
+ <class>Payu_PayuCheckout_Model</class>
12
+ <resourceModel>payucheckout_mysql4</resourceModel>
13
+ </payucheckout>
14
+ <payucheckout_mysql4>
15
+ <class>Payu_PayuCheckout_Model_Mysql4</class>
16
+ <entities>
17
+ <api_debug><table>payucheckout_api_debug</table></api_debug>
18
+ </entities>
19
+ </payucheckout_mysql4>
20
+ </models>
21
+ <helpers>
22
+ <payucheckout>
23
+ <class>Payu_PayuCheckout_Helper</class>
24
+ </payucheckout>
25
+ </helpers>
26
+ <resources>
27
+ <payucheckout_setup>
28
+ <setup>
29
+ <module>Payu_PayuCheckout</module>
30
+ <class>Payu_PayuCheckout_Model_Mysql4_Setup</class>
31
+ </setup>
32
+ <connection>
33
+ <use>core_setup</use>
34
+ </connection>
35
+ </payucheckout_setup>
36
+ <payucheckout_write>
37
+ <connection>
38
+ <use>core_write</use>
39
+ </connection>
40
+ </payucheckout_write>
41
+ <payucheckout_read>
42
+ <connection>
43
+ <use>core_read</use>
44
+ </connection>
45
+ </payucheckout_read>
46
+ </resources>
47
+ <blocks>
48
+ <payucheckout><class>Payu_PayuCheckout_Block</class></payucheckout>
49
+ </blocks>
50
+ </global>
51
+ <frontend>
52
+ <secure_url>
53
+ <payucheckout_shared>/payucheckout/shared</payucheckout_shared>
54
+ </secure_url>
55
+ <routers>
56
+ <payucheckout>
57
+ <use>standard</use>
58
+ <args>
59
+ <module>Payu_PayuCheckout</module>
60
+ <frontName>payucheckout</frontName>
61
+ </args>
62
+ </payucheckout>
63
+ </routers>
64
+ <translate>
65
+ <modules>
66
+ <Payu_PayuCheckout>
67
+ <files>
68
+ <default>Payu_PayuCheckout.csv</default>
69
+ </files>
70
+ </Payu_PayuCheckout>
71
+ </modules>
72
+ </translate>
73
+ <layout>
74
+ <updates>
75
+ <payucheckout>
76
+ <file>payucheckout.xml</file>
77
+ </payucheckout>
78
+ </updates>
79
+ </layout>
80
+ </frontend>
81
+ <adminhtml>
82
+ <translate>
83
+ <modules>
84
+ <Payu_PayuCheckout>
85
+ <files>
86
+ <default>Payu_PayuCheckout.csv</default>
87
+ </files>
88
+ </Payu_PayuCheckout>
89
+ </modules>
90
+ </translate>
91
+ </adminhtml>
92
+ <default>
93
+ <payment>
94
+ <payucheckout_shared>
95
+ <customer_id backend_model="adminhtml/system_config_backend_encrypted"/>
96
+ <currency>USD</currency>
97
+ <model>payucheckout/shared</model>
98
+ <title>Payu Checkout</title>
99
+ <secret_word>PUT SECRET WORD HERE</secret_word>
100
+ <check_hash>1</check_hash>
101
+ <direct_return>redirect</direct_return>
102
+ <demo_mode></demo_mode>
103
+ <skip_landing>0</skip_landing>
104
+ <order_status>processing</order_status>
105
+ <fraud_wait>holded</fraud_wait>
106
+ <fraud_passed>pending</fraud_passed>
107
+ <fraud_failed>canceled</fraud_failed>
108
+ <invoice_pending></invoice_pending>
109
+ <invoice_deposited></invoice_deposited>
110
+ <invoice_declined>canceled</invoice_declined>
111
+ <refund_issued>canceled</refund_issued>
112
+ <allowspecific>0</allowspecific>
113
+ </payucheckout_shared>
114
+ </payment>
115
+ </default>
116
+ </config>
app/code/community/Payu/PayuCheckout/etc/system.xml ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <sections>
5
+ <payment>
6
+ <groups>
7
+ <payucheckout_shared translate="label" module="payucheckout">
8
+ <label>PayuCheckout</label>
9
+ <frontend_type>text</frontend_type>
10
+ <sort_order>303</sort_order>
11
+ <show_in_default>1</show_in_default>
12
+ <show_in_website>1</show_in_website>
13
+ <show_in_store>0</show_in_store>
14
+ <fields>
15
+ <active translate="label">
16
+ <label>Enabled</label>
17
+ <frontend_type>select</frontend_type>
18
+ <source_model>adminhtml/system_config_source_yesno</source_model>
19
+ <sort_order>1</sort_order>
20
+ <show_in_default>1</show_in_default>
21
+ <show_in_website>1</show_in_website>
22
+ <show_in_store>0</show_in_store>
23
+ </active>
24
+ <title translate="label">
25
+ <label>Title</label>
26
+ <comment>This is what the customers will see as the name of the payment option</comment>
27
+ <frontend_type>text</frontend_type>
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
+ </title>
33
+
34
+ <key translate="label">
35
+ <label>Merchant Id</label>
36
+
37
+ <frontend_type>text</frontend_type>
38
+ <sort_order>3</sort_order>
39
+ <show_in_default>2</show_in_default>
40
+ <show_in_website>2</show_in_website>
41
+ <show_in_store>0</show_in_store>
42
+ </key>>
43
+
44
+ <salt translate="label">
45
+ <label>Salt</label>
46
+ <comment>This is salt hash key provided by Payu</comment>
47
+ <frontend_type>text</frontend_type>
48
+ <sort_order>4</sort_order>
49
+ <show_in_default>3</show_in_default>
50
+ <show_in_website>3</show_in_website>
51
+ <show_in_store>0</show_in_store>
52
+ </salt>
53
+
54
+
55
+ <demo_mode translate="label">
56
+ <label>Transaction Mode?</label>
57
+ <frontend_type>select</frontend_type>
58
+ <source_model>payucheckout/source_DemoModes</source_model>
59
+ <sort_order>55</sort_order>
60
+ <show_in_default>1</show_in_default>
61
+ <show_in_website>1</show_in_website>
62
+ <show_in_store>0</show_in_store>
63
+ </demo_mode>
64
+
65
+ <order_status translate="label">
66
+ <label>New order status</label>
67
+ <frontend_type>select</frontend_type>
68
+ <source_model>adminhtml/system_config_source_order_status</source_model>
69
+ <sort_order>6</sort_order>
70
+
71
+ <show_in_default>1</show_in_default>
72
+ <show_in_website>1</show_in_website>
73
+ <show_in_store>0</show_in_store>
74
+ </order_status>
75
+
76
+ <debug_mode translate="label">
77
+ <label>Debug Mode</label>
78
+ <frontend_type>select</frontend_type>
79
+ <source_model>adminhtml/system_config_source_yesno</source_model>
80
+ <sort_order>10</sort_order>
81
+ <show_in_default>1</show_in_default>
82
+ <show_in_website>1</show_in_website>
83
+ <show_in_store>0</show_in_store>
84
+ </debug_mode>
85
+
86
+
87
+ </fields>
88
+ </payucheckout_shared>
89
+ </groups>
90
+ </payment>
91
+ </sections>
92
+ </config>
app/code/community/Payu/PayuCheckout/sql/payucheckout_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ $installer = $this;
5
+
6
+ $installer->startSetup();
7
+
8
+ $installer->run("
9
+
10
+ -- DROP TABLE IF EXISTS `{$this->getTable('payucheckout/api_debug')}`;
11
+ CREATE TABLE `{$this->getTable('payucheckout/api_debug')}` (
12
+ `debug_id` int(10) unsigned NOT NULL auto_increment,
13
+ `debug_at` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
14
+ `request_body` text,
15
+ `response_body` text,
16
+ PRIMARY KEY (`debug_id`),
17
+ KEY `debug_at` (`debug_at`)
18
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
19
+
20
+ ");
21
+
22
+ $installer->endSetup();
app/design/frontend/default/default/layout/payucheckout.xml ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <layout version="0.1.0">
4
+ <!-- Payucgeckout Failure Response Review -->
5
+ <payucheckout_shared_failure>
6
+ <reference name="root">
7
+ <action method="setTemplate"><template>page/2columns-right.phtml</template></action>
8
+ </reference>
9
+ <reference name="content">
10
+ <block type="payucheckout/shared_failure" name="payucheckout_shared_failure" template="payucheckout/shared/failure.phtml">
11
+ </block>
12
+
13
+ </reference>
14
+ <reference name="content">
15
+
16
+ </reference>
17
+ </payucheckout_shared_failure>
18
+
19
+
20
+ <!-- Payucgeckout Cancel Response Review -->
21
+ <payucheckout_shared_canceled>
22
+ <reference name="root">
23
+ <action method="setTemplate"><template>page/2columns-right.phtml</template></action>
24
+ </reference>
25
+ <reference name="content">
26
+ <block type="payucheckout/shared_canceled" name="payucheckout_shared_canceled"
27
+ template="payucheckout/shared/canceled.phtml">
28
+ </block>
29
+
30
+ </reference>
31
+ <reference name="content">
32
+
33
+ </reference>
34
+ </payucheckout_shared_canceled>
35
+
36
+
37
+
38
+
39
+ </layout>
40
+
41
+
42
+
43
+
app/design/frontend/default/default/template/payucheckout/form.phtml ADDED
@@ -0,0 +1 @@
 
1
+
app/design/frontend/default/default/template/payucheckout/info.phtml ADDED
File without changes
app/design/frontend/default/default/template/payucheckout/shared/canceled.phtml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+
2
+ <div class="page-head">
3
+ <h3><?php echo $this->__('Payment transaction has been canceled.') ?></h3>
4
+ </div>
5
+ <p><?php //echo $this->getErrorMessage() ?>.</p>
6
+ <p><?php echo $this->__('Please <a href="%s">continue shopping</a>.', $this->getContinueShoppingUrl()) ?></p>
app/design/frontend/default/default/template/payucheckout/shared/failure.phtml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+
2
+ <div class="page-head">
3
+ <h3><?php echo $this->__('Order payment has been failed') ?></h3>
4
+ </div>
5
+ <p><?php echo $this->getErrorMessage() ?>.</p>
6
+ <p><?php echo $this->__('Please <a href="%s">continue shopping</a>.', $this->getContinueShoppingUrl()) ?></p>
app/design/frontend/default/default/template/payucheckout/shared/form.phtml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+
2
+ <fieldset class="form-list">
3
+ <?php $_code=$this->getMethodCode() ?>
4
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
5
+ <li>
6
+ <?php echo $this->__('You will be redirected to PayuCheckout website when you place an order.') ?>
7
+ </li>
8
+ </ul>
9
+ </fieldset>
app/etc/modules/Payu_PayuCheckout.xml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Payu_PayuCheckout>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <depends>
8
+ <Mage_Payment/>
9
+ </depends>
10
+ </Payu_PayuCheckout>
11
+ </modules>
12
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>payu_payment</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license>PayU v1.0.5</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>PayU Payment Gateway</summary>
10
+ <description>PayU Payment Gateway</description>
11
+ <notes>you can use this extension for integrating PayU payment gateway</notes>
12
+ <authors><author><name>Ramakant</name><user>ramakant2you</user><email>ramakant2you@gmail.com</email></author></authors>
13
+ <date>2012-01-19</date>
14
+ <time>13:16:45</time>
15
+ <contents><target name="magecommunity"><dir name="Payu"><dir name="PayuCheckout"><dir name="Block"><dir name="Shared"><file name="Canceled.php" hash="bb19a12f92b3f4813dfbea0b39d54239"/><file name="Failure.php" hash="08abafbca12b0b90026f868f94baff29"/><file name="Form.php" hash="1910d6be84e75325aea85821133ce73c"/><file name="Redirect.php" hash="62bd8f284ca07038f11b81ddcdefe1ff"/></dir></dir><dir name="Controller"><file name="Abstract.php" hash="35e4b83aa3aed060125fbeb653192b4f"/></dir><dir name="Helper"><file name="Data.php" hash="896c95a620ad4ecc5aaa93e157e369fb"/></dir><dir name="Model"><dir name="Api"><file name="Debug.php" hash="b841c48492958030919d40f1e106755c"/></dir><dir name="Mysql4"><dir name="Api"><dir name="Debug"><file name="Collection.php" hash="f6c9e33b04b46242737204488fcd9081"/></dir><file name="Debug.php" hash="7d02543559f7d7cca60d8339898ad76b"/></dir><file name="Setup.php" hash="a03cdaf2dda7cb47e5cab334aa15cebd"/></dir><file name="Shared.php" hash="a13530746c7ff6adb8bf0317e9baf27e"/><dir name="Source"><file name="DemoModes.php" hash="3bd1cc16836adecb9d29a55ba9d3bffc"/><file name="DirectReturn.php" hash="be10b40fe41199d36d1d49c1e1af59cb"/><file name="PaymentRoutines.php" hash="5e6e78e13cf245c790762bf5e754fad3"/></dir></dir><dir name="controllers"><file name="SharedController.php" hash="a4979e849b15b46ff7d5133b2a4c43b8"/><file name="SharedController26.php" hash="2af9a71dc45c8e7f6c3a7c731dce8b25"/></dir><dir name="etc"><file name="config.xml" hash="8d61170d5acbebf04feefffd6e00b468"/><file name="system.xml" hash="f4c823828cb787d107c6e204f4342226"/></dir><dir name="sql"><dir name="payucheckout_setup"><file name="mysql4-install-0.1.0.php" hash="e551af7989f2bdca0e863ccdd14cfa56"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="payucheckout"><file name="form.phtml" hash="68b329da9893e34099c7d8ad5cb9c940"/><file name="info.phtml" hash="d41d8cd98f00b204e9800998ecf8427e"/><dir name="shared"><file name="canceled.phtml" hash="bdef89131c08a83d3c1742399d58b433"/><file name="failure.phtml" hash="a54ece778621c5e2b35f4983923bfeb3"/><file name="form.phtml" hash="f8f62958bac1bf15fde40ed24078d97f"/></dir></dir></dir><dir name="layout"><file name="payucheckout.xml" hash="c77d92a6c0a9fe598e61525658382fe6"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Payu_PayuCheckout.xml" hash="284666c8d3fdb0742ceb390ee7081e80"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>