Subversion Repositories SmartDukaan

Rev

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

Rev 15750 Rev 15788
Line 133... Line 133...
133
				redirect(base_url().'recharge');
133
				redirect(base_url().'recharge');
134
			}
134
			}
135
			$data['response']=$this->recharge_model->getList($this->input->get(),$this->input->post(),$this->config->item('rechargeAmount'));
135
			$data['response']=$this->recharge_model->getList($this->input->get(),$this->input->post(),$this->config->item('rechargeAmount'));
136
			$data['response']['response']['recharge_confirmation'] = $this->session->userdata('recharge_confirmation');	
136
			$data['response']['response']['recharge_confirmation'] = $this->session->userdata('recharge_confirmation');	
137
			if(isset($data['response']['response']['recharge_amount'][0]->payAmount) && $data['response']['response']['recharge_amount'][0]->payAmount == 0){
137
			if(isset($data['response']['response']['recharge_amount'][0]->payAmount) && $data['response']['response']['recharge_amount'][0]->payAmount == 0){
138
				$captcha = $this->captcha_model->generateCaptcha();
-
 
139
				$this->session->set_userdata('captcha',$captcha['word']);
-
 
140
				$data['captcha'] = $captcha;
138
				$data['captcha'] = true;
141
			}						
139
			}						
142
			$this->layout->view('recharge/recharge_view',$data);
140
			$this->layout->view('recharge/recharge_view',$data);
143
		}
141
		}
144
		elseif(isset($_POST['submit']) && (($_POST['submit'] == 'Confirm') || ($_POST['submit'] == 'Recharge Now')) && (isset($_POST['captcha_response_field']) && !empty($_POST['captcha_response_field']))) {
142
		elseif(isset($_POST['submit']) && (($_POST['submit'] == 'Confirm') || ($_POST['submit'] == 'Recharge Now')) && (isset($_POST['g-recaptcha-response']) && !empty($_POST['g-recaptcha-response']))) {
145
			$userId = $this->session->userdata('userId');
143
			$userId = $this->session->userdata('userId');
-
 
144
			//set POST variables
-
 
145
			$url = 'https://www.google.com/recaptcha/api/siteverify';
-
 
146
			$fields = array(
146
			$captcha = $this->session->userdata('captcha');
147
									'secret' => $this->config->item('captcha_secret_key'),
147
			if(strcmp($captcha,$_POST['captcha_response_field']) != 0){
148
									'response' => $_POST['g-recaptcha-response']
-
 
149
							);
-
 
150
			// use key 'http' even if you send the request to https://...
-
 
151
			$options = array(
-
 
152
			    'http' => array(
-
 
153
			        'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
-
 
154
			        'method'  => 'POST',
-
 
155
			        'content' => http_build_query($fields),
-
 
156
			    ),
-
 
157
			);
-
 
158
			$context  = stream_context_create($options);
-
 
159
			$result = file_get_contents($url, false, $context);
-
 
160
			$result = json_decode($result, 1);
-
 
161
			$verified = isset($result) && isset($result["success"]) && $result['success'];
-
 
162
			if(!$verified){
148
				$rechargeconfig = $this->config->item('recharge');
163
				$rechargeconfig = $this->config->item('recharge');
149
				unset($rechargeconfig['response'][0]);
164
				unset($rechargeconfig['response'][0]);
150
				unset($rechargeconfig['response'][1]);
165
				unset($rechargeconfig['response'][1]);
151
				unset($rechargeconfig['response'][2]);
166
				unset($rechargeconfig['response'][2]);
152
				unset($rechargeconfig['response'][3]);
167
				unset($rechargeconfig['response'][3]);
Line 189... Line 204...
189
				}
204
				}
190
				$data['stylesheet'] = 'recharge.css';
205
				$data['stylesheet'] = 'recharge.css';
191
 
206
 
192
				$data['response']=$this->recharge_model->getList($this->input->get(),$this->input->post(),$rechargeconfig);
207
				$data['response']=$this->recharge_model->getList($this->input->get(),$this->input->post(),$rechargeconfig);
193
				if(isset($data['response']['response']['recharge_amount'][0]->payAmount) && $data['response']['response']['recharge_amount'][0]->payAmount == 0){
208
				if(isset($data['response']['response']['recharge_amount'][0]->payAmount) && $data['response']['response']['recharge_amount'][0]->payAmount == 0){
194
				$captcha = $this->captcha_model->generateCaptcha();
-
 
195
				$this->session->set_userdata('captcha',$captcha['word']);
-
 
196
				$data['captcha'] = $captcha;
209
					$data['captcha'] = true;
197
				}
210
				}
198
				if(isset($data['response']['response']['recharge_confirmation'][0]->userId) && !empty($data['response']['response']['recharge_confirmation'][0]->userId)){
211
				if(isset($data['response']['response']['recharge_confirmation'][0]->userId) && !empty($data['response']['response']['recharge_confirmation'][0]->userId)){
199
					$this->session->set_userdata('userId',$data['response']['response']['recharge_confirmation'][0]->userId);
212
					$this->session->set_userdata('userId',$data['response']['response']['recharge_confirmation'][0]->userId);
200
					$this->layout->view('recharge/recharge_view',$data);
213
					$this->layout->view('recharge/recharge_view',$data);
201
				}else{
214
				}else{
202
					redirect(base_url().'recharge');
215
					redirect(base_url().'recharge');
203
				}
216
				}
204
	      	}elseif(strcmp($captcha,$_POST['captcha_response_field']) == 0){
217
	      	} else {
205
	      		if(isset($userId) && !empty($userId)){
218
	      		if(isset($userId) && !empty($userId)){
206
				if(isset($authorized) && !empty($authorized)){
219
					if(isset($authorized) && !empty($authorized)){
207
					if($authorized['isLoggedIn'] == 1){
220
						if($authorized['isLoggedIn'] == 1){
208
						$_POST['userId'] = $authorized['Id'];
221
							$_POST['userId'] = $authorized['Id'];
209
						$_POST['rechargeUserId'] = $userId;
222
							$_POST['rechargeUserId'] = $userId;
210
						$_POST['isLoggedIn'] = 'true';
223
							$_POST['isLoggedIn'] = 'true';
211
					}
224
						}
212
					elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
225
						elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
213
						$_POST['userId'] = $authorized['Id'];
226
							$_POST['userId'] = $authorized['Id'];
-
 
227
							$_POST['rechargeUserId'] = $userId;
-
 
228
							$_POST['isLoggedIn'] = 'false';
-
 
229
						}
-
 
230
					}else{
-
 
231
						$_POST['userId'] = -1;
214
						$_POST['rechargeUserId'] = $userId;
232
						$_POST['rechargeUserId'] = $userId;
215
						$_POST['isLoggedIn'] = 'false';
233
						$_POST['isLoggedIn'] = 'false';
216
					}
234
					}
217
				}else{
-
 
218
					$_POST['userId'] = -1;
-
 
219
					$_POST['rechargeUserId'] = $userId;
-
 
220
					$_POST['isLoggedIn'] = 'false';
-
 
221
				}
-
 
222
				foreach (getallheaders() as $name => $value) {
235
					foreach (getallheaders() as $name => $value) {
223
			   		if($name == "X-FORWARDED-FOR" || $name == 'X-Forwarded-For'){
236
				   		if($name == "X-FORWARDED-FOR" || $name == 'X-Forwarded-For'){
224
			   			$ips = explode(',',$value);
237
				   			$ips = explode(',',$value);
225
			   			if(sizeof($ips)>1){
238
				   			if(sizeof($ips)>1){
226
			   				$ipAddress = trim($ips[sizeof($ips)-1]);
239
				   				$ipAddress = trim($ips[sizeof($ips)-1]);
227
			   			}else{
240
				   			}else{
228
				   			$ipAddress = $value;
241
					   			$ipAddress = $value;
-
 
242
					   		}
229
				   		}
243
				   		}
230
			   		}
-
 
231
			   	}			   	
244
				   	}			   	
232
				$_POST['ipAddress'] =  isset($ipAddress)?$ipAddress:$_SERVER['REMOTE_ADDR'];
245
					$_POST['ipAddress'] =  isset($ipAddress)?$ipAddress:$_SERVER['REMOTE_ADDR'];
233
				error_log("[ipAddress] ".$_POST['ipAddress']);
246
					error_log("[ipAddress] ".$_POST['ipAddress']);
234
				if($_POST['ipAddress']=='192.168.255.1'){
247
					if($_POST['ipAddress']=='192.168.255.1'){
235
					error_log("[headers] ".print_r(getallheaders(),1));
248
						error_log("[headers] ".print_r(getallheaders(),1));
236
				}
249
					}
237
				$data = array();
250
					$data = array();
238
				$data['response']=$this->recharge_model->getList($this->input->get(),$this->input->post(),$this->config->item('rechargeConfirm'));
251
					$data['response']=$this->recharge_model->getList($this->input->get(),$this->input->post(),$this->config->item('rechargeConfirm'));
239
				if(isset($data['response']['response']['recharge_confirm'][0]->response) && !empty($data['response']['response']['recharge_confirm'][0]->response)){
252
					if(isset($data['response']['response']['recharge_confirm'][0]->response) && !empty($data['response']['response']['recharge_confirm'][0]->response)){
240
					$redirectUrl = $data['response']['response']['recharge_confirm'][0]->response->redirectUrl;
253
						$redirectUrl = $data['response']['response']['recharge_confirm'][0]->response->redirectUrl;
241
					if(strpos($redirectUrl, 'zero-pay-recharge') !== false){
254
						if(strpos($redirectUrl, 'zero-pay-recharge') !== false){
242
						$url = $this->config->item('curl_base_url').$redirectUrl;
255
							$url = $this->config->item('curl_base_url').$redirectUrl;
243
						$params = array();
256
							$params = array();
244
						$this->mcurl->add_call('zero_pay','get',$url,$params);
257
							$this->mcurl->add_call('zero_pay','get',$url,$params);
245
	         			$response = $this->mcurl->execute($url);
258
		         			$response = $this->mcurl->execute($url);
246
	         			$data['response'] = $response['zero_pay']['response'];
259
		         			$data['response'] = $response['zero_pay']['response'];
247
	         			$response = $this->magento_model->payment_submit($data);
260
		         			$response = $this->magento_model->payment_submit($data);
248
	         			$redirectUrl = $response[0]->response->redirectUrl;
261
		         			$redirectUrl = $response[0]->response->redirectUrl;
249
	         			$redirectUrl = explode('?', $redirectUrl);
262
		         			$redirectUrl = explode('?', $redirectUrl);
250
	         			redirect(base_url().'recharge-result?'.$redirectUrl[1]);
263
		         			redirect(base_url().'recharge-result?'.$redirectUrl[1]);
251
					}else{
264
						}else{
252
						redirect(base_url().$redirectUrl);
265
							redirect(base_url().$redirectUrl);
-
 
266
						}
-
 
267
					} else{
-
 
268
						redirect(base_url().'confirm');
253
					}
269
					}
254
				}
270
				}
255
				else{
271
				else {
256
					redirect(base_url().'confirm');
272
					redirect(base_url().'recharge');
257
				}
273
				}
258
			}
-
 
259
			else{
-
 
260
 
-
 
261
				redirect(base_url().'recharge');
-
 
262
			}
-
 
263
	      	}else{
-
 
264
	      		redirect(base_url().'recharge');
-
 
265
	      	}
274
	      	}
266
		}
275
		}
267
		elseif(isset($_POST['submit']) && (($_POST['submit'] == 'Confirm') || ($_POST['submit'] == 'Recharge Now')) && (!isset($_POST['captcha_response_field']) || empty($_POST['captcha_response_field']))){
276
		elseif(isset($_POST['submit']) && (($_POST['submit'] == 'Confirm') || ($_POST['submit'] == 'Recharge Now')) && (!isset($_POST['captcha_response_field']) || empty($_POST['captcha_response_field']))){
268
			$userId = $this->session->userdata('userId');
277
			$userId = $this->session->userdata('userId');
269
			if(isset($userId) && !empty($userId)){
278
			if(isset($userId) && !empty($userId)){
Line 735... Line 744...
735
 
744
 
736
	public function getstatus() {
745
	public function getstatus() {
737
		if(isset($_GET['rechargeOrderId']) && !empty($_GET['rechargeOrderId'])){
746
		if(isset($_GET['rechargeOrderId']) && !empty($_GET['rechargeOrderId'])){
738
			//$_GET['rechargeOrderId'] = $_GET['rechargeOrderId'];
747
			//$_GET['rechargeOrderId'] = $_GET['rechargeOrderId'];
739
			// $this->lessphp->object()->ccompile('assets/css/recharge.less','assets/css/recharge.css');
748
			// $this->lessphp->object()->ccompile('assets/css/recharge.less','assets/css/recharge.css');
740
			$rechargeId = $_GET['id'];
749
			#$rechargeId = $_GET['id'];
741
			$isFinal = isset($_GET['isFinal'])?$_GET['isFinal']:false;
750
			$isFinal = isset($_GET['isFinal'])?$_GET['isFinal']:false;
742
			// $data['stylesheet'] = 'recharge.css';
751
			// $data['stylesheet'] = 'recharge.css';
743
			$data['response']=$this->recharge_model->getList($this->input->get(),$this->input->post(),$this->config->item('rechargeStatus'));
752
			$data['response']=$this->recharge_model->getList($this->input->get(),$this->input->post(),$this->config->item('rechargeStatus'));
744
			if(!empty($data['response']['response'])){
753
			if(!empty($data['response']['response'])){
745
				print_r($data['response']['response']['recharge_status'][0]->response->rechargeStatus);die;
754
				print_r($data['response']['response']['recharge_status'][0]->response->rechargeStatus);die;