Skip to content

Instantly share code, notes, and snippets.

@jeonghwan-kim
Last active October 8, 2015 10:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeonghwan-kim/89a9153b14f217911239 to your computer and use it in GitHub Desktop.
Save jeonghwan-kim/89a9153b14f217911239 to your computer and use it in GitHub Desktop.
var https = require('https');
var iconv = require('iconv-lite');
function (req, reply) {
// 인증결과 확인
if (req.payload.P_STATUS !== '00') {
// 에러 처리
}
// TID 체크
checkTid(req.payload.P_TID).then(function () {
// 승인 요청
var P_MID = 'INIpayTest';
var params = '?P_TID=' + req.payload.P_TID + '&P_MID=' + P_MID;
var url = req.payload.P_REQ_URL + params;
https.get(url, function (res) {
res.pipe(iconv.decodeStream('euckr')).collect(function (err, decodedBody) {
if (err) {
// 에러처리
}
// 데이터 베이스에 결재 정보 저장
saveTransaction(decodedBody);
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment