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
4ca26f90
Commit
4ca26f90
authored
Jun 06, 2023
by
iWallet Dev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remittance API Enhancement
parent
821415bf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
127 additions
and
70 deletions
+127
-70
MoneyRequest.php
api/MoneyRequest.php
+127
-70
No files found.
api/MoneyRequest.php
View file @
4ca26f90
...
...
@@ -109,6 +109,19 @@ class MoneyRequest extends System {
*/
private
$accessLogDir
=
NO_STRING
;
/**
*
*
* @var boolean
*/
private
$forTest
=
false
;
/**
*
* @var integer
*/
private
$responseCode
=
200
;
public
function
__construct
(){
parent
::
__construct
();
...
...
@@ -125,6 +138,7 @@ class MoneyRequest extends System {
$this
->
currency
=
$this
->
getDataPost
(
'currency'
);
$this
->
message
=
$this
->
getDataPost
(
'message'
);
$this
->
signature
=
$this
->
getDataPost
(
'signature'
);
$this
->
forTest
=
$this
->
getDataPost
(
"test"
);
$this
->
ip
=
$this
->
getColumnData
(
$_SERVER
,
"REMOTE_ADDR"
);
$this
->
referer
=
$this
->
getColumnData
(
$_SERVER
,
"HTTP_REFERER"
);
...
...
@@ -196,6 +210,8 @@ class MoneyRequest extends System {
&&
(
$this
->
fromAccount
==
$this
->
toAccount
)){
$this
->
result
[
PARAM_RESULT
]
=
sprintf
(
'%02d'
,
VAL_INT_93
);
$this
->
result
[
PARAM_STATUS
]
=
"REJECTED"
;
$this
->
responseCode
=
406
;
}
else
{
// APIチェック用データ
// シグネチャ生成用のデータを取得する
...
...
@@ -218,6 +234,8 @@ class MoneyRequest extends System {
$this
->
result
[
PARAM_RESULT
]
=
sprintf
(
"%02d"
,
VAL_INT_90
);
$this
->
result
[
PARAM_STATUS
]
=
"REJECTED"
;
$this
->
responseCode
=
406
;
}
else
{
$this
->
randomSecondsDelay
();
...
...
@@ -235,12 +253,16 @@ class MoneyRequest extends System {
$this
->
result
[
PARAM_RESULT
]
=
$format
;
$this
->
result
[
PARAM_STATUS
]
=
"ERROR(CODE:
{
$format
}
)"
;
$this
->
responseCode
=
406
;
}
}
}
}
else
{
$this
->
result
[
PARAM_RESULT
]
=
sprintf
(
"%02d"
,
VAL_INT_92
);
$this
->
result
[
PARAM_STATUS
]
=
"REJECTED"
;
$this
->
responseCode
=
406
;
}
$this
->
logPost
(
$this
->
pnum
);
...
...
@@ -264,7 +286,9 @@ class MoneyRequest extends System {
$this
->
debitAmount
=
$this
->
getColumnData
(
$this
->
ctransfer
,
PARAM_AMOUNT
);
// 取引番号の生成
$this
->
transactionNum
=
$this
->
getTransactionNumberCommon
(
VAR_TRANSACTION_TRANSFER_DEPOSIT
);
$this
->
transactionNum
=
!
$this
->
forTest
?
$this
->
getTransactionNumberCommon
(
VAR_TRANSACTION_TRANSFER_DEPOSIT
)
:
"T01234567"
;
//to fee
$this
->
toFee
=
$this
->
currencyToInt
(
$this
->
getColumnData
(
$this
->
ctransfer
,
PARAM_TO_FEE
),
$this
->
currency
);
...
...
@@ -330,6 +354,8 @@ class MoneyRequest extends System {
}
private
function
printCallbackResult
(){
header
(
"HTTP/1.1
{
$this
->
responseCode
}
"
);
$this
->
accessModifyCommon
(
'INSERT_LOG_POST'
,
[
$this
->
ip
,
...
...
@@ -348,82 +374,113 @@ class MoneyRequest extends System {
echo
json_encode
(
$this
->
result
);
}
public
function
listen
(){
if
(
$this
->
proceedToRemittanceRequest
){
$params
=
$this
->
getTransactionalParams
();
private
function
actualProcessing
(
$params
){
$insertNewTransfer
=
$this
->
accessModify
(
'INSERT_TRANSFER'
,
$params
,
false
);
if
(
$insertNewTransfer
){
$encodedParams
=
json_encode
(
$params
);
$this
->
accessModifyCommon
(
'INSERT_LOG_POST'
,
[
$this
->
ip
,
$this
->
pnum
,
$this
->
referer
,
"[INSERT_DB]
{
$encodedParams
}
"
]);
$transactionNum
=
$params
[
VAL_INT_18
];
// send email to receiver
$emailParams
=
$this
->
getSendDataParams
();
$insertNewTransfer
=
$this
->
accessModify
(
'INSERT_TRANSFER'
,
$params
,
false
);
$toAccountData
=
$this
->
getAccountCommon
(
$this
->
toAccount
);
$language
=
$this
->
getColumnData
(
$this
->
getRowData
(
$toAccountData
),
COLUMN_USE_LANGUAGE
);
if
(
$insertNewTransfer
){
$encodedParams
=
json_encode
(
$params
);
$this
->
sendMailByTmp
(
$language
.
DIRECTORY_SEPARATOR
.
'transfer_receive_user.xml'
,
$emailParams
,
$emailParams
[
VAL_INT_11
]
,
VAR_CS_MAIL_ADDRESS
);
// 通貨が違う場合は、為替コミッションの発生
if
(
$this
->
debitCurrency
!=
$this
->
currency
)
{
$this
->
accessModifyCommon
(
'INSERT_LOG_POST'
,
[
// 着金額指定の場合
$this
->
registCommisionExchange
(
$this
->
fromAccount
,
$this
->
currency
,
$this
->
debitCurrency
,
$this
->
currencyToInt
(
$this
->
debitAmount
,
$this
->
debitCurrency
));
}
// コミッションの集計(送金元)
$this
->
registCommision
(
VAR_TRANSFER
,
null
,
$this
->
fromAccount
,
$this
->
debitCurrency
,
$this
->
getColumnData
(
$this
->
ctransfer
,
PARAM_FROM_FEE
));
// コミッションの集計(送金先)
$this
->
registCommision
(
VAR_TRANSFER
,
null
,
$this
->
toAccount
,
$this
->
currency
,
$this
->
getColumnData
(
$this
->
ctransfer
,
PARAM_TO_FEE
)
,
PARAM_TO
);
$this
->
result
[
PARAM_RESULT
]
=
sprintf
(
"%02d"
,
NO_COUNT
);
$this
->
result
[
PARAM_STATUS
]
=
"OK"
;
$this
->
result
[
PARAM_TRANSACTION_NUMBER
]
=
$transactionNum
;
$this
->
result
[
PARAM_CURRENCY
]
=
$this
->
debitCurrency
;
$this
->
result
[
PARAM_AMOUNT
]
=
$this
->
debitAmount
;
$this
->
result
[
PARAM_FEE
]
=
$this
->
getColumnData
(
$this
->
ctransfer
,
PARAM_FROM_FEE
);
// this brings back memories - anton (2021)
$this
->
result
[
PARAM_FROM_ACCOUNT
]
=
$this
->
fromAccount
;
$this
->
result
[
PARAM_TO_ACCOUNT
]
=
$this
->
toAccount
;
}
else
{
$this
->
result
[
PARAM_RESULT
]
=
sprintf
(
"%02d"
,
VAL_INT_99
);
$this
->
result
[
PARAM_STATUS
]
=
"REJECTED"
;
$this
->
responseCode
=
406
;
$this
->
accessModifyCommon
(
"INSERT_LOG_POST"
,
[
$this
->
ip
,
$this
->
pnum
,
$this
->
referer
,
"[INSERT_DB]
{
$encodedParams
}
"
'[INSERT_DB_ERR]'
.
json_encode
(
$params
)
]);
$transactionNum
=
$params
[
VAL_INT_18
];
// send email to receiver
$emailParams
=
$this
->
getSendDataParams
();
$toAccountData
=
$this
->
getAccountCommon
(
$this
->
toAccount
);
$language
=
$this
->
getColumnData
(
$this
->
getRowData
(
$toAccountData
),
COLUMN_USE_LANGUAGE
);
$this
->
sendMailByTmp
(
$language
.
DIRECTORY_SEPARATOR
.
'transfer_receive_user.xml'
,
$emailParams
,
$emailParams
[
VAL_INT_11
]
,
VAR_CS_MAIL_ADDRESS
);
// 通貨が違う場合は、為替コミッションの発生
if
(
$this
->
debitCurrency
!=
$this
->
currency
)
{
// 着金額指定の場合
$this
->
registCommisionExchange
(
$this
->
fromAccount
,
$this
->
currency
,
$this
->
debitCurrency
,
$this
->
currencyToInt
(
$this
->
debitAmount
,
$this
->
debitCurrency
));
}
// コミッションの集計(送金元)
$this
->
registCommision
(
VAR_TRANSFER
,
null
,
$this
->
fromAccount
,
$this
->
debitCurrency
,
$this
->
getColumnData
(
$this
->
ctransfer
,
PARAM_FROM_FEE
));
// コミッションの集計(送金先)
$this
->
registCommision
(
VAR_TRANSFER
,
null
,
$this
->
toAccount
,
$this
->
currency
,
$this
->
getColumnData
(
$this
->
ctransfer
,
PARAM_TO_FEE
)
,
PARAM_TO
);
$this
->
result
[
PARAM_RESULT
]
=
sprintf
(
"%02d"
,
NO_COUNT
);
$this
->
result
[
PARAM_STATUS
]
=
"OK"
;
$this
->
result
[
PARAM_TRANSACTION_NUMBER
]
=
$transactionNum
;
$this
->
result
[
PARAM_CURRENCY
]
=
$this
->
debitCurrency
;
$this
->
result
[
PARAM_AMOUNT
]
=
$this
->
debitAmount
;
$this
->
result
[
PARAM_FEE
]
=
$this
->
getColumnData
(
$this
->
ctransfer
,
PARAM_FROM_FEE
);
// this brings back memories - anton (2021)
$this
->
result
[
PARAM_FROM_ACCOUNT
]
=
$this
->
fromAccount
;
$this
->
result
[
PARAM_TO_ACCOUNT
]
=
$this
->
toAccount
;
}
else
{
$this
->
result
[
PARAM_RESULT
]
=
sprintf
(
"%02d"
,
VAL_INT_99
);
$this
->
result
[
PARAM_STATUS
]
=
"REJECTED"
;
$this
->
accessModifyCommon
(
"INSERT_LOG_POST"
,
[
$this
->
ip
,
$this
->
pnum
,
$this
->
referer
,
'[INSERT_DB_ERR]'
.
json_encode
(
$params
)
]);
}
}
}
private
function
emulateProcessing
(
$params
){
$encodedParams
=
json_encode
(
$params
);
$this
->
accessModifyCommon
(
'INSERT_LOG_POST'
,
[
$this
->
ip
,
$this
->
pnum
,
$this
->
referer
,
"[TEST_INSERT_DB]
{
$encodedParams
}
"
]);
$this
->
result
[
PARAM_RESULT
]
=
sprintf
(
"%02d"
,
NO_COUNT
);
$this
->
result
[
PARAM_STATUS
]
=
"OK"
;
$this
->
result
[
PARAM_TRANSACTION_NUMBER
]
=
$params
[
VAL_INT_18
];
$this
->
result
[
PARAM_CURRENCY
]
=
$this
->
debitCurrency
;
$this
->
result
[
PARAM_AMOUNT
]
=
$this
->
debitAmount
;
$this
->
result
[
PARAM_FEE
]
=
$this
->
getColumnData
(
$this
->
ctransfer
,
PARAM_FROM_FEE
);
// this brings back memories - anton (2021)
$this
->
result
[
PARAM_FROM_ACCOUNT
]
=
$this
->
fromAccount
;
$this
->
result
[
PARAM_TO_ACCOUNT
]
=
$this
->
toAccount
;
}
public
function
listen
(){
if
(
$this
->
proceedToRemittanceRequest
){
$params
=
$this
->
getTransactionalParams
();
if
(
$this
->
forTest
)
$this
->
emulateProcessing
(
$params
);
else
$this
->
actualProcessing
(
$params
);
}
$this
->
printCallbackResult
();
...
...
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