구분 | IP | 비고 |
---|---|---|
테스트 | 211.193.35.11 | STG |
운영 - 결제 | 211.193.35.20 | |
운영 - 재통보 | 211.193.35.215 | 재통보 서비스 사용시 |
상세 파라미터
파라미터 | 항목명 | 길이(char) | 필수여부 | 설명 |
---|---|---|---|---|
PayMethod | 결제수단 | 10 | 필수 | CARD: 신용카드 |
Mid | 상점ID | 10 | 필수 | |
Amt | 거래 금액 | 12 | 숫자만 가능, 문장부호 제외 | |
Moid | 상품주문번호 | 40 | 필수 | |
MallUserId | 회원사 고객 ID | 20 | 필수 | 회원가입 시 고객 구분값으로 사용 |
GoodsName | 상품명 | 40 | 필수 | |
GoodsCnt | 결제상품 개수 | 2 | 필수 | |
MallReserved | 상점예비정보 | 500 | 필수 | Base64 인코딩필요
(평문으로 전달시 한글 및 특수문자가 정상적으로 전달되지 않음) |
BuyerName | 구매자명 | 30 | 필수 | |
BuyerTel | 구매자연락처 | 40 | 필수 | |
BuyerEmail | 구매자메일주소 | 60 | 필수 | |
ReturnUrl | 상점 결제결과 전송 URL | 200 | 필수 | |
EdiDate | 전문생성일시 | 14 | 필수 | |
EncryptData | 암호화 데이터 | 필수 | 가변 | 위·변조 방지를 위해 전달 |
SspMallId | 간편결제 가맹점 ID | 10 | 필수 | 발급받은 SspMallId |
PopCheck | 팝카드 체크 유무 | 1 | 필수 | Y: 체크, N: 미체크(기본값) |
FnCd | 카드사 코드 | 2 | 선택 | 통합코드조회 > 카드사코드 발급사코드로 호출 |
CardQuota | 할부개월 | 2 | 선택 | 00: 일시불(기본값), 02, 03, ... |
MallIp | 상점 IP | 20 | 선택 | 상점서버 IP |
UserIp | 고객 IP | 20 | 선택 | 고객 IP |
EncodingType | 응답 Charset | 6 | 선택 | utf8(기본값), euckr |
SkinColor | UI 스타일 | 10 | 선택 | RED(기본값), GREEN, BLUE, PURPLE |
TaxCd | 세금사용코드 | 1 | 선택 | **: empty(기본값) |
TaxAmt | 과세 | 9 | 선택 | |
TaxFreeAmt | 비과세 | 9 | 선택 | |
VatAmt | 부가세 | 9 | 선택 |
파라미터 | 항목명 | 길이(char) | 설명 |
---|---|---|---|
PayMethod | 지불수단 | 10 | CARD |
Mid | 상점 ID | 10 | |
Amt | 금액 | 12 | |
GoodsName | 상품명 | 40 | |
Tid | 거래번호 | 30 | |
Moid | 주문번호 | 100 | |
BuyerName | 구매자명 | 30 | |
MallUserId | 고객사회원ID | 20 | 간편결제 고객 고유식별번호 |
AuthDate | 승인일자 | 12 | YYMMDDHHMMSS(형식) |
AuthCode | 승인번호 | 30 | |
ResultCode | 결과코드 | 4 | |
ResultMsg | 결과메시지 | 100 | |
AppCardCode | 발급사코드 | 2 | |
AppCardName | 발급사명 | 20 | |
AcquCardCode | 매입사코드 | 2 | |
AcquCardName | 매입사명 | 20 | |
CardMerchantNo | 카드사 가맹점번호 | 15 | |
CardNum | 카드번호 | 16 | 7~12자리 Masking 처리 |
MallReserved | 상점예비정보 | 500 |
옵션 | 비고 |
---|---|
미사용 | 본인인증 성공 여부만 체크(default) |
성명 일치 | 본인인증 성명과 구매자명(BuyerName) 일치여부 확인 |
휴대폰번호 일치 | 본인인증 휴대폰 번호와 구매자 휴대폰번호(BuyerTel) 일치여부 확인 |
성명&휴대폰번호 일치 |
본인인증 성명과 구매자명(BuyerName) 일치 & 본인인증 휴대폰 번호와 구매자 휴대폰번호(BuyerTel) 일치 확인 |
String Mid = ""; // 발급받은 테스트 Mid 설정(Real 전환 시 운영 Mid 설정)
String MerchantKey = ""; // 발급받은 테스트 상점키 설정(Real 전환 시 운영 상점키 설정)
String EdiDate = getyyyyMMddHHmmss();
String Amt = "1004";
String EncryptData = encodeSHA256Base64(EdiDate + Mid + Amt + MerchantKey);
String today = getyyyyMMddHHmm(); // 현재일자. 캐시방지용으로 사용
/* SHA256 암호화 */
public static final String encodeSHA256Base64(String strPW) {
String passACL = null;
MessageDigest md = null;
try {
md = MessageDigest.getInstance("SHA-256");
} catch (Exception e) {
e.printStackTrace();
}
md.update(strPW.getBytes());
byte[] raw = md.digest();
byte[] encodedBytes = Base64.encodeBase64(raw);
passACL = new String(encodedBytes);
return passACL;
}
/* 현재일자 */
public static final String getyyyyMMddHHmmss() {
SimpleDateFormat yyyyMMddHHmmss = new SimpleDateFormat("yyyyMMddHHmmss");
return yyyyMMddHHmmss.format(new Date());
}
/* 현재일자 */
public static final String getyyyyMMddHHmm() {
SimpleDateFormat yyyyMMddHHmm = new SimpleDateFormat("yyyyMMddHHmm");
return yyyyMMddHHmm.format(new Date());
}
$Mid = ""; // 발급받은 테스트 Mid 설정(Real 전환 시 운영 Mid 설정)
$MerchantKey = ""; // 발급받은 테스트 상점키 설정(Real 전환 시 운영 상점키 설정)
$EdiDate = date("YmdHis");
$Amt = "1004";
$EncryptData = base64_encode(hash('sha256', $EdiDate.$Mid.$Amt.$MerchantKey, true));
$today = date("YmdHi"); // 현재일자. 캐시방지용으로 사용
Mid = "" ' 발급받은 테스트 Mid 설정(Real 전환 시 운영 Mid 설정)
MerchantKey = "" ' 발급받은 테스트 상점키 설정(Real 전환 시 운영 상점키 설정)
EdiDate = Year(Now()) & right("0"&Month(Now()),2) & right("0"&Day(Now()),2) & right("0"&Hour(Now()),2) & right("0"&Minute(Now()),2) & right("0"&Second(Now()),2)
Amt = "1004"
EncryptData = CryptoUtil.Sha256Encrypt(EdiDate & Mid & Amt & MerchantKey))
today = Year(Now()) & right("0"&Month(Now()),2) & right("0"&Day(Now()),2) & right("0"&Hour(Now()),2) & right("0"&Minute(Now()),2) ' 현재일자. 캐시방지용으로 사용
// DLL 암호화 소스
using System;
using System.EnterpriseServices;
using System.IO;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text;
namespace SmartropayLib
{
public class CryptoUtil : ServicedComponent
{
///
/// SHA256 암호화
///
/// 문자열
/// 암호화 문자열
public string Sha256Encrypt(string text)
{
SHA256Managed sha256Managed = new SHA256Managed();
byte[] encryptBytes = sha256Managed.ComputeHash(Encoding.UTF8.GetBytes(text));
return Convert.ToBase64String(encryptBytes);
}
}
}
SmartroPAY 연동가이드
String url = "https://tapproval.smartropay.co.kr/payment/approval/urlCallApproval.do"; // 테스트
//String url = "https://approval.smartropay.co.kr/payment/approval/urlCallApproval.do"; // 운영
String Tid = request.getParameter("Tid")==null?"":request.getParameter("Tid");
String TrAuthKey = request.getParameter("TrAuthKey")==null?"":request.getParameter("TrAuthKey");
HashMap<String, Object> result = callApi(TrAuthKey , Tid, url);
public HashMap<String, Object> callApi(String TrAuthKey, String Tid, String callUrl) {
StringBuilder responseBody = null;
HashMap<String, Object> result = new HashMap<>();
// http urlCall 승인 요청 및 TrAuthKey 유효성 검증
int connectTimeout = 1000;
int readTimeout = 10000; // 가맹점에 맞게 TimeOut 조절
URL url = null;
HttpsURLConnection connection = null;
try {
SSLContext sslCtx = SSLContext.getInstance("TLSv1.2");
sslCtx.init(null, null, new SecureRandom());
url = new URL(callUrl);
System.out.println(" url " + url.toString());
connection = (HttpsURLConnection)url.openConnection();
connection.setSSLSocketFactory(sslCtx.getSocketFactory());
connection.addRequestProperty("Content-Type", "application/json");
connection.addRequestProperty("Accept", "application/json");
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setConnectTimeout(connectTimeout);
connection.setReadTimeout(readTimeout);
OutputStreamWriter osw = new OutputStreamWriter(new BufferedOutputStream(connection.getOutputStream()) , "utf-8" );
JSONObject body = new JSONObject();
body.put("Tid" ,Tid);
body.put("TrAuthKey" ,TrAuthKey);
char[] bytes = body.toString().toCharArray();
osw.write(bytes,0,bytes.length);
osw.flush();
osw.close();
BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8"));
String line = null;
responseBody = new StringBuilder();
while ((line = br.readLine()) != null) {
System.out.println(" response " + line);
responseBody.append(line);
}
br.close();
// 결제결과
result = new ObjectMapper().readValue(responseBody.toString(), HashMap.class);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
$url = "https://tapproval.smartropay.co.kr/payment/approval/urlCallApproval.do"; // 테스트
//$url = "https://approval.smartropay.co.kr/payment/approval/urlCallApproval.do"; // 운영
$approval_data = array(
'Tid' => $_REQUEST['Tid'],
'TrAuthKey' => $_REQUEST['TrAuthKey']
);
// json data
$json = json_encode($approval_data);
$http_status = 0;
// https 통신
$ret = Curl($url, $json, $http_status);
function Curl($url, $post_data, &$http_status, &$header = null) {
$ch=curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url);
// post_data
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json', 'Content-Type: application/json'));
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
$body = null;
// error
if (!$response) {
$body = curl_error($ch);
// HostNotFound, No route to Host, etc Network related error
$http_status = -1;
Log::error("CURL Error: = " . $body);
} else {
//parsing http status code
$http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if (!is_null($header)) {
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$body = substr($response, $header_size);
} else {
$body = $response;
}
}
curl_close($ch);
return $body;
}
url = "https://tapproval.smartropay.co.kr/payment/approval/urlCallApproval.do" ' 테스트
'url = "https://approval.smartropay.co.kr/payment/approval/urlCallApproval.do" ' 운영
Set json = jsObject()
json("Tid") = request("Tid")
json("TrAuthKey") = request("TrAuthKey")
result = sendPost(url, json)
Function sendPost(callUrl, objJson)
Set httpRequest = Server.CreateObject("MSXML2.ServerXMLHTTP")
httpRequest.open "POST", url, False
httpRequest.setRequestHeader "Content-type","application/json"
httpRequest.setRequestHeader "Accept","application/json"
httpRequest.send objJson.jsString
postResponse = httpRequest.ResponseText
sendPost = postResponse
End Function
SS-Pay 회원 삭제 파라미터
파라미터 | 항목명 | 길이(char) | 필수여부 | 설명 |
---|---|---|---|---|
MID | 상점 아이디 | 10 | 필수 | |
SspMallId | 결제MALL ID | 10 | 필수 | 발급받은 SspMallId |
MallUserId | 회원사 고객 ID | 20 | 필수 | 고객 구분값 |
ServiceType | 서비스 타입 | 2 | 필수 | 회원 삭제 : MD |
VerifyValue | 위·변조 검증값 | 가변 | 필수 | SHA256 해시 암호화 |
MallReserved | 상점예비정보 | 100 | 선택 | Base64 인코딩필요
(평문으로 전달시 한글 및 특수문자가 정상적으로 전달되지 않음) |
파라미터 | 항목명 | 길이(char) | 설명 |
---|---|---|---|
SspMallId | 결제MALL ID | 10 | |
ResultCode | 결과코드 | 10 | 성공: PD00, PS40 실패: 그 외 PD00 : 회원정보와 등록된 카드 정보 삭제 PS40 : 등록된 카드 정보가 없는 경우 회원 정보 삭제 |
ResultMsg | 결과메시지 | 80 | |
MallReserved | 상점 예비필드 | 500 | 요청한 값 응답 |
String url = "https://tapproval.smartropay.co.kr/payment/approval/ssbMemberDel.do"; // 테스트
// String url = "https://approval.smartropay.co.kr/payment/approval/ssbMemberDel.do"; // 운영
JSONObject body = new JSONObject();
JSONObject paramData = new JSONObject();
String merchantKey =" "; /// 발급받은 MerchantKey
String Mid = "SMTPAY006m"; // 발급받은 테스트 Mid 설정(Real 전환 시 운영 Mid 설정)
String SspMallId = " "; // 발급받은 SspMallId
String MallUserID =" "; // 발급받은 MallUserID
String VerifyValue = encodeSHA256Base64(Mid +SspMallId+MallUserID);
// 요청 파라미터 (각 값들은 가맹점 환경에 맞추어 설정해 주세요.)
paramData.put("Mid" ,Mid);
paramData.put("SspMallId" ,SspMallId);
paramData.put("MallUserId" ,MallUserID);
paramData.put("VerifyValue" ,VerifyValue);
paramData.put("ServiceType" ,"MD");
// json 데이터 AES256 암호화
try {
body.put("EncData", AES256Cipher.AES_Encode(paramData.toString(), merchantKey.substring(0,32)));
body.put("Mid", Mid);
} catch(Exception e){
e.printStackTrace();
}
HashMap result = callApi(body, url);
public static HashMap callApi(JSONObject json, String callUrl) {
StringBuilder responseBody = null;
HashMap result = new HashMap<>();
// http urlCall 승인 요청 및 TrAuthKey 유효성 검증
int connectTimeout = 1000;
int readTimeout = 10000; // 가맹점에 맞게 TimeOut 조절
URL url = null;
HttpsURLConnection connection = null;
try {
SSLContext sslCtx = SSLContext.getInstance("TLSv1.2");
sslCtx.init(null, null, new SecureRandom());
url = new URL(callUrl);
System.out.println(" url " + url.toString());
connection = (HttpsURLConnection)url.openConnection();
connection.setSSLSocketFactory(sslCtx.getSocketFactory());
connection.addRequestProperty("Content-Type", "application/json");
connection.addRequestProperty("Accept", "application/json");
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setConnectTimeout(connectTimeout);
connection.setReadTimeout(readTimeout);
OutputStreamWriter osw = new OutputStreamWriter(new BufferedOutputStream(connection.getOutputStream()) , "utf-8" );
char[] bytes = json.toString().toCharArray();
osw.write(bytes,0,bytes.length);
osw.flush();
osw.close();
BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8"));
String line = null;
responseBody = new StringBuilder();
while ((line = br.readLine()) != null) {
System.out.println(" response " + line);
responseBody.append(line);
}
br.close();
// 결제결과
result = new ObjectMapper().readValue(responseBody.toString(), HashMap.class);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return result;
}