Subversion Repositories SmartDukaan

Rev

Rev 20609 | Rev 20862 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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