Subversion Repositories SmartDukaan

Rev

Rev 20255 | Rev 20622 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 20255 Rev 20609
Line 70... Line 70...
70
		// $this->session->unset_userdata('billing');
70
		// $this->session->unset_userdata('billing');
71
		// $this->session->unset_userdata('shoppingId');
71
		// $this->session->unset_userdata('shoppingId');
72
		$this->session->unset_userdata(array('hotspotId','addressId'));
72
		$this->session->unset_userdata(array('hotspotId','addressId'));
73
		$this->layout->view('checkout/checkout_view',$data);
73
		$this->layout->view('checkout/checkout_view',$data);
74
	}
74
	}
-
 
75
	public function payment1()
-
 
76
	{
-
 
77
		$this->layout->setlayout('layout/layout_bigutsav');
-
 
78
		//standard array
-
 
79
		if (!empty($_GET['cq'])) {
-
 
80
			$this->session->userdata['authorized']['totalItems'] = $_GET['cq'];
-
 
81
			$this->session->set_userdata('addressId',$_GET['addressid']);
-
 
82
		}
-
 
83
		$authorized = $this->session->userdata('authorized');
-
 
84
		if(!isset($authorized) || empty($authorized)){
-
 
85
			redirect(base_url()."cart");
-
 
86
		}
-
 
87
		
-
 
88
		$data = array();
-
 
89
		$codCaptcha = $this->session->userdata('cod');
-
 
90
		if(isset($codCaptcha) && $codCaptcha == 1){
-
 
91
			$data['codCaptcha'] = 1;
-
 
92
			$this->session->unset_userdata('cod');
-
 
93
		}else{
-
 
94
			$data['codCaptcha'] = 0;
-
 
95
		}
-
 
96
		$paymentconfig = $this->config->item('payment1');
-
 
97
		if(!isset($_POST['submit'])){
-
 
98
			$hotspot = $this->session->userdata('hotspotId');
-
 
99
			if(isset($hotspot) && !empty($hotspot)){
-
 
100
				$_GET['hotSpotAddressId'] = $hotspot;
-
 
101
				$_GET['deliveryLocation'] = 'hotSpot';
-
 
102
			}else{
-
 
103
				$_GET['deliveryLocation'] = 'myLocation';
-
 
104
			}
-
 
105
			unset($paymentconfig['response'][2]);
-
 
106
			if(isset($authorized) && !empty($authorized)){
-
 
107
				$_GET['userId'] = $authorized['Id'];
-
 
108
				$_GET['Id'] = $authorized['cartId'];
-
 
109
				if($authorized['isLoggedIn'] == 1){
-
 
110
					$_GET['isLoggedIn'] = 'true';
-
 
111
				}
-
 
112
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
-
 
113
					$_GET['isLoggedIn'] = 'false';
-
 
114
				}
-
 
115
				if(isset($authorized['isPrivateDealUser']) && $authorized['isPrivateDealUser'] == 1){
-
 
116
					$this->session->set_userdata('skipcaptcha',1);
-
 
117
					$data['skipcaptcha'] = 1;
-
 
118
				}
-
 
119
			}
-
 
120
			$addressId = $this->session->userdata('addressId');
-
 
121
			$_GET['addressid'] = $addressId;
-
 
122
			$this->lessphp->object()->ccompile('assets/css/shipping.less','assets/css/shipping.css');
-
 
123
      		$data['stylesheet'] = 'shipping.css';
-
 
124
      		$data['title'] = 'Saholic';
-
 
125
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),'',$paymentconfig);
-
 
126
			if(isset($data['response']['response']['payment_process1'])){
-
 
127
				$result = json_decode($data['response']['response']['payment_process1'][0]);
-
 
128
				$totalAmount = $result->results->totalAmount;
-
 
129
				if(isset($result->results->isTotalAmountZero)){
-
 
130
					$isTotalAmountZero = $result->results->isTotalAmountZero;
-
 
131
				}
-
 
132
				$totalAmount = number_format((float)$totalAmount,0,'.','');
-
 
133
				$captcha = $this->captcha_model->generateCaptcha();
-
 
134
				$this->session->set_userdata('captcha',$captcha['word']);
-
 
135
				$data['captcha'] = $captcha;
-
 
136
				// if($totalAmount == 0 && isset($isTotalAmountZero) && $isTotalAmountZero == 1){
-
 
137
				// 	$captcha = $this->captcha_model->generateCaptcha();
-
 
138
				// 	$this->session->set_userdata('captcha',$captcha['word']);
-
 
139
				// 	$this->session->set_userdata('captchaDisplay',$isTotalAmountZero);
-
 
140
				// 	$data['captcha'] = $captcha;
-
 
141
				// }
-
 
142
				$this->layout->view('checkout/checkout_view',$data);
-
 
143
			}
-
 
144
			else{
-
 
145
				redirect(base_url()."cart");
-
 
146
			}
-
 
147
		}
-
 
148
		elseif(isset($_POST['submit'])) {
-
 
149
			if(isset($_POST['captcha_response_field']) && !empty($_POST['captcha_response_field'])){
-
 
150
				$captcha = $this->session->userdata('captcha');
-
 
151
				if(strcmp($captcha,$_POST['captcha_response_field']) != 0){
-
 
152
					if(isset($_POST['payoption']) && ($_POST['payoption'] == 3000) || $_POST['payoption'] == 3001) {
-
 
153
						$this->session->set_userdata('cod',1);
-
 
154
					}
-
 
155
        			redirect(base_url().'payment');
-
 
156
      			}
-
 
157
			}
-
 
158
			unset($paymentconfig['response'][0]);
-
 
159
			unset($paymentconfig['response'][1]);
-
 
160
			if(isset($authorized) && !empty($authorized)){
-
 
161
				$_POST['userId'] = $authorized['Id'];
-
 
162
				if($authorized['isLoggedIn'] == 1){
-
 
163
					$_POST['isLoggedIn'] = 'true';
-
 
164
				}
-
 
165
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
-
 
166
					$_POST['isLoggedIn'] = 'false';
-
 
167
				}
-
 
168
			}
-
 
169
			$addressId = $this->session->userdata('addressId');
-
 
170
			$_POST['addressid'] = $addressId;
-
 
171
			$_POST['payment_option'] = $_POST['payoption'];
-
 
172
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$paymentconfig);
-
 
173
			error_log('[USER] ' .print_r($authorized,1),3,'/tmp/payments.log');
-
 
174
			error_log('[RESPONSE] '. print_r($data['response']['response'],1),3,'/tmp/payments.log');
-
 
175
			if(isset($data['response']['response']['payment_submit'][0]) && !empty($data['response']['response']['payment_submit'][0])) {
-
 
176
				$paymentSubmit = $data['response']['response']['payment_submit'][0];
-
 
177
				if(isset($paymentSubmit->response->isPaymentRedirect) && $paymentSubmit->response->isPaymentRedirect == 1){
-
 
178
					$image = '/assets/images/loading.gif';
-
 
179
					$location = $paymentSubmit->response->redirectUrl;
-
 
180
					echo '<html><head><meta http-equiv="refresh" content="1;url='.$paymentSubmit->response->redirectUrl.'">
-
 
181
  					<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
-
 
182
  					<title>Saholic Mobile Site: Redirecting to <'.$paymentSubmit->response->gatewayName.'> Payment Gateway</title>
-
 
183
 					</head>
-
 
184
 						<body>
-
 
185
     					<div style="text-align:center; margin-top:200px;">Please wait while we redirect you to the Payment Gateway.</div>
-
 
186
     					<div align="center" class="img">
-
 
187
      					<img title="loading" alt="loading" src="'.$image.'">
-
 
188
     					</div>
-
 
189
 						</body>
-
 
190
						</html>';
-
 
191
				}elseif(strpos($paymentSubmit->response->redirectUrl, 'ebs-pay') !== false) {
-
 
192
					$url = $this->config->item('curl_base_url').$paymentSubmit->response->redirectUrl;
-
 
193
					//echo $url;
-
 
194
					$authorized = $this->session->userdata('authorized');
-
 
195
					if(isset($authorized) && !empty($authorized)){
-
 
196
						$params['userId'] = $authorized['Id'];
-
 
197
						if($authorized['isLoggedIn'] == 1){
-
 
198
							$params['isLoggedIn'] = 'true';
-
 
199
						}
-
 
200
						elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
-
 
201
							$params['isLoggedIn'] = 'false';
-
 
202
						}
-
 
203
					}
-
 
204
					$this->mcurl->add_call('ebs','get',$url,$params);
-
 
205
         			$response = $this->mcurl->execute($url);
-
 
206
         			$data['response'] = $response['ebs']['response'];
-
 
207
         			$response = $this->magento_model->payment_submit($data);
-
 
208
         			if(isset($response) && !empty($response)) {
-
 
209
         				$ebs = $response[0]->response;
-
 
210
         				$image = './assets/images/loading.gif';
-
 
211
         				echo '<html>
-
 
212
						<head>
-
 
213
						 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
-
 
214
						 <title>m.saholic.com: Redirecting to EBS Payment Page</title>
-
 
215
						</head>
-
 
216
						<body>
-
 
217
						    <div style="text-align:center; margin-top:200px;">Please wait while we redirect you to the Payment Gateway.</div>
-
 
218
						 <div align="center" class="img">
-
 
219
						  <img title="loading" alt="loading" src="'.$image.'">
-
 
220
						 </div>
-
 
221
						 <div style="display:none">
-
 
222
						  <form  method="post" action="'.$ebs->postAction.'" name="frmTransaction" id="frmTransaction">  
-
 
223
				           <!-- Account Id -->
-
 
224
				           <input name="account_id" type="hidden" value="'.$ebs->account_id.'" />
-
 
225
				           <!-- Transaction Details -->
-
 
226
				           <input name="reference_no" type="hidden" value="'.$ebs->reference_no.'" />
-
 
227
				           <input name="amount" type="hidden" value="'.$ebs->amount.'" />
-
 
228
				           <input name="description" type="hidden" value="'.$ebs->description.'" />
-
 
229
				           <input name="payment_option" type="hidden" value="'.$ebs->payment_option.'"/>
-
 
230
				           <!-- Billing Address -->
-
 
231
				           <input name="name" type="hidden" value="'.$ebs->name.'" />
-
 
232
				           <input name="address" type="hidden" value="'.$ebs->address.'" />
-
 
233
				           <input name="city" type="hidden" value="'.$ebs->city.'" />
-
 
234
				           <input name="state" type="hidden" value="'.$ebs->state.'" />
-
 
235
				           <input name="postal_code" type="hidden" value="'.$ebs->postal_code.'" />
-
 
236
				           <input name="country" type="hidden" value="'.$ebs->country.'"/>
-
 
237
				           <input name="email" type="hidden" value="'.$ebs->email.'" />
-
 
238
				           <input name="phone" type="hidden" value="'.$ebs->phone.'" />
-
 
239
				           <!-- Delivery Address -->
-
 
240
				           <input name="ship_name" type="hidden" value="'.$ebs->ship_name.'" />
-
 
241
				           <input name="ship_address" type="hidden" value="'.$ebs->ship_address.'" />
-
 
242
				           <input name="ship_city" type="hidden" value="'.$ebs->ship_city.'" />
-
 
243
				           <input name="ship_state" type="hidden" value="'.$ebs->ship_state.'" />
-
 
244
				           <input name="ship_postal_code" type="hidden" value="'.$ebs->ship_postal_code.'" />
-
 
245
				           <input name="ship_country" type="hidden" value="'.$ebs->ship_country.'"/> 
-
 
246
				           <input name="ship_phone" type="hidden" value="'.$ebs->ship_phone.'" />
-
 
247
				           <input name="return_url" type="hidden" value="'.$ebs->return_url.'" />
-
 
248
				           <input name="mode" value="'.$ebs->mode.'"/>
-
 
249
				           <input name="secure_hash" type="hidden" value="'.$ebs->secure_hash.'" />
-
 
250
				           <input name="channel" type="hidden" value="'.$ebs->channel.'" />
-
 
251
				           <input name="page_id" type="hidden" value="'.$ebs->page_id.'" />
-
 
252
						  </form>
-
 
253
						    </div>
-
 
254
						    <script type="text/javascript">
-
 
255
						     document.getElementById("frmTransaction").submit();
-
 
256
						    </script>
-
 
257
						  </body>
-
 
258
						</html>';
-
 
259
         			}
-
 
260
         			else{
-
 
261
         				redirect(base_url().'payment');
-
 
262
         			}
-
 
263
				}
-
 
264
				elseif(strpos($paymentSubmit->response->redirectUrl, 'payu-pay') !== false) {
-
 
265
					$url = $this->config->item('curl_base_url').$paymentSubmit->response->redirectUrl;
-
 
266
					//echo $url;
-
 
267
					$params = array();
-
 
268
					$authorized = $this->session->userdata('authorized');
-
 
269
					if(isset($authorized) && !empty($authorized)){
-
 
270
						$params['userId'] = $authorized['Id'];
-
 
271
						if($authorized['isLoggedIn'] == 1){
-
 
272
							$params['isLoggedIn'] = 'true';
-
 
273
						}
-
 
274
						elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
-
 
275
							$params['isLoggedIn'] = 'false';
-
 
276
						}
-
 
277
					}
-
 
278
					$this->mcurl->add_call('payu','get',$url,$params);
-
 
279
         			$response = $this->mcurl->execute($url);
-
 
280
         			error_log("payu response".print_r($response,1));
-
 
281
         			$data['response'] = $response['payu']['response'];
-
 
282
         			$response = $this->magento_model->payment_submit($data);
-
 
283
         			if(isset($response) && !empty($response)){
-
 
284
         				$payu = $response[0]->response;
-
 
285
         				$image = '/assets/images/loading.gif';
-
 
286
         				// $return_url = base_url().'ebs-pay-processing/?DR={DR}';
-
 
287
         				$ci = get_instance();
-
 
288
         			}
-
 
289
         			?>
-
 
290
         				<html>
-
 
291
						<head>
-
 
292
						<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
-
 
293
						 <title>m.saholic.com: Redirecting to PayU Payment Gateway</title>
-
 
294
						</head>
-
 
295
						<body>
-
 
296
						    <div style="text-align:center; margin-top:200px;">Please wait while we redirect you to the Payment Gateway.</div>
-
 
297
						 <div align="center" class="img">
-
 
298
						  <img title="loading" alt="loading" src="<?php echo $image;?>">
-
 
299
						 </div>
-
 
300
						 <div style="display:none;">
-
 
301
						   <form action="<?php echo $payu->postActionUrl; ?>" method="post" id="payuForm">
-
 
302
						      	<input type="hidden" name="key" value="<?php echo $payu->key; ?>" />
-
 
303
						      	<input type="hidden" name="hash" value="<?php echo $payu->hash ?>"/>
-
 
304
						      	<input type="hidden" name="txnid" value="<?php echo $payu->txnid ?>" />
-
 
305
						      	<input name="amount" value="<?php echo $payu->amount; ?>" />
-
 
306
								<input name="firstname" id="firstname" value="<?php echo $payu->firstname;?>" />
-
 
307
						        <input name="email" id="email" value="<?php echo $payu->email; ?>" />
-
 
308
						        <input name="phone" value="<?php echo $payu->phone; ?>" />
-
 
309
						        <input name="productinfo" value="<?php echo $payu->productinfo; ?>" />
-
 
310
						        <input name="surl" value="<?php echo rtrim(base_url(), "/").$payu->surl; ?>"  />
-
 
311
						        <input name="furl" value="<?php echo rtrim(base_url(), "/").$payu->furl; ?>" />
-
 
312
						        <input name="bankcode" value="<?php echo $payu->bankcode; ?>" />
-
 
313
						        <input name="pg" value="<?php echo $payu->pg; ?>" />
-
 
314
						        <input name="curl" value="<?php echo rtrim(base_url(), "/").$payu->curl; ?>" />
-
 
315
						        <input type="submit" value="Submit" />						          
-
 
316
						    </form>
-
 
317
					    </div>
-
 
318
					    <script type="text/javascript">
-
 
319
						    document.getElementById("payuForm").submit();
-
 
320
					    </script>
-
 
321
					  </body>
-
 
322
					</html>
-
 
323
					<?php
-
 
324
				}  
-
 
325
				else{
-
 
326
					redirect(base_url().$paymentSubmit->response->redirectUrl);
-
 
327
				}
-
 
328
			} else {
-
 
329
				redirect(base_url()."payment");	
-
 
330
			}
-
 
331
		}		
-
 
332
	}
75
	public function payment()
333
	public function payment()
76
	{
334
	{
77
		//standard array
335
		//standard array
78
		if (!empty($_GET['cq'])) {
336
		if (!empty($_GET['cq'])) {
79
			$this->session->userdata['authorized']['totalItems'] = $_GET['cq'];
337
			$this->session->userdata['authorized']['totalItems'] = $_GET['cq'];