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
9752e130
Commit
9752e130
authored
Oct 10, 2019
by
Tobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dc
parent
7b08f979
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
89 additions
and
18 deletions
+89
-18
Api.php
application/controllers/Api.php
+68
-2
generals_helper.php
application/helpers/generals_helper.php
+3
-3
Validation_model.php
application/models/Validation_model.php
+18
-13
CUST_QR_173.png
assets/uploads/user/CUST_QR_173.png
+0
-0
No files found.
application/controllers/Api.php
View file @
9752e130
...
...
@@ -53,7 +53,7 @@ class Api extends CI_Controller {
'message'
=>
'Success'
,
'responseResult'
=>
$data
);
print
json_encode
(
$result
);
print
json_encode
(
$result
);
exit
;
}
public
function
errorResponse
(
$errorCode
,
$errorDesc
)
{
...
...
@@ -63,7 +63,7 @@ class Api extends CI_Controller {
'errorCode'
=>
$errorCode
,
'errorDesc'
=>
$errorDesc
);
print
json_encode
(
$result
);
print
json_encode
(
$result
);
exit
;
}
public
function
login
(){
...
...
@@ -561,5 +561,71 @@ class Api extends CI_Controller {
$this
->
errorResponse
(
$res
[
'code'
],
$res
[
'message'
]);
}
}
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
;
$ch
=
curl_init
();
curl_setopt
(
$ch
,
CURLOPT_URL
,
'https://staging.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'
);
}
$this
->
response
(
array
(
'saved_cards'
=>
$resp
->
txnCardDetails
));
}
function
encryptePayData
(
$merchant_iv
=
''
,
$merchant_key
=
''
,
$plainText
=
''
)
{
if
(
empty
(
$merchant_iv
)
||
empty
(
$merchant_key
)
||
empty
(
$plainText
)){
return
false
;
}
$key
=
'AES-256-CBC'
;
$size
=
openssl_cipher_iv_length
(
$key
);
$mKey
=
base64_decode
(
$merchant_key
);
$padDat
=
$size
-
(
strlen
(
$plainText
)
%
$size
);
$padtext
=
$plainText
.
str_repeat
(
chr
(
$padDat
),
$padDat
);
$encText
=
openssl_encrypt
(
$padtext
,
$key
,
$mKey
,
OPENSSL_RAW_DATA
|
OPENSSL_ZERO_PADDING
,
$merchant_iv
);
return
base64_encode
(
$encText
);
}
function
decryptePayData
(
$merchant_iv
=
''
,
$merchant_key
=
''
,
$encText
=
''
)
{
if
(
empty
(
$merchant_iv
)
||
empty
(
$merchant_key
)
||
empty
(
$encText
)){
return
false
;
}
$key
=
'AES-256-CBC'
;
$mKey
=
base64_decode
(
$merchant_key
);
$encText
=
base64_decode
(
$encText
);
$padtext
=
openssl_decrypt
(
$encText
,
$key
,
$mKey
,
OPENSSL_RAW_DATA
|
OPENSSL_ZERO_PADDING
,
$merchant_iv
);
$padData
=
ord
(
$padtext
{
strlen
(
$padtext
)
-
1
});
if
(
$padData
>
strlen
(
$padtext
))
return
false
;
if
(
strspn
(
$padtext
,
$padtext
{
strlen
(
$padtext
)
-
1
},
strlen
(
$padtext
)
-
$padData
)
!=
$padData
)
return
false
;
$response
=
substr
(
$padtext
,
0
,
-
1
*
$padData
);
return
json_decode
(
$response
);
}
}
?>
application/helpers/generals_helper.php
View file @
9752e130
...
...
@@ -109,8 +109,8 @@
$QR
=
imagecreatefrompng
(
'https://chart.googleapis.com/chart?cht=qr&chld=H|1&chs=500x500&chl='
.
$qr_id
);
$logo
=
imagecreatefromstring
(
file_get_contents
(
$logo
));
$qrWidth
=
imagesx
(
$QR
)
/
2
;
$qrHeight
=
imagesy
(
$QR
)
/
2
;
$qrWidth
=
imagesx
(
$QR
)
/
2
.5
;
$qrHeight
=
imagesy
(
$QR
)
/
2
.5
;
$logoWidth
=
imagesx
(
$logo
);
$logoHeight
=
imagesy
(
$logo
);
...
...
@@ -119,7 +119,7 @@
$imgWidth
=
$qrWidth
;
$imgHeight
=
$logoHeight
/
$scale
;
imagecopyresampled
(
$QR
,
$logo
,
1
25
,
12
0
,
0
,
0
,
$imgWidth
,
$imgHeight
,
$logoWidth
,
$logoHeight
);
imagecopyresampled
(
$QR
,
$logo
,
1
55
,
15
0
,
0
,
0
,
$imgWidth
,
$imgHeight
,
$logoWidth
,
$logoHeight
);
imagepng
(
$QR
,
$savePath
);
return
$savePath
;
...
...
application/models/Validation_model.php
View file @
9752e130
...
...
@@ -389,14 +389,25 @@ class Validation_model extends CI_Model {
'message'
=>
'checker ID is null or empty'
)
)
),
'getSavedCards'
=>
array
(
'email'
=>
array
(
'required'
=>
array
(
'code'
=>
'ER18'
,
'message'
=>
'Customer Email ID is null or empty'
)
),
'auth_token'
=>
array
(
'required'
=>
array
(
'code'
=>
'ER19'
,
'message'
=>
'User Id is null or empty'
)
)
)
);
public
function
_consruct
(){
parent
::
_construct
();
}
public
function
validation_check
(
$method_name
,
$parms
)
{
...
...
@@ -407,7 +418,7 @@ class Validation_model extends CI_Model {
foreach
(
$value
as
$keys
=>
$values
)
{
switch
(
$keys
)
{
case
'required'
:
if
(
!
isset
(
$parms
[
$key
])
||
$parms
[
$key
]
==
''
||
$parms
[
$key
]
==
null
){
if
(
!
isset
(
$parms
[
$key
])
||
$parms
[
$key
]
==
''
||
$parms
[
$key
]
==
null
){
$state
=
1
;
$error_key
=
$values
;
}
...
...
@@ -427,17 +438,11 @@ class Validation_model extends CI_Model {
}
}
break
;
default
:
# code...
break
;
}
if
(
$state
==
1
){
break
;
default
:
break
;
}
if
(
$state
==
1
)
break
;
}
if
(
$state
==
1
){
break
;
}
if
(
$state
==
1
)
break
;
}
return
array
(
'state'
=>
$state
,
'response'
=>
$error_key
);
}
...
...
assets/uploads/user/CUST_QR_173.png
View replaced file @
7b08f979
View file @
9752e130
46.9 KB
|
W:
|
H:
33.3 KB
|
W:
|
H:
2-up
Swipe
Onion skin
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