1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
|
<?php require_once dirname(__FILE__).'/lib/nicepay/web/NicePayWEB.php'; require_once dirname(__FILE__).'/lib/nicepay/core/Constants.php'; require_once dirname(__FILE__).'/lib/nicepay/web/NicePayHttpServletRequestWrapper.php';
/** 1. Request Wrapper 클래스를 등록한다. */ $httpRequestWrapper = new NicePayHttpServletRequestWrapper($_REQUEST); $_REQUEST = $httpRequestWrapper->getHttpRequestMap();
/** 2. 소켓 어댑터와 연동하는 Web 인터페이스 객체를 생성한다.*/ $nicepayWEB = new NicePayWEB();
/** 2-1. 로그 디렉토리 설정 */ $nicepayWEB->setParam("NICEPAY_LOG_HOME","/wwwroot/adapter_log/log");
/** 2-2. 로그 모드 설정(0: DISABLE, 1: ENABLE) */ $nicepayWEB->setParam("APP_LOG","1");
/** 2-3. 암호화플래그 설정(N: 평문, S:암호화) */ $nicepayWEB->setParam("EncFlag","S");
/** 2-4. 서비스모드 설정(결제 서비스 : PY0 , 취소 서비스 : CL0) */ $nicepayWEB->setParam("SERVICE_MODE", "PY0");
/** 2-5. 통화구분 설정(현재 KRW(원화) 가능) */ $nicepayWEB->setParam("Currency", "KRW");
$nicepayWEB->setParam("CHARSET", "UTF8");
/** 2-7. 결제수단 설정 (신용카드결제 : CARD, 계좌이체: BANK, 가상계좌이체 : VBANK, 휴대폰결제 : CELLPHONE ) */ $payMethod = $_REQUEST['PayMethod']; // 결제수단 $nicepayWEB->setParam("PayMethod",$payMethod);
/** 2-8 라이센스키 설정 상점 ID에 맞는 상점키를 설정하십시요. */ $nicepayWEB->setParam("LicenseKey","33F49GnCMS1mFYlGXisbUDzVf2ATWCl9k3R++d5hDd3Frmuos/XLx8XhXpe+LDYAbpGKZYSwtlyyLOtS/8aD7A==");
/** 3. 결제 요청 */ $responseDTO = $nicepayWEB->doService($_REQUEST);
/** 4. 결제 결과 */ $resultCode = $responseDTO->getParameter("ResultCode"); // 결과코드 (정상 :3001 , 그 외 에러) $resultMsg = $responseDTO->getParameterUTF("ResultMsg"); // 결과메시지 $authDate = $responseDTO->getParameter("AuthDate"); // 승인일시 YYMMDDHH24mmss $authCode = $responseDTO->getParameter("AuthCode"); // 승인번호 $buyerName = $responseDTO->getParameterUTF("BuyerName"); // 구매자명 $mallUserID = $responseDTO->getParameter("MallUserID"); // 회원사고객ID $goodsName = $responseDTO->getParameterUTF("GoodsName"); // 상품명 $mallUserID = $responseDTO->getParameter("MallUserID"); // 회원사ID $mid = $responseDTO->getParameter("MID"); // 상점ID $tid = $responseDTO->getParameter("TID"); // 거래ID $moid = $responseDTO->getParameter("Moid"); // 주문번호 $amt = $responseDTO->getParameter("Amt"); // 금액
$cardQuota = $responseDTO->getParameter("CardQuota"); // 할부개월 $cardCode = $responseDTO->getParameter("CardCode"); // 결제카드사코드 $cardName = $responseDTO->getParameterUTF("CardName"); // 결제카드사명
$bankCode = $responseDTO->getParameter("BankCode"); // 은행코드 $bankName = $responseDTO->getParameterUTF("BankName"); // 은행명 $rcptType = $responseDTO->getParameter("RcptType"); //현금 영수증 타입 (0:발행되지않음,1:소득공제,2:지출증빙) $rcptAuthCode = $responseDTO->getParameter("RcptAuthCode"); // 현금영수증 승인번호
$carrier = $responseDTO->getParameter("Carrier"); // 이통사구분 $dstAddr = $responseDTO->getParameter("DstAddr"); // 휴대폰번호
$vbankBankCode = $responseDTO->getParameter("VbankBankCode"); // 가상계좌은행코드 $vbankBankName = $responseDTO->getParameterUTF("VbankBankName"); // 가상계좌은행명 $vbankNum = $responseDTO->getParameter("VbankNum"); // 가상계좌번호 $vbankExpDate = $responseDTO->getParameter("VbankExpDate"); // 가상계좌입금예정일
/** 위의 응답 데이터 외에도 전문 Header와 개별부 데이터 Get 가능 */
$paySuccess = false; // 결제 성공 여부 if($payMethod == "CARD"){ //신용카드 if($resultCode == "3001") $paySuccess = true; // 결과코드 (정상 :3001 , 그 외 에러) }else if($payMethod == "BANK"){ //계좌이체 if($resultCode == "4000") $paySuccess = true; // 결과코드 (정상 :4000 , 그 외 에러) }else if($payMethod == "CELLPHONE"){ //휴대폰 if($resultCode == "A000") $paySuccess = true; //결과코드 (정상 : A000, 그 외 비정상) }else if($payMethod == "VBANK"){ //가상계좌 if($resultCode == "4100") $paySuccess = true; // 결과코드 (정상 :4100 , 그 외 에러) }
if($paySuccess == true){ // 결제 성공시 DB처리 하세요. }else{ // 결제 실패시 DB처리 하세요. }
?>
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>NICEPAY :: 결제 요청 결과</title> <link rel="stylesheet" href="css/basic.css" type="text/css" /> <link rel="stylesheet" href="css/style.css" type="text/css" /> </head> <body> <br> <table width="632" border="0" cellspacing="0" cellpadding="0" align="center"> <tr> <td > <table width="632" border="0" cellspacing="0" cellpadding="0" class="title"> <tr> <td width="35"> </td> <td>결제 요청 결과</td> <td> </td> </tr> </table> </td> </tr> <tr> <td align="left" valign="top" background="images/bodyMiddle.gif"><table width="632" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="35" height="10"> </td> <!--상단여백 높이 10px --> <td width="562"> </td> <td width="35"> </td> </tr> <tr> <td height="30"> </td> <td>결제 요청이 완료되었습니다. </td> <td> </td> </tr> <tr> <td height="15"> </td> <!--컨텐츠와 컨텐츠 사이 간격 15px--> <td> </td> <td> </td> </tr> <tr> <td height="30"> </td> <td class="bold"><img src="images/bullet.gif" /> 결제 내역입니다. <td> </td> </tr> <tr> <td > </td> <td ><table width="562" border="0" cellspacing="0" cellpadding="0" class="talbeBorder" > <tr> <!-- 테이블 일반의 높이는 30px // 홀수행셀의 경우 class="thead01" 사용 --> <td width="100" height="30" id="borderBottom" class="thead01">결과 내용</td> <td id="borderBottom" > [<?php echo $resultCode?>] <?php echo $resultMsg?></td> </tr> <tr> <!-- 테이블 일반의 높이는 30px // 홀수행셀의 경우 class="thead02" 사용 --> <td width="100" height="30" id="borderBottom" class="thead02">결제 수단</td> <td id="borderBottom" > <?php echo $payMethod ?></td> </tr> <tr> <td width="100" height="30" id="borderBottom" class="thead01">상품명</td> <td id="borderBottom" > <?php echo $goodsName ?></td> </tr> <tr> <td width="100" height="30" id="borderBottom" class="thead02">금액</td> <td id="borderBottom" > <?php echo $amt ?> 원</td> </tr> <tr> <td width="100" height="30" id="borderBottom" class="thead01">거래아이디</td> <td id="borderBottom" > <?php echo $tid ?></td> </tr> <?if($payMethod == "CARD"){?> <tr> <td width="100" height="30" id="borderBottom" class="thead02">카드사명</td> <td id="borderBottom" ><?php echo $cardName ?> </td> </tr> <tr> <td width="100" height="30" id="borderBottom" class="thead01">할부개월</td> <td id="borderBottom" ><?php echo $cardQuota ?> </td> </tr> <?}else if($payMethod == "BANK"){?> <tr> <td width="100" height="30" id="borderBottom" class="thead02">은행</td> <td id="borderBottom" ><?php echo $bankName ?> </td> </tr> <tr> <td width="100" height="30" id="borderBottom" class="thead01">현금영수증 타입</td> <td id="borderBottom" ><?php echo $rcptType ?> (0:발행안함,1:소득공제,2:지출증빙)</td> </tr> <tr> <td width="100" height="30" id="borderBottom" class="thead02">현금영수증 승인번호</td> <td id="borderBottom" ><?php echo $rcptAuthCode ?> </td> </tr> <?}else if($payMethod== "CELLPHONE"){?> <tr> <td width="100" height="30" id="borderBottom" class="thead02">이통사 구분</td> <td id="borderBottom" ><?php echo $carrier ?> </td> </tr> <tr> <td width="100" height="30" id="borderBottom" class="thead01">휴대폰 번호</td> <td id="borderBottom" ><?php echo $dstAddr ?> </td> </tr> <?}else if($payMethod == "VBANK"){?> <tr> <td width="100" height="30" id="borderBottom" class="thead02">입금 은행</td> <td id="borderBottom" ><?php echo $vbankBankName ?> </td> </tr> <tr> <td width="100" height="30" id="borderBottom" class="thead01">입금 계좌</td> <td id="borderBottom" ><?php echo $vbankNum ?> </td> </tr> <tr> <td width="100" height="30" id="borderBottom" class="thead02">입금 기한</td> <td id="borderBottom" ><?php echo $vbankExpDate ?> </td> </tr> <?}?>
</table></td> <td height="15"> </td> </tr> <tr> <td height="15"></td> <!--컨텐츠와 컨텐츠 사이 간격 15px--> <td > </td> <td> </td> </tr> <tr> <td></td> <td class="comment">테스트 아이디인경우 당일 오후 11시 30분에 취소됩니다. </td> <td> </td> </tr> <tr> <td height="10"></td> <!--하단여백 높이 10px --> <td > </td> <td> </td> </tr> </table></td> </tr> <tr> <td><img src="images/bodyBottom.gif" /></td> </tr> </table> </body> </html>
|