Subversion Repositories SmartDukaan

Rev

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

Rev 18529 Rev 18613
Line 365... Line 365...
365
			$orderCreationResponse = $this->post_cartinfo_request($url, null);
365
			$orderCreationResponse = $this->post_cartinfo_request($url, null);
366
			//{"response":{"success":true,"redirectUrl":"pay-success?paymentId=998593"}}
366
			//{"response":{"success":true,"redirectUrl":"pay-success?paymentId=998593"}}
367
			$redirecturl = $orderCreationResponse['response']['redirectUrl'];
367
			$redirecturl = $orderCreationResponse['response']['redirectUrl'];
368
			if (strpos($redirecturl,'pay-success') === false) {
368
			if (strpos($redirecturl,'pay-success') === false) {
369
			    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
				}
370
			}
421
			}
371
			$this->layout = 'innerpages';
422
			$this->layout = 'innerpages';
372
			$next = $redirecturl;					
423
			$next = $redirecturl;					
373
			$redirectUrl = $this->getAutoLoginUrl($userId,$next);
424
			$redirectUrl = $this->getAutoLoginUrl($userId,$next);
374
			$this->log($redirectUrl,'headers');
425
			$this->log($redirectUrl,'headers');