| Line 93... |
Line 93... |
| 93 |
$current_address_id = - 1;
|
93 |
$current_address_id = - 1;
|
| 94 |
$defaultpin = - 1;
|
94 |
$defaultpin = - 1;
|
| 95 |
$defaultcookiepin = - 1;
|
95 |
$defaultcookiepin = - 1;
|
| 96 |
$defaultcheckedaddress = - 1;
|
96 |
$defaultcheckedaddress = - 1;
|
| 97 |
$defaultpinaddress = - 1;
|
97 |
$defaultpinaddress = - 1;
|
| - |
|
98 |
$taxInvoiceCounter = $response ['taxInvoiceCounter'];
|
| 98 |
foreach ( $response ['addresses'] as $key => $value ) {
|
99 |
foreach ( $response ['addresses'] as $key => $value ) {
|
| 99 |
// debug($value['']);
|
100 |
// debug($value['']);
|
| 100 |
|
101 |
|
| 101 |
if ($value ['id'] == intval ( $response ['defaultAddress'] ) && intval ( $value ['pin'] ) == $pincode) {
|
102 |
if ($value ['id'] == intval ( $response ['defaultAddress'] ) && intval ( $value ['pin'] ) == $pincode) {
|
| 102 |
$defaultcookiepin = $key;
|
103 |
$defaultcookiepin = $key;
|
| Line 144... |
Line 145... |
| 144 |
array_push ( $firstshowaddress, $moreshowaddress [$i] );
|
145 |
array_push ( $firstshowaddress, $moreshowaddress [$i] );
|
| 145 |
}
|
146 |
}
|
| 146 |
|
147 |
|
| 147 |
$this->set ( 'address', $response );
|
148 |
$this->set ( 'address', $response );
|
| 148 |
|
149 |
|
| 149 |
$this->set ( compact ( 'firstshowaddress', 'totalPayable', 'user_name', 'user_contact', 'pincode', 'defaultselectedaddress', 'message', 'codAvailable') );
|
150 |
$this->set ( compact ( 'firstshowaddress', 'totalPayable', 'user_name', 'user_contact', 'pincode', 'defaultselectedaddress', 'message', 'codAvailable', 'taxInvoiceCounter') );
|
| 150 |
}
|
151 |
}
|
| 151 |
}
|
152 |
}
|
| 152 |
public function add($user_name = null, $user_contact = null) {
|
153 |
public function add($user_name = null, $user_contact = null) {
|
| 153 |
$this->layout = 'cartinnerpages';
|
154 |
$this->layout = 'cartinnerpages';
|
| 154 |
|
155 |
|
| Line 353... |
Line 354... |
| 353 |
$semailId = base64_decode($_COOKIE['s_email']);
|
354 |
$semailId = base64_decode($_COOKIE['s_email']);
|
| 354 |
|
355 |
|
| 355 |
if(isset($_COOKIE['txn_comp'])) {
|
356 |
if(isset($_COOKIE['txn_comp'])) {
|
| 356 |
unset($_COOKIE['txn_comp']);
|
357 |
unset($_COOKIE['txn_comp']);
|
| 357 |
}
|
358 |
}
|
| 358 |
|
359 |
|
| 359 |
if($cod==1){
|
360 |
if($cod==1){
|
| 360 |
$url = Configure::read('saholicapihost').'order?payment_option=3000&isLoggedIn=true&privateDealUser=true&userId='.$suserId.'&id='.$scartId.'&email='.$semailId.'&addressid='.$addressid;
|
361 |
$url = Configure::read('saholicapihost').'order?payment_option=3000&isLoggedIn=true&privateDealUser=true&userId='.$suserId.'&id='.$scartId.'&email='.$semailId.'&addressid='.$addressid;
|
| 361 |
if($pincode!='0'){
|
362 |
if($pincode!='0'){
|
| 362 |
$url = $url.'&pinCode='.$pincode;
|
363 |
$url = $url.'&pinCode='.$pincode;
|
| 363 |
}
|
364 |
}
|
| 364 |
$orderCreationResponse = $this->post_cartinfo_request($url, null);
|
365 |
$orderCreationResponse = $this->post_cartinfo_request($url, null);
|
| 365 |
//{"response":{"success":true,"redirectUrl":"pay-success?paymentId=998593"}}
|
366 |
//{"response":{"success":true,"redirectUrl":"pay-success?paymentId=998593"}}
|
| 366 |
$redirecturl = $orderCreationResponse['response']['redirectUrl'];
|
367 |
$redirecturl = $orderCreationResponse['response']['redirectUrl'];
|
| 367 |
|
- |
|
| 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 |
}
|
- |
|
| 421 |
}
|
370 |
}
|
| 422 |
$this->layout = 'innerpages';
|
371 |
$this->layout = 'innerpages';
|
| 423 |
$next = $redirecturl;
|
372 |
$next = $redirecturl;
|
| 424 |
$redirectUrl = $this->getAutoLoginUrl($userId,$next);
|
373 |
$redirectUrl = $this->getAutoLoginUrl($userId,$next);
|
| 425 |
$this->log($redirectUrl,'headers');
|
374 |
$this->log($redirectUrl,'headers');
|