Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
TimeOutAdmin
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
TimeOut
TimeOutAdmin
Commits
f4d51eb4
Commit
f4d51eb4
authored
Dec 18, 2019
by
Jansa Jose
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into 'dev_production'
Master See merge request
!239
parents
b4521e0f
8a8f2333
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
109 additions
and
56 deletions
+109
-56
Api.php
application/controllers/Api.php
+82
-49
Api_model.php
application/models/Api_model.php
+11
-5
HotelServices_model.php
application/models/HotelServices_model.php
+1
-1
Organizer_model.php
application/models/Organizer_model.php
+1
-1
Validation_model.php
application/models/Validation_model.php
+14
-0
No files found.
application/controllers/Api.php
View file @
f4d51eb4
...
...
@@ -371,7 +371,9 @@ class Api extends CI_Controller {
redirect
(
$redUrl
.
'failure'
);
}
$payData
=
array
(
'auth_token'
=>
$auth_token
,
'amount'
=>
$amount
,
'booking_id'
=>
$booking_id
);
$callback_url
=
(
isset
(
$reqData
[
'callback_url'
]))
?
$reqData
[
'callback_url'
]
:
''
;
$payData
=
array
(
'auth_token'
=>
$auth_token
,
'amount'
=>
$amount
,
'booking_id'
=>
$booking_id
,
'callback_url'
=>
$callback_url
);
$res
=
$this
->
Api_model
->
payNow
(
$payData
);
if
(
$res
[
'status'
]
==
1
){
...
...
@@ -533,12 +535,16 @@ class Api extends CI_Controller {
}
if
(
!
empty
(
$transaction_id
)
&&
!
empty
(
$last_id
)){
$this
->
Api_model
->
update_payment
(
$response
,
$transaction_id
,
$last_id
,
'1'
,
$eventid
);
$
resp
=
$
this
->
Api_model
->
update_payment
(
$response
,
$transaction_id
,
$last_id
,
'1'
,
$eventid
);
$customData
=
$this
->
txnManager
(
$eventid
,
array
(
'tnx_id'
=>
$booking_id
,
'status'
=>
'1'
));
}
if
(
!
empty
(
$booking_id
)){
redirect
(
$redUrl
.
'bookingdetails?booking_id='
.
$booking_id
);
$callback_url
=
$redUrl
.
'bookingdetails?booking_id='
;
if
(
isset
(
$resp
[
'callback_url'
])
&&
!
empty
(
$resp
[
'callback_url'
])){
$callback_url
=
$redUrl
.
$resp
[
'callback_url'
];
}
redirect
(
$callback_url
.
$booking_id
);
}
}
redirect
(
$redUrl
.
'failure'
);
...
...
@@ -581,7 +587,7 @@ class Api extends CI_Controller {
$last_id
=
$data
[
1
];
$eventid
=
$data
[
2
];
$booking_id
=
$data
[
3
];
$this
->
Api_model
->
update_payment
(
$response
,
''
,
$last_id
,
'0'
,
$eventid
);
$
resp
=
$
this
->
Api_model
->
update_payment
(
$response
,
''
,
$last_id
,
'0'
,
$eventid
);
$customData
=
$this
->
txnManager
(
$eventid
,
array
(
'tnx_id'
=>
$booking_id
,
'status'
=>
'2'
));
$sql
=
"SELECT BOK.event_id FROM transaction AS TX
...
...
@@ -589,7 +595,11 @@ class Api extends CI_Controller {
WHERE TX.id='
$last_id
'"
;
$trxData
=
$this
->
db
->
query
(
$sql
)
->
row_array
();
if
(
!
empty
(
$trxData
)
&&
isset
(
$trxData
[
'event_id'
])
&&
!
empty
(
$trxData
[
'event_id'
])){
redirect
(
$redUrl
.
'failure?event_id='
.
$trxData
[
'event_id'
]);
$callback_url
=
$redUrl
.
'failure?event_id='
;
if
(
isset
(
$resp
[
'callback_url'
])
&&
!
empty
(
$resp
[
'callback_url'
])){
$callback_url
=
$redUrl
.
$resp
[
'callback_url'
];
}
redirect
(
$callback_url
.
$trxData
[
'event_id'
]);
}
}
}
...
...
@@ -601,8 +611,7 @@ class Api extends CI_Controller {
$res
=
$this
->
Api_model
->
reset_password
(
$data
);
if
(
$res
[
'status'
]
!=
0
){
$this
->
response
(
$res
[
'data'
]);
}
else
{
}
else
{
$this
->
errorResponse
(
$res
[
'code'
],
$res
[
'message'
]);
}
}
...
...
@@ -617,8 +626,7 @@ class Api extends CI_Controller {
$res
=
$this
->
Api_model
->
checkSeatAvailability
(
$data
);
if
(
$res
[
'status'
]
!=
0
){
$this
->
response
(
$res
[
'data'
]);
}
else
{
}
else
{
$this
->
errorResponse
(
$res
[
'code'
],
$res
[
'message'
]);
}
}
...
...
@@ -627,8 +635,7 @@ class Api extends CI_Controller {
$res
=
$this
->
Api_model
->
getCountry
();
if
(
$res
[
'status'
]
!=
0
){
$this
->
response
(
$res
[
'data'
]);
}
else
{
}
else
{
$this
->
errorResponse
(
$res
[
'code'
],
$res
[
'message'
]);
}
}
...
...
@@ -643,44 +650,48 @@ class Api extends CI_Controller {
}
public
function
getSavedCards
(){
$data
=
(
array
)
json_decode
(
file_get_contents
(
'php://input'
));
$cust_id
=
$this
->
Api_model
->
auth_token_get
(
$this
->
auth_token
);
if
(
empty
(
$cust_id
)
||
empty
(
$data
)
||
!
isset
(
$data
[
'email'
])
||
empty
(
$email
=
$data
[
'email'
])){
$this
->
errorResponse
(
'891'
,
'Invalid User'
);
}
$settings
=
getSettings
();
$merchant_iv
=
$settings
[
'merchant_iv'
];
$merchant_id
=
$settings
[
'merchant_id'
];
$merchant_key
=
$settings
[
'merchant_key'
];
$ses_id
=
time
()
.
rand
(
100000
,
999999
);
$reqData
=
'{"sessionId":"'
.
$ses_id
.
'","merchantId":"'
.
$merchant_id
.
'","custId":"'
.
$cust_id
.
'","emailId":"'
.
$email
.
'"}'
;
$plainText
=
$this
->
encryptePayData
(
$merchant_iv
,
$merchant_key
,
$reqData
);
$plainText
=
$merchant_id
.
'|'
.
$plainText
;
$env
=
(
strpos
(
$settings
[
'payment_gateway_url'
],
'staging'
)
!==
false
)
?
'staging'
:
'payments'
;
$ch
=
curl_init
();
curl_setopt
(
$ch
,
CURLOPT_URL
,
"https://
$env
.bayanpay.sa/direcpay/secure/PaymentsMerchStoredCardDtlsAPI"
);
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
1
);
curl_setopt
(
$ch
,
CURLOPT_POST
,
1
);
curl_setopt
(
$ch
,
CURLOPT_POSTFIELDS
,
$plainText
);
curl_setopt
(
$ch
,
CURLOPT_HTTPHEADER
,
array
(
'Content-Type: text/plain'
));
$result
=
curl_exec
(
$ch
);
if
(
empty
(
$result
)){
$this
->
errorResponse
(
'892'
,
'Something went wrong, Please try again'
);
}
$resp
=
$this
->
decryptePayData
(
$merchant_iv
,
$merchant_key
,
$result
);
if
(
empty
(
$resp
)
||
!
isset
(
$resp
->
txnCardDetails
)
||
empty
(
$resp
->
txnCardDetails
)
||
count
(
$resp
->
txnCardDetails
)
<=
0
){
$this
->
errorResponse
(
'893'
,
'No Data Found'
);
}
$cardData
=
json_encode
(
json_decode
(
json_encode
(
$resp
->
txnCardDetails
),
true
));
$resp
=
$this
->
encrypt
(
$cardData
,
$this
->
local_key
,
$this
->
local_iv
);
$this
->
response
(
array
(
'saved_cards'
=>
$resp
));
try
{
$data
=
(
array
)
json_decode
(
file_get_contents
(
'php://input'
));
$cust_id
=
$this
->
Api_model
->
auth_token_get
(
$this
->
auth_token
);
if
(
empty
(
$cust_id
)
||
empty
(
$data
)
||
!
isset
(
$data
[
'email'
])
||
empty
(
$email
=
$data
[
'email'
])){
$this
->
errorResponse
(
'891'
,
'Invalid User'
);
}
$settings
=
getSettings
();
$merchant_iv
=
$settings
[
'merchant_iv'
];
$merchant_id
=
$settings
[
'merchant_id'
];
$merchant_key
=
$settings
[
'merchant_key'
];
$ses_id
=
time
()
.
rand
(
100000
,
999999
);
$reqData
=
'{"sessionId":"'
.
$ses_id
.
'","merchantId":"'
.
$merchant_id
.
'","custId":"'
.
$cust_id
.
'","emailId":"'
.
$email
.
'"}'
;
$plainText
=
$this
->
encryptePayData
(
$merchant_iv
,
$merchant_key
,
$reqData
);
$plainText
=
$merchant_id
.
'|'
.
$plainText
;
$env
=
(
strpos
(
$settings
[
'payment_gateway_url'
],
'staging'
)
!==
false
)
?
'staging'
:
'payments'
;
$ch
=
curl_init
();
curl_setopt
(
$ch
,
CURLOPT_URL
,
"https://
$env
.bayanpay.sa/direcpay/secure/PaymentsMerchStoredCardDtlsAPI"
);
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
1
);
curl_setopt
(
$ch
,
CURLOPT_POST
,
1
);
curl_setopt
(
$ch
,
CURLOPT_POSTFIELDS
,
$plainText
);
curl_setopt
(
$ch
,
CURLOPT_HTTPHEADER
,
array
(
'Content-Type: text/plain'
));
$result
=
curl_exec
(
$ch
);
if
(
empty
(
$result
)){
$this
->
errorResponse
(
'892'
,
'Something went wrong, Please try again'
);
}
$resp
=
$this
->
decryptePayData
(
$merchant_iv
,
$merchant_key
,
$result
);
if
(
empty
(
$resp
)
||
!
isset
(
$resp
->
txnCardDetails
)
||
empty
(
$resp
->
txnCardDetails
)
||
count
(
$resp
->
txnCardDetails
)
<=
0
){
$this
->
errorResponse
(
'893'
,
'No Data Found'
);
}
$cardData
=
json_encode
(
json_decode
(
json_encode
(
$resp
->
txnCardDetails
),
true
));
$resp
=
$this
->
encrypt
(
$cardData
,
$this
->
local_key
,
$this
->
local_iv
);
$this
->
response
(
array
(
'saved_cards'
=>
$resp
));
}
catch
(
Exception
$e
)
{
$this
->
errorResponse
(
'894'
,
'Something went wrong, Please try again'
);
}
}
function
encryptePayData
(
$merchant_iv
=
''
,
$merchant_key
=
''
,
$plainText
=
''
)
{
...
...
@@ -761,5 +772,27 @@ class Api extends CI_Controller {
redirect
(
$redUrl
.
'failure'
);
}
}
function
hotelBooking
(){
try
{
$data
=
(
array
)
json_decode
(
file_get_contents
(
'php://input'
));
$cust_id
=
$this
->
Api_model
->
auth_token_get
(
$this
->
auth_token
);
if
(
empty
(
$cust_id
)){
$this
->
errorResponse
(
'891'
,
'Invalid User'
);
}
if
(
empty
(
$data
)
||
!
isset
(
$data
[
'request_data'
])
||
empty
(
$request_data
=
$data
[
'request_data'
])){
$this
->
errorResponse
(
'892'
,
'Request Data Missing'
);
}
pre
(
$request_data
);
$reqData
=
$this
->
encrypt
(
json_encode
(
$request_data
),
$this
->
local_key
,
$this
->
local_iv
);
$reqData
=
urlencode
(
base64_encode
(
$reqData
));
$res
[
'data'
][
'reqData'
]
=
$reqData
;
$this
->
response
(
$res
[
'data'
]);
}
catch
(
Exception
$e
)
{
$this
->
errorResponse
(
'894'
,
'Something went wrong, Please try again'
);
}
}
}
?>
application/models/Api_model.php
View file @
f4d51eb4
...
...
@@ -1341,7 +1341,11 @@ class Api_model extends CI_Model {
try
{
$user_id
=
$this
->
auth_token_get
(
$data
[
'auth_token'
]);
if
(
$user_id
>
0
)
{
$this
->
db
->
insert
(
'transaction'
,
array
(
'customer_id'
=>
$user_id
,
'booking_id'
=>
$data
[
'booking_id'
],
'datetime'
=>
date
(
'Y-m-d h:i:s'
),
'amount'
=>
$data
[
'amount'
]));
$callback_url
=
(
isset
(
$data
[
'callback_url'
]))
?
$data
[
'callback_url'
]
:
''
;
$insertData
=
array
(
'customer_id'
=>
$user_id
,
'booking_id'
=>
$data
[
'booking_id'
],
'datetime'
=>
date
(
'Y-m-d h:i:s'
),
'amount'
=>
$data
[
'amount'
],
'callback_url'
=>
$callback_url
);
$this
->
db
->
insert
(
'transaction'
,
$insertData
);
$last_id
=
$this
->
db
->
insert_id
();
$custData
=
$this
->
getUserData
(
$user_id
);
...
...
@@ -1404,8 +1408,10 @@ class Api_model extends CI_Model {
$this
->
db
->
update
(
'transaction'
,
array
(
'transaction_id'
=>
$transactionid
,
'status'
=>
$status
,
'transaction_response'
=>
json_encode
(
$response
)),
array
(
'id'
=>
$last_id
));
if
(
!
empty
(
$eventid
)){
$callback_url
=
''
;
$transResp
=
$this
->
db
->
get_where
(
'transaction'
,
array
(
'id'
=>
$last_id
))
->
row_array
();
if
(
!
empty
(
$transResp
)){
$callback_url
=
$transResp
[
'callback_url'
];
}
if
(
$status
==
1
){
$trBook
=
$this
->
db
->
get_where
(
'transaction'
,
array
(
'id'
=>
$last_id
))
->
row_array
();
...
...
@@ -1460,9 +1466,9 @@ class Api_model extends CI_Model {
$this
->
db
->
update
(
'event_invites'
,
array
(
'status'
=>
'1'
),
array
(
'book_id'
=>
$book_id
));
$this
->
db
->
update
(
'promocode_used'
,
array
(
'status'
=>
'1'
),
array
(
'booking_id'
=>
$book_id
));
}
$res
=
array
(
'status'
=>
1
);
$res
=
array
(
'status'
=>
1
,
'callback_url'
=>
$callback_url
);
}
catch
(
Exception
$e
){
$res
=
array
(
'status'
=>
0
,
'
message'
=>
'Ohh No!! Something went South!!'
,
'code'
=>
'ER06'
);
$res
=
array
(
'status'
=>
0
,
'
callback_url'
=>
$callback_url
);
}
return
$res
;
}
...
...
application/models/HotelServices_model.php
View file @
f4d51eb4
...
...
@@ -73,10 +73,10 @@ class HotelServices_model extends CI_Model {
if
(
$user_id
>
0
)
{
$trackingId
=
time
()
.
rand
(
100000
,
999999
);
$settings
=
getSettings
();
$countryData
=
$this
->
getCountryData
(
$user_id
);
if
(
!
isset
(
$data
[
'nextToken'
])
&&
empty
(
$data
[
'nextToken'
])){
$this
->
db
->
select
(
'nationality'
);
$userData
=
$this
->
db
->
get_where
(
'customer'
,
array
(
'customer_id'
=>
$user_id
))
->
row_array
();
$countryData
=
$this
->
getCountryData
(
$user_id
);
}
$url
=
(
isset
(
$data
[
'nextToken'
])
&&
!
empty
(
$data
[
'nextToken'
]))
?
"https://trawex.biz/api/hotel_trawexv5/getMoreHotels?user_id="
.
$settings
[
'trawex_user_id'
]
.
"&user_password="
.
$settings
[
'trawex_user_password'
]
.
"&access="
.
$settings
[
'trawex_access'
]
.
"&ip_address="
.
$settings
[
'trawex_ip_address'
]
.
"&sessionId="
.
$data
[
'sessionId'
]
.
"&nextToken="
.
$data
[
'nextToken'
]
.
"&trackingId="
.
$data
[
'trackingId'
]
.
""
:
"https://trawex.biz/api/hotel_trawexv5/hotel_search"
;
if
(
!
isset
(
$data
[
'nextToken'
])
&&
empty
(
$data
[
'nextToken'
])){
...
...
application/models/Organizer_model.php
View file @
f4d51eb4
...
...
@@ -226,7 +226,7 @@ class Organizer_model extends CI_Model {
$cdate
=
strtotime
(
$postData
[
'start_date'
]);
while
(
$cdate
<=
strtotime
(
$postData
[
'end_date'
]))
{
$cdate
=
date
(
'Y-m-d'
,
$cdate
);
foreach
(
$show
_t
iming
AS
$time
)
{
foreach
(
$show
T
iming
AS
$time
)
{
$insertEventDate
[]
=
array
(
'event_id'
=>
$postData
[
'event_id'
],
'date'
=>
$cdate
,
'time'
=>
$time
);
}
$cdate
=
strtotime
(
$cdate
.
' +1 day'
);
...
...
application/models/Validation_model.php
View file @
f4d51eb4
...
...
@@ -333,6 +333,20 @@ class Validation_model extends CI_Model {
)
)
,
'payNow'
=>
array
(),
'hotelBooking'
=>
array
(
'auth_token'
=>
array
(
'required'
=>
array
(
'code'
=>
'ER16'
,
'message'
=>
'User Id is null or empty'
)
)
,
'request_data'
=>
array
(
'required'
=>
array
(
'code'
=>
'ER18'
,
'message'
=>
'Booking Data is null or empty'
)
,
)
),
'searchEvent'
=>
array
(),
'validate_promo_code'
=>
array
(
'promo_code'
=>
array
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment