Subversion Repositories SmartDukaan

Rev

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