diff --git a/adm/shop_admin/orderformcartupdate.php b/adm/shop_admin/orderformcartupdate.php index f9adc509b..de72c36b7 100644 --- a/adm/shop_admin/orderformcartupdate.php +++ b/adm/shop_admin/orderformcartupdate.php @@ -435,7 +435,7 @@ if (in_array($ct_status, $status_cancel)) { $partialCancelCode = 0; if($cancelAmt <= 0) { - $pg_res_cd = ''; + $pg_res_cd = 'NO_CANCEL_AMT'; $pg_res_msg = '취소 요청금액이 없습니다.'; break; } diff --git a/shop/nicepay/escrow.register.php b/shop/nicepay/escrow.register.php index c10ec3978..430cc0767 100644 --- a/shop/nicepay/escrow.register.php +++ b/shop/nicepay/escrow.register.php @@ -64,13 +64,14 @@ $dlv_date = isset($nice_result['ProcessDate']) ? $nice_result['ProcessDate'] : $dlv_time = isset($nice_result['ProcessTime']) ? $nice_result['ProcessTime'] : ''; // 성공이면 -if ($resultCode === 'C000') { +$escrow_register_success = ($resultCode === 'C000'); +$escrow_register_result = $nice_result; -} else { +if (!$escrow_register_success) { // C000 이 아니면 다 실패 - /* - C002 에스크로 가맹점 아님 + /* + C002 에스크로 가맹점 아님 C003 에스크로 거래만 배송등록 가능 C004 에스크로결제 신청내역 미존재 C005 에스크로배송등록 불가상태 @@ -78,5 +79,14 @@ if ($resultCode === 'C000') { C007 취소된 거래는 배송등록 불가 */ - alert('나이스페이 에스크로 배송등록이 실패했습니다.\\n\\n'.$resultCode.' : '.$resultMsg); + if (isset($od['od_id']) && $od['od_id']) { + $escrow_result_code = $resultCode !== '' ? $resultCode : 'NO_RESPONSE'; + $escrow_memo = G5_TIME_YMDHIS.' 나이스페이 에스크로 배송등록 실패 ('.$escrow_result_code.') '.$resultMsg."\n"; + $escrow_memo = sql_escape_string($escrow_memo); + $escrow_od_id = sql_escape_string($od['od_id']); + + sql_query(" update {$g5['g5_shop_order_table']} set od_shop_memo = concat(od_shop_memo, '$escrow_memo') where od_id = '$escrow_od_id' ", false); + } + + return; } diff --git a/shop/nicepay/taxsave_result.php b/shop/nicepay/taxsave_result.php index 469baef52..8452c2261 100644 --- a/shop/nicepay/taxsave_result.php +++ b/shop/nicepay/taxsave_result.php @@ -35,63 +35,7 @@ if (($useopt == 1 && !in_array(strlen($reg_num), array(10, 11, 13))) || ($useopt alert('현금영수증 발급번호를 정확히 입력해 주시기 바랍니다.'); } -if (!function_exists('nicepay_cancel_cash_receipt')) { - function nicepay_cancel_cash_receipt($tid, $order_id, $reason) - { - global $default; - - if (!$tid || !$order_id) { - return array('resultCode' => '', 'resultMsg' => '취소 요청 정보가 올바르지 않습니다.'); - } - - $ediDate = date('c', G5_SERVER_TIME); - $merchantKey = $default['de_nicepay_key']; - $data = array( - 'orderId' => $order_id, - 'reason' => $reason, - 'ediDate' => $ediDate, - 'signData' => bin2hex(hash('sha256', $tid.$ediDate.$merchantKey, true)), - 'returnCharSet' => 'utf-8' - ); - - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, 'https://api.nicepay.co.kr/v1/receipt/'.rawurlencode($tid).'/cancel'); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); - curl_setopt($ch, CURLOPT_POST, true); - curl_setopt($ch, CURLOPT_HTTPHEADER, array( - 'Content-Type: application/json;charset=utf-8', - 'Authorization: Basic '.base64_encode($default['de_nicepay_mid'].':'.$merchantKey) - )); - $response = curl_exec($ch); - curl_close($ch); - - $result = json_decode($response, true); - - if (!is_array($result)) { - return array('resultCode' => '', 'resultMsg' => '나이스페이 현금영수증 취소 응답을 확인할 수 없습니다.'); - } - - if (isset($result['signature']) && $result['signature']) { - $response_tid = isset($result['tid']) ? $result['tid'] : ''; - $response_order_id = isset($result['orderId']) ? $result['orderId'] : ''; - $response_edi_date = isset($result['ediDate']) ? $result['ediDate'] : ''; - $response_signature = bin2hex(hash('sha256', $response_tid.$response_order_id.$response_edi_date.$merchantKey, true)); - - if ($result['signature'] != $response_signature) { - $result['resultCode'] = '9998'; - $result['resultMsg'] = '현금영수증 취소 응답 유효성 검증 실패'; - } - } - - return $result; - } -} - -if($tx == 'personalpay') { +if($tx == 'personalpay') { $od = sql_fetch(" select * from {$g5['g5_shop_personalpay_table']} where pp_id = '$od_id' "); if (!$od) die('

개인결제 내역이 존재하지 않습니다.

'); @@ -220,15 +164,7 @@ if ($result_code === '7001') { $sql_result = sql_query($sql, false); if (!$sql_result) { - $cancel_result = nicepay_cancel_cash_receipt($result_tid, $moid, '쇼핑몰 DB 반영 실패'); - $cancel_code = isset($cancel_result['resultCode']) ? $cancel_result['resultCode'] : ''; - $cancel_msg = isset($cancel_result['resultMsg']) ? $cancel_result['resultMsg'] : ''; - - if ($cancel_code === '0000') { - alert_close('현금영수증은 나이스페이에 발급 요청되었으나 쇼핑몰 DB 반영에 실패하여 자동 취소를 요청했습니다.\\n관리자에게 문의해 주세요.\\n현금영수증 거래번호 : '.$result_tid); - } - - alert_close('현금영수증은 나이스페이에 발급 요청되었으나 쇼핑몰 DB 반영에 실패했습니다.\\n자동 취소 요청도 정상적으로 완료되지 않았습니다.\\n관리자에게 문의해 주세요.\\n현금영수증 거래번호 : '.$result_tid.'\\n취소 응답 : '.$cancel_code.' '.$cancel_msg); + alert_close('현금영수증은 나이스페이에 발급 요청되었으나 쇼핑몰 DB 반영에 실패했습니다.\\n나이스페이 관리자에서 현금영수증 발급 상태를 확인하고 필요 시 수동 취소해 주세요.\\n현금영수증 거래번호 : '.$result_tid); } } else {