Commit 4ca26f90 authored by iWallet Dev's avatar iWallet Dev

Remittance API Enhancement

parent 821415bf
......@@ -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,10 +374,7 @@ 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){
......@@ -416,6 +439,8 @@ class MoneyRequest extends System {
$this -> result[PARAM_RESULT] = sprintf("%02d", VAL_INT_99);
$this -> result[PARAM_STATUS] = "REJECTED";
$this -> responseCode = 406;
$this -> accessModifyCommon("INSERT_LOG_POST",
[
$this -> ip,
......@@ -426,6 +451,38 @@ class MoneyRequest extends System {
}
}
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();
}
}
......
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