Update orderpay.step2.pgkcp.php

This commit is contained in:
Namhyeon Go 2018-11-11 03:54:02 +09:00 committed by GitHub
parent 50be46089e
commit 856b400d7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,8 +14,10 @@ if(check_token_abuse_by_requests("_token", "_POST")) {
show_errors(); show_errors();
} }
loadHelper("webpagetool"); // load webpage tools
loadHelper("networktool"); // load network tools loadHelper("networktool"); // load network tools
loadHelper("pgkcp.lnk"); // load KCP PG Helper loadHelper("string.utl"); // load string utility
loadHelper("pgkcp.lnk"); // load KCP PG Helper
loadHelper("JSLoader.class"); // load javascript loader loadHelper("JSLoader.class"); // load javascript loader
// load PGKCP configuration // load PGKCP configuration
@ -29,66 +31,77 @@ load_pgkcp_library();
// 01. 지불 요청 정보 설정 // 01. 지불 요청 정보 설정
$payres = array(); $payres = array();
$payinfo = array( $payinfo = array();
"req_tx" => get_requested_value("req_tx"), $fieldnames = array(
"tran_cd" => get_requested_value("tran_cd"), "req_tx",
"cust_ip" => get_network_client_addr(), "tran_cd",
"ordr_idxx" => get_requested_value("ordr_idxx"), "cust_ip",
"good_name" => get_requested_value("good_name"), "ordr_idxx",
"res_cd" => "", "good_name",
"res_msg" => "", "res_cd",
"res_en_msg" => "", "res_msg",
"tno" => get_requested_value("tno"), "res_en_msg",
"buyr_name" => get_requested_value("buyr_name"), "tno",
"buyr_tel1" => get_requested_value("buyr_tel1"), "buyr_name",
"buyr_tel2" => get_requested_value("buyr_tel2"), "buyr_tel1",
"buyr_mail" => get_requested_value("buyr_mail"), "buyr_tel2",
"use_pay_method_alias" => "", "buyr_mail",
"use_pay_method" => get_requested_value("use_pay_method"), "pay_method_alias",
"bSucc" => "", "pay_method",
"app_time" => "", "use_pay_method",
"amount" => "", "bSucc",
"total_amount" => 0, "app_time",
"coupon_mny" => "", "amount",
"app_time" => "", "total_amount",
"amount" => "", "coupon_mny",
"total_amount" => 0, "app_time",
"coupon_mny" => "", "amount",
"card_cd" => "", "total_amount",
"card_name" => "", "coupon_mny",
"app_no" => "", "card_cd",
"noinf" => "", "card_name",
"quota" => "", "app_no",
"partcanc_yn" => "", "noinf",
"card_bin_type_01" => "", "quota",
"card_bin_type_02" => "", "partcanc_yn",
"card_mny" => "", "card_bin_type_01",
"bank_name" => "", "card_bin_type_02",
"bank_code" => "", "card_mny",
"bk_mny" => "", "bank_name",
"bankname" => "", "bank_code",
"depositor" => "", "bk_mny",
"account" => "", "bankname",
"va_date" => "", "depositor",
"pnt_issue" => "", "account",
"pnt_amount" => "", "va_date",
"pnt_app_time" => "", "pnt_issue",
"pnt_app_no" => "", "pnt_amount",
"add_pnt" => "", "pnt_app_time",
"use_pnt" => "", "pnt_app_no",
"rsv_pnt" => "", "add_pnt",
"commid" => "", "use_pnt",
"mobile_no" => "", "rsv_pnt",
"shop_user_id" => get_requested_value("shop_user_id"), "commid",
"tk_van_code" => "", "mobile_no",
"tk_app_no" => "", "shop_user_id",
"cash_yn" => get_requested_value("cash_yn"), "tk_van_code",
"cash_authno" => "", "tk_app_no",
"cash_tr_code" => get_requested_value("cash_tr_code"), "cash_yn",
"cash_id_info" => get_requested_value("cash_id_info"), "cash_authno",
"cash_no" => get_requested_value("cash_no"), "cash_tr_code",
"pay_data" => get_requested_value("pay_data") "cash_id_info",
"cash_no",
"pay_data"
); );
foreach($fieldnames as $name) {
$payinfo[$name] = make_safe_argument(get_requested_value($name));
}
// set current ip address
$payinfo['cust_ip'] = get_network_client_addr();
// set converted result message
$payinfo['res_msg'] = get_converted_string($payinfo['res_msg'], "utf-8", "cp949");
// extract payinfo // extract payinfo
extract($payinfo); extract($payinfo);
@ -136,7 +149,7 @@ if($req_tx == "pay") {
$payres['amount'] = $c_PayPlus->mf_get_res_data("amount"); // KCP 실제 거래 금액 $payres['amount'] = $c_PayPlus->mf_get_res_data("amount"); // KCP 실제 거래 금액
$payres['pnt_issue'] = $c_PayPlus->mf_get_res_data("pnt_issue"); // 결제 포인트사 코드 $payres['pnt_issue'] = $c_PayPlus->mf_get_res_data("pnt_issue"); // 결제 포인트사 코드
$payres['coupon_mny'] = $c_PayPlus->mf_get_res_data("coupon_mny" ); // 쿠폰금액 $payres['coupon_mny'] = $c_PayPlus->mf_get_res_data("coupon_mny" ); // 쿠폰금액
switch($use_pay_method) { switch($use_pay_method) {
case "100000000000": // 05-1. 신용카드 승인 결과 처리 case "100000000000": // 05-1. 신용카드 승인 결과 처리
$payres['card_cd'] = $c_PayPlus->mf_get_res_data( "card_cd" ); // 카드사 코드 $payres['card_cd'] = $c_PayPlus->mf_get_res_data( "card_cd" ); // 카드사 코드
@ -149,7 +162,7 @@ if($req_tx == "pay") {
$payres['card_bin_type_01'] = $c_PayPlus->mf_get_res_data( "card_bin_type_01" ); // 카드구분1 $payres['card_bin_type_01'] = $c_PayPlus->mf_get_res_data( "card_bin_type_01" ); // 카드구분1
$payres['card_bin_type_02'] = $c_PayPlus->mf_get_res_data( "card_bin_type_02" ); // 카드구분2 $payres['card_bin_type_02'] = $c_PayPlus->mf_get_res_data( "card_bin_type_02" ); // 카드구분2
$payres['card_mny'] = $c_PayPlus->mf_get_res_data( "card_mny" ); // 카드결제금액 $payres['card_mny'] = $c_PayPlus->mf_get_res_data( "card_mny" ); // 카드결제금액
// 05-1.1. 복합결제(포인트+신용카드) 승인 결과 처리 // 05-1.1. 복합결제(포인트+신용카드) 승인 결과 처리
if(in_array($pnt_issue, array("SCSK", "SCWB"))) { if(in_array($pnt_issue, array("SCSK", "SCWB"))) {
$payres['pnt_amount'] = $c_PayPlus->mf_get_res_data ( "pnt_amount" ); // 적립금액 or 사용금액 $payres['pnt_amount'] = $c_PayPlus->mf_get_res_data ( "pnt_amount" ); // 적립금액 or 사용금액
@ -203,18 +216,16 @@ if($req_tx == "pay") {
break; // END 05-6 break; // END 05-6
} }
// 05-7. 현금영수증 결과 처리 // 05-7. 현금영수증 결과 처리
$payres['cash_authno'] = $c_PayPlus->mf_get_res_data( "cash_authno" ); // 현금 영수증 승인 번호 $payres['cash_authno'] = $c_PayPlus->mf_get_res_data( "cash_authno" ); // 현금 영수증 승인 번호
$payres['cash_no'] = $c_PayPlus->mf_get_res_data( "cash_no" ); // 현금 영수증 거래 번호 $payres['cash_no'] = $c_PayPlus->mf_get_res_data( "cash_no" ); // 현금 영수증 거래 번호
} }
} }
// extract result // checking vaild payment method
extract($payres); $res_succ_flag = false;
$pay_method_alias = get_value_in_array("pay_method_alias", $payinfo, "");
// process database
$use_pay_method_alias = get_value_in_array("use_pay_method_alias", $payinfo, "");
$pay_method_rules = array( $pay_method_rules = array(
"CRE" => "100000000000", // 신용카드 "CRE" => "100000000000", // 신용카드
"ACC" => "010000000000", // 계좌이체 "ACC" => "010000000000", // 계좌이체
@ -223,18 +234,20 @@ $pay_method_rules = array(
"PHO" => "000010000000", // 휴대폰 "PHO" => "000010000000", // 휴대폰
"GIF" => "000000001000", // 상품권 "GIF" => "000000001000", // 상품권
"ARS" => "000000000010", // ARS "ARS" => "000000000010", // ARS
"CAV" => "111000000000" // 신용카드/계좌이체/가상계좌 "CAV" => "111000000000", // 신용카드/계좌이체/가상계좌
"NOP" => "" // 수기결제/무통장입금
); );
if(in_array($pay_method_rules, array_values($pay_method_rules))) { foreach($pay_method_rules as $k=>$v) {
foreach($pay_method_rules as $k=>$v) { if($pay_method_alias == $k) {
if($use_pay_method == $v) { $payres['use_pay_method_alias'] = $k;
$use_pay_method_alias = $k; $res_succ_flag = true;
} break;
} }
$payres['bSucc'] = "true";
} else {
$payres['bSucc'] = "false";
} }
$payres['bSucc'] = $res_succ_flag ? "true" : "false";
// set result
extract($payres);
// cancel payment when failed // cancel payment when failed
if($req_tx == "pay") { if($req_tx == "pay") {
@ -261,13 +274,14 @@ if($req_tx == "pay") {
} }
} // End of [res_cd = "0000"] } // End of [res_cd = "0000"]
// extract result // set result
extract($payres); extract($payres);
// 08. 폼 구성 및 결과페이지 호출 // 08. 폼 구성 및 결과페이지 호출
// set javascript files // set javascript files
$jsloader = new JSLoader(); $jsloader = new JSLoader();
$jsloader->add_scripts(get_webproxy_url("https://code.jquery.com/jquery-3.3.1.min.js"));
$jsloader->add_scripts(base_url() . "view/public/js/route/orderpay.step2.pgkcp.js"); $jsloader->add_scripts(base_url() . "view/public/js/route/orderpay.step2.pgkcp.js");
$jsoutput = $jsloader->get_output(); $jsoutput = $jsloader->get_output();
$data['jsoutput'] = $jsoutput; $data['jsoutput'] = $jsoutput;