Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dcarfixers
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
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
Tobin
dcarfixers
Commits
d862c06e
Commit
d862c06e
authored
Jul 09, 2019
by
Jansa Jose
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change in payment gateway api
parent
ff69c537
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
27 deletions
+37
-27
Webservices.php
application/controllers/Webservices.php
+12
-8
Webservice_model.php
application/models/Webservice_model.php
+25
-19
No files found.
application/controllers/Webservices.php
View file @
d862c06e
...
...
@@ -1515,6 +1515,7 @@
//Payment Integration of Mechanic Booking
public
function
payNow
(
$transId
=
''
){
//pr($transId);
if
(
empty
(
$transId
)){
$this
->
fail
();
}
...
...
@@ -1527,7 +1528,7 @@
'reference'
=>
$transId
,
'callback_url'
=>
$callback
);
$this
->
payStackPayment
(
$postdata
);
$this
->
payStackPayment
(
$postdata
,
1
);
}
//Payment Integration of Order Booking
...
...
@@ -1544,11 +1545,11 @@
'amount'
=>
$amount
,
'reference'
=>
$orderId
,
'callback_url'
=>
$callback
);
$this
->
payStackPayment
(
$postdata
);
$this
->
payStackPayment
(
$postdata
,
2
);
}
}
public
function
payStackPayment
(
$postdata
=
array
())
{
public
function
payStackPayment
(
$postdata
=
array
()
,
$payFor
=
'1'
)
{
$url
=
"https://api.paystack.co/transaction/initialize"
;
$ch
=
curl_init
();
curl_setopt
(
$ch
,
CURLOPT_URL
,
$url
);
...
...
@@ -1566,14 +1567,17 @@
curl_setopt
(
$ch
,
CURLOPT_HTTPHEADER
,
$headers
);
$request
=
curl_exec
(
$ch
);
curl_close
(
$ch
);
$result
=
array
();
if
(
$request
)
{
$result
=
json_decode
(
$request
,
true
);
}
if
(
!
empty
(
$result
=
json_decode
(
$request
,
true
))
&&
isset
(
$result
[
'data'
])
&&
!
empty
(
$result
[
'data'
])
&&
isset
(
$result
[
'data'
][
'authorization_url'
])
&&
!
empty
(
$result
[
'data'
][
'authorization_url'
])){
$redir
=
$result
[
'data'
][
'authorization_url'
];
header
(
"Location: "
.
$redir
);
}
//pr($result);
$status
=
$this
->
Webservice_model
->
transactionResp
(
$postdata
[
'reference'
],
$result
,
$payFor
);
$this
->
fail
();
}
public
function
verify_payment
(
$ref
=
''
,
$payFor
=
'1'
)
{
if
(
empty
(
$ref
)){
...
...
application/models/Webservice_model.php
View file @
d862c06e
...
...
@@ -651,7 +651,7 @@ class Webservice_model extends CI_Model {
return
$respArr
;
}
public
function
getMechAmount
(
$transId
){
public
function
getMechAmount
(
$transId
=
''
){
$respArr
=
array
(
'status'
=>
'error'
);
if
(
empty
(
$transId
)){
return
$respArr
;
...
...
@@ -667,35 +667,41 @@ class Webservice_model extends CI_Model {
return
$respArr
;
}
public
function
transactionResp
(
$transId
,
$result
,
$payfor
){
public
function
transactionResp
(
$transId
=
''
,
$result
=
array
(),
$payfor
=
'1'
){
$status
=
0
;
if
(
$result
[
'data'
][
'status'
]
==
'success'
){
$odrStat
=
9
;
$trancRef
=
''
;
$respJson
=
(
!
empty
(
$result
))
?
json_encode
(
$result
)
:
''
;
if
(
!
empty
(
$result
)
&&
isset
(
$result
[
'data'
])
&&
!
empty
(
$result
[
'data'
])){
$trancReference
=
$result
[
'data'
][
'id'
];
if
(
isset
(
$result
[
'data'
][
'status'
])
&&
$result
[
'data'
][
'status'
]
==
'success'
){
$status
=
1
;
$odrStat
=
(
$payfor
==
'2'
)
?
2
:
$odrStat
;
}
$odr_status
=
9
;
if
(
$result
[
'data'
][
'status'
]
==
'success'
&&
$payfor
==
'2'
){
$odr_status
=
2
;
}
$this
->
db
->
update
(
'transaction'
,
array
(
'transaction_response'
=>
json_encode
(
$result
),
'transaction_reference'
=>
$result
[
'data'
][
'id'
],
'status'
=>
$status
),
array
(
'id'
=>
$transId
));
$bookData
=
$this
->
db
->
get_where
(
'transaction'
,
array
(
'id'
=>
$transId
))
->
row
();
$this
->
db
->
update
(
'bookings'
,
array
(
'status'
=>
'1'
),
array
(
'booking_id'
=>
$bookData
->
booking_id
));
if
(
$payfor
==
'2'
){
$this
->
db
->
query
(
"UPDATE orders JOIN transaction ON transaction.booking_id = orders.order_id SET orders.status =
$odr_status
WHERE transaction.id =
$transId
"
);
$this
->
db
->
update
(
'transaction'
,
array
(
'transaction_response'
=>
$respJson
,
'transaction_reference'
=>
$trancRef
,
'status'
=>
$status
),
array
(
'id'
=>
$transId
));
if
(
$payfor
==
'1'
){
$this
->
db
->
query
(
"UPDATE bookings
JOIN transaction ON transaction.booking_id=bookings.booking_id
SET bookings.status =
$status
WHERE transaction.id =
$transId
"
);
}
else
if
(
$payfor
==
'2'
){
$this
->
db
->
query
(
"UPDATE orders
JOIN transaction ON transaction.booking_id = orders.order_id
SET orders.status =
$odrStat
WHERE transaction.id =
$transId
"
);
}
return
1
;
}
public
function
transactionRespApi
(
$transId
,
$result
,
$payfor
){
public
function
transactionRespApi
(
$transId
=
''
,
$result
=
array
(),
$payfor
=
'1'
){
$status
=
0
;
if
(
$result
[
'data'
][
'status'
]
==
'success'
){
$status
=
1
;
}
$odr_status
=
9
;
if
(
$result
[
'data'
][
'status'
]
==
'success'
&&
$payfor
==
'2'
){
$odr_status
=
2
;
if
(
!
empty
(
$result
)
&&
isset
(
$result
[
'data'
])
&&
!
empty
(
$result
[
'data'
])
&&
isset
(
$result
[
'data'
][
'status'
])
&&
$result
[
'data'
][
'status'
]
==
'success'
){
$status
=
1
;
$odr_status
=
(
$payfor
==
'2'
)
?
2
:
$odr_status
;
}
$bookData
=
$this
->
db
->
get_where
(
'transaction'
,
array
(
'id'
=>
$transId
))
->
row
();
...
...
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