Subversion Repositories SmartDukaan

Rev

Rev 20877 | 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
	}
20622 amit.gupta 75
	public function orderconfirmation1()
76
	{
77
		$this->layout->setlayout('layout/layout_bigutsav');
78
		$authorized = $this->session->userdata('authorized');
79
	    if(isset($authorized) && !empty($authorized)){
80
			$_GET['userId'] = $authorized['Id'];
81
			$_GET['Id'] = $authorized['cartId'];
82
			if($authorized['isLoggedIn'] == 1){
83
				$_GET['isLoggedIn'] = 'true';
84
			}
85
			elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
86
				$_GET['isLoggedIn'] = 'false';
87
			}
88
			$newValues = $authorized;
89
			$newValues['totalItems'] = 0;
90
			$this->session->userdata['authorized'] = $newValues;
91
		}
92
    	//die();
93
    	$this->lessphp->object()->ccompile('assets/css/shipping.less','assets/css/shipping.css');
94
        $data['stylesheet'] = 'shipping.css';
95
		$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$this->config->item('orderconfirmation1'));
96
		// $this->session->unset_userdata('shipping');
97
		// $this->session->unset_userdata('billing');
98
		// $this->session->unset_userdata('shoppingId');
99
		$this->session->unset_userdata(array('hotspotId','addressId'));
100
		$this->layout->view('checkout/checkout_view',$data);
101
	}
20609 amit.gupta 102
	public function payment1()
103
	{
104
		$this->layout->setlayout('layout/layout_bigutsav');
105
		//standard array
106
		if (!empty($_GET['cq'])) {
107
			$this->session->userdata['authorized']['totalItems'] = $_GET['cq'];
108
			$this->session->set_userdata('addressId',$_GET['addressid']);
109
		}
110
		$authorized = $this->session->userdata('authorized');
111
		if(!isset($authorized) || empty($authorized)){
112
			redirect(base_url()."cart");
113
		}
114
 
115
		$data = array();
116
		$codCaptcha = $this->session->userdata('cod');
117
		if(isset($codCaptcha) && $codCaptcha == 1){
118
			$data['codCaptcha'] = 1;
119
			$this->session->unset_userdata('cod');
120
		}else{
121
			$data['codCaptcha'] = 0;
122
		}
123
		$paymentconfig = $this->config->item('payment1');
124
		if(!isset($_POST['submit'])){
125
			$hotspot = $this->session->userdata('hotspotId');
126
			if(isset($hotspot) && !empty($hotspot)){
127
				$_GET['hotSpotAddressId'] = $hotspot;
128
				$_GET['deliveryLocation'] = 'hotSpot';
129
			}else{
130
				$_GET['deliveryLocation'] = 'myLocation';
131
			}
132
			unset($paymentconfig['response'][2]);
133
			if(isset($authorized) && !empty($authorized)){
134
				$_GET['userId'] = $authorized['Id'];
135
				$_GET['Id'] = $authorized['cartId'];
136
				if($authorized['isLoggedIn'] == 1){
137
					$_GET['isLoggedIn'] = 'true';
138
				}
139
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
140
					$_GET['isLoggedIn'] = 'false';
141
				}
142
				if(isset($authorized['isPrivateDealUser']) && $authorized['isPrivateDealUser'] == 1){
143
					$this->session->set_userdata('skipcaptcha',1);
144
					$data['skipcaptcha'] = 1;
145
				}
146
			}
147
			$addressId = $this->session->userdata('addressId');
148
			$_GET['addressid'] = $addressId;
20862 amit.gupta 149
 
20609 amit.gupta 150
			$this->lessphp->object()->ccompile('assets/css/shipping.less','assets/css/shipping.css');
151
      		$data['stylesheet'] = 'shipping.css';
152
      		$data['title'] = 'Saholic';
153
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),'',$paymentconfig);
154
			if(isset($data['response']['response']['payment_process1'])){
155
				$result = json_decode($data['response']['response']['payment_process1'][0]);
20862 amit.gupta 156
				if(isset($_GET['walletUsed'])) {
20877 amit.gupta 157
					$walletUsed = (int)($_GET['walletUsed']);
20609 amit.gupta 158
				}
20862 amit.gupta 159
				$this->session->set_userdata('walletUsed',$walletUsed);
20609 amit.gupta 160
				$this->layout->view('checkout/checkout_view',$data);
161
			}
162
			else{
163
				redirect(base_url()."cart");
164
			}
165
		}
166
		elseif(isset($_POST['submit'])) {
167
			if(isset($_POST['captcha_response_field']) && !empty($_POST['captcha_response_field'])){
168
				$captcha = $this->session->userdata('captcha');
169
				if(strcmp($captcha,$_POST['captcha_response_field']) != 0){
170
					if(isset($_POST['payoption']) && ($_POST['payoption'] == 3000) || $_POST['payoption'] == 3001) {
171
						$this->session->set_userdata('cod',1);
172
					}
173
        			redirect(base_url().'payment');
174
      			}
175
			}
176
			unset($paymentconfig['response'][0]);
177
			unset($paymentconfig['response'][1]);
178
			if(isset($authorized) && !empty($authorized)){
179
				$_POST['userId'] = $authorized['Id'];
180
				if($authorized['isLoggedIn'] == 1){
181
					$_POST['isLoggedIn'] = 'true';
182
				}
183
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
184
					$_POST['isLoggedIn'] = 'false';
185
				}
186
			}
187
			$addressId = $this->session->userdata('addressId');
20862 amit.gupta 188
			$walletUsed = $this->session->userdata('walletUsed');
20609 amit.gupta 189
			$_POST['addressid'] = $addressId;
20862 amit.gupta 190
			$_POST['walletUsed'] = $walletUsed;
20609 amit.gupta 191
			$_POST['payment_option'] = $_POST['payoption'];
192
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$paymentconfig);
193
			error_log('[USER] ' .print_r($authorized,1),3,'/tmp/payments.log');
194
			error_log('[RESPONSE] '. print_r($data['response']['response'],1),3,'/tmp/payments.log');
195
			if(isset($data['response']['response']['payment_submit'][0]) && !empty($data['response']['response']['payment_submit'][0])) {
196
				$paymentSubmit = $data['response']['response']['payment_submit'][0];
197
				if(isset($paymentSubmit->response->isPaymentRedirect) && $paymentSubmit->response->isPaymentRedirect == 1){
198
					$image = '/assets/images/loading.gif';
199
					$location = $paymentSubmit->response->redirectUrl;
200
					echo '<html><head><meta http-equiv="refresh" content="1;url='.$paymentSubmit->response->redirectUrl.'">
201
  					<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
202
  					<title>Saholic Mobile Site: Redirecting to <'.$paymentSubmit->response->gatewayName.'> Payment Gateway</title>
203
 					</head>
204
 						<body>
205
     					<div style="text-align:center; margin-top:200px;">Please wait while we redirect you to the Payment Gateway.</div>
206
     					<div align="center" class="img">
207
      					<img title="loading" alt="loading" src="'.$image.'">
208
     					</div>
209
 						</body>
210
						</html>';
211
				}elseif(strpos($paymentSubmit->response->redirectUrl, 'ebs-pay') !== false) {
212
					$url = $this->config->item('curl_base_url').$paymentSubmit->response->redirectUrl;
213
					//echo $url;
214
					$authorized = $this->session->userdata('authorized');
215
					if(isset($authorized) && !empty($authorized)){
216
						$params['userId'] = $authorized['Id'];
217
						if($authorized['isLoggedIn'] == 1){
218
							$params['isLoggedIn'] = 'true';
219
						}
220
						elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
221
							$params['isLoggedIn'] = 'false';
222
						}
223
					}
224
					$this->mcurl->add_call('ebs','get',$url,$params);
225
         			$response = $this->mcurl->execute($url);
226
         			$data['response'] = $response['ebs']['response'];
227
         			$response = $this->magento_model->payment_submit($data);
228
         			if(isset($response) && !empty($response)) {
229
         				$ebs = $response[0]->response;
230
         				$image = './assets/images/loading.gif';
231
         				echo '<html>
232
						<head>
233
						 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
234
						 <title>m.saholic.com: Redirecting to EBS Payment Page</title>
235
						</head>
236
						<body>
237
						    <div style="text-align:center; margin-top:200px;">Please wait while we redirect you to the Payment Gateway.</div>
238
						 <div align="center" class="img">
239
						  <img title="loading" alt="loading" src="'.$image.'">
240
						 </div>
241
						 <div style="display:none">
242
						  <form  method="post" action="'.$ebs->postAction.'" name="frmTransaction" id="frmTransaction">  
243
				           <!-- Account Id -->
244
				           <input name="account_id" type="hidden" value="'.$ebs->account_id.'" />
245
				           <!-- Transaction Details -->
246
				           <input name="reference_no" type="hidden" value="'.$ebs->reference_no.'" />
247
				           <input name="amount" type="hidden" value="'.$ebs->amount.'" />
248
				           <input name="description" type="hidden" value="'.$ebs->description.'" />
249
				           <input name="payment_option" type="hidden" value="'.$ebs->payment_option.'"/>
250
				           <!-- Billing Address -->
251
				           <input name="name" type="hidden" value="'.$ebs->name.'" />
252
				           <input name="address" type="hidden" value="'.$ebs->address.'" />
253
				           <input name="city" type="hidden" value="'.$ebs->city.'" />
254
				           <input name="state" type="hidden" value="'.$ebs->state.'" />
255
				           <input name="postal_code" type="hidden" value="'.$ebs->postal_code.'" />
256
				           <input name="country" type="hidden" value="'.$ebs->country.'"/>
257
				           <input name="email" type="hidden" value="'.$ebs->email.'" />
258
				           <input name="phone" type="hidden" value="'.$ebs->phone.'" />
259
				           <!-- Delivery Address -->
260
				           <input name="ship_name" type="hidden" value="'.$ebs->ship_name.'" />
261
				           <input name="ship_address" type="hidden" value="'.$ebs->ship_address.'" />
262
				           <input name="ship_city" type="hidden" value="'.$ebs->ship_city.'" />
263
				           <input name="ship_state" type="hidden" value="'.$ebs->ship_state.'" />
264
				           <input name="ship_postal_code" type="hidden" value="'.$ebs->ship_postal_code.'" />
265
				           <input name="ship_country" type="hidden" value="'.$ebs->ship_country.'"/> 
266
				           <input name="ship_phone" type="hidden" value="'.$ebs->ship_phone.'" />
267
				           <input name="return_url" type="hidden" value="'.$ebs->return_url.'" />
268
				           <input name="mode" value="'.$ebs->mode.'"/>
269
				           <input name="secure_hash" type="hidden" value="'.$ebs->secure_hash.'" />
270
				           <input name="channel" type="hidden" value="'.$ebs->channel.'" />
271
				           <input name="page_id" type="hidden" value="'.$ebs->page_id.'" />
272
						  </form>
273
						    </div>
274
						    <script type="text/javascript">
275
						     document.getElementById("frmTransaction").submit();
276
						    </script>
277
						  </body>
278
						</html>';
279
         			}
280
         			else{
281
         				redirect(base_url().'payment');
282
         			}
283
				}
284
				elseif(strpos($paymentSubmit->response->redirectUrl, 'payu-pay') !== false) {
285
					$url = $this->config->item('curl_base_url').$paymentSubmit->response->redirectUrl;
286
					//echo $url;
287
					$params = array();
288
					$authorized = $this->session->userdata('authorized');
289
					if(isset($authorized) && !empty($authorized)){
290
						$params['userId'] = $authorized['Id'];
291
						if($authorized['isLoggedIn'] == 1){
292
							$params['isLoggedIn'] = 'true';
293
						}
294
						elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
295
							$params['isLoggedIn'] = 'false';
296
						}
297
					}
298
					$this->mcurl->add_call('payu','get',$url,$params);
299
         			$response = $this->mcurl->execute($url);
300
         			error_log("payu response".print_r($response,1));
301
         			$data['response'] = $response['payu']['response'];
302
         			$response = $this->magento_model->payment_submit($data);
303
         			if(isset($response) && !empty($response)){
304
         				$payu = $response[0]->response;
305
         				$image = '/assets/images/loading.gif';
306
         				// $return_url = base_url().'ebs-pay-processing/?DR={DR}';
307
         				$ci = get_instance();
308
         			}
309
         			?>
310
         				<html>
311
						<head>
312
						<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
313
						 <title>m.saholic.com: Redirecting to PayU Payment Gateway</title>
314
						</head>
315
						<body>
316
						    <div style="text-align:center; margin-top:200px;">Please wait while we redirect you to the Payment Gateway.</div>
317
						 <div align="center" class="img">
318
						  <img title="loading" alt="loading" src="<?php echo $image;?>">
319
						 </div>
320
						 <div style="display:none;">
321
						   <form action="<?php echo $payu->postActionUrl; ?>" method="post" id="payuForm">
322
						      	<input type="hidden" name="key" value="<?php echo $payu->key; ?>" />
323
						      	<input type="hidden" name="hash" value="<?php echo $payu->hash ?>"/>
324
						      	<input type="hidden" name="txnid" value="<?php echo $payu->txnid ?>" />
325
						      	<input name="amount" value="<?php echo $payu->amount; ?>" />
326
								<input name="firstname" id="firstname" value="<?php echo $payu->firstname;?>" />
327
						        <input name="email" id="email" value="<?php echo $payu->email; ?>" />
328
						        <input name="phone" value="<?php echo $payu->phone; ?>" />
329
						        <input name="productinfo" value="<?php echo $payu->productinfo; ?>" />
330
						        <input name="surl" value="<?php echo rtrim(base_url(), "/").$payu->surl; ?>"  />
331
						        <input name="furl" value="<?php echo rtrim(base_url(), "/").$payu->furl; ?>" />
332
						        <input name="bankcode" value="<?php echo $payu->bankcode; ?>" />
333
						        <input name="pg" value="<?php echo $payu->pg; ?>" />
334
						        <input name="curl" value="<?php echo rtrim(base_url(), "/").$payu->curl; ?>" />
20622 amit.gupta 335
						        <input type="hidden" name="service_provider" value="payu_paisa" />
20609 amit.gupta 336
						        <input type="submit" value="Submit" />						          
337
						    </form>
338
					    </div>
339
					    <script type="text/javascript">
340
						    document.getElementById("payuForm").submit();
341
					    </script>
342
					  </body>
343
					</html>
344
					<?php
345
				}  
346
				else{
347
					redirect(base_url().$paymentSubmit->response->redirectUrl);
348
				}
349
			} else {
350
				redirect(base_url()."payment");	
351
			}
352
		}		
353
	}
10582 lgm 354
	public function payment()
355
	{
356
		//standard array
17868 amit.gupta 357
		if (!empty($_GET['cq'])) {
358
			$this->session->userdata['authorized']['totalItems'] = $_GET['cq'];
17985 amit.gupta 359
			$this->session->set_userdata('addressId',$_GET['addressid']);
17868 amit.gupta 360
		}
17884 amit.gupta 361
		$authorized = $this->session->userdata('authorized');
10582 lgm 362
		if(!isset($authorized) || empty($authorized)){
363
			redirect(base_url()."cart");
364
		}
365
 
366
		$data = array();
367
		$codCaptcha = $this->session->userdata('cod');
368
		if(isset($codCaptcha) && $codCaptcha == 1){
369
			$data['codCaptcha'] = 1;
370
			$this->session->unset_userdata('cod');
371
		}else{
372
			$data['codCaptcha'] = 0;
373
		}
374
		$paymentconfig = $this->config->item('payment');
375
		if(!isset($_POST['submit'])){
376
			$hotspot = $this->session->userdata('hotspotId');
377
			if(isset($hotspot) && !empty($hotspot)){
378
				$_GET['hotSpotAddressId'] = $hotspot;
379
				$_GET['deliveryLocation'] = 'hotSpot';
380
			}else{
381
				$_GET['deliveryLocation'] = 'myLocation';
382
			}
383
			unset($paymentconfig['response'][2]);
384
			if(isset($authorized) && !empty($authorized)){
385
				$_GET['userId'] = $authorized['Id'];
386
				$_GET['Id'] = $authorized['cartId'];
387
				if($authorized['isLoggedIn'] == 1){
388
					$_GET['isLoggedIn'] = 'true';
389
				}
390
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
391
					$_GET['isLoggedIn'] = 'false';
392
				}
14939 anikendra 393
				if(isset($authorized['isPrivateDealUser']) && $authorized['isPrivateDealUser'] == 1){
394
					$this->session->set_userdata('skipcaptcha',1);
395
					$data['skipcaptcha'] = 1;
396
				}
10582 lgm 397
			}
398
			$addressId = $this->session->userdata('addressId');
399
			$_GET['addressid'] = $addressId;
400
			$this->lessphp->object()->ccompile('assets/css/shipping.less','assets/css/shipping.css');
401
      		$data['stylesheet'] = 'shipping.css';
11012 lgm 402
      		$data['title'] = 'Saholic';
10582 lgm 403
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),'',$paymentconfig);
404
			if(isset($data['response']['response']['payment_process'])){
405
				$result = json_decode($data['response']['response']['payment_process'][0]);
406
				$totalAmount = $result->results->totalAmount;
407
				if(isset($result->results->isTotalAmountZero)){
408
					$isTotalAmountZero = $result->results->isTotalAmountZero;
409
				}
410
				$totalAmount = number_format((float)$totalAmount,0,'.','');
411
				$captcha = $this->captcha_model->generateCaptcha();
412
				$this->session->set_userdata('captcha',$captcha['word']);
413
				$data['captcha'] = $captcha;
414
				// if($totalAmount == 0 && isset($isTotalAmountZero) && $isTotalAmountZero == 1){
415
				// 	$captcha = $this->captcha_model->generateCaptcha();
416
				// 	$this->session->set_userdata('captcha',$captcha['word']);
417
				// 	$this->session->set_userdata('captchaDisplay',$isTotalAmountZero);
418
				// 	$data['captcha'] = $captcha;
419
				// }
420
				$this->layout->view('checkout/checkout_view',$data);
421
			}
422
			else{
423
				redirect(base_url()."cart");
424
			}
425
		}
15792 anikendra 426
		elseif(isset($_POST['submit'])) {
10582 lgm 427
			if(isset($_POST['captcha_response_field']) && !empty($_POST['captcha_response_field'])){
428
				$captcha = $this->session->userdata('captcha');
429
				if(strcmp($captcha,$_POST['captcha_response_field']) != 0){
10630 lgm 430
					if(isset($_POST['payoption']) && ($_POST['payoption'] == 3000) || $_POST['payoption'] == 3001) {
10582 lgm 431
						$this->session->set_userdata('cod',1);
432
					}
433
        			redirect(base_url().'payment');
434
      			}
435
			}
436
			unset($paymentconfig['response'][0]);
437
			unset($paymentconfig['response'][1]);
438
			if(isset($authorized) && !empty($authorized)){
439
				$_POST['userId'] = $authorized['Id'];
440
				if($authorized['isLoggedIn'] == 1){
441
					$_POST['isLoggedIn'] = 'true';
442
				}
443
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
444
					$_POST['isLoggedIn'] = 'false';
445
				}
446
			}
447
			$addressId = $this->session->userdata('addressId');
448
			$_POST['addressid'] = $addressId;
20881 amit.gupta 449
			$walletUsed = $this->session->userdata('walletUsed');
450
			$_POST['walletUsed'] = $walletUsed;
10582 lgm 451
			$_POST['payment_option'] = $_POST['payoption'];
452
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$paymentconfig);
15792 anikendra 453
			error_log('[USER] ' .print_r($authorized,1),3,'/tmp/payments.log');
454
			error_log('[RESPONSE] '. print_r($data['response']['response'],1),3,'/tmp/payments.log');
455
			if(isset($data['response']['response']['payment_submit'][0]) && !empty($data['response']['response']['payment_submit'][0])) {
10582 lgm 456
				$paymentSubmit = $data['response']['response']['payment_submit'][0];
457
				if(isset($paymentSubmit->response->isPaymentRedirect) && $paymentSubmit->response->isPaymentRedirect == 1){
16276 amit.gupta 458
					$image = '/assets/images/loading.gif';
10582 lgm 459
					$location = $paymentSubmit->response->redirectUrl;
10735 lgm 460
					echo '<html><head><meta http-equiv="refresh" content="1;url='.$paymentSubmit->response->redirectUrl.'">
11301 lgm 461
  					<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
10582 lgm 462
  					<title>Saholic Mobile Site: Redirecting to <'.$paymentSubmit->response->gatewayName.'> Payment Gateway</title>
463
 					</head>
464
 						<body>
465
     					<div style="text-align:center; margin-top:200px;">Please wait while we redirect you to the Payment Gateway.</div>
466
     					<div align="center" class="img">
467
      					<img title="loading" alt="loading" src="'.$image.'">
468
     					</div>
469
 						</body>
470
						</html>';
13350 anikendra 471
				}elseif(strpos($paymentSubmit->response->redirectUrl, 'ebs-pay') !== false) {
10582 lgm 472
					$url = $this->config->item('curl_base_url').$paymentSubmit->response->redirectUrl;
473
					//echo $url;
474
					$authorized = $this->session->userdata('authorized');
475
					if(isset($authorized) && !empty($authorized)){
476
						$params['userId'] = $authorized['Id'];
477
						if($authorized['isLoggedIn'] == 1){
478
							$params['isLoggedIn'] = 'true';
479
						}
480
						elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
481
							$params['isLoggedIn'] = 'false';
482
						}
483
					}
484
					$this->mcurl->add_call('ebs','get',$url,$params);
485
         			$response = $this->mcurl->execute($url);
486
         			$data['response'] = $response['ebs']['response'];
487
         			$response = $this->magento_model->payment_submit($data);
13350 anikendra 488
         			if(isset($response) && !empty($response)) {
10582 lgm 489
         				$ebs = $response[0]->response;
11339 lgm 490
         				$image = './assets/images/loading.gif';
10582 lgm 491
         				echo '<html>
492
						<head>
11301 lgm 493
						 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
10582 lgm 494
						 <title>m.saholic.com: Redirecting to EBS Payment Page</title>
495
						</head>
496
						<body>
497
						    <div style="text-align:center; margin-top:200px;">Please wait while we redirect you to the Payment Gateway.</div>
498
						 <div align="center" class="img">
10735 lgm 499
						  <img title="loading" alt="loading" src="'.$image.'">
10582 lgm 500
						 </div>
501
						 <div style="display:none">
502
						  <form  method="post" action="'.$ebs->postAction.'" name="frmTransaction" id="frmTransaction">  
503
				           <!-- Account Id -->
504
				           <input name="account_id" type="hidden" value="'.$ebs->account_id.'" />
505
				           <!-- Transaction Details -->
506
				           <input name="reference_no" type="hidden" value="'.$ebs->reference_no.'" />
507
				           <input name="amount" type="hidden" value="'.$ebs->amount.'" />
508
				           <input name="description" type="hidden" value="'.$ebs->description.'" />
509
				           <input name="payment_option" type="hidden" value="'.$ebs->payment_option.'"/>
510
				           <!-- Billing Address -->
511
				           <input name="name" type="hidden" value="'.$ebs->name.'" />
512
				           <input name="address" type="hidden" value="'.$ebs->address.'" />
513
				           <input name="city" type="hidden" value="'.$ebs->city.'" />
514
				           <input name="state" type="hidden" value="'.$ebs->state.'" />
515
				           <input name="postal_code" type="hidden" value="'.$ebs->postal_code.'" />
11413 amit.gupta 516
				           <input name="country" type="hidden" value="'.$ebs->country.'"/>
10582 lgm 517
				           <input name="email" type="hidden" value="'.$ebs->email.'" />
518
				           <input name="phone" type="hidden" value="'.$ebs->phone.'" />
519
				           <!-- Delivery Address -->
520
				           <input name="ship_name" type="hidden" value="'.$ebs->ship_name.'" />
521
				           <input name="ship_address" type="hidden" value="'.$ebs->ship_address.'" />
522
				           <input name="ship_city" type="hidden" value="'.$ebs->ship_city.'" />
523
				           <input name="ship_state" type="hidden" value="'.$ebs->ship_state.'" />
524
				           <input name="ship_postal_code" type="hidden" value="'.$ebs->ship_postal_code.'" />
11413 amit.gupta 525
				           <input name="ship_country" type="hidden" value="'.$ebs->ship_country.'"/> 
10582 lgm 526
				           <input name="ship_phone" type="hidden" value="'.$ebs->ship_phone.'" />
527
				           <input name="return_url" type="hidden" value="'.$ebs->return_url.'" />
528
				           <input name="mode" value="'.$ebs->mode.'"/>
529
				           <input name="secure_hash" type="hidden" value="'.$ebs->secure_hash.'" />
530
				           <input name="channel" type="hidden" value="'.$ebs->channel.'" />
531
				           <input name="page_id" type="hidden" value="'.$ebs->page_id.'" />
532
						  </form>
533
						    </div>
534
						    <script type="text/javascript">
535
						     document.getElementById("frmTransaction").submit();
536
						    </script>
537
						  </body>
538
						</html>';
13350 anikendra 539
         			}
540
         			else{
10582 lgm 541
         				redirect(base_url().'payment');
542
         			}
543
				}
13350 anikendra 544
				elseif(strpos($paymentSubmit->response->redirectUrl, 'payu-pay') !== false) {
545
					$url = $this->config->item('curl_base_url').$paymentSubmit->response->redirectUrl;
546
					//echo $url;
547
					$params = array();
548
					$authorized = $this->session->userdata('authorized');
549
					if(isset($authorized) && !empty($authorized)){
550
						$params['userId'] = $authorized['Id'];
551
						if($authorized['isLoggedIn'] == 1){
552
							$params['isLoggedIn'] = 'true';
553
						}
554
						elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
555
							$params['isLoggedIn'] = 'false';
556
						}
557
					}
558
					$this->mcurl->add_call('payu','get',$url,$params);
559
         			$response = $this->mcurl->execute($url);
560
         			error_log("payu response".print_r($response,1));
561
         			$data['response'] = $response['payu']['response'];
562
         			$response = $this->magento_model->payment_submit($data);
563
         			if(isset($response) && !empty($response)){
564
         				$payu = $response[0]->response;
16276 amit.gupta 565
         				$image = '/assets/images/loading.gif';
13350 anikendra 566
         				// $return_url = base_url().'ebs-pay-processing/?DR={DR}';
567
         				$ci = get_instance();
568
         			}
569
         			?>
570
         				<html>
571
						<head>
572
						<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
19411 amit.gupta 573
						 <title>m.saholic.com: Redirecting to PayU Payment Gateway</title>
13350 anikendra 574
						</head>
575
						<body>
576
						    <div style="text-align:center; margin-top:200px;">Please wait while we redirect you to the Payment Gateway.</div>
577
						 <div align="center" class="img">
16276 amit.gupta 578
						  <img title="loading" alt="loading" src="<?php echo $image;?>">
13350 anikendra 579
						 </div>
580
						 <div style="display:none;">
581
						   <form action="<?php echo $payu->postActionUrl; ?>" method="post" id="payuForm">
582
						      	<input type="hidden" name="key" value="<?php echo $payu->key; ?>" />
583
						      	<input type="hidden" name="hash" value="<?php echo $payu->hash ?>"/>
584
						      	<input type="hidden" name="txnid" value="<?php echo $payu->txnid ?>" />
585
						      	<input name="amount" value="<?php echo $payu->amount; ?>" />
586
								<input name="firstname" id="firstname" value="<?php echo $payu->firstname;?>" />
587
						        <input name="email" id="email" value="<?php echo $payu->email; ?>" />
588
						        <input name="phone" value="<?php echo $payu->phone; ?>" />
589
						        <input name="productinfo" value="<?php echo $payu->productinfo; ?>" />
19411 amit.gupta 590
						        <input name="surl" value="<?php echo rtrim(base_url(), "/").$payu->surl; ?>"  />
591
						        <input name="furl" value="<?php echo rtrim(base_url(), "/").$payu->furl; ?>" />
13350 anikendra 592
						        <input name="bankcode" value="<?php echo $payu->bankcode; ?>" />
593
						        <input name="pg" value="<?php echo $payu->pg; ?>" />
20622 amit.gupta 594
						        <input type="hidden" name="service_provider" value="payu_paisa" />
19418 amit.gupta 595
						        <input name="curl" value="<?php echo rtrim(base_url(), "/").$payu->curl; ?>" />
13350 anikendra 596
						        <input type="submit" value="Submit" />						          
597
						    </form>
598
					    </div>
599
					    <script type="text/javascript">
600
						    document.getElementById("payuForm").submit();
601
					    </script>
602
					  </body>
603
					</html>
604
					<?php
605
				}  
10582 lgm 606
				else{
607
					redirect(base_url().$paymentSubmit->response->redirectUrl);
608
				}
15792 anikendra 609
			} else {
610
				redirect(base_url()."payment");	
10582 lgm 611
			}
15792 anikendra 612
		}		
10582 lgm 613
	}
13350 anikendra 614
 
10582 lgm 615
	public function ebsprocessing(){
616
		if(isset($_GET['DR']) && !empty($_GET['DR'])){
617
			$paymentconfig = $this->config->item('ebsProcessing');
618
			$authorized = $this->session->userdata('authorized');
619
			if(isset($authorized) && !empty($authorized)){
620
				$_GET['userId'] = $authorized['Id'];
621
				if($authorized['isLoggedIn'] == 1){
622
					$_GET['isLoggedIn'] = 'true';
623
				}
624
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
625
					$_GET['isLoggedIn'] = 'false';
626
				}
627
			}
628
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$paymentconfig);
629
			if(isset($data['response']['response']['ebs_processing'][0]->response)){
630
				$redirectUrl = $data['response']['response']['ebs_processing'][0]->response->redirectUrl;
631
				$redirectUrl = explode('?', $redirectUrl);
632
				$redirectUrl = base_url().'ebs-pay-response/?'.$redirectUrl[1];
16276 amit.gupta 633
				$image = '/assets/images/loading.gif';
10582 lgm 634
				echo '<html><head><meta http-equiv="refresh" content="2;url='.$redirectUrl.'">
11301 lgm 635
					<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
10582 lgm 636
  					<title>Saholic Mobile Site:</title>
637
 					</head>
638
 						<body>
639
     					<div style="text-align:center; margin-top:200px;">'.$data['response']['response']['ebs_processing'][0]->response->redirectMessage.'</div>
640
     					<div align="center" class="img">
10735 lgm 641
      					<img title="loading" alt="loading" src="'.$image.'">
10582 lgm 642
     					</div>
643
 						</body>
644
						</html>';
645
			}
646
		}
647
	}
648
	public function ebsresponse(){
649
		if(isset($_GET['DR']) && !empty($_GET['DR'])){
650
			$paymentconfig = $this->config->item('ebsResponse');
651
			$authorized = $this->session->userdata('authorized');
652
			if(isset($authorized) && !empty($authorized)){
653
				$_GET['userId'] = $authorized['Id'];
654
				if($authorized['isLoggedIn'] == 1){
655
					$_GET['isLoggedIn'] = 'true';
656
				}
657
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
658
					$_GET['isLoggedIn'] = 'false';
659
				}
660
			}
661
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$paymentconfig);
662
			if(isset($data['response']['response']['ebs_response'][0]->response) && !empty($data['response']['response']['ebs_response'][0]->response)){
663
				$redirectUrl = $data['response']['response']['ebs_response'][0]->response->redirectUrl;
20255 amit.gupta 664
				redirect($redirectUrl);
10582 lgm 665
			}
666
			else{
667
				redirect(base_url().'payment');
668
			}
669
		}
670
	}
13304 anikendra 671
 
672
	public function payuresponse(){
673
		error_log("payu response ".print_r($_REQUEST,1));
674
		$paymentconfig = $this->config->item('payuResponse');
675
		$authorized = $this->session->userdata('authorized');
676
		if(isset($authorized) && !empty($authorized)){
677
			$_GET['userId'] = $authorized['Id'];
678
			if($authorized['isLoggedIn'] == 1){
679
				$_GET['isLoggedIn'] = 'true';
680
			}
681
			elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
682
				$_GET['isLoggedIn'] = 'false';
683
			}
684
		}
685
		$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$paymentconfig);
686
		error_log("payu response ".print_r($data['response'],1));
687
		if(isset($data['response']['response']['payu_response'][0]->response) && !empty($data['response']['response']['payu_response'][0]->response)){
688
			$redirectUrl = $data['response']['response']['payu_response'][0]->response->redirectUrl;
20061 amit.gupta 689
			redirect(rtrim(base_url(), "/").$redirectUrl);
13304 anikendra 690
		}
691
		else{
19417 amit.gupta 692
			redirect(rtrim(base_url(), "/").'payment');
13304 anikendra 693
		}
694
	}
695
 
10582 lgm 696
	public function hdfcPayResponse(){
697
		if(isset($_POST)){
698
			$paymentconfig = $this->config->item('hdfcResponse');
699
			$authorized = $this->session->userdata('authorized');
700
			if(isset($authorized) && !empty($authorized)){
701
				$_POST['userId'] = $authorized['Id'];
702
				if($authorized['isLoggedIn'] == 1){
703
					$_POST['isLoggedIn'] = 'true';
704
				}
705
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
706
					$_POST['isLoggedIn'] = 'false';
707
				}
708
			}
709
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$paymentconfig);
710
			if(isset($data['response']['response']['hdfc_response'][0]->response) && !empty($data['response']['response']['hdfc_response'][0]->response)){
711
				$redirectUrl = $data['response']['response']['hdfc_response'][0]->response->redirectUrl;
712
				redirect($redirectUrl);
713
			}
714
			else{
715
				redirect(base_url());
716
			}	
717
		}else{
718
			redirect(base_url());
719
		}
720
	}
10890 lgm 721
	public function hdfcEmiResponse(){
722
		if(isset($_POST)){
723
			$paymentconfig = $this->config->item('hdfcEmiResponse');
724
			$authorized = $this->session->userdata('authorized');
725
			if(isset($authorized) && !empty($authorized)){
726
				$_POST['userId'] = $authorized['Id'];
727
				if($authorized['isLoggedIn'] == 1){
728
					$_POST['isLoggedIn'] = 'true';
729
				}
730
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
731
					$_POST['isLoggedIn'] = 'false';
732
				}
733
			}
734
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$paymentconfig);
735
			if(isset($data['response']['response']['hdfc_emi_response'][0]->response) && !empty($data['response']['response']['hdfc_emi_response'][0]->response)){
736
				$redirectUrl = $data['response']['response']['hdfc_emi_response'][0]->response->redirectUrl;
737
				redirect($redirectUrl);
738
			}
739
			else{
740
				redirect(base_url());
741
			}	
742
		}else{
743
			redirect(base_url());
744
		}
745
	}
10582 lgm 746
	public function innovitiPayment(){
747
		$last = $this->uri->total_segments();
748
		$itemcode = $this->uri->segment($last);
749
		if(isset($itemcode) && !empty($itemcode)){
750
			$url = $this->config->item('curl_base_url').'innoviti-pay/'.$itemcode;
751
			$params = array();
752
			$authorized = $this->session->userdata('authorized');
753
			if(isset($authorized) && !empty($authorized)){
754
				$params['userId'] = $authorized['Id'];
755
				if($authorized['isLoggedIn'] == 1){
756
					$params['isLoggedIn'] = 'true';
757
				}
758
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
759
					$params['isLoggedIn'] = 'false';
760
				}
761
			$this->mcurl->add_call('innoviti','get',$url,$params);
762
 			$response = $this->mcurl->execute($url);
763
 			$data['response'] = $response['innoviti']['response'];
764
         	$response = $this->magento_model->payment_submit($data);
765
         	if(isset($response) && !empty($response)){
766
         		$innoviti = $response[0]->response;
11339 lgm 767
         		$image = './assets/images/loading.gif';
11301 lgm 768
         		echo '<html>
769
						<head>
770
						 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
771
						 <title>m.saholic.com: Redirecting to Innoviti Payment Page</title>
772
						</head>
773
						<body>
774
						    <div style="text-align:center; margin-top:200px;">Please wait while we redirect you to the Payment Gateway.</div>
775
						 <div align="center" class="img">
776
						  <img title="loading" alt="loading" src="'.$image.'">
777
						 </div>
778
						 <div style="display:none">
779
						  <form  method="post" action="'.$innoviti->action.'" name="frmTransaction" id="frmTransaction">  
780
								<input name="merchantId" type="hidden" value="'.$innoviti->merchantId.'" />
781
								<input name="subMerchantId" type="hidden" value="'.$innoviti->subMerchantId.'" />
782
										<!-- Transaction Details -->
783
								<input name="orderId" type="hidden" value="'.$innoviti->orderId.'" />
784
								<input name="amt" type="hidden" value="'.$innoviti->amt.'" />   
785
								<input name="cur" type="hidden" value="INR" />
786
								<input name="processingCode" type="hidden" value="'.$innoviti->processingCode.'" />
787
								<input name="proSku" type="hidden" value="'.$innoviti->proSku.'" />
788
								<input name="Cname" type="hidden" value="'.$innoviti->Cname.'" /></td>
789
								<input name="mobile" type="hidden" value="'.$innoviti->mobile.'" />
790
								<input name="emailId" type="hidden" value="'.$innoviti->emailId.'" />     
791
								<input name="redirUrl" type="hidden" value="'.$innoviti->redirUrl.'" />
792
								<input name="chksum" type="hidden" value="'.$innoviti->chksum.'" />
793
								<input name="isCtx" type="hidden" value="NO" />
794
							<input name="submitted" value="Submit" type="submit" />&nbsp; 
795
							  </form>
796
						    </div><script type="text/javascript">
10582 lgm 797
						    document.getElementById("frmTransaction").submit();
11301 lgm 798
						</script></body></html>';
10582 lgm 799
         	}
800
			}else{
801
				redirect(base_url());
802
			}
803
 
804
		}else{
805
			redirect(base_url());
806
		}
807
	}
808
	public function innovitiResponse(){
809
		if(isset($_POST)){
810
			$paymentconfig = $this->config->item('innovitiResponse');
811
			$authorized = $this->session->userdata('authorized');
812
			if(isset($authorized) && !empty($authorized)){
813
				$_POST['userId'] = $authorized['Id'];
814
				if($authorized['isLoggedIn'] == 1){
815
					$_POST['isLoggedIn'] = 'true';
816
				}
817
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
818
					$_POST['isLoggedIn'] = 'false';
819
				}
820
			}
821
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$paymentconfig);
822
			if(isset($data['response']['response']['innoviti_response'][0]->response) && !empty($data['response']['response']['innoviti_response'][0]->response)){
823
				$redirectUrl = $data['response']['response']['innoviti_response'][0]->response->redirectUrl;
824
				redirect($redirectUrl);
825
			}
826
			else{
827
				redirect(base_url());
828
			}	
829
		}else{
830
			redirect(base_url());
831
		}
832
	}
833
	public function paymenterror(){
834
			$authorized = $this->session->userdata('authorized');
835
			if(isset($authorized) && !empty($authorized)){
836
				$data = array();
837
				$paymentconfig = $this->config->item('paymenterror');
10634 lgm 838
				$this->lessphp->object()->ccompile('assets/css/shipping.less','assets/css/shipping.css');
10582 lgm 839
				$data['stylesheet'] = 'shipping.css';
840
				$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$paymentconfig);
841
				$this->layout->view('checkout/checkout_view',$data);
842
			}else{
843
				redirect(base_url());
844
			}
845
	}
846
	public function shipping()
847
	{
848
 
849
		$data = array();
850
		$authorized = $this->session->userdata('authorized');
851
		if($authorized['isLoggedIn'] != 1){
852
			$this->session->set_userdata('location','shipping');
853
			redirect(base_url()."login");
854
		}
855
		$shippingconfig = $this->config->item('shipping');
856
		if(!isset($_POST['submit']))
857
		{
858
			$authorized = $this->session->userdata('authorized');
859
				if(isset($authorized) && !empty($authorized)){
860
					$_GET['userId'] = $authorized['Id'];
861
					$_GET['Id'] = $authorized['cartId'];
862
					if($authorized['isLoggedIn'] == 1){
863
						$_GET['isLoggedIn'] = 'true';
864
					}
865
					elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
866
						$_GET['isLoggedIn'] = 'false';
867
					}
868
				}
869
			$this->lessphp->object()->ccompile('assets/css/shipping.less','assets/css/shipping.css');
870
			$data['stylesheet'] = 'shipping.css';
11012 lgm 871
			$data['title'] = 'Saholic';
10582 lgm 872
			$cache = getFileCache('pickup');
873
			if(isset($cache) && !empty($cache)){
874
				unset($shippingconfig['response'][1]);
875
				$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$shippingconfig);
876
				$data['response']['response']['pickup'] = $cache;
877
			}else{
878
				$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$shippingconfig);
879
        		if(isset($data['response']['response']['pickup']) && !empty($data['response']['response']['pickup']))
880
        		setFileCache($data['response']['response']['pickup'], 'pickup',900);
881
			}
10758 lgm 882
			$carts = $data['response']['response']['carts'][0];
10757 lgm 883
			$shipping = $data['response']['response']['shipping_process'][0]; 
884
			if((isset($carts) && !empty($carts)) && (isset($shipping) && !empty($shipping))){
10752 lgm 885
				$this->layout->view('checkout/checkout_view',$data);
886
			}else{
887
				redirect(base_url()."cart");
888
			}
10582 lgm 889
		}
890
		if(isset($_POST['submit']))
891
		{
892
			unset($shippingconfig['response'][1]);	
893
			$data = $this->get_shipping_billing($_POST);
894
			$this->session->set_userdata($data);
895
			$authorized = $this->session->userdata('authorized');
896
			if(isset($authorized) && !empty($authorized)){
897
				$_POST['userId'] = $authorized['Id'];
11530 lgm 898
				$_POST['Id'] = $authorized['cartId'];
10582 lgm 899
					if($authorized['isLoggedIn'] == 1){
900
						$_POST['isLoggedIn'] = 'true';
901
					}
902
					elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
903
						$_POST['isLoggedIn'] = 'false';
904
					}
905
				}
906
			//$data['stylesheet'] = 'shipping.less';
907
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$shippingconfig);
908
			//$this->layout->view('checkout/checkout_view',$data);
909
			redirect(base_url()."shipping");
910
 
911
		}
912
 
913
	}
914
 
915
	public function get_shipping_billing($data=array()){
916
		$billing =array();
917
		$shipping =array();
918
		if (isset($data) && !empty($data)) {
919
			$shipping=array('name'  => $data['name'],'line1' => $data['line1'],'line2' => $data['line2'], 'city' => $data['city'], 'pin' => $data['pin'], 'phonenumber' => $data['phone']);
920
			return array('shipping'=>$shipping,'billing'=>$billing);
921
		}
922
	}
923
 
924
	public function delete($addressId){
925
		$shippingconfig = $this->config->item('shipping_delete');
926
		$_GET['addressId'] = $addressId;
927
		$authorized = $this->session->userdata('authorized');
928
		if(isset($authorized) && !empty($authorized)){
929
			$_GET['userId'] = $authorized['Id'];
930
			$_GET['Id'] = $authorized['cartId'];
931
			if($authorized['isLoggedIn'] == 1){
932
				$_GET['isLoggedIn'] = 'true';
933
			}
934
			elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
935
				$_GET['isLoggedIn'] = 'false';
936
				}
937
			}
938
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$shippingconfig);
939
			print_r($data['response']);
940
		}
941
 
942
	public function changeAddress($addressId,$type){
943
		if(isset($addressId) && isset($type)){
944
		$shippingconfig = $this->config->item('shipping_change');
945
		$_GET['addressId'] = $addressId;
946
		$_GET['addressType'] = $type;
947
		$authorized = $this->session->userdata('authorized');
948
		if(isset($authorized) && !empty($authorized)){
949
			$_GET['userId'] = $authorized['Id'];
950
			$_GET['Id'] = $authorized['cartId'];
951
			if($authorized['isLoggedIn'] == 1){
952
				$_GET['isLoggedIn'] = 'true';
953
			}
954
			elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
955
				$_GET['isLoggedIn'] = 'false';
956
				}
957
			}
958
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$shippingconfig);
959
			$this->session->set_userdata('addressId',$addressId);
10788 lgm 960
			echo json_encode($data['response']['response']['changeAddress'][0]);
10582 lgm 961
		}
962
	}
963
	public function changeCaptcha(){
964
		$captchaDisplay = $this->session->userdata('captchaDisplay');
965
		//if(isset($captchaDisplay) && $captchaDisplay == 1){
966
			$captcha = $this->captcha_model->generateCaptcha();
967
			$this->session->set_userdata('captcha',$captcha['word']);
968
			unset($captcha['word']);
969
			unset($captcha['time']);
970
			unset($captcha['name']);
971
			echo json_encode($captcha);
972
		//}
973
	}
974
	public function insuranceInfo($bday,$gname,$addressId){
975
	if((isset($bday) && !empty($bday)) && (isset($gname) && !empty($gname)) && (isset($addressId) && !empty($addressId))){
976
		if(isset($gname) && !empty($gname)){
10840 lgm 977
			$gname = str_replace('-',' ',$gname);
10582 lgm 978
			$gname = ltrim($gname);
979
			$gname = rtrim($gname);
980
			$_GET['guardianName'] = $gname;
981
		}
982
		if(isset($bday) && !empty($bday)){
983
			$dob = explode('-',$bday);
10840 lgm 984
			//$dob = array_reverse($dob);
10582 lgm 985
			$temp1 = $dob[1];
986
			$temp2 = $dob[0];
987
			$dob[0] = $temp1;
988
			$dob[1] = $temp2;
10840 lgm 989
 
10582 lgm 990
			$dob = implode('/', $dob);
991
			$_GET['dob'] = $dob; 
10840 lgm 992
		} 
10582 lgm 993
		$insuranceconfig = $this->config->item('insurance_info');
994
		$_GET['addressId'] = $addressId;
995
		$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$insuranceconfig);
996
		if(isset($data['response']['response']['insuranceInfo'][0]->response) && (!empty($data['response']['response']['insuranceInfo'][0]->response))) {
997
			echo json_encode($data['response']['response']['insuranceInfo'][0]);
998
		}
999
	}
1000
  }
1001
  public function pickupSpot($id){
1002
  	if(isset($id) && !empty($id) && is_numeric($id)){
1003
  		$this->session->set_userdata('hotspotId',$id);
1004
  		$response['msg'] = 'sucess';
1005
  		echo json_encode($response);
1006
  	}
1007
  }
1008
 
1009
}
1010
 
10611 amit.gupta 1011
 
10582 lgm 1012
/* End of file welcome.php */
13350 anikendra 1013
/* Location: ./application/controllers/welcome.php */