Subversion Repositories SmartDukaan

Rev

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