Subversion Repositories SmartDukaan

Rev

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