Commit 6aa6da11 by Tobin

dc

parent 1a18dd8b
...@@ -21,6 +21,8 @@ class Api extends CI_Controller { ...@@ -21,6 +21,8 @@ class Api extends CI_Controller {
var $auth_token; var $auth_token;
private $cipher = "AES-256-CBC"; private $cipher = "AES-256-CBC";
private $local_iv = "9H77F2KL7KRF4W51";
private $local_key = "af5b2a1h6947gt8fd045k78s2ah5609f";
public function __construct() { public function __construct() {
parent::__construct(); parent::__construct();
date_default_timezone_set("Asia/Riyadh"); date_default_timezone_set("Asia/Riyadh");
...@@ -603,7 +605,7 @@ class Api extends CI_Controller { ...@@ -603,7 +605,7 @@ class Api extends CI_Controller {
empty($resp->txnCardDetails) || count($resp->txnCardDetails) <= 0){ empty($resp->txnCardDetails) || count($resp->txnCardDetails) <= 0){
$this->errorResponse('893','No Data Found'); $this->errorResponse('893','No Data Found');
} }
$this->response(array('saved_cards'=>$resp->txnCardDetails)); $this->response(array('saved_cards'=>encrypt($resp->txnCardDetails,$this->local_key,$this->local_iv)));
} }
function encryptePayData($merchant_iv='',$merchant_key='',$plainText='') { function encryptePayData($merchant_iv='',$merchant_key='',$plainText='') {
...@@ -641,25 +643,45 @@ class Api extends CI_Controller { ...@@ -641,25 +643,45 @@ class Api extends CI_Controller {
return ''; return '';
} }
if (in_array($this->cipher, openssl_get_cipher_methods())) { if (in_array($this->cipher, openssl_get_cipher_methods())) {
$ciphertext = openssl_encrypt($plainText, $this->cipher, $this->key, $options=0, $this->iv); $ciphertext = openssl_encrypt($plainText,$this->cipher,$mKey,$options=0,$mIv);
return $ciphertext; return $ciphertext;
} }
} }
public function decrypt($encText='',$mKey='',$mIv='') { public function decrypt($encText='',$mKey='',$mIv='') {
if(empty($plainText) || empty($mKey) || empty($mIv)){ if(empty($encText) || empty($mKey) || empty($mIv)){
return ''; return '';
} }
if (in_array($this->cipher, openssl_get_cipher_methods())) { if (in_array($this->cipher, openssl_get_cipher_methods())) {
$original_plaintext = openssl_decrypt($encText, $this->cipher, $this->key, $options=0, $this->iv); $original_plaintext = openssl_decrypt($encText,$this->cipher,$mKey,$options=0,$mIv);
return $original_plaintext; return $original_plaintext;
} }
} }
public function addCard(){ public function addCard(){
pr($_POST); $data = (array) json_decode(file_get_contents('php://input'));
// $dmyData = '{"auth_token":"cc731b6bd572eb452d85c96aaec77898","cardNumber":"5111111111111118",
// "expMonthYear":"0622","cardHolderName":"John","cvv":"100","cardType":"MasterCard"}';
// $data['requestData'] = $this->encrypt($dmyData,$this->local_key,$this->local_iv);
$settings = getSettings();
$merchant_iv = $settings['merchant_iv'];
$merchant_key = $settings['merchant_key'];
$reqData = $this->decrypt($data['requestData'],$this->local_key,$this->local_iv);
if(empty($reqData) || empty($reqData=json_decode($reqData,true))){
redirect($redUrl.'failure');
} }
$payData = array('auth_token'=>$reqData['auth_token'],'amount'=>'1','booking_id'=>'ADD_CARD');
$res = $this->Api_model->payNow($payData);
if($res['status']==1){
unset($reqData['auth_token']);
$this->paymentGateway(1,$res['transaction_id'],'test','ADD_CARD',$res['custData'],$reqData);
}else{
redirect($redUrl.'failure');
}
}
/*================ START : Checker API ================*/ /*================ START : Checker API ================*/
......
...@@ -1730,7 +1730,7 @@ class Api_model extends CI_Model { ...@@ -1730,7 +1730,7 @@ class Api_model extends CI_Model {
->select('booking.id AS book_id,booking.bookId,customer.name AS customer_name, ->select('booking.id AS book_id,booking.bookId,customer.name AS customer_name,
booking.status,booking.no_of_ticket,booking.qrcode, booking.status,booking.no_of_ticket,booking.qrcode,
booking.ticket_details,event_date_time.date AS booking_date') booking.ticket_details,event_date_time.date AS booking_date')
->where('booking.bookId',$data['qr_pin']) ->where(array('booking.bookId'=>$data['qr_pin'],'status'=>'1'))
->from('booking') ->from('booking')
->join('events','booking.event_id = events.event_id') ->join('events','booking.event_id = events.event_id')
->join('event_date_time','booking.event_date_id = event_date_time.id') ->join('event_date_time','booking.event_date_id = event_date_time.id')
......
...@@ -686,7 +686,14 @@ class Validation_model extends CI_Model { ...@@ -686,7 +686,14 @@ class Validation_model extends CI_Model {
) )
) )
), ),
'addCard' => array() 'addCard' => array(
'requestData' => array(
'required' => array(
'code' => 'ER18',
'message' => 'Request Data is null or empty'
)
)
)
); );
public function _consruct(){ public function _consruct(){
......
...@@ -1832,9 +1832,10 @@ class Webservice_model extends CI_Model { ...@@ -1832,9 +1832,10 @@ class Webservice_model extends CI_Model {
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 WHERE ($phNumbers) 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 (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'))"); 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");
$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:[];
...@@ -1873,7 +1874,8 @@ class Webservice_model extends CI_Model { ...@@ -1873,7 +1874,8 @@ class Webservice_model extends CI_Model {
CUST.customer_id CUST.customer_id
FROM customer AS CUST FROM customer AS CUST
INNER JOIN chats AS CHT ON (CUST.customer_id = CHT.from_user) INNER JOIN chats AS CHT ON (CUST.customer_id = CHT.from_user)
WHERE type='0' AND to_user='".$user_id."'"); WHERE type='0' AND to_user='$user_id'
GROUP BY CUST.customer_id");
if(!empty($result) && !empty($result = $result->result())){ if(!empty($result) && !empty($result = $result->result())){
$respArr['status'] = 1; $respArr['status'] = 1;
$respArr['data'] = $result; $respArr['data'] = $result;
......
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