Subversion Repositories SmartDukaan

Rev

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

Rev 18039 Rev 18260
Line 353... Line 353...
353
		$semailId = base64_decode($_COOKIE['s_email']);
353
		$semailId = base64_decode($_COOKIE['s_email']);
354
		
354
		
355
		if(isset($_COOKIE['txn_comp'])) {
355
		if(isset($_COOKIE['txn_comp'])) {
356
			unset($_COOKIE['txn_comp']);
356
			unset($_COOKIE['txn_comp']);
357
		}
357
		}
358
		
358
	
359
		if($cod==1){
359
		if($cod==1){
360
			$url = Configure::read('saholicapihost').'order?payment_option=3000&isLoggedIn=true&privateDealUser=true&userId='.$suserId.'&id='.$scartId.'&email='.$semailId.'&addressid='.$addressid;
360
			$url = Configure::read('saholicapihost').'order?payment_option=3000&isLoggedIn=true&privateDealUser=true&userId='.$suserId.'&id='.$scartId.'&email='.$semailId.'&addressid='.$addressid;
361
		 	if($pincode!='0'){
361
		 	if($pincode!='0'){
362
				$url = $url.'&pinCode='.$pincode;
362
				$url = $url.'&pinCode='.$pincode;
363
			}
363
			}
364
			$orderCreationResponse = $this->post_cartinfo_request($url, null);
364
			$orderCreationResponse = $this->post_cartinfo_request($url, null);
365
			//{"response":{"success":true,"redirectUrl":"pay-success?paymentId=998593"}}
365
			//{"response":{"success":true,"redirectUrl":"pay-success?paymentId=998593"}}
366
			$redirecturl = $orderCreationResponse['response']['redirectUrl'];
366
			$redirecturl = $orderCreationResponse['response']['redirectUrl'];
-
 
367
			
367
			if (strpos($redirecturl,'pay-success') === false) {
368
			if (strpos($redirecturl,'pay-success') === false) {
368
			    setcookie('txn_comp', 'no', -1, '/');
369
			    setcookie('txn_comp', 'no', -1, '/');
-
 
370
			} else {
-
 
371
				$order_det = array();
-
 
372
				$this->loadModel('Order');
-
 
373
				$order_det['user_id'] = $this->Auth->User('id');
-
 
374
				$order_det['store_id'] = 4;
-
 
375
				$str = Configure::read('saholicauthurl');
-
 
376
				$order_det['order_url'] = explode('/autologin/',$str)[0]."/".$redirecturl;
-
 
377
				$this->log(print_r($order_det,1),'ordersdet');
-
 
378
				$this->Order->create();
-
 
379
				
-
 
380
				if ($this->Order->save($order_det)) {
-
 
381
					$id = $this->Order->getLastInsertID();
-
 
382
					$order = $this->Order->find('first',array('conditions'=>array('id'=>$id),'recursive'=>-1));
-
 
383
					$apihost = Configure::read('pythonapihost');
-
 
384
					$url = $apihost."storeorder";
-
 
385
					
-
 
386
					$this->log(print_r($url,1),'ordersdet');
-
 
387
					
-
 
388
					$this->log(print_r($order,1),'ordersdet');
-
 
389
					$response = array();
-
 
390
// 					$params = array('sourceId'=>$order['Order']['store_id'],'orderId'=>$order['Order']['id'],'subTagId'=>$order['Order']['sub_tag'],'userId'=>$order['Order']['user_id'],'rawHtml'=>$order['Order']['rawhtml'],'orderSuccessUrl'=>$order['Order']['order_url']);
-
 
391
					if(!empty($order)) {
-
 
392
						$params = array('sourceId'=>$order['Order']['store_id'],'orderId'=>$order['Order']['id'],'subTagId'=>$order['Order']['sub_tag'],'userId'=>$order['Order']['user_id'],'rawHtml'=>$order['Order']['rawhtml'],'orderSuccessUrl'=>$order['Order']['order_url']);
-
 
393
						$jsonVar = json_encode($params);
-
 
394
						$response =  $this->make_request($url,$jsonVar);
-
 
395
					}else{
-
 
396
						$result = array('success'=>false,'message'=>'Empty order array');
-
 
397
						$response = $result;
-
 
398
					}
-
 
399
					$this->log(print_r('response',1),'ordersdet');
-
 
400
					$this->log(print_r($response,1),'ordersdet');
-
 
401
					if(!empty($response) && $response['result']) {
-
 
402
						if($response['htmlRequired'] == 1) {
-
 
403
							$this->loadModel('Rawhtml');
-
 
404
							$data = array('order_id' => $order['Order']['id'],'url' => $response['url'], 'status' => 'new');
-
 
405
							$this->Rawhtml->create();
-
 
406
							$this->Rawhtml->save($data);
-
 
407
							$this->log(print_r('insideif',1),'ordersdet');
-
 
408
							$result =  $response;
-
 
409
							$sql = "UPDATE orders SET status = '".$response['result']."' WHERE id = ".$order['Order']['id'];
-
 
410
						}
-
 
411
						else {
-
 
412
							$result =array('success'=>true,'message'=> $response['result']);
-
 
413
							$sql = "UPDATE orders SET status = '".$response['result']."' WHERE id = ".$order['Order']['id'];
-
 
414
							$this->log(print_r('insideelse',1),'ordersdet');
-
 
415
						}
-
 
416
						$this->log(print_r($sql,1),'ordersdet');
-
 
417
						$this->Order->query($sql);
-
 
418
						
-
 
419
					}					
-
 
420
				}
369
			}
421
			}
370
			$this->layout = 'innerpages';
422
			$this->layout = 'innerpages';
371
			$next = $redirecturl;					
423
			$next = $redirecturl;					
372
			$redirectUrl = $this->getAutoLoginUrl($userId,$next);
424
			$redirectUrl = $this->getAutoLoginUrl($userId,$next);
373
			$this->log($redirectUrl,'headers');
425
			$this->log($redirectUrl,'headers');