Commit ac795216 authored by Antonio.Suerte's avatar Antonio.Suerte

Payment API Callback Sender Issue Fix [Multiple CB Prevention]

parent 9ccfb8e0
...@@ -127,25 +127,11 @@ class LogicSettlement extends SettlementModelClass { ...@@ -127,25 +127,11 @@ class LogicSettlement extends SettlementModelClass {
} }
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
* @function_name: データの登録 * @function_name: データは商人へ送信する処理
* @parameter : なし * @parameter : なし
* @return : なし * @return : なし
-------------------------------------------------------------------------*/ -------------------------------------------------------------------------*/
private function forward($result) { private function sendCallbackToIntegrator($callBack, $data){
// 変数宣言部
$url = NO_STRING;
$data = null;
// 転送先
$url = $this -> getUrl();
$callBack = $this -> getCallBackUrl();
$failUrl = $this -> getFailUrl();
// コールバック
$data = $this -> getForwardParams($result);
$jsonData = json_encode($data);
$data = http_build_query($data, '', '&');
//log directory //log directory
$apiPath = dirname(SYSTEM_PATH).DIRECTORY_SEPARATOR.'api'; $apiPath = dirname(SYSTEM_PATH).DIRECTORY_SEPARATOR.'api';
$responseUrl = $apiPath.DIRECTORY_SEPARATOR.'Logs'.DIRECTORY_SEPARATOR.'settlement'.DIRECTORY_SEPARATOR.'settlement_response_data'; $responseUrl = $apiPath.DIRECTORY_SEPARATOR.'Logs'.DIRECTORY_SEPARATOR.'settlement'.DIRECTORY_SEPARATOR.'settlement_response_data';
...@@ -192,6 +178,29 @@ class LogicSettlement extends SettlementModelClass { ...@@ -192,6 +178,29 @@ class LogicSettlement extends SettlementModelClass {
chmod($logFileName, 511); chmod($logFileName, 511);
// end of logging response data // end of logging response data
}
/*-------------------------------------------------------------------------
* @function_name: データの登録
* @parameter : なし
* @return : なし
-------------------------------------------------------------------------*/
private function forward($result) {
header("Content-type: text/plain");
// 変数宣言部
$url = NO_STRING;
$data = null;
// 転送先
$url = $this -> getUrl();
$callBack = $this -> getCallBackUrl();
$failUrl = $this -> getFailUrl();
// コールバック
$data = $this -> getForwardParams($result);
$jsonData = json_encode($data);
$data = http_build_query($data, '', '&');
if(isset($_SERVER['REMOTE_ADDR'])) { if(isset($_SERVER['REMOTE_ADDR'])) {
$ip = $_SERVER['REMOTE_ADDR']; $ip = $_SERVER['REMOTE_ADDR'];
...@@ -205,24 +214,31 @@ class LogicSettlement extends SettlementModelClass { ...@@ -205,24 +214,31 @@ class LogicSettlement extends SettlementModelClass {
} }
// 転送をする // 転送をする
if($url != NO_STRING && $result == NO_COUNT) { // 正常終了 if($result == NO_COUNT) { // 正常終了
$this -> sendCallbackToIntegrator($callBack, $data);
// this insert command also comtains data that will passed to merchant's system. // this insert command also comtains data that will passed to merchant's system.
$this -> accessModifyCommon('INSERT_LOG_POST', array( $this -> accessModifyCommon('INSERT_LOG_POST', array(
$ip, $ip,
$this -> getProgramCode(), $this -> getProgramCode(),
$referer, $referer,
"[CALLBACK_SUCCESSFUL]{$jsonData}")); "[CALLBACK_SUCCESSFUL]{$jsonData}"));
header('Location: ' . $url);
if($url != NO_STRING)
header("Location: {$url}");
else
echo "Successfully transferred!";
} else { // 異常 } else { // 異常
$this -> accessModifyCommon('INSERT_LOG_POST', array( $this -> accessModifyCommon('INSERT_LOG_POST', array(
$ip, $ip,
$this -> getProgramCode(), $this -> getProgramCode(),
$referer, $referer,
"[CALLBACK_ERROR]{$jsonData}")); "[CALLBACK_ERROR]{$jsonData}"));
if($failUrl != NO_STRING) {
header('Location: ' . $failUrl); if($failUrl != NO_STRING)
} header("Location: {$failUrl}");
else
echo "The settlement failed to proceed!";
} }
} }
......
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