Skip to content
This repository has been archived by the owner on Jun 24, 2021. It is now read-only.

Commit

Permalink
이니시스 모듈 보안 코드 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
chicpro committed Aug 10, 2016
1 parent 0660c6a commit 826440f
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 3 deletions.
12 changes: 11 additions & 1 deletion shop/inicis/INIStdPayReturn.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@
$tid = $resultMap['tid'];
$oid = $resultMap['MOID'];

/************************* 결제보안 추가 2016-05-18 START ****************************/
$secureMap['mid'] = $mid; //mid
$secureMap['tstamp'] = $timestamp; //timestemp
$secureMap['MOID'] = $resultMap['MOID']; //MOID
$secureMap['TotPrice'] = $resultMap['TotPrice']; //TotPrice

// signature 데이터 생성
$secureSignature = $util->makeSignatureAuth($secureMap);
/************************* 결제보안 추가 2016-05-18 END ****************************/

$sql = " select * from {$g5['g5_shop_order_data_table']} where od_id = '$oid' ";
$row = sql_fetch($sql);

Expand All @@ -100,7 +110,7 @@
$page_return_url .= '?sw_direct=1';
}

if (strcmp('0000', $resultMap['resultCode']) == 0) {
if ((strcmp('0000', $resultMap['resultCode']) == 0) && (strcmp($secureSignature, $resultMap['authSignature']) == 0) ) { //결제보안 추가 2016-05-18
/* * ***************************************************************************
* 여기에 가맹점 내부 DB에 결제 결과를 반영하는 관련 프로그램 코드를 구현한다.
Expand Down
55 changes: 53 additions & 2 deletions shop/inicis/libs/INIStdPayUtil.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


<?php

class INIStdPayUtil {
Expand Down Expand Up @@ -69,6 +67,59 @@ function makeHash($data, $alg) {
$ret = hash($alg, $data);
return $ret;
}

//
function makeSignatureAuth($parameters) {

if ($parameters == null || sizeof($parameters) == 0) {
throw new Exception("<p>Parameters can not be empty.</P>");
}

$stringToSign = ""; //반환용 text
$mid = $parameters["mid"]; //mid
$tstamp = $parameters["tstamp"]; //auth timestamp
$MOID = $parameters["MOID"]; //OID
$TotPrice = $parameters["TotPrice"]; //total price
$tstampKey = substr($parameters["tstamp"], strlen($parameters["tstamp"]) - 1); // timestamp 마지막 자리 1자리 숫자

switch (intval($tstampKey)){
case 1 :
$stringToSign = "MOID=" . $MOID . "&mid=" . $mid . "&tstamp=" . $tstamp ;
break;
case 2 :
$stringToSign = "MOID=" . $MOID . "&tstamp=" . $tstamp . "&mid=" . $mid ;
break;
case 3 :
$stringToSign = "mid=" . $mid . "&MOID=" . $MOID . "&tstamp=" . $tstamp ;
break;
case 4 :
$stringToSign = "mid=" . $mid . "&tstamp=" . $tstamp . "&MOID=" . $MOID ;
break;
case 5 :
$stringToSign = "tstamp=" . $tstamp . "&mid=" . $mid . "&MOID=" . $MOID ;
break;
case 6 :
$stringToSign = "tstamp=" . $tstamp . "&MOID=" . $MOID . "&mid=" . $mid ;
break;
case 7 :
$stringToSign = "TotPrice=" . $TotPrice . "&mid=" . $mid . "&tstamp=" . $tstamp ;
break;
case 8 :
$stringToSign = "TotPrice=" . $TotPrice . "&tstamp=" . $tstamp . "&mid=" . $mid ;
break;
case 9 :
$stringToSign = "TotPrice=" . $TotPrice . "&MOID=" . $MOID . "&tstamp=" . $tstamp ;
break;
case 0 :
$stringToSign = "TotPrice=" . $TotPrice . "&tstamp=" . $tstamp . "&MOID=" . $MOID ;
break;
}

$signature = hash("sha256", $stringToSign); // sha256 처리하여 hash 암호화
//$signature = $this->makeHash($stringToSign, "sha256"); // sha256 처리하여 hash 암호화

return $signature;
}

}
?>

0 comments on commit 826440f

Please sign in to comment.