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
f94889c3
Commit
f94889c3
authored
Dec 04, 2019
by
Tobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
t : payment commit
parent
b0ab2f3e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
93 additions
and
20 deletions
+93
-20
Api.php
application/controllers/Api.php
+30
-5
Api_model.php
application/models/Api_model.php
+63
-15
No files found.
application/controllers/Api.php
View file @
f94889c3
...
...
@@ -325,6 +325,13 @@ class Api extends CI_Controller {
}
}
public
function
txnManager
(
$txnType
=
''
,
$txnData
=
array
()){
switch
(
$txnType
){
case
'WALLET'
:
return
$this
->
Api_model
->
updateWalletTxn
(
$txnData
);
}
}
public
function
payNow
(
$reqData
=
''
){
$settings
=
getSettings
();
$redUrl
=
$settings
[
'web_base_url'
];
...
...
@@ -337,9 +344,24 @@ class Api extends CI_Controller {
if
(
empty
(
$reqData
)
||
empty
(
$reqData
=
json_decode
(
$reqData
,
true
))
||
!
isset
(
$reqData
[
'amount'
])
||
empty
(
$amount
=
$reqData
[
'amount'
])
||
!
isset
(
$reqData
[
'event_id'
])
||
empty
(
$event_id
=
$reqData
[
'event_id'
])
||
!
isset
(
$reqData
[
'auth_token'
])
||
empty
(
$auth_token
=
$reqData
[
'auth_token'
])){
redirect
(
$redUrl
.
'failure'
);
}
if
(
isset
(
$reqData
[
'txnType'
])
&&
!
empty
(
$reqData
[
'txnType'
])){
$params
=
array
(
'mode'
=>
'1'
,
'status'
=>
'0'
,
'auth_token'
=>
$reqData
[
'auth_token'
],
'amount'
=>
$reqData
[
'amount'
]);
$customData
=
$this
->
txnManager
(
$reqData
[
'txnType'
],
$params
);
if
(
empty
(
$customData
)){
redirect
(
$redUrl
.
'failure'
);
}
$reqData
[
'event_id'
]
=
$reqData
[
'txnType'
];
$reqData
[
'booking_id'
]
=
$customData
[
'transaction_id'
];
}
if
(
!
isset
(
$reqData
[
'event_id'
])
||
empty
(
$event_id
=
$reqData
[
'event_id'
])
||
!
isset
(
$reqData
[
'cardData'
])
||
empty
(
$cardData
=
$reqData
[
'cardData'
])
||
!
isset
(
$reqData
[
'auth_token'
])
||
empty
(
$auth_token
=
$reqData
[
'auth_token'
])
||
!
isset
(
$reqData
[
'booking_id'
])
||
empty
(
$booking_id
=
$reqData
[
'booking_id'
])){
redirect
(
$redUrl
.
'failure'
);
}
...
...
@@ -506,7 +528,8 @@ class Api extends CI_Controller {
}
if
(
!
empty
(
$transaction_id
)
&&
!
empty
(
$last_id
)){
$this
->
Api_model
->
update_payment
(
$response
,
$transaction_id
,
$last_id
,
'1'
);
$this
->
Api_model
->
update_payment
(
$response
,
$transaction_id
,
$last_id
,
'1'
,
$eventid
);
$customData
=
$this
->
txnManager
(
$eventid
,
array
(
'tnx_id'
=>
$last_id
));
}
if
(
!
empty
(
$booking_id
)){
...
...
@@ -551,7 +574,9 @@ class Api extends CI_Controller {
if
(
isset
(
$response
[
1
])
&&
!
empty
(
$response
[
1
])
&&
!
empty
(
$data
=
explode
(
'|'
,
$response
[
1
]))
&&
isset
(
$data
[
1
])
&&
!
empty
(
$data
[
1
])){
$last_id
=
$data
[
1
];
$this
->
Api_model
->
update_payment
(
$response
,
''
,
$last_id
,
'0'
);
$eventid
=
$data
[
2
];
$this
->
Api_model
->
update_payment
(
$response
,
''
,
$last_id
,
'0'
,
$eventid
);
$customData
=
$this
->
txnManager
(
$eventid
,
array
(
'tnx_id'
=>
$last_id
));
$sql
=
"SELECT BOK.event_id FROM transaction AS TX
INNER JOIN booking AS BOK ON (BOK.bookId=TX.booking_id)
...
...
@@ -719,7 +744,7 @@ class Api extends CI_Controller {
$res
=
$this
->
Api_model
->
payNow
(
$payData
);
if
(
$res
[
'status'
]
==
1
){
$params
=
array
(
'amount'
=>
1
,
'last_id'
=>
$res
[
'transaction_id'
],
'event_id'
=>
'
test
'
,
$params
=
array
(
'amount'
=>
1
,
'last_id'
=>
$res
[
'transaction_id'
],
'event_id'
=>
'
ADD_CARD
'
,
'booking_id'
=>
'ADD_CARD'
,
'custData'
=>
$res
[
'custData'
],
'cardData'
=>
$reqData
);
$reqData
=
$this
->
encrypt
(
json_encode
(
$params
),
$this
->
local_key
,
$this
->
local_iv
);
...
...
application/models/Api_model.php
View file @
f94889c3
...
...
@@ -1336,6 +1336,20 @@ class Api_model extends CI_Model {
return
$res
;
}
function
getUserData
(
$cust_id
=
''
){
if
(
empty
(
$cust_id
)){
return
0
;
}
$this
->
db
->
select
(
'customer.name,customer.dob,customer.phone,customer.email,customer.gender,
customer.profile_image AS image,users.id AS userId,customer.profile_city AS city,customer.dob,
customer.email_verified'
);
$this
->
db
->
where
(
'users.status'
,
1
);
$this
->
db
->
where
(
'customer.customer_id'
,
$cust_id
);
$this
->
db
->
from
(
'users'
);
$this
->
db
->
join
(
'customer'
,
'customer.customer_id = users.id'
);
return
$this
->
db
->
get
()
->
row
();
}
function
payNow
(
$data
){
try
{
$user_id
=
$this
->
auth_token_get
(
$data
[
'auth_token'
]);
...
...
@@ -1354,29 +1368,63 @@ class Api_model extends CI_Model {
return
$res
;
}
function
getUserData
(
$cust_id
=
''
){
if
(
empty
(
$cust_id
)){
return
0
;
function
updateWalletTxn
(
$txnData
=
array
()){
try
{
if
(
empty
(
$txnData
)){
return
;
}
$this
->
db
->
select
(
'customer.name,customer.dob,customer.phone,customer.email,customer.gender,
customer.profile_image AS image,users.id AS userId,customer.profile_city AS city,customer.dob,
customer.email_verified'
);
$this
->
db
->
where
(
'users.status'
,
1
);
$this
->
db
->
where
(
'customer.customer_id'
,
$cust_id
);
$this
->
db
->
from
(
'users'
);
$this
->
db
->
join
(
'customer'
,
'customer.customer_id = users.id'
);
return
$this
->
db
->
get
()
->
row
();
if
(
$txnData
[
'status'
]
==
'0'
){
if
(
!
isset
(
$txnData
[
'mode'
])
||
empty
(
$txnData
[
'mode'
])
||
!
isset
(
$txnData
[
'amount'
])
||
empty
(
$txnData
[
'amount'
])
||
!
isset
(
$txnData
[
'auth_token'
])
||
empty
(
$txnData
[
'auth_token'
])){
return
;
}
$user_id
=
$this
->
auth_token_get
(
$txnData
[
'auth_token'
]);
if
(
empty
(
$user_id
)){
return
;
}
$txnCode
=
'TXN'
.
date
(
'ymd'
)
.
str_pad
(
rand
(
1111
,
9999
),
4
,
0
,
STR_PAD_LEFT
);
$insertData
=
array
(
'customer_id'
=>
$user_id
,
'transaction_type'
=>
$txnData
[
'mode'
],
'created_date'
=>
date
(
'Y-m-d h:i:s'
),
'amount'
=>
$txnData
[
'amount'
],
'transaction_code'
=>
$txnCode
,
'status'
=>
0
);
$this
->
db
->
insert
(
'wallet_transactions'
,
$insertData
);
return
array
(
'status'
=>
1
,
'transaction_id'
=>
$txnCode
);
}
else
{
if
(
!
isset
(
$txnData
[
'tnx_id'
])
||
empty
(
$txnData
[
'tnx_id'
])){
return
;
}
$this
->
db
->
update
(
'wallet_transactions'
,
array
(
'status'
=>
$txnData
[
'status'
]),
array
(
'transaction_code'
=>
$txnData
[
'tnx_id'
]));
}
}
catch
(
Exception
$e
){}
}
function
update_payment
(
$response
=
''
,
$transactionid
=
''
,
$last_id
,
$status
){
function
updateCustomTxn
(
$txnType
=
''
,
){
try
{
$insertData
=
array
(
'customer_id'
=>
$user_id
,
'transaction_type'
=>
$txnType
,
'created_date'
=>
date
(
'Y-m-d h:i:s'
),
'amount'
=>
$amount
,
'transaction_code'
=>
$txnCode
);
$this
->
db
->
insert
(
'wallet_transactions'
,
$insertData
);
$last_id
=
$this
->
db
->
insert_id
();
$res
=
array
(
'status'
=>
1
,
'transaction_id'
=>
$txnCode
);
}
catch
(
Exception
$e
){
$res
=
array
(
'status'
=>
0
,
'message'
=>
'Ohh No!! Something went South!!'
,
'code'
=>
'ER06'
);
}
return
$res
;
}
function
update_payment
(
$response
=
''
,
$transactionid
=
''
,
$last_id
,
$status
,
$eventid
=
''
){
try
{
if
(
empty
(
$last_id
)){
return
;
}
$this
->
db
->
update
(
'transaction'
,
array
(
'transaction_id'
=>
$transactionid
,
'transaction_response'
=>
json_encode
(
$response
),
'status'
=>
$status
),
$this
->
db
->
update
(
'transaction'
,
array
(
'transaction_id'
=>
$transactionid
,
'status'
=>
$status
,
'transaction_response'
=>
json_encode
(
$response
)),
array
(
'id'
=>
$last_id
));
if
(
!
empty
(
$eventid
)){
}
if
(
$status
==
1
){
$trBook
=
$this
->
db
->
get_where
(
'transaction'
,
array
(
'id'
=>
$last_id
))
->
row_array
();
$book_id
=
$trBook
[
'booking_id'
];
...
...
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