Subversion Repositories SmartDukaan

Rev

Rev 17908 | Rev 19411 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
10606 amit.gupta 1
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
10611 amit.gupta 2
 
10582 lgm 3
class Checkout extends MY_Controller {
4
 
5
public $layoutName ='';
6
 
7
	function __construct() {
8
 
9
		// Call the CI_controller constructor
10
		parent::__construct();
11
		$admin = $this->session->userdata('admin');
11108 lgm 12
		// if(!isset($admin) || empty($admin)) {
13
		// 	redirect(base_url().'authorize');
14
		// }
11421 lgm 15
		$this->output->set_header("Expires: Tue, 01 Jan 2000 00:00:00 GMT");
16
		$this->output->set_header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
17
		$this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
18
		$this->output->set_header("Cache-Control: post-check=0, pre-check=0", false);
19
		$this->output->set_header("Pragma: no-cache");
10582 lgm 20
		$this->layout->setlayout('layout/layout_main');
21
		$this->load->model('checkout_model');
22
		$this->load->model('captcha_model');
23
		$this->layoutName= $this->layout->getLayout();
24
		$this->layoutName =substr($this->layoutName , 0, strrpos($this->layoutName , "/")).'/';
11301 lgm 25
		//print_r($this->session->userdata);
10582 lgm 26
 
27
 
28
	}
29
	public function index()
30
	{
31
		$authorized = $this->session->userdata('authorized');
32
		if(isset($authorized) and !empty($authorized['id']))
33
		{
34
			//if user logged-in
35
			redirect(base_url().strtolower(__CLASS__).'/shipping');
36
		}
37
 
38
		//standard array
39
	}
40
	public function __paginateList($data=array())
41
	{
42
			//$data['baseSubTotal']=$data['baseSubTotal'];
43
			$data['subTotal'] = $data['subTotal'];
44
			//$data['shippingCharges'] = $data['shippingCharges'];
45
			return $data;	
46
 
47
	}
48
 
49
	public function orderconfirmation()
50
	{
51
		$authorized = $this->session->userdata('authorized');
52
	    if(isset($authorized) && !empty($authorized)){
53
			$_GET['userId'] = $authorized['Id'];
54
			$_GET['Id'] = $authorized['cartId'];
55
			if($authorized['isLoggedIn'] == 1){
56
				$_GET['isLoggedIn'] = 'true';
57
			}
16276 amit.gupta 58
			elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
10582 lgm 59
				$_GET['isLoggedIn'] = 'false';
60
			}
10834 lgm 61
			$newValues = $authorized;
62
			$newValues['totalItems'] = 0;
16276 amit.gupta 63
			$this->session->userdata['authorized'] = $newValues;
10582 lgm 64
		}
65
    	//die();
66
    	$this->lessphp->object()->ccompile('assets/css/shipping.less','assets/css/shipping.css');
67
        $data['stylesheet'] = 'shipping.css';
68
		$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$this->config->item('orderconfirmation'));
69
		// $this->session->unset_userdata('shipping');
70
		// $this->session->unset_userdata('billing');
71
		// $this->session->unset_userdata('shoppingId');
16276 amit.gupta 72
		$this->session->unset_userdata(array('hotspotId','addressId'));
10582 lgm 73
		$this->layout->view('checkout/checkout_view',$data);
74
	}
75
	public function payment()
76
	{
77
		//standard array
17868 amit.gupta 78
		if (!empty($_GET['cq'])) {
79
			$this->session->userdata['authorized']['totalItems'] = $_GET['cq'];
17985 amit.gupta 80
			$this->session->set_userdata('addressId',$_GET['addressid']);
17868 amit.gupta 81
		}
17884 amit.gupta 82
		$authorized = $this->session->userdata('authorized');
10582 lgm 83
		if(!isset($authorized) || empty($authorized)){
84
			redirect(base_url()."cart");
85
		}
86
 
87
		$data = array();
88
		$codCaptcha = $this->session->userdata('cod');
89
		if(isset($codCaptcha) && $codCaptcha == 1){
90
			$data['codCaptcha'] = 1;
91
			$this->session->unset_userdata('cod');
92
		}else{
93
			$data['codCaptcha'] = 0;
94
		}
95
		$paymentconfig = $this->config->item('payment');
96
		if(!isset($_POST['submit'])){
97
			$hotspot = $this->session->userdata('hotspotId');
98
			if(isset($hotspot) && !empty($hotspot)){
99
				$_GET['hotSpotAddressId'] = $hotspot;
100
				$_GET['deliveryLocation'] = 'hotSpot';
101
			}else{
102
				$_GET['deliveryLocation'] = 'myLocation';
103
			}
104
			unset($paymentconfig['response'][2]);
105
			if(isset($authorized) && !empty($authorized)){
106
				$_GET['userId'] = $authorized['Id'];
107
				$_GET['Id'] = $authorized['cartId'];
108
				if($authorized['isLoggedIn'] == 1){
109
					$_GET['isLoggedIn'] = 'true';
110
				}
111
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
112
					$_GET['isLoggedIn'] = 'false';
113
				}
14939 anikendra 114
				if(isset($authorized['isPrivateDealUser']) && $authorized['isPrivateDealUser'] == 1){
115
					$this->session->set_userdata('skipcaptcha',1);
116
					$data['skipcaptcha'] = 1;
117
				}
10582 lgm 118
			}
119
			$addressId = $this->session->userdata('addressId');
120
			$_GET['addressid'] = $addressId;
121
			$this->lessphp->object()->ccompile('assets/css/shipping.less','assets/css/shipping.css');
122
      		$data['stylesheet'] = 'shipping.css';
11012 lgm 123
      		$data['title'] = 'Saholic';
10582 lgm 124
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),'',$paymentconfig);
125
			if(isset($data['response']['response']['payment_process'])){
126
				$result = json_decode($data['response']['response']['payment_process'][0]);
127
				$totalAmount = $result->results->totalAmount;
128
				if(isset($result->results->isTotalAmountZero)){
129
					$isTotalAmountZero = $result->results->isTotalAmountZero;
130
				}
131
				$totalAmount = number_format((float)$totalAmount,0,'.','');
132
				$captcha = $this->captcha_model->generateCaptcha();
133
				$this->session->set_userdata('captcha',$captcha['word']);
134
				$data['captcha'] = $captcha;
135
				// if($totalAmount == 0 && isset($isTotalAmountZero) && $isTotalAmountZero == 1){
136
				// 	$captcha = $this->captcha_model->generateCaptcha();
137
				// 	$this->session->set_userdata('captcha',$captcha['word']);
138
				// 	$this->session->set_userdata('captchaDisplay',$isTotalAmountZero);
139
				// 	$data['captcha'] = $captcha;
140
				// }
141
				$this->layout->view('checkout/checkout_view',$data);
142
			}
143
			else{
144
				redirect(base_url()."cart");
145
			}
146
		}
15792 anikendra 147
		elseif(isset($_POST['submit'])) {
10582 lgm 148
			if(isset($_POST['captcha_response_field']) && !empty($_POST['captcha_response_field'])){
149
				$captcha = $this->session->userdata('captcha');
150
				if(strcmp($captcha,$_POST['captcha_response_field']) != 0){
10630 lgm 151
					if(isset($_POST['payoption']) && ($_POST['payoption'] == 3000) || $_POST['payoption'] == 3001) {
10582 lgm 152
						$this->session->set_userdata('cod',1);
153
					}
154
        			redirect(base_url().'payment');
155
      			}
156
			}
157
			unset($paymentconfig['response'][0]);
158
			unset($paymentconfig['response'][1]);
159
			if(isset($authorized) && !empty($authorized)){
160
				$_POST['userId'] = $authorized['Id'];
161
				if($authorized['isLoggedIn'] == 1){
162
					$_POST['isLoggedIn'] = 'true';
163
				}
164
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
165
					$_POST['isLoggedIn'] = 'false';
166
				}
167
			}
168
			$addressId = $this->session->userdata('addressId');
169
			$_POST['addressid'] = $addressId;
170
			$_POST['payment_option'] = $_POST['payoption'];
171
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$paymentconfig);
15792 anikendra 172
			error_log('[USER] ' .print_r($authorized,1),3,'/tmp/payments.log');
173
			error_log('[RESPONSE] '. print_r($data['response']['response'],1),3,'/tmp/payments.log');
174
			if(isset($data['response']['response']['payment_submit'][0]) && !empty($data['response']['response']['payment_submit'][0])) {
10582 lgm 175
				$paymentSubmit = $data['response']['response']['payment_submit'][0];
176
				if(isset($paymentSubmit->response->isPaymentRedirect) && $paymentSubmit->response->isPaymentRedirect == 1){
16276 amit.gupta 177
					$image = '/assets/images/loading.gif';
10582 lgm 178
					$location = $paymentSubmit->response->redirectUrl;
10735 lgm 179
					echo '<html><head><meta http-equiv="refresh" content="1;url='.$paymentSubmit->response->redirectUrl.'">
11301 lgm 180
  					<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
10582 lgm 181
  					<title>Saholic Mobile Site: Redirecting to <'.$paymentSubmit->response->gatewayName.'> Payment Gateway</title>
182
 					</head>
183
 						<body>
184
     					<div style="text-align:center; margin-top:200px;">Please wait while we redirect you to the Payment Gateway.</div>
185
     					<div align="center" class="img">
186
      					<img title="loading" alt="loading" src="'.$image.'">
187
     					</div>
188
 						</body>
189
						</html>';
13350 anikendra 190
				}elseif(strpos($paymentSubmit->response->redirectUrl, 'ebs-pay') !== false) {
10582 lgm 191
					$url = $this->config->item('curl_base_url').$paymentSubmit->response->redirectUrl;
192
					//echo $url;
193
					$authorized = $this->session->userdata('authorized');
194
					if(isset($authorized) && !empty($authorized)){
195
						$params['userId'] = $authorized['Id'];
196
						if($authorized['isLoggedIn'] == 1){
197
							$params['isLoggedIn'] = 'true';
198
						}
199
						elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
200
							$params['isLoggedIn'] = 'false';
201
						}
202
					}
203
					$this->mcurl->add_call('ebs','get',$url,$params);
204
         			$response = $this->mcurl->execute($url);
205
         			$data['response'] = $response['ebs']['response'];
206
         			$response = $this->magento_model->payment_submit($data);
13350 anikendra 207
         			if(isset($response) && !empty($response)) {
10582 lgm 208
         				$ebs = $response[0]->response;
11339 lgm 209
         				$image = './assets/images/loading.gif';
10582 lgm 210
         				echo '<html>
211
						<head>
11301 lgm 212
						 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
10582 lgm 213
						 <title>m.saholic.com: Redirecting to EBS Payment Page</title>
214
						</head>
215
						<body>
216
						    <div style="text-align:center; margin-top:200px;">Please wait while we redirect you to the Payment Gateway.</div>
217
						 <div align="center" class="img">
10735 lgm 218
						  <img title="loading" alt="loading" src="'.$image.'">
10582 lgm 219
						 </div>
220
						 <div style="display:none">
221
						  <form  method="post" action="'.$ebs->postAction.'" name="frmTransaction" id="frmTransaction">  
222
				           <!-- Account Id -->
223
				           <input name="account_id" type="hidden" value="'.$ebs->account_id.'" />
224
				           <!-- Transaction Details -->
225
				           <input name="reference_no" type="hidden" value="'.$ebs->reference_no.'" />
226
				           <input name="amount" type="hidden" value="'.$ebs->amount.'" />
227
				           <input name="description" type="hidden" value="'.$ebs->description.'" />
228
				           <input name="payment_option" type="hidden" value="'.$ebs->payment_option.'"/>
229
				           <!-- Billing Address -->
230
				           <input name="name" type="hidden" value="'.$ebs->name.'" />
231
				           <input name="address" type="hidden" value="'.$ebs->address.'" />
232
				           <input name="city" type="hidden" value="'.$ebs->city.'" />
233
				           <input name="state" type="hidden" value="'.$ebs->state.'" />
234
				           <input name="postal_code" type="hidden" value="'.$ebs->postal_code.'" />
11413 amit.gupta 235
				           <input name="country" type="hidden" value="'.$ebs->country.'"/>
10582 lgm 236
				           <input name="email" type="hidden" value="'.$ebs->email.'" />
237
				           <input name="phone" type="hidden" value="'.$ebs->phone.'" />
238
				           <!-- Delivery Address -->
239
				           <input name="ship_name" type="hidden" value="'.$ebs->ship_name.'" />
240
				           <input name="ship_address" type="hidden" value="'.$ebs->ship_address.'" />
241
				           <input name="ship_city" type="hidden" value="'.$ebs->ship_city.'" />
242
				           <input name="ship_state" type="hidden" value="'.$ebs->ship_state.'" />
243
				           <input name="ship_postal_code" type="hidden" value="'.$ebs->ship_postal_code.'" />
11413 amit.gupta 244
				           <input name="ship_country" type="hidden" value="'.$ebs->ship_country.'"/> 
10582 lgm 245
				           <input name="ship_phone" type="hidden" value="'.$ebs->ship_phone.'" />
246
				           <input name="return_url" type="hidden" value="'.$ebs->return_url.'" />
247
				           <input name="mode" value="'.$ebs->mode.'"/>
248
				           <input name="secure_hash" type="hidden" value="'.$ebs->secure_hash.'" />
249
				           <input name="channel" type="hidden" value="'.$ebs->channel.'" />
250
				           <input name="page_id" type="hidden" value="'.$ebs->page_id.'" />
251
						  </form>
252
						    </div>
253
						    <script type="text/javascript">
254
						     document.getElementById("frmTransaction").submit();
255
						    </script>
256
						  </body>
257
						</html>';
13350 anikendra 258
         			}
259
         			else{
10582 lgm 260
         				redirect(base_url().'payment');
261
         			}
262
				}
13350 anikendra 263
				elseif(strpos($paymentSubmit->response->redirectUrl, 'payu-pay') !== false) {
264
					$url = $this->config->item('curl_base_url').$paymentSubmit->response->redirectUrl;
265
					//echo $url;
266
					$params = array();
267
					$authorized = $this->session->userdata('authorized');
268
					if(isset($authorized) && !empty($authorized)){
269
						$params['userId'] = $authorized['Id'];
270
						if($authorized['isLoggedIn'] == 1){
271
							$params['isLoggedIn'] = 'true';
272
						}
273
						elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
274
							$params['isLoggedIn'] = 'false';
275
						}
276
					}
277
					$this->mcurl->add_call('payu','get',$url,$params);
278
         			$response = $this->mcurl->execute($url);
279
         			error_log("payu response".print_r($response,1));
280
         			$data['response'] = $response['payu']['response'];
281
         			$response = $this->magento_model->payment_submit($data);
282
         			if(isset($response) && !empty($response)){
283
         				$payu = $response[0]->response;
16276 amit.gupta 284
         				$image = '/assets/images/loading.gif';
13350 anikendra 285
         				// $return_url = base_url().'ebs-pay-processing/?DR={DR}';
286
         				$ci = get_instance();
287
         			}
288
         			?>
289
         				<html>
290
						<head>
291
						<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
292
						 <title>m.saholic.com: Redirecting to EBS Payment Page</title>
293
						</head>
294
						<body>
295
						    <div style="text-align:center; margin-top:200px;">Please wait while we redirect you to the Payment Gateway.</div>
296
						 <div align="center" class="img">
16276 amit.gupta 297
						  <img title="loading" alt="loading" src="<?php echo $image;?>">
13350 anikendra 298
						 </div>
299
						 <div style="display:none;">
300
						   <form action="<?php echo $payu->postActionUrl; ?>" method="post" id="payuForm">
301
						      	<input type="hidden" name="key" value="<?php echo $payu->key; ?>" />
302
						      	<input type="hidden" name="hash" value="<?php echo $payu->hash ?>"/>
303
						      	<input type="hidden" name="txnid" value="<?php echo $payu->txnid ?>" />
304
						      	<input name="amount" value="<?php echo $payu->amount; ?>" />
305
								<input name="firstname" id="firstname" value="<?php echo $payu->firstname;?>" />
306
						        <input name="email" id="email" value="<?php echo $payu->email; ?>" />
307
						        <input name="phone" value="<?php echo $payu->phone; ?>" />
308
						        <input name="productinfo" value="<?php echo $payu->productinfo; ?>" />
309
						        <input name="surl" value="<?php echo base_url().$payu->surl; ?>"  />
310
						        <input name="furl" value="<?php echo base_url().$payu->furl; ?>" />
311
						        <input name="bankcode" value="<?php echo $payu->bankcode; ?>" />
312
						        <input name="pg" value="<?php echo $payu->pg; ?>" />
313
						        <input name="curl" value="<?php echo base_url().$payu->curl; ?>" />
314
						        <input type="submit" value="Submit" />						          
315
						    </form>
316
					    </div>
317
					    <script type="text/javascript">
318
						    document.getElementById("payuForm").submit();
319
					    </script>
320
					  </body>
321
					</html>
322
					<?php
323
				}  
10582 lgm 324
				else{
325
					redirect(base_url().$paymentSubmit->response->redirectUrl);
326
				}
15792 anikendra 327
			} else {
328
				redirect(base_url()."payment");	
10582 lgm 329
			}
15792 anikendra 330
		}		
10582 lgm 331
	}
13350 anikendra 332
 
10582 lgm 333
	public function ebsprocessing(){
334
		if(isset($_GET['DR']) && !empty($_GET['DR'])){
335
			$paymentconfig = $this->config->item('ebsProcessing');
336
			$authorized = $this->session->userdata('authorized');
337
			if(isset($authorized) && !empty($authorized)){
338
				$_GET['userId'] = $authorized['Id'];
339
				if($authorized['isLoggedIn'] == 1){
340
					$_GET['isLoggedIn'] = 'true';
341
				}
342
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
343
					$_GET['isLoggedIn'] = 'false';
344
				}
345
			}
346
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$paymentconfig);
347
			if(isset($data['response']['response']['ebs_processing'][0]->response)){
348
				$redirectUrl = $data['response']['response']['ebs_processing'][0]->response->redirectUrl;
349
				$redirectUrl = explode('?', $redirectUrl);
350
				$redirectUrl = base_url().'ebs-pay-response/?'.$redirectUrl[1];
16276 amit.gupta 351
				$image = '/assets/images/loading.gif';
10582 lgm 352
				echo '<html><head><meta http-equiv="refresh" content="2;url='.$redirectUrl.'">
11301 lgm 353
					<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
10582 lgm 354
  					<title>Saholic Mobile Site:</title>
355
 					</head>
356
 						<body>
357
     					<div style="text-align:center; margin-top:200px;">'.$data['response']['response']['ebs_processing'][0]->response->redirectMessage.'</div>
358
     					<div align="center" class="img">
10735 lgm 359
      					<img title="loading" alt="loading" src="'.$image.'">
10582 lgm 360
     					</div>
361
 						</body>
362
						</html>';
363
			}
364
		}
365
	}
366
	public function ebsresponse(){
367
		if(isset($_GET['DR']) && !empty($_GET['DR'])){
368
			$paymentconfig = $this->config->item('ebsResponse');
369
			$authorized = $this->session->userdata('authorized');
370
			if(isset($authorized) && !empty($authorized)){
371
				$_GET['userId'] = $authorized['Id'];
372
				if($authorized['isLoggedIn'] == 1){
373
					$_GET['isLoggedIn'] = 'true';
374
				}
375
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
376
					$_GET['isLoggedIn'] = 'false';
377
				}
378
			}
379
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$paymentconfig);
380
			if(isset($data['response']['response']['ebs_response'][0]->response) && !empty($data['response']['response']['ebs_response'][0]->response)){
381
				$redirectUrl = $data['response']['response']['ebs_response'][0]->response->redirectUrl;
382
				redirect($redirectUrl);
383
			}
384
			else{
385
				redirect(base_url().'payment');
386
			}
387
		}
388
	}
13304 anikendra 389
 
390
	public function payuresponse(){
391
		error_log("payu response ".print_r($_REQUEST,1));
392
		$paymentconfig = $this->config->item('payuResponse');
393
		$authorized = $this->session->userdata('authorized');
394
		if(isset($authorized) && !empty($authorized)){
395
			$_GET['userId'] = $authorized['Id'];
396
			if($authorized['isLoggedIn'] == 1){
397
				$_GET['isLoggedIn'] = 'true';
398
			}
399
			elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
400
				$_GET['isLoggedIn'] = 'false';
401
			}
402
		}
403
		$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$paymentconfig);
404
		error_log("payu response ".print_r($data['response'],1));
405
		if(isset($data['response']['response']['payu_response'][0]->response) && !empty($data['response']['response']['payu_response'][0]->response)){
406
			$redirectUrl = $data['response']['response']['payu_response'][0]->response->redirectUrl;
407
			redirect($redirectUrl);
408
		}
409
		else{
410
			redirect(base_url().'payment');
411
		}
412
	}
413
 
10582 lgm 414
	public function hdfcPayResponse(){
415
		if(isset($_POST)){
416
			$paymentconfig = $this->config->item('hdfcResponse');
417
			$authorized = $this->session->userdata('authorized');
418
			if(isset($authorized) && !empty($authorized)){
419
				$_POST['userId'] = $authorized['Id'];
420
				if($authorized['isLoggedIn'] == 1){
421
					$_POST['isLoggedIn'] = 'true';
422
				}
423
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
424
					$_POST['isLoggedIn'] = 'false';
425
				}
426
			}
427
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$paymentconfig);
428
			if(isset($data['response']['response']['hdfc_response'][0]->response) && !empty($data['response']['response']['hdfc_response'][0]->response)){
429
				$redirectUrl = $data['response']['response']['hdfc_response'][0]->response->redirectUrl;
430
				redirect($redirectUrl);
431
			}
432
			else{
433
				redirect(base_url());
434
			}	
435
		}else{
436
			redirect(base_url());
437
		}
438
	}
10890 lgm 439
	public function hdfcEmiResponse(){
440
		if(isset($_POST)){
441
			$paymentconfig = $this->config->item('hdfcEmiResponse');
442
			$authorized = $this->session->userdata('authorized');
443
			if(isset($authorized) && !empty($authorized)){
444
				$_POST['userId'] = $authorized['Id'];
445
				if($authorized['isLoggedIn'] == 1){
446
					$_POST['isLoggedIn'] = 'true';
447
				}
448
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
449
					$_POST['isLoggedIn'] = 'false';
450
				}
451
			}
452
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$paymentconfig);
453
			if(isset($data['response']['response']['hdfc_emi_response'][0]->response) && !empty($data['response']['response']['hdfc_emi_response'][0]->response)){
454
				$redirectUrl = $data['response']['response']['hdfc_emi_response'][0]->response->redirectUrl;
455
				redirect($redirectUrl);
456
			}
457
			else{
458
				redirect(base_url());
459
			}	
460
		}else{
461
			redirect(base_url());
462
		}
463
	}
10582 lgm 464
	public function innovitiPayment(){
465
		$last = $this->uri->total_segments();
466
		$itemcode = $this->uri->segment($last);
467
		if(isset($itemcode) && !empty($itemcode)){
468
			$url = $this->config->item('curl_base_url').'innoviti-pay/'.$itemcode;
469
			$params = array();
470
			$authorized = $this->session->userdata('authorized');
471
			if(isset($authorized) && !empty($authorized)){
472
				$params['userId'] = $authorized['Id'];
473
				if($authorized['isLoggedIn'] == 1){
474
					$params['isLoggedIn'] = 'true';
475
				}
476
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
477
					$params['isLoggedIn'] = 'false';
478
				}
479
			$this->mcurl->add_call('innoviti','get',$url,$params);
480
 			$response = $this->mcurl->execute($url);
481
 			$data['response'] = $response['innoviti']['response'];
482
         	$response = $this->magento_model->payment_submit($data);
483
         	if(isset($response) && !empty($response)){
484
         		$innoviti = $response[0]->response;
11339 lgm 485
         		$image = './assets/images/loading.gif';
11301 lgm 486
         		echo '<html>
487
						<head>
488
						 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
489
						 <title>m.saholic.com: Redirecting to Innoviti Payment Page</title>
490
						</head>
491
						<body>
492
						    <div style="text-align:center; margin-top:200px;">Please wait while we redirect you to the Payment Gateway.</div>
493
						 <div align="center" class="img">
494
						  <img title="loading" alt="loading" src="'.$image.'">
495
						 </div>
496
						 <div style="display:none">
497
						  <form  method="post" action="'.$innoviti->action.'" name="frmTransaction" id="frmTransaction">  
498
								<input name="merchantId" type="hidden" value="'.$innoviti->merchantId.'" />
499
								<input name="subMerchantId" type="hidden" value="'.$innoviti->subMerchantId.'" />
500
										<!-- Transaction Details -->
501
								<input name="orderId" type="hidden" value="'.$innoviti->orderId.'" />
502
								<input name="amt" type="hidden" value="'.$innoviti->amt.'" />   
503
								<input name="cur" type="hidden" value="INR" />
504
								<input name="processingCode" type="hidden" value="'.$innoviti->processingCode.'" />
505
								<input name="proSku" type="hidden" value="'.$innoviti->proSku.'" />
506
								<input name="Cname" type="hidden" value="'.$innoviti->Cname.'" /></td>
507
								<input name="mobile" type="hidden" value="'.$innoviti->mobile.'" />
508
								<input name="emailId" type="hidden" value="'.$innoviti->emailId.'" />     
509
								<input name="redirUrl" type="hidden" value="'.$innoviti->redirUrl.'" />
510
								<input name="chksum" type="hidden" value="'.$innoviti->chksum.'" />
511
								<input name="isCtx" type="hidden" value="NO" />
512
							<input name="submitted" value="Submit" type="submit" />&nbsp; 
513
							  </form>
514
						    </div><script type="text/javascript">
10582 lgm 515
						    document.getElementById("frmTransaction").submit();
11301 lgm 516
						</script></body></html>';
10582 lgm 517
         	}
518
			}else{
519
				redirect(base_url());
520
			}
521
 
522
		}else{
523
			redirect(base_url());
524
		}
525
	}
526
	public function innovitiResponse(){
527
		if(isset($_POST)){
528
			$paymentconfig = $this->config->item('innovitiResponse');
529
			$authorized = $this->session->userdata('authorized');
530
			if(isset($authorized) && !empty($authorized)){
531
				$_POST['userId'] = $authorized['Id'];
532
				if($authorized['isLoggedIn'] == 1){
533
					$_POST['isLoggedIn'] = 'true';
534
				}
535
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
536
					$_POST['isLoggedIn'] = 'false';
537
				}
538
			}
539
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$paymentconfig);
540
			if(isset($data['response']['response']['innoviti_response'][0]->response) && !empty($data['response']['response']['innoviti_response'][0]->response)){
541
				$redirectUrl = $data['response']['response']['innoviti_response'][0]->response->redirectUrl;
542
				redirect($redirectUrl);
543
			}
544
			else{
545
				redirect(base_url());
546
			}	
547
		}else{
548
			redirect(base_url());
549
		}
550
	}
551
	public function paymenterror(){
552
			$authorized = $this->session->userdata('authorized');
553
			if(isset($authorized) && !empty($authorized)){
554
				$data = array();
555
				$paymentconfig = $this->config->item('paymenterror');
10634 lgm 556
				$this->lessphp->object()->ccompile('assets/css/shipping.less','assets/css/shipping.css');
10582 lgm 557
				$data['stylesheet'] = 'shipping.css';
558
				$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$paymentconfig);
559
				$this->layout->view('checkout/checkout_view',$data);
560
			}else{
561
				redirect(base_url());
562
			}
563
	}
564
	public function shipping()
565
	{
566
 
567
		$data = array();
568
		$authorized = $this->session->userdata('authorized');
569
		if($authorized['isLoggedIn'] != 1){
570
			$this->session->set_userdata('location','shipping');
571
			redirect(base_url()."login");
572
		}
573
		$shippingconfig = $this->config->item('shipping');
574
		if(!isset($_POST['submit']))
575
		{
576
			$authorized = $this->session->userdata('authorized');
577
				if(isset($authorized) && !empty($authorized)){
578
					$_GET['userId'] = $authorized['Id'];
579
					$_GET['Id'] = $authorized['cartId'];
580
					if($authorized['isLoggedIn'] == 1){
581
						$_GET['isLoggedIn'] = 'true';
582
					}
583
					elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
584
						$_GET['isLoggedIn'] = 'false';
585
					}
586
				}
587
			$this->lessphp->object()->ccompile('assets/css/shipping.less','assets/css/shipping.css');
588
			$data['stylesheet'] = 'shipping.css';
11012 lgm 589
			$data['title'] = 'Saholic';
10582 lgm 590
			$cache = getFileCache('pickup');
591
			if(isset($cache) && !empty($cache)){
592
				unset($shippingconfig['response'][1]);
593
				$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$shippingconfig);
594
				$data['response']['response']['pickup'] = $cache;
595
			}else{
596
				$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$shippingconfig);
597
        		if(isset($data['response']['response']['pickup']) && !empty($data['response']['response']['pickup']))
598
        		setFileCache($data['response']['response']['pickup'], 'pickup',900);
599
			}
10758 lgm 600
			$carts = $data['response']['response']['carts'][0];
10757 lgm 601
			$shipping = $data['response']['response']['shipping_process'][0]; 
602
			if((isset($carts) && !empty($carts)) && (isset($shipping) && !empty($shipping))){
10752 lgm 603
				$this->layout->view('checkout/checkout_view',$data);
604
			}else{
605
				redirect(base_url()."cart");
606
			}
10582 lgm 607
		}
608
		if(isset($_POST['submit']))
609
		{
610
			unset($shippingconfig['response'][1]);	
611
			$data = $this->get_shipping_billing($_POST);
612
			$this->session->set_userdata($data);
613
			$authorized = $this->session->userdata('authorized');
614
			if(isset($authorized) && !empty($authorized)){
615
				$_POST['userId'] = $authorized['Id'];
11530 lgm 616
				$_POST['Id'] = $authorized['cartId'];
10582 lgm 617
					if($authorized['isLoggedIn'] == 1){
618
						$_POST['isLoggedIn'] = 'true';
619
					}
620
					elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
621
						$_POST['isLoggedIn'] = 'false';
622
					}
623
				}
624
			//$data['stylesheet'] = 'shipping.less';
625
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$shippingconfig);
626
			//$this->layout->view('checkout/checkout_view',$data);
627
			redirect(base_url()."shipping");
628
 
629
		}
630
 
631
	}
632
 
633
	public function get_shipping_billing($data=array()){
634
		$billing =array();
635
		$shipping =array();
636
		if (isset($data) && !empty($data)) {
637
			$shipping=array('name'  => $data['name'],'line1' => $data['line1'],'line2' => $data['line2'], 'city' => $data['city'], 'pin' => $data['pin'], 'phonenumber' => $data['phone']);
638
			return array('shipping'=>$shipping,'billing'=>$billing);
639
		}
640
	}
641
 
642
	public function delete($addressId){
643
		$shippingconfig = $this->config->item('shipping_delete');
644
		$_GET['addressId'] = $addressId;
645
		$authorized = $this->session->userdata('authorized');
646
		if(isset($authorized) && !empty($authorized)){
647
			$_GET['userId'] = $authorized['Id'];
648
			$_GET['Id'] = $authorized['cartId'];
649
			if($authorized['isLoggedIn'] == 1){
650
				$_GET['isLoggedIn'] = 'true';
651
			}
652
			elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
653
				$_GET['isLoggedIn'] = 'false';
654
				}
655
			}
656
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$shippingconfig);
657
			print_r($data['response']);
658
		}
659
 
660
	public function changeAddress($addressId,$type){
661
		if(isset($addressId) && isset($type)){
662
		$shippingconfig = $this->config->item('shipping_change');
663
		$_GET['addressId'] = $addressId;
664
		$_GET['addressType'] = $type;
665
		$authorized = $this->session->userdata('authorized');
666
		if(isset($authorized) && !empty($authorized)){
667
			$_GET['userId'] = $authorized['Id'];
668
			$_GET['Id'] = $authorized['cartId'];
669
			if($authorized['isLoggedIn'] == 1){
670
				$_GET['isLoggedIn'] = 'true';
671
			}
672
			elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
673
				$_GET['isLoggedIn'] = 'false';
674
				}
675
			}
676
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$shippingconfig);
677
			$this->session->set_userdata('addressId',$addressId);
10788 lgm 678
			echo json_encode($data['response']['response']['changeAddress'][0]);
10582 lgm 679
		}
680
	}
681
	public function changeCaptcha(){
682
		$captchaDisplay = $this->session->userdata('captchaDisplay');
683
		//if(isset($captchaDisplay) && $captchaDisplay == 1){
684
			$captcha = $this->captcha_model->generateCaptcha();
685
			$this->session->set_userdata('captcha',$captcha['word']);
686
			unset($captcha['word']);
687
			unset($captcha['time']);
688
			unset($captcha['name']);
689
			echo json_encode($captcha);
690
		//}
691
	}
692
	public function insuranceInfo($bday,$gname,$addressId){
693
	if((isset($bday) && !empty($bday)) && (isset($gname) && !empty($gname)) && (isset($addressId) && !empty($addressId))){
694
		if(isset($gname) && !empty($gname)){
10840 lgm 695
			$gname = str_replace('-',' ',$gname);
10582 lgm 696
			$gname = ltrim($gname);
697
			$gname = rtrim($gname);
698
			$_GET['guardianName'] = $gname;
699
		}
700
		if(isset($bday) && !empty($bday)){
701
			$dob = explode('-',$bday);
10840 lgm 702
			//$dob = array_reverse($dob);
10582 lgm 703
			$temp1 = $dob[1];
704
			$temp2 = $dob[0];
705
			$dob[0] = $temp1;
706
			$dob[1] = $temp2;
10840 lgm 707
 
10582 lgm 708
			$dob = implode('/', $dob);
709
			$_GET['dob'] = $dob; 
10840 lgm 710
		} 
10582 lgm 711
		$insuranceconfig = $this->config->item('insurance_info');
712
		$_GET['addressId'] = $addressId;
713
		$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$insuranceconfig);
714
		if(isset($data['response']['response']['insuranceInfo'][0]->response) && (!empty($data['response']['response']['insuranceInfo'][0]->response))) {
715
			echo json_encode($data['response']['response']['insuranceInfo'][0]);
716
		}
717
	}
718
  }
719
  public function pickupSpot($id){
720
  	if(isset($id) && !empty($id) && is_numeric($id)){
721
  		$this->session->set_userdata('hotspotId',$id);
722
  		$response['msg'] = 'sucess';
723
  		echo json_encode($response);
724
  	}
725
  }
726
 
727
}
728
 
10611 amit.gupta 729
 
10582 lgm 730
/* End of file welcome.php */
13350 anikendra 731
/* Location: ./application/controllers/welcome.php */