Subversion Repositories SmartDukaan

Rev

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