Commit 935453c1 authored by iWallet Dev's avatar iWallet Dev

Remittance API Enhancement

parent 978ad27d
...@@ -109,6 +109,19 @@ class MoneyRequest extends System { ...@@ -109,6 +109,19 @@ class MoneyRequest extends System {
*/ */
private $accessLogDir = NO_STRING; private $accessLogDir = NO_STRING;
/**
*
*
* @var boolean
*/
private $forTest = false;
/**
*
* @var integer
*/
private $responseCode = 200;
public function __construct(){ public function __construct(){
parent::__construct(); parent::__construct();
...@@ -125,6 +138,7 @@ class MoneyRequest extends System { ...@@ -125,6 +138,7 @@ class MoneyRequest extends System {
$this -> currency = $this -> getDataPost('currency'); $this -> currency = $this -> getDataPost('currency');
$this -> message = $this -> getDataPost('message'); $this -> message = $this -> getDataPost('message');
$this -> signature = $this -> getDataPost('signature'); $this -> signature = $this -> getDataPost('signature');
$this -> forTest = $this -> getDataPost("test");
$this -> ip = $this -> getColumnData($_SERVER, "REMOTE_ADDR"); $this -> ip = $this -> getColumnData($_SERVER, "REMOTE_ADDR");
$this -> referer = $this -> getColumnData($_SERVER, "HTTP_REFERER"); $this -> referer = $this -> getColumnData($_SERVER, "HTTP_REFERER");
...@@ -196,6 +210,8 @@ class MoneyRequest extends System { ...@@ -196,6 +210,8 @@ class MoneyRequest extends System {
&& ($this -> fromAccount == $this -> toAccount)){ && ($this -> fromAccount == $this -> toAccount)){
$this -> result[PARAM_RESULT] = sprintf('%02d', VAL_INT_93); $this -> result[PARAM_RESULT] = sprintf('%02d', VAL_INT_93);
$this -> result[PARAM_STATUS] = "REJECTED"; $this -> result[PARAM_STATUS] = "REJECTED";
$this -> responseCode = 406;
}else{ }else{
// APIチェック用データ // APIチェック用データ
// シグネチャ生成用のデータを取得する // シグネチャ生成用のデータを取得する
...@@ -218,6 +234,8 @@ class MoneyRequest extends System { ...@@ -218,6 +234,8 @@ class MoneyRequest extends System {
$this -> result[PARAM_RESULT] = sprintf("%02d", VAL_INT_90); $this -> result[PARAM_RESULT] = sprintf("%02d", VAL_INT_90);
$this -> result[PARAM_STATUS] = "REJECTED"; $this -> result[PARAM_STATUS] = "REJECTED";
$this -> responseCode = 406;
}else{ }else{
$this -> randomSecondsDelay(); $this -> randomSecondsDelay();
...@@ -235,12 +253,16 @@ class MoneyRequest extends System { ...@@ -235,12 +253,16 @@ class MoneyRequest extends System {
$this -> result[PARAM_RESULT] = $format; $this -> result[PARAM_RESULT] = $format;
$this -> result[PARAM_STATUS] = "ERROR(CODE:{$format})"; $this -> result[PARAM_STATUS] = "ERROR(CODE:{$format})";
$this -> responseCode = 406;
} }
} }
} }
}else{ }else{
$this -> result[PARAM_RESULT] = sprintf("%02d", VAL_INT_92); $this -> result[PARAM_RESULT] = sprintf("%02d", VAL_INT_92);
$this -> result[PARAM_STATUS] = "REJECTED"; $this -> result[PARAM_STATUS] = "REJECTED";
$this -> responseCode = 406;
} }
$this -> logPost($this -> pnum); $this -> logPost($this -> pnum);
...@@ -264,7 +286,9 @@ class MoneyRequest extends System { ...@@ -264,7 +286,9 @@ class MoneyRequest extends System {
$this -> debitAmount = $this -> getColumnData($this -> ctransfer, PARAM_AMOUNT); $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 //to fee
$this -> toFee = $this -> currencyToInt($this -> getColumnData($this -> ctransfer, PARAM_TO_FEE), $this -> currency); $this -> toFee = $this -> currencyToInt($this -> getColumnData($this -> ctransfer, PARAM_TO_FEE), $this -> currency);
...@@ -330,6 +354,8 @@ class MoneyRequest extends System { ...@@ -330,6 +354,8 @@ class MoneyRequest extends System {
} }
private function printCallbackResult(){ private function printCallbackResult(){
header("HTTP/1.1 {$this -> responseCode}");
$this -> accessModifyCommon('INSERT_LOG_POST', $this -> accessModifyCommon('INSERT_LOG_POST',
[ [
$this -> ip, $this -> ip,
...@@ -348,82 +374,113 @@ class MoneyRequest extends System { ...@@ -348,82 +374,113 @@ class MoneyRequest extends System {
echo json_encode($this -> result); echo json_encode($this -> result);
} }
public function listen(){ private function actualProcessing($params){
if($this -> proceedToRemittanceRequest){ $insertNewTransfer = $this -> accessModify('INSERT_TRANSFER', $params, false);
$params = $this -> getTransactionalParams();
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){ $this -> sendMailByTmp($language.DIRECTORY_SEPARATOR.'transfer_receive_user.xml'
$encodedParams = json_encode($params); , $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 -> ip,
$this -> pnum, $this -> pnum,
$this -> referer, $this -> referer,
"[INSERT_DB]{$encodedParams}" '[INSERT_DB_ERR]'.json_encode($params)
]); ]);
}
$transactionNum = $params[VAL_INT_18]; }
// send email to receiver private function emulateProcessing($params){
$emailParams = $this -> getSendDataParams(); $encodedParams = json_encode($params);
$toAccountData = $this -> getAccountCommon($this -> toAccount); $this -> accessModifyCommon('INSERT_LOG_POST', [
$language = $this -> getColumnData($this -> getRowData($toAccountData), COLUMN_USE_LANGUAGE); $this -> ip,
$this -> pnum,
$this -> sendMailByTmp($language.DIRECTORY_SEPARATOR.'transfer_receive_user.xml' $this -> referer,
, $emailParams "[TEST_INSERT_DB]{$encodedParams}"
, $emailParams[VAL_INT_11] ]);
, VAR_CS_MAIL_ADDRESS);
$this -> result[PARAM_RESULT] = sprintf("%02d", NO_COUNT);
// 通貨が違う場合は、為替コミッションの発生 $this -> result[PARAM_STATUS] = "OK";
if($this -> debitCurrency != $this -> currency) { $this -> result[PARAM_TRANSACTION_NUMBER] = $params[VAL_INT_18];
$this -> result[PARAM_CURRENCY] = $this -> debitCurrency;
// 着金額指定の場合 $this -> result[PARAM_AMOUNT] = $this -> debitAmount;
$this -> registCommisionExchange($this -> fromAccount $this -> result[PARAM_FEE] = $this -> getColumnData($this -> ctransfer, PARAM_FROM_FEE);
, $this -> currency
, $this -> debitCurrency // this brings back memories - anton (2021)
, $this -> currencyToInt($this -> debitAmount, $this -> debitCurrency)); $this -> result[PARAM_FROM_ACCOUNT] = $this -> fromAccount;
} $this -> result[PARAM_TO_ACCOUNT] = $this -> toAccount;
}
// コミッションの集計(送金元)
$this -> registCommision(VAR_TRANSFER public function listen(){
, null if($this -> proceedToRemittanceRequest){
, $this -> fromAccount $params = $this -> getTransactionalParams();
, $this -> debitCurrency
, $this -> getColumnData($this -> ctransfer, PARAM_FROM_FEE)); if($this -> forTest)
$this -> emulateProcessing($params);
// コミッションの集計(送金先) else
$this -> registCommision(VAR_TRANSFER $this -> actualProcessing($params);
, 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)
]);
}
} }
$this -> printCallbackResult(); $this -> printCallbackResult();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment