Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
iwl-live
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Anthony.Suerte
iwl-live
Commits
6133c69e
Commit
6133c69e
authored
Jul 21, 2022
by
Antonio.Suerte
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merchant Account Balance API
parent
1566738e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
152 additions
and
0 deletions
+152
-0
MerchantBalance.php
api/MerchantBalance.php
+152
-0
No files found.
api/MerchantBalance.php
0 → 100644
View file @
6133c69e
<?php
require_once
__DIR__
.
"/../system/lib/config.php"
;
class
MerchantBalance
extends
System
{
/**
*
* integrator's input
* @var string
*/
private
$pnum
;
/**
*
* integrator's input
* @var string
*/
private
$password
;
/**
*
* auto
* @var string
*/
private
$requestMethod
;
/**
*
* auto
* @var string
*/
private
$userAccount
;
/**
*
* auto
* @var string
*/
private
$remoteAddress
;
public
function
__construct
(){
parent
::
__construct
();
$this
->
setParameter
();
$this
->
validation
();
}
/**
*
* initializing user inputs and automated values to properties indicated within the function
*/
private
function
setParameter
(){
header
(
"Content-type: text/json"
);
$this
->
pnum
=
$this
->
getColumnData
(
$_SERVER
,
"HTTP_PROGRAM_CODE"
);
$this
->
password
=
$this
->
getColumnData
(
$_SERVER
,
"HTTP_SECRET_KEY"
);
$this
->
requestMethod
=
$this
->
getColumnData
(
$_SERVER
,
"REQUEST_METHOD"
);
$this
->
remoteAddress
=
$this
->
getColumnData
(
$_SERVER
,
"REMOTE_ADDR"
);
}
/**
*
* process validations to whatever the integrator has passed to the headers
*/
private
function
validation
(){
$invalid
=
[];
if
(
$this
->
requestMethod
==
"POST"
){
$macc
=
$this
->
getAPISignatureCommon
(
$this
->
pnum
);
if
(
$this
->
isLoopData
(
$macc
)){
$this
->
credentialCheck
(
$macc
,
$invalid
);
}
else
$invalid
[]
=
"Account doesn't exist: {{$this -> userAccount}}"
;
}
else
$invalid
[]
=
"Invalid Request Method: {{$this -> requestMethod}}"
;
if
(
$this
->
isLoopData
(
$invalid
)){
header
(
"HTTP/1.1 403 Forbidden due to validation results"
);
$remarks
=
print_r
(
$invalid
,
true
);
$remarks
=
print_r
(
apache_request_headers
(),
true
)
.
"
\n\n
{
$remarks
}
"
;
$this
->
logDetails
(
$remarks
);
die
(
print_r
(
$invalid
,
true
));
}
}
/**
*
* @param array $macc
* @param array $invalid
*/
private
function
credentialCheck
(
$macc
,
&
$invalid
){
$macc
=
$this
->
getRowData
(
$macc
);
$registPassword
=
$this
->
getColumnData
(
$macc
,
COLUMN_PASSWORD
);
if
(
$this
->
password
==
$registPassword
){
$wIpAddresses
=
$this
->
getColumnData
(
$macc
,
COLUMN_IP_ADDRESS
);
$wIpAddresses
=
explode
(
DELIMIT_COMMA
,
$wIpAddresses
);
if
(
in_array
(
$this
->
remoteAddress
,
$wIpAddresses
)){
$this
->
userAccount
=
$this
->
getAccountCommon
(
$this
->
getColumnData
(
$macc
,
COLUMN_USER_ACCOUNT
));
if
(
$this
->
isLoopData
(
$this
->
userAccount
)){
$this
->
userAccount
=
$this
->
getRowData
(
$this
->
userAccount
);
}
else
$invalid
[]
=
"Account for pnum
{
$this
->
pnum
}
doesn't exist."
;
}
else
$invalid
[]
=
"Invalid IP Address"
;
}
else
$invalid
[]
=
"Incorrect Password"
;
}
/**
*
* @param string $content
*/
private
function
logDetails
(
$content
){
$timestamp
=
date
(
"Y-m-d H:i:s"
);
$logDir
=
SITE_ROOT
.
"api/Logs/settlement/checkbal"
;
if
(
!@
file_exists
(
$logDir
))
mkdir
(
$logDir
,
0777
,
true
);
$logFile
=
"
{
$logDir
}
/Log_"
.
date
(
"Y-m-d"
)
.
".log"
;
error_log
(
"[
{
$timestamp
}
]
\n\n
{
$content
}
\n\n
"
,
VAL_INT_3
,
$logFile
);
}
/**
*
* main method
*/
public
function
listen
(){
$accNum
=
$this
->
getColumnData
(
$this
->
userAccount
,
COLUMN_USER_ACCOUNT
);
$balances
=
$this
->
accessSelect
(
'SELECT_USER_BALANCES'
,
[
$accNum
]);
foreach
(
$balances
as
&
$balance
){
unset
(
$balance
[
COLUMN_USER_ACCOUNT
]);
$balance
[
COLUMN_BALANCE
]
=
$this
->
intToCurrency
(
$balance
[
COLUMN_BALANCE
],
$balance
[
COLUMN_CURRENCY
]);
}
echo
json_encode
(
$balances
);
$this
->
logDetails
(
print_r
(
apache_request_headers
(),
true
)
.
"
\n\n
Checked Balance"
);
}
}
$bal
=
new
MerchantBalance
();
$bal
->
listen
();
\ No newline at end of file
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