Commit f60c20b3 by Tobin

t : payment changes

parent 8005f3c8
...@@ -339,7 +339,7 @@ class Api extends CI_Controller { ...@@ -339,7 +339,7 @@ class Api extends CI_Controller {
} }
public function paymentGateway($amount='0',$last_id='0',$event_id='0',$booking_id='0', public function paymentGateway($amount='0',$last_id='0',$event_id='0',$booking_id='0',
$custData=array(),$cardData=array()){ $custData=array(),$cardData=''){
$customerName = array(); $customerName = array();
if(isset($custData->name) && !empty($custData->name)){ if(isset($custData->name) && !empty($custData->name)){
$customerName = explode(' ',$custData->name); $customerName = explode(' ',$custData->name);
...@@ -353,12 +353,17 @@ class Api extends CI_Controller { ...@@ -353,12 +353,17 @@ class Api extends CI_Controller {
$add1 = $add2 = $city = $state = 'Saudi Arabia'; $add1 = $add2 = $city = $state = 'Saudi Arabia';
$pincode = '61961'; $pincode = '61961';
$noCard = 0;
$saveCard = 1; $saveCard = 1;
$savedCard = 0; $savedCard = 0;
$cvv = $tocken = $cardNo = $holder = $cardType = $expMonth = $expYear = '';
if(!empty($cardData)){ if(!empty($cardData)){
if(isset($cardData['cvv']) && !empty($cardData['cvv']) && $cardData = $this->encrypt($cardData,$this->local_key,$this->local_iv);
if(empty($cardData)){
redirect($redUrl.'failure');
} else if (isset($cardData['cvv']) && !empty($cardData['cvv']) &&
isset($cardData['tocken']) && !empty($cardData['tocken'])){ isset($cardData['tocken']) && !empty($cardData['tocken'])){
$cvv = $cardData['cvv'];
$tocken = $cardData['tocken'];
$savedCard = 1; $savedCard = 1;
} else if(isset($cardData['cvv']) && !empty($cardData['cvv']) || } else if(isset($cardData['cvv']) && !empty($cardData['cvv']) ||
isset($cardData['cardType']) && !empty($cardData['cardType']) || isset($cardData['cardType']) && !empty($cardData['cardType']) ||
...@@ -372,12 +377,12 @@ class Api extends CI_Controller { ...@@ -372,12 +377,12 @@ class Api extends CI_Controller {
$cardType = $cardData['cardType']; $cardType = $cardData['cardType'];
$expMonth = substr($cardData['expMonthYear'],0,2); $expMonth = substr($cardData['expMonthYear'],0,2);
$expYear = '20'.substr($cardData['expMonthYear'],2,2); $expYear = '20'.substr($cardData['expMonthYear'],2,2);
$saveCard = (isset($cardData['saveCard'])&&!empty($cardData['saveCard'])&&$cardData['saveCard']==0)?0:1; $saveCard = (isset($cardData['saveCard']) && $cardData['saveCard'] == 0)?0:1;
} else { } else {
$noCard = 1; redirect($redUrl.'failure');
} }
} else { } else {
$noCard = 1; redirect($redUrl.'failure');
} }
$failureUrl = base_url('Api/paymentFailureUrl'); $failureUrl = base_url('Api/paymentFailureUrl');
...@@ -390,13 +395,9 @@ class Api extends CI_Controller { ...@@ -390,13 +395,9 @@ class Api extends CI_Controller {
$pText .= '111111111111|'.$f_Name.'|'.$l_Name.'|'.$add1.'|'.$add2.'|'.$city.'|'.$state.'|'.$pincode. $pText .= '111111111111|'.$f_Name.'|'.$l_Name.'|'.$add1.'|'.$add2.'|'.$city.'|'.$state.'|'.$pincode.
'|SA|'.$phone.'|34|344|34355344||'; '|SA|'.$phone.'|34|344|34355344||';
if($savedCard == 1){ if($savedCard == 1){
$pText .= '00010000001|'.$cardData['cvv'].'|'.$cardData['tocken'].'||'; $pText .= '00010000001|'.$cvv.'|'.$tocken.'||';
} else {
if($noCard == 0){
$pText .= '11111100000|'.$cardNo.'|'.$expMonth.'|'.$expYear.'|'.$cvv.'|'.$holder.'|'.$cardType.'||';
} else { } else {
// Provide Card Details Manually in Bayanpay Payment gateway. $pText .='11111100000|'.$cardNo.'|'.$expMonth.'|'.$expYear.'|'.$cvv.'|'.$holder.'|'.$cardType.'||';
}
} }
$pText .= '1110000|'.$last_id.'|'.$event_id.'|'.$booking_id.'||'; $pText .= '1110000|'.$last_id.'|'.$event_id.'|'.$booking_id.'||';
if($saveCard == 1){ if($saveCard == 1){
......
...@@ -1813,29 +1813,53 @@ class Webservice_model extends CI_Model { ...@@ -1813,29 +1813,53 @@ class Webservice_model extends CI_Model {
public function sync_contacts($data){ public function sync_contacts($data){
$user_id = $this->auth_token_get($data['auth_token']); $user_id = $this->auth_token_get($data['auth_token']);
$respArr = array('status'=>0,'code'=>'918','message'=>'Data Missing');
if(empty($data)){ if(empty($data)){
return $respArr; return array('status'=>0,'code'=>'918','message'=>'Data Missing');
} }
$phNumbers = ''; $phNumbers = '';
foreach($data['contacts'] AS $key => $number) { foreach($data['contacts'] AS $key => $number) {
$number = preg_replace('/\D/', '', $number); $number = preg_replace('/\D/', '', $number);
$eCond = ($key != count($data['contacts'])-1)?' OR ':''; $cond = " AND CUST.enable_chat='1' AND USR.status='1'";
$eCond = ($key != count($data['contacts'])-1)?') OR ':')';
$eCond = $cond.$eCond;
if(strlen($number) > 9){ if(strlen($number) > 9){
$phNumbers .= " phone LIKE '%".substr($number, strlen($number)-9)."' ".$eCond; $phNumbers .= " (CUST.phone LIKE '%".substr($number, strlen($number)-9)."' ".$eCond;
} else { } else {
$phNumbers .= " phone LIKE '%".$number."' ".$eCond; $phNumbers .= " (CUST.phone LIKE '%".$number."' ".$eCond;
}
}
if(empty($phNumbers)){
return array('status'=>0,'code'=>'919','message'=>'Invalid Data');
}
$sql = "SELECT CUST.customer_id FROM customer AS CUST
INNER JOIN users AS USR ON (USR.id=CUST.customer_id)
WHERE $phNumbers";
$custIds = $this->db->query($sql)->result_array();
if(empty($custIds)){
return array('status'=>0,'code'=>'919','message'=>'No Data Found');
} }
$user_ids = '';
foreach ($custIds AS $id) {
$user_ids = $id['customer_id'].',';
} }
$user_ids = trim($user_ids,',');
$result = $this->db->query("SELECT CUST.customer_id,CUST.name,CUST.phone,CUST.profile_image, $result = $this->db->query("SELECT CUST.customer_id,CUST.name,CUST.phone,CUST.profile_image,
CUST.profile_image_qr,CHT.type AS friend_status CUST.profile_image_qr,CHT.type AS friend_status
FROM customer AS CUST FROM customer AS CUST
LEFT JOIN chats AS CHT ON ((CUST.customer_id=CHT.from_user OR CUST.customer_id=CHT.to_user) AND CHT.type=1) LEFT JOIN chats AS CHT ON ((CUST.customer_id=CHT.from_user OR CUST.customer_id=CHT.to_user) AND CHT.type=1)
WHERE ($phNumbers) AND CUST.enable_chat='1' AND WHERE CUST.customer_id IN ($user_ids) AND
customer_id NOT IN (SELECT from_user FROM chats WHERE (from_user=$user_id AND type='2') OR (to_user =$user_id AND type='2')) AND customer_id NOT IN
customer_id NOT IN (SELECT to_user FROM chats WHERE (from_user=$user_id AND type='2') OR (to_user =$user_id AND type='2')) (SELECT from_user FROM chats
WHERE (from_user=$user_id AND type='2') OR
(to_user=$user_id AND type='2'))
AND
customer_id NOT IN
(SELECT to_user FROM chats
WHERE (from_user=$user_id AND type='2') OR
(to_user=$user_id AND type='2'))
GROUP BY CUST.customer_id"); GROUP BY CUST.customer_id");
$respArr['status'] = 1; $respArr['status'] = 1;
$respArr['data'] = (!empty($result) && !empty($result=$result->result_array()))?$result:[]; $respArr['data'] = (!empty($result) && !empty($result=$result->result_array()))?$result:[];
return $respArr; return $respArr;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment