Пример #1
0
 function connectURL($msg)
 {
     $httpclient = new HttpClient("true", HOST_IP);
     $this->printLog("Start INImx_APPL");
     $this->printLog("Start HTTP Connect:" . HOST_IP . $this->m_serviceurl);
     if ($httpclient->HttpConnect()) {
         $this->printLog("HTTP CONNECTION SUCCESS");
         if ($httpclient->HttpRequest($this->m_serviceurl, $msg)) {
             $this->printLog("RECV REQUEST:" . trim($httpclient->getBody()));
             // ���� �� �Ľ�
             parse_str(trim($httpclient->getBody()), $resultString);
             //����
             $this->m_tid = $resultString['P_TID'];
             $this->m_resultCode = $resultString['P_STATUS'];
             $this->m_resultMsg = $resultString['P_RMESG1'];
             $this->m_payMethod = $resultString['P_TYPE'];
             $this->m_mid = $resultString['P_MID'];
             $this->m_moid = $resultString['P_OID'];
             $this->m_resultprice = $resultString['P_AMT'];
             $this->m_buyerName = $resultString['P_UNAME'];
             $this->m_noti = $resultString['P_NOTI'];
             $this->m_nextUrl = $resultString['P_NEXT_URL'];
             $this->m_notiUrl = $resultString['P_NOTEURL'];
             //�ſ�ī��
             $this->m_pgAuthDate = substr($resultString['P_AUTH_DT'], '0', '8');
             $this->m_pgAuthTime = substr($resultString['P_AUTH_DT'], '8', '6');
             $this->m_authCode = $resultString['P_AUTH_NO'];
             $this->m_cardQuota = $resultString['P_RMESG2'];
             $this->m_cardCode = $resultString['P_FN_CD1'];
             $this->m_cardIssuerCode = $resultString['P_CARD_ISSUER_CODE'];
             $this->m_cardNumber = $resultString['P_CARD_NUM'];
             $this->m_cardMember = $resultString['P_CARD_MEMBER_NUM'];
             $this->m_cardpurchase = $resultString['P_CARD_PURCHASE_CODE'];
             $this->m_prtc = $resultString['P_CARD_PRTC_CODE'];
             //�޴���
             $this->m_codegw = $resultString['P_HPP_CORP'];
             //�������
             $this->m_vacct = $resultString['P_VACT_NUM'];
             $this->m_dtinput = $resultString['P_VACT_DATE'];
             $this->m_tminput = $resultString['P_VACT_TIME'];
             $this->m_nmvacct = $resultString['P_VACT_NAME'];
             $this->m_vcdbank = $resultString['P_VACT_BANK_CODE'];
         } else {
             $this->printLog("HTTP REQUEST FAIL:" . $httpclient->getErrorCode() . ":" . $httpclient->getErrorMsg());
             // �� ���� ��û ����
             $this->m_resultCode = "05";
             $this->m_resultmsg = "HTTP REQUEST FAIL";
         }
     } else {
         $this->printLog("HTTP CONNECTION FAIL:" . $httpclient->getErrorCode() . ":" . $httpclient->getErrorMsg());
         // ���� ���� ����
         $this->m_resultCode = "05";
         $this->m_resultmsg = "HTTP CONNECTION FAIL";
     }
     $this->printLog("P_STATUS:" . $this->m_resultCode);
     $this->printLog("P_RMESG1:" . $this->m_resultMsg);
     $this->printLog("P_TYPE:" . $this->m_payMethod);
     $this->printLog("P_TID:" . $this->m_tid);
     $this->printLog("P_MID:" . $this->m_mid);
     $this->printLog("P_OID:" . $this->m_moid);
     $this->printLog("P_UNAME:" . $this->m_buyerName);
     $this->printLog("P_AMT:" . $this->m_resultprice);
     $this->printLog("P_AUTH_DT:" . $this->m_pgAuthDate);
     $this->printLog("P_AUTH_TM:" . $this->m_pgAuthTime);
     $this->printLog("P_AUTH_NO:" . $this->m_authCode);
     $this->printLog("P_RMESG2:" . $this->m_cardQuota);
     $this->printLog("P_FN_CD1:" . $this->m_cardCode);
     $this->printLog("P_CARD_ISSUER_CODE:" . $this->m_cardIssuerCode);
     $this->printLog("P_CARD_PURCHASE_CODE:" . $this->m_cardpurchase);
     $this->printLog("P_CARD_PRTC_CODE:" . $this->m_prtc);
     $this->printLog("P_VACT_NUM:" . $this->m_vacct);
     $this->printLog("P_VACT_BANK_CODE:" . $this->m_vcdbank);
     $this->printLog("P_VACT_DATE:" . $this->m_dtinput);
     $this->printLog("P_VACT_TIME:" . $this->m_tminput);
     $this->printLog("P_VACT_NAME:" . $this->m_nmvacct);
     $this->printLog("P_NEXT_URL:" . $this->m_nextUrl);
     $this->printLog("P_NOTEURL:" . $this->m_notiUrl);
     $this->printLog("APPL Transaction End");
 }
Пример #2
0
 function startAction()
 {
     if (trim($this->m_ActionType) == "") {
         $this->MakeErrorMsg(ERR_WRONG_ACTIONTYPE, "actionType 설정이 잘못되었습니다.");
         return;
     }
     $NICELog = new NICELog($this->m_log, $this->m_debug, $this->m_ActionType);
     if (!$NICELog->StartLog($this->m_NicepayHome, $this->m_MID)) {
         $this->MakeErrorMsg(ERR_OPENLOG, "로그파일을 열수가 없습니다.");
         return;
     }
     // 취소인 경우,
     if (trim($this->m_ActionType) == "CLO") {
         if (trim($this->m_TID) == "") {
             $this->MakeErrorMsg(ERR_WRONG_PARAMETER, "요청페이지 파라메터가 잘못되었습니다. [TID]");
             return;
         } else {
             if (trim($this->m_CancelAmt) == "") {
                 $this->MakeErrorMsg(ERROR_WRONG_PARAMETER, "요청페이지 파라메터가 잘못되었습니다. [CancelAmt]");
                 return;
             } else {
                 if (trim($this->m_CancelMsg) == "") {
                     $this->MakeErrorMsg(ERROR_WRONG_PARAMETER, "요청페이지 파라메터가 잘못되었습니다. [CancelMsg]");
                     return;
                 }
             }
         }
         $this->m_uri = "/lite/cancelProcess.jsp";
         unset($this->m_queryString);
         $this->m_queryString = $_POST;
         $this->m_queryString["MID"] = substr($this->m_TID, 0, 10);
         $this->m_queryString["TID"] = $this->m_TID;
         $this->m_queryString["CancelAmt"] = $this->m_CancelAmt;
         $this->m_queryString["CancelMsg"] = $this->m_CancelMsg;
         $this->m_queryString["CancelPwd"] = $this->m_CancelPwd;
         $this->m_queryString["PartialCancelCode"] = $this->m_PartialCancelCode;
         $NICELog->WriteLog($this->m_queryString["TID"]);
         //입금 후 취소
     } else {
         if (trim($this->m_ActionType) == "DPO") {
             if (trim($this->m_TID) == "") {
                 $this->MakeErrorMsg(ERR_WRONG_PARAMETER, "요청페이지 파라메터가 잘못되었습니다. [TID]");
                 return;
             } else {
                 if (trim($this->m_CancelAmt) == "") {
                     $this->MakeErrorMsg(ERROR_WRONG_PARAMETER, "요청페이지 파라메터가 잘못되었습니다. [CancelAmt]");
                     return;
                 } else {
                     if (trim($this->m_CancelMsg) == "") {
                         $this->MakeErrorMsg(ERROR_WRONG_PARAMETER, "요청페이지 파라메터가 잘못되었습니다. [CancelMsg]");
                         return;
                     }
                 }
             }
             $this->m_uri = "/lite/setOffProcess.jsp";
             unset($this->m_queryString);
             $this->m_queryString["MID"] = substr($this->m_TID, 0, 10);
             $this->m_queryString["TID"] = $this->m_TID;
             $this->m_queryString["CancelAmt"] = $this->m_CancelAmt;
             $this->m_queryString["CancelMsg"] = $this->m_CancelMsg;
             $this->m_queryString["PartialCancelCode"] = $this->m_PartialCancelCode;
             $this->m_queryString["ExpDate"] = $this->m_ExpDate;
             $this->m_queryString["ReqName"] = $this->m_ReqName;
             $this->m_queryString["ReqTel"] = $this->m_ReqTel;
             $NICELog->WriteLog($this->m_queryString["TID"]);
             // 빌링 승인
         } else {
             if (trim($this->m_ActionType) == "PYO" && trim($this->m_PayMethod) == "BILL") {
                 $this->m_uri = "/lite/billingProcess.jsp";
                 unset($this->m_queryString);
                 $this->m_queryString["BillKey"] = $this->m_BillKey;
                 // new
                 $this->m_queryString["BuyerName"] = $this->m_BuyerName;
                 $this->m_queryString["Amt"] = $this->m_Amt;
                 $this->m_queryString["MID"] = $this->m_MID;
                 $this->m_TID = genTID($this->m_MID, "01", "16");
                 $this->m_queryString["TID"] = $this->m_TID;
                 $this->m_queryString["EncodeKey"] = $this->m_LicenseKey;
                 $this->m_queryString["MallIP"] = $_SERVER['SERVER_NAME'];
                 $this->m_queryString["actionType"] = $this->m_ActionType;
                 $this->m_queryString["PayMethod"] = $this->m_PayMethod;
                 $this->m_queryString["Moid"] = $this->m_Moid;
                 $this->m_queryString["GoodsName"] = $this->m_GoodsName;
                 if ($this->m_charSet == "UTF8") {
                     $this->m_queryString["BuyerName"] = iconv("UTF-8", "EUC-KR", $this->m_queryString["BuyerName"]);
                     $this->m_queryString["GoodsName"] = iconv("UTF-8", "EUC-KR", $this->m_queryString["GoodsName"]);
                 }
                 $NICELog->WriteLog($this->m_queryString["TID"]);
                 // 빌키 발급
             } else {
                 if (trim($this->m_ActionType) == "PYO" && trim($this->m_PayMethod) == "BILLKEY") {
                     $this->m_uri = "/lite/billkeyProcess.jsp";
                     unset($this->m_queryString);
                     $this->m_queryString["CardNo"] = $this->m_CardNo;
                     // new
                     $this->m_queryString["ExpYear"] = $this->m_ExpYear;
                     $this->m_queryString["ExpMonth"] = $this->m_ExpMonth;
                     $this->m_queryString["IDNo"] = $this->m_IDNo;
                     $this->m_queryString["CardPw"] = $this->m_CardPw;
                     $this->m_queryString["MID"] = $this->m_MID;
                     $this->m_queryString["EncodeKey"] = $this->m_LicenseKey;
                     $this->m_queryString["MallIP"] = $_SERVER['SERVER_NAME'];
                     $this->m_queryString["actionType"] = $this->m_ActionType;
                     $this->m_queryString["PayMethod"] = $this->m_PayMethod;
                     // 지급 대행 서브몰 등록
                 } else {
                     if (trim($this->m_ActionType) == "PYO" && trim($this->m_PayMethod) == "OM_SUB_INS") {
                         $this->m_uri = "/lite/payproxy/subMallSetProcess.jsp";
                         unset($this->m_queryString);
                         $this->m_queryString = $_POST;
                         $this->m_queryString["EncodeKey"] = $this->m_LicenseKey;
                         // 서브몰 이체
                     } else {
                         if (trim($this->m_ActionType) == "PYO" && trim($this->m_PayMethod) == "OM_SUB_PAY") {
                             $this->m_uri = "/lite/payproxy/subMallIcheProcess.jsp";
                             unset($this->m_queryString);
                             $this->m_queryString = $_POST;
                             $this->m_queryString["EncodeKey"] = $this->m_LicenseKey;
                             // SMS
                         } else {
                             if (trim($this->m_ActionType) == "PYO" && trim($this->m_PayMethod) == "SMS_REQ") {
                                 $this->m_uri = "/api/sendSmsForETAX.jsp";
                                 unset($this->m_queryString);
                                 $this->m_queryString = $_POST;
                                 $this->m_queryString["EncodeKey"] = $this->m_LicenseKey;
                                 // 현금영수증,
                             } else {
                                 if (trim($this->m_ActionType) == "PYO" && trim($this->m_PayMethod) == "RECEIPT") {
                                     $this->m_uri = "/lite/cashReceiptProcess.jsp";
                                     unset($this->m_queryString);
                                     $this->m_queryString["MID"] = $this->m_MID;
                                     $this->m_queryString["TID"] = $this->m_MID . "04" . "01" . SetTimestamp1();
                                     $this->m_queryString["GoodsName"] = $this->m_GoodsName;
                                     $this->m_queryString["BuyerName"] = $this->m_BuyerName;
                                     $this->m_queryString["Amt"] = $this->m_Amt;
                                     $this->m_queryString["ReceiptAmt"] = $this->m_ReceiptAmt;
                                     $this->m_queryString["ReceiptSupplyAmt"] = $this->m_ReceiptSupplyAmt;
                                     $this->m_queryString["ReceiptVAT"] = $this->m_ReceiptVAT;
                                     $this->m_queryString["ReceiptServiceAmt"] = $this->m_ReceiptServiceAmt;
                                     $this->m_queryString["ReceiptType"] = $this->m_ReceiptType;
                                     $this->m_queryString["ReceiptTypeNo"] = $this->m_ReceiptTypeNo;
                                     $this->m_queryString["EncodeKey"] = $this->m_LicenseKey;
                                     $this->m_queryString["actionType"] = $this->m_ActionType;
                                     $this->m_queryString["PayMethod"] = $this->m_PayMethod;
                                     $this->m_queryString["CancelPwd"] = $this->m_CancelPwd;
                                     $this->m_queryString["CancelAmt"] = $this->m_Amt;
                                     $this->m_queryString["MallIP"] = $_SERVER['SERVER_NAME'];
                                     // 승인인 경우,
                                 } else {
                                     if (trim($this->m_ActionType) == "PYO" && trim($this->m_PayMethod) != "RECEIPT") {
                                         if (trim($_POST["MID"]) == "") {
                                             $this->MakeErrorMsg(ERROR_WRONG_PARAMETER, "요청페이지 파라메터가 잘못되었습니다. [MID]");
                                             return;
                                         } else {
                                             if (trim($_POST["Amt"]) == "") {
                                                 $this->MakeErrorMsg(ERROR_WRONG_PARAMETER, "요청페이지 파라메터가 잘못되었습니다. [Amt]");
                                                 return;
                                             }
                                         }
                                         $this->m_uri = "/lite/payProcess.jsp";
                                         unset($this->m_queryString);
                                         $this->m_queryString = $_POST;
                                         $this->m_queryString["EncodeKey"] = $this->m_LicenseKey;
                                         $this->m_queryString["TID"] = "";
                                         if ($this->m_charSet == "UTF8") {
                                             $this->m_queryString["BuyerName"] = iconv("UTF-8", "EUC-KR", $this->m_queryString["BuyerName"]);
                                             $this->m_queryString["GoodsName"] = iconv("UTF-8", "EUC-KR", $this->m_queryString["GoodsName"]);
                                             $this->m_queryString["BuyerAddr"] = iconv("UTF-8", "EUC-KR", $this->m_queryString["BuyerAddr"]);
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $httpclient = new HttpClient($this->m_ssl);
     //connect
     if (!$httpclient->HttpConnect($NICELog)) {
         $NICELog->WriteLog('Server Connect Error!!' . $httpclient->getErrorMsg());
         $resultMsg = $httpclient->getErrorMsg() . "서버연결을 할 수가 없습니다.";
         if ($this->m_ssl == "true") {
             $resultMsg .= "<br>귀하의 서버는 SSL통신을 지원하지 않습니다. 결제처리파일에서 m_ssl=false로 셋팅하고 시도하세오.";
             $this->MakeErrorMsg(ERR_SSLCONN, $resultMsg);
         } else {
             $this->MakeErrorMsg(ERR_CONN, $resultMsg);
         }
         $NICELog->CloseNiceLog("");
         return;
     }
     //request
     if (!$httpclient->HttpRequest($this->m_uri, $this->m_queryString, $NICELog)) {
         // 요청 오류시 처리
         $NICELog->WriteLog('POST Error!!' . $httpclient->getErrorMsg());
         $this->MakeErrorMsg(ERR_NO_RESPONSE, "서버 응답 오류");
         //NET CANCEL Start---------------------------------
         if ($httpclient->getErrorCode() == READ_TIMEOUT_ERR) {
             $NICELog->WriteLog("Net Cancel Start");
             $this->m_uri = "/lite/cancelProcess.jsp";
             unset($this->m_queryString);
             $this->m_queryString["MID"] = substr($this->m_TID, 0, 10);
             $this->m_queryString["TID"] = $this->m_TID;
             $this->m_queryString["CancelAmt"] = $this->m_NetCancelAmt;
             $this->m_queryString["CancelMsg"] = "NICE_NET_CANCEL";
             $this->m_queryString["CancelPwd"] = $this->m_NetCancelPW;
             $this->m_queryString["NetCancelCode"] = "1";
             $NICELog->WriteLog($this->m_queryString["TID"]);
             if (!$httpclient->HttpConnect($NICELog)) {
                 $NICELog->WriteLog('Server Connect Error!!' . $httpclient->getErrorMsg());
                 $resultMsg = $httpclient->getErrorMsg() . "서버연결을 할 수가 없습니다.";
                 $this->MakeErrorMsg(ERR_CONN, $resultMsg);
                 $NICELog->CloseNiceLog($this->m_resultMsg);
                 return;
             }
             if (!$httpclient->HttpRequest($this->m_uri, $this->m_queryString, $NICELog) && $httpclient->getErrorCode() == READ_TIMEOUT_ERR) {
                 $NICELog->WriteLog("Net Cancel FAIL");
                 if ($this->m_ActionType == "PYO") {
                     $this->MakeErrorMsg(ERR_NO_RESPONSE, "승인여부 확인요망");
                 } else {
                     if ($this->m_ActionType == "CLO") {
                         $this->MakeErrorMsg(ERR_NO_RESPONSE, "취소여부 확인요망");
                     }
                 }
             } else {
                 $NICELog->WriteLog("Net Cancel SUCESS");
             }
         }
         //NET CANCEL End---------------------------------
         $this->ParseMsg($httpclient->getBody(), $NICELog);
         $NICELog->CloseNiceLog($this->m_resultMsg);
         return;
     }
     if ($httpclient->getStatus() == "200") {
         $this->ParseMsg($httpclient->getBody(), $NICELog);
         $NICELog->WriteLog("TID -> " . "[" . $this->m_ResultData['TID'] . "]");
         $NICELog->WriteLog($this->m_ResultData['ResultCode'] . "[" . $this->m_ResultData['ResultMsg'] . "]");
         $NICELog->CloseNiceLog("");
     } else {
         $NICELog->WriteLog('SERVER CONNECT FAIL:' . $httpclient->getStatus() . $httpclient->getErrorMsg() . $httpclient->getHeaders());
         $resultMsg = $httpclient->getStatus() . "서버에러가 발생했습니다.";
         $this->MakeErrorMsg(ERR_NO_RESPONSE, $resultMsg);
         //NET CANCEL Start---------------------------------
         if ($httpclient->getStatus() != 200) {
             $NICELog->WriteLog("Net Cancel Start");
             //Set Field
             $this->m_uri = "/lite/cancelProcess.jsp";
             unset($this->m_queryString);
             $this->m_queryString["MID"] = substr($this->m_TID, 0, 10);
             $this->m_queryString["TID"] = $this->m_TID;
             $this->m_queryString["CancelAmt"] = $this->m_NetCancelAmt;
             $this->m_queryString["CancelMsg"] = "NICE_NET_CANCEL";
             $this->m_queryString["CancelPwd"] = $this->m_NetCancelPW;
             $this->m_queryString["NetCancelCode"] = "1";
             if (!$httpclient->HttpConnect($NICELog)) {
                 $NICELog->WriteLog('Server Connect Error!!' . $httpclient->getErrorMsg());
                 $resultMsg = $httpclient->getErrorMsg() . "서버연결을 할 수가 없습니다.";
                 $this->MakeErrorMsg(ERR_CONN, $resultMsg);
                 $NICELog->CloseNiceLog($this->m_resultMsg);
                 return;
             }
             if (!$httpclient->HttpRequest($this->m_uri, $this->m_queryString, $NICELog)) {
                 $NICELog->WriteLog("Net Cancel FAIL");
                 if ($this->m_ActionType == "PYO") {
                     $this->MakeErrorMsg(ERR_NO_RESPONSE, "승인여부 확인요망");
                 } else {
                     if ($this->m_ActionType == "CLO") {
                         $this->MakeErrorMsg(ERR_NO_RESPONSE, "취소여부 확인요망");
                     }
                 }
             } else {
                 $NICELog->WriteLog("Net Cancel SUCESS");
             }
         }
         //NET CANCEL End---------------------------------
         $this->ParseMsg($httpclient->getBody(), $NICELog);
         $NICELog->CloseNiceLog("");
         return;
     }
 }