| Line 340... |
Line 340... |
| 340 |
$addressid = json_decode($this->request->data['addressid']);
|
340 |
$addressid = json_decode($this->request->data['addressid']);
|
| 341 |
$pincode = 0;
|
341 |
$pincode = 0;
|
| 342 |
$cod = $this->request->query('cod');
|
342 |
$cod = $this->request->query('cod');
|
| 343 |
$userId = $this->request->query('user_id');
|
343 |
$userId = $this->request->query('user_id');
|
| 344 |
|
344 |
|
| 345 |
if(isset($this->request->data->pincode)){
|
345 |
//Added token validation to ensure only user
|
| 346 |
$pincode = $this->request->data->pincode;
|
346 |
$tokenValidated = !Configure::read ( 'requireusercheck' ) || $this->checkToken($userId);
|
| 347 |
}
|
- |
|
| 348 |
if($pincode==0 && isset($_COOKIE['s_pincode'])){
|
347 |
if(!empty($userId) && $tokenValidated==1){
|
| 349 |
$pincode = base64_decode($_COOKIE['s_pincode']);
|
- |
|
| 350 |
}
|
- |
|
| 351 |
|
- |
|
| 352 |
$suserId = base64_decode($_COOKIE['s_id']);
|
348 |
$url = $this->getAutoLoginUrl($userId,$url);
|
| 353 |
$scartId = base64_decode($_COOKIE['s_cart']);
|
- |
|
| 354 |
$semailId = base64_decode($_COOKIE['s_email']);
|
- |
|
| 355 |
|
349 |
|
| 356 |
if(isset($_COOKIE['txn_comp'])) {
|
350 |
if(isset($this->request->data->pincode)){
|
| 357 |
unset($_COOKIE['txn_comp']);
|
- |
|
| 358 |
}
|
- |
|
| 359 |
|
- |
|
| 360 |
if($cod==1){
|
- |
|
| 361 |
$url = Configure::read('saholicapihost').'order?payment_option=3000&isLoggedIn=true&privateDealUser=true&userId='.$suserId.'&id='.$scartId.'&email='.$semailId.'&addressid='.$addressid;
|
- |
|
| 362 |
if($pincode!='0'){
|
- |
|
| 363 |
$url = $url.'&pinCode='.$pincode;
|
351 |
$pincode = $this->request->data->pincode;
|
| 364 |
}
|
352 |
}
|
| - |
|
353 |
if($pincode==0 && isset($_COOKIE['s_pincode'])){
|
| - |
|
354 |
$pincode = base64_decode($_COOKIE['s_pincode']);
|
| - |
|
355 |
}
|
| - |
|
356 |
|
| - |
|
357 |
$suserId = base64_decode($_COOKIE['s_id']);
|
| - |
|
358 |
$scartId = base64_decode($_COOKIE['s_cart']);
|
| - |
|
359 |
$semailId = base64_decode($_COOKIE['s_email']);
|
| - |
|
360 |
|
| - |
|
361 |
if(isset($_COOKIE['txn_comp'])) {
|
| - |
|
362 |
unset($_COOKIE['txn_comp']);
|
| - |
|
363 |
}
|
| - |
|
364 |
|
| - |
|
365 |
if($cod==1){
|
| - |
|
366 |
$url = Configure::read('saholicapihost').'order?payment_option=3000&isLoggedIn=true&privateDealUser=true&userId='.$suserId.'&id='.$scartId.'&email='.$semailId.'&addressid='.$addressid;
|
| - |
|
367 |
if($pincode!='0'){
|
| - |
|
368 |
$url = $url.'&pinCode='.$pincode;
|
| - |
|
369 |
}
|
| 365 |
$orderCreationResponse = $this->post_cartinfo_request($url, null);
|
370 |
$orderCreationResponse = $this->post_cartinfo_request($url, null);
|
| 366 |
//{"response":{"success":true,"redirectUrl":"pay-success?paymentId=998593"}}
|
371 |
//{"response":{"success":true,"redirectUrl":"pay-success?paymentId=998593"}}
|
| 367 |
$redirecturl = $orderCreationResponse['response']['redirectUrl'];
|
372 |
$redirecturl = $orderCreationResponse['response']['redirectUrl'];
|
| 368 |
if (strpos($redirecturl,'pay-success') === false) {
|
373 |
if (strpos($redirecturl,'pay-success') === false) {
|
| 369 |
setcookie('txn_comp', 'no', -1, '/');
|
374 |
setcookie('txn_comp', 'no', -1, '/');
|
| 370 |
} else {
|
375 |
} else {
|
| 371 |
$order_det = array();
|
376 |
$order_det = array();
|
| 372 |
$this->loadModel('Order');
|
377 |
$this->loadModel('Order');
|
| 373 |
$order_det['user_id'] = $this->Auth->User('id');
|
378 |
$order_det['user_id'] = $this->Auth->User('id');
|
| 374 |
$order_det['store_id'] = 4;
|
379 |
$order_det['store_id'] = 4;
|
| 375 |
$str = Configure::read('saholicauthurl');
|
380 |
$str = Configure::read('saholicauthurl');
|
| 376 |
$order_det['order_url'] = explode('/autologin/',$str)[0]."/".$redirecturl;
|
381 |
$order_det['order_url'] = explode('/autologin/',$str)[0]."/".$redirecturl;
|
| 377 |
$this->log(print_r($order_det,1),'ordersdet');
|
382 |
$this->log(print_r($order_det,1),'ordersdet');
|
| 378 |
$this->Order->create();
|
383 |
$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 |
|
384 |
|
| 388 |
$this->log(print_r($order,1),'ordersdet');
|
385 |
if ($this->Order->save($order_det)) {
|
| 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']);
|
386 |
$id = $this->Order->getLastInsertID();
|
| 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']);
|
387 |
$order = $this->Order->find('first',array('conditions'=>array('id'=>$id),'recursive'=>-1));
|
| 393 |
$jsonVar = json_encode($params);
|
- |
|
| 394 |
$response = $this->make_request($url,$jsonVar);
|
388 |
$apihost = Configure::read('pythonapihost');
|
| 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();
|
389 |
$url = $apihost."storeorder";
|
| 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 |
|
390 |
|
| - |
|
391 |
$this->log(print_r($url,1),'ordersdet');
|
| - |
|
392 |
|
| - |
|
393 |
$this->log(print_r($order,1),'ordersdet');
|
| - |
|
394 |
$response = array();
|
| - |
|
395 |
// $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']);
|
| - |
|
396 |
if(!empty($order)) {
|
| 419 |
}
|
397 |
$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']);
|
| - |
|
398 |
$jsonVar = json_encode($params);
|
| - |
|
399 |
$response = $this->make_request($url,$jsonVar);
|
| - |
|
400 |
}else{
|
| - |
|
401 |
$result = array('success'=>false,'message'=>'Empty order array');
|
| - |
|
402 |
$response = $result;
|
| - |
|
403 |
}
|
| - |
|
404 |
$this->log(print_r('response',1),'ordersdet');
|
| - |
|
405 |
$this->log(print_r($response,1),'ordersdet');
|
| - |
|
406 |
if(!empty($response) && $response['result']) {
|
| - |
|
407 |
if($response['htmlRequired'] == 1) {
|
| - |
|
408 |
$this->loadModel('Rawhtml');
|
| - |
|
409 |
$data = array('order_id' => $order['Order']['id'],'url' => $response['url'], 'status' => 'new');
|
| - |
|
410 |
$this->Rawhtml->create();
|
| - |
|
411 |
$this->Rawhtml->save($data);
|
| - |
|
412 |
$this->log(print_r('insideif',1),'ordersdet');
|
| - |
|
413 |
$result = $response;
|
| - |
|
414 |
$sql = "UPDATE orders SET status = '".$response['result']."' WHERE id = ".$order['Order']['id'];
|
| - |
|
415 |
}
|
| - |
|
416 |
else {
|
| - |
|
417 |
$result =array('success'=>true,'message'=> $response['result']);
|
| - |
|
418 |
$sql = "UPDATE orders SET status = '".$response['result']."' WHERE id = ".$order['Order']['id'];
|
| - |
|
419 |
$this->log(print_r('insideelse',1),'ordersdet');
|
| - |
|
420 |
}
|
| - |
|
421 |
$this->log(print_r($sql,1),'ordersdet');
|
| - |
|
422 |
$this->Order->query($sql);
|
| - |
|
423 |
|
| - |
|
424 |
}
|
| - |
|
425 |
}
|
| 420 |
}
|
426 |
}
|
| - |
|
427 |
$this->layout = 'innerpages';
|
| - |
|
428 |
$next = $redirecturl;
|
| - |
|
429 |
$redirectUrl = $this->getAutoLoginUrl($userId,$next);
|
| - |
|
430 |
$this->log($redirectUrl,'headers');
|
| - |
|
431 |
$this->set(compact('redirectUrl','next'));
|
| - |
|
432 |
}else{
|
| - |
|
433 |
$dataGiven = json_decode($this->request->data['cart_details']);
|
| - |
|
434 |
$totalSkus= intval($dataGiven->totalSkus);
|
| - |
|
435 |
setcookie('txn_comp', 'no', -1, '/');
|
| - |
|
436 |
$this->layout = 'innerpages';
|
| - |
|
437 |
$next = "payment?cq=".$totalSkus.'&addressid='.$addressid;
|
| - |
|
438 |
$redirectUrl = $this->getAutoLoginUrl($userId,$next);
|
| - |
|
439 |
$this->log($redirectUrl,'headers');
|
| - |
|
440 |
$this->set(compact('redirectUrl','next'));
|
| - |
|
441 |
}
|
| - |
|
442 |
} else {
|
| - |
|
443 |
if($tokenValidated == 0){
|
| - |
|
444 |
$url = '/special/native/login';
|
| - |
|
445 |
}elseif($tokenValidated == -1){
|
| - |
|
446 |
$url = '/abouts/askforupdate';
|
| 421 |
}
|
447 |
}
|
| 422 |
$this->layout = 'innerpages';
|
- |
|
| 423 |
$next = $redirecturl;
|
- |
|
| 424 |
$redirectUrl = $this->getAutoLoginUrl($userId,$next);
|
- |
|
| 425 |
$this->log($redirectUrl,'headers');
|
448 |
$this->redirect($url);
|
| 426 |
$this->set(compact('redirectUrl','next'));
|
- |
|
| 427 |
}else{
|
- |
|
| 428 |
$dataGiven = json_decode($this->request->data['cart_details']);
|
- |
|
| 429 |
$totalSkus= intval($dataGiven->totalSkus);
|
- |
|
| 430 |
setcookie('txn_comp', 'no', -1, '/');
|
- |
|
| 431 |
$this->layout = 'innerpages';
|
- |
|
| 432 |
$next = "payment?cq=".$totalSkus.'&addressid='.$addressid;
|
- |
|
| 433 |
$redirectUrl = $this->getAutoLoginUrl($userId,$next);
|
- |
|
| 434 |
$this->log($redirectUrl,'headers');
|
- |
|
| 435 |
$this->set(compact('redirectUrl','next'));
|
- |
|
| 436 |
}
|
449 |
}
|
| 437 |
}
|
450 |
}
|
| 438 |
}
|
451 |
}
|