Subversion Repositories SmartDukaan

Rev

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