$price = $_POST['item_amount']; $goodsname = $_POST['item_name']; $buyername = $_POST['buyername']; $buyertel = $_POST['buyertel']; $buyeremail = $_POST['buyeremail']; $merchantData = $goodsname . '***' . $_POST['item_name'] . '***' . $price . '***' . $buyername . '***' . $buyertel . '***' . $buyeremail . '***' . $orderNumber; $cardNoInterestQuota = "11-2:3:,34-5:12,14-6:12:24,12-12:36,06-9:12,01-3:4"; // 카드 무이자 여부 설정(가맹점에서 직접 설정) $cardQuotaBase = "2:3:4:5:6:11:12:24:36"; // 가맹점에서 사용할 할부 개월수 설정 //################################### // 2. 가맹점 확인을 위한 signKey를 해시값으로 변경 (SHA-256방식 사용) //################################### $mKey = $SignatureUtil->makeHash($signKey, "sha256"); $params = array("oid" => $orderNumber, "price" => $price, "timestamp" => $timestamp); $sign = $SignatureUtil->makeSignature($params, "sha256"); /* 기타 */ $referer = $_SERVER['HTTP_REFERER']; $siteDomain = site_url() . '/wp-content/plugins/simple_inicis/INIStdPaySample'; //가맹점 도메인 입력 // 페이지 URL에서 고정된 부분을 적는다. // Ex) returnURL이 http://localhost:8082/demo/INIpayStdSample/INIStdPayReturn.jsp 라면 // http://localhost:8082/demo/INIpayStdSample 까지만 기입한다. ?> <!DOCTYPE html> <html> <head> <script> function myFunction() { alert("I am an alert box!"); // this is the message in ""
/** *@brief 결제 처리 **/ function procInipaystandardDoIt() { if (!$_SESSION['inipaystandard']['transaction_srl']) { return new Object(-1, 'msg_invalid_request'); } $vars = Context::getRequestVars(); $oEpayController = getController('epay'); //결제 실패시 if (strcmp("0000", $vars->resultCode) !== 0) { /* $payArgs = new Object(-1, $resultMap["resultMsg"]); $payArgs->add('transaction_srl', $_SESSION['inipaystandard']['transaction_srl']); $payArgs->add('state', '3'); $payArgs->add('result_code', $vars->resultCode); $payArgs->add('result_message', $vars->resultMsg); $output = $oEpayController->afterPayment($payArgs); if(!$output->toBool()) return $output; */ return new Object(-1, '결제가 취소되었습니다.'); /* $return_url = substr(Context::getRequestUri() , 0, -1) . $_SESSION['inipaystandard']['error_return_url']; unset($_SESSION['inipaystandard']); header('location:' . $return_url); */ } else { if (!$vars->authUrl || !$vars->authToken) { return new Object(-1, 'msg_invalid_request'); } } $vars->transaction_srl = $_SESSION['inipaystandard']['transaction_srl']; $output = $oEpayController->beforePayment($vars); if (!$output->toBool()) { return $output; } require_once 'libs/INIStdPayUtil.php'; require_once 'libs/HttpClient.php'; $util = new INIStdPayUtil(); $httpUtil = new HttpClient(); $timestamp = $util->getTimestamp(); $signParam = array(); $signParam["authToken"] = $vars->authToken; $signParam["timestamp"] = $timestamp; $signature = $util->makeSignature($signParam); $authMap = array(); $authMap["mid"] = $this->module_info->inipay_mid; $authMap["authToken"] = $vars->authToken; $authMap["signature"] = $signature; $authMap["timestamp"] = $timestamp; $authMap["charset"] = 'UTF-8'; $authMap["format"] = 'JSON'; $authMap["price"] = $_SESSION['inipaystandard']['price']; //결제 인증 $authResultString = ''; if ($httpUtil->processHTTP($vars->authUrl, $authMap)) { $authResultString = $httpUtil->body; } else { echo "Http Connect Error\n"; echo $httpUtil->errormsg; throw new Exception("Http Connect Error"); } //인증 결과 $resultMap = json_decode($authResultString, true); //성공 if (strcmp("0000", $resultMap["resultCode"]) == 0) { $payArgs = new Object(0, $resultMap["resultMsg"]); //가상계좌 if ($this->getPaymethod($resultMap["payMethod"]) == 'VA') { $payArgs->add('state', '1'); } else { $payArgs->add('state', '2'); } } else { $payArgs = new Object(-1, $resultMap["resultMsg"]); $payArgs->add('state', '3'); } $payArgs->add('transaction_srl', $_SESSION['inipaystandard']['transaction_srl']); $payArgs->add('payment_method', $this->getPaymethod($resultMap["payMethod"])); $payArgs->add('payment_amount', $resultMap["TotPrice"]); $payArgs->add('result_code', $resultMap["resultCode"]); $payArgs->add('result_message', $resultMap["resultMsg"]); $payArgs->add('pg_tid', $resultMap["tid"]); //가상계좌 if ($this->getPaymethod($resultMap["payMethod"]) == 'VA') { $payArgs->add('vact_num', $resultMap["VACT_Num"]); $payArgs->add('vact_bankname', $this->getBankName($resultMap["VACT_BankCode"])); $payArgs->add('vact_bankcode', $resultMap["VACT_BankCode"]); $payArgs->add('vact_name', $resultMap["VACT_Name"]); $payArgs->add('vact_inputname', $resultMap["VACT_InputName"]); $payArgs->add('vact_date', $resultMap["VACT_Date"]); $payArgs->add('vact_time', $resultMap["VACT_Time"]); } $output = $oEpayController->afterPayment($payArgs); if (!$output->toBool()) { //DB 에러시 결제 취소 if (!$httpUtil->processHTTP($vars->netCancel, $authMap)) { echo "Http Connect Error\n"; echo $httpUtil->errormsg; throw new Exception("Http Connect Error"); } return $output; } $return_url = $output->get('return_url'); if ($return_url) { $this->setRedirectUrl($return_url); } unset($_SESSION['inipaystandard']); }
function wp_ajax_generate_payment_form() { global $woocommerce, $inicis_payment; $orderid = $_REQUEST['orderid']; if (!empty($this->id)) { switch ($this->id) { case 'inicis_card': case 'inicis_bank': case 'inicis_vbank': case 'inicis_hpp': case 'inicis_kpay': case 'inicis_escrow_bank': //라이브러리 존재여부 체크 if (!file_exists($inicis_payment->plugin_path() . "/lib/inipay50/INILib.php")) { wp_send_json_error(__('에러 : INILib.php 파일이 없습니다. 사이트 관리자에게 문의하여 주십시오.', 'inicis_payment')); } try { require_once $inicis_payment->plugin_path() . "/lib/inipay50/INILib.php"; } catch (Exception $e) { wp_send_json_error(__('에러 : INILib.php 파일이 없습니다. 사이트 관리자에게 문의하여 주십시오.', 'inicis_payment') . ' [' . $e->getMessage() . ']'); } //SSL 체크 $use_ssl = get_option('woocommerce_force_ssl_checkout'); //결제옵션 가져오기 $acceptmethod = $this->get_accpetmethod(); $userid = get_current_user_id(); $order = new WC_Order($orderid); $txnid = $this->make_txnid($order); $productinfo = $this->make_product_info($order); $order_total = $this->inicis_get_order_total($order); $inipay = new INIpay50(); $inipay->SetField("inipayhome", $this->settings['libfolder']); $inipay->SetField("type", "chkfake"); $inipay->SetField("debug", "true"); $inipay->SetField("enctype", "asym"); $inipay->SetField("admin", "1111"); $inipay->SetField("checkopt", "false"); $inipay->SetField("mid", $this->merchant_id); $inipay->SetField("price", $order_total); $inipay->SetField("nointerest", $this->settings['nointerest']); $inipay->SetField("quotabase", mb_convert_encoding($this->settings['quotabase'], "EUC-KR", "UTF-8")); $inipay->startAction(); if ($inipay->GetResult("ResultCode") != "00") { wp_send_json_error($inipay->GetResult("ResultMsg")); } update_post_meta($orderid, "ini_rn", $inipay->GetResult("rn")); update_post_meta($orderid, "ini_enctype", $inipay->GetResult("enctype")); if (wp_is_mobile()) { $str = "{$this->merchant_id}|{$txnid}||{$order_total}|{$productinfo}|{$order->billing_first_name}|{$order->billing_email}|||||||||||"; $hash = hash('sha512', $str); $notification = $this->encrypt_notification($txnid, $hash); ob_start(); include $inicis_payment->plugin_path() . '/templates/payment_form_mobile.php'; $form_tag = ob_get_clean(); } else { $str = "{$this->merchant_id}|{$txnid}|{$userid}|{$order_total}|{$productinfo}|{$order->billing_first_name}|{$order->billing_email}|||||||||||"; $hash = hash('sha512', $str); ob_start(); include $inicis_payment->plugin_path() . '/templates/payment_form_pc.php'; $form_tag = ob_get_clean(); } break; case 'inicis_stdcard': //웹표준 //라이브러리 존재여부 체크 if (!file_exists($inicis_payment->plugin_path() . "/lib/inistd/INIStdPayUtil.php")) { wp_send_json_error(__('에러 : INIStdPayUtil.php 파일이 없습니다. 사이트 관리자에게 문의하여 주십시오.', 'inicis_payment')); } try { require_once $inicis_payment->plugin_path() . "/lib/inistd/INIStdPayUtil.php"; } catch (Exception $e) { wp_send_json_error(__('에러 : INIStdPayUtil.php 파일이 없습니다. 사이트 관리자에게 문의하여 주십시오.', 'inicis_payment') . ' [' . $e->getMessage() . ']'); } $use_ssl = get_option('woocommerce_force_ssl_checkout'); //SSL 체크 $SignatureUtil = new INIStdPayUtil(); $mid = $this->settings['merchant_id']; if (empty($this->settings['signkey'])) { $signKey = 'SU5JTElURV9UUklQTEVERVNfS0VZU1RS'; //INIpayTest 기본값 } else { $signKey = $this->settings['signkey']; } $timestamp = $SignatureUtil->getTimestamp(); //타임스탬프 //결제옵션 가져오기 $acceptmethod = $this->get_accpetmethod(); $cardNoInterestQuota = $this->settings['nointerest']; //카드무이자 여부 설정 $cardQuotaBase = $this->settings['quotabase']; //가맹점에서 사용할 할부 개월수 설정 $mKey = $SignatureUtil->makeHash($signKey, "sha256"); $userid = get_current_user_id(); $order = new WC_Order($orderid); $txnid = $this->make_txnid($order); $productinfo = $this->make_product_info($order); $price = $this->inicis_get_order_total($order); $order_total = $this->inicis_get_order_total($order); $params = array("oid" => $txnid, "price" => $price, "timestamp" => $timestamp); $sign = $SignatureUtil->makeSignature($params, "sha256"); $str = "{$this->merchant_id}|{$txnid}|{$userid}|{$order_total}|{$productinfo}|{$order->billing_first_name}|{$order->billing_email}|||||||||||"; $hash = hash('sha512', $str); $notification = $this->encrypt_notification($txnid, $hash); $payView_type = 'overlay'; ob_start(); include $inicis_payment->plugin_path() . '/templates/payment_form_std.php'; $form_tag = ob_get_clean(); break; default: wp_send_json_error(__('결제오류 : 결제 수단이 선택되지 않았습니다 사이트 관리자에게 문의하여 주십시오', 'inicis_payment')); break; } } else { wp_send_json_error(__('결제오류 : 결제 수단이 선택되지 않았습니다 사이트 관리자에게 문의하여 주십시오', 'inicis_payment')); } wp_send_json_success('<div data-id="mshop-payment-form" style="display:none">' . $form_tag . '</div>'); }
function dispInipaystandardForm() { $oEpayController = getController('epay'); $reviewOutput = $oEpayController->reviewOrder(); if (!$reviewOutput->toBool()) { return $reviewOutput; } $payment_method = Context::get('payment_method'); $_SESSION['inipaystandard']['payment_method'] = $payment_method; $_SESSION['inipaystandard']['transaction_srl'] = $reviewOutput->transaction_srl; $_SESSION['inipaystandard']['price'] = $reviewOutput->price; $_SESSION['inipaystandard']['error_return_url'] = Context::get('error_return_url'); Context::set('order_srl', $reviewOutput->order_srl); Context::set('review_form', $reviewOutput->review_form); Context::set('item_name', $reviewOutput->item_name); Context::set('price', $reviewOutput->price); Context::set('purchaser_name', $reviewOutput->purchaser_name); Context::set('purchaser_email', $reviewOutput->purchaser_email); Context::set('purchaser_telnum', '010-0000-0000'); //payment method switch ($payment_method) { case "CC": $payment_method = "Card"; break; case "IB": $payment_method = "DirectBank"; break; case "VA": $payment_method = "VBank"; break; case "MP": $payment_method = "HPP"; break; default: $payment_method = "Card"; } Context::set('payment_method', $payment_method); if ($this->module_info->method_mobilephone == 'Y') { $HPP = '1'; } if ($this->module_info->method_mobilephone == 'M') { $HPP = '2'; } $acceptmethod = sprintf("HPP(%s):Card(0):OCB:receipt:cardpoint", $HPP); if (!$this->module_info->va_receipt || $this->module_info->va_receipt == 'Y') { $acceptmethod .= ':va_receipt'; } Context::set('acceptmethod', $acceptmethod); require_once 'libs/INIStdPayUtil.php'; $SignatureUtil = new INIStdPayUtil(); if ($this->module_info->ini_payment_test_mode == 'Y') { $inipay_mid = 'INIpayTest'; $inipay_signkey = 'SU5JTElURV9UUklQTEVERVNfS0VZU1RS'; } else { $inipay_mid = $this->module_info->inipay_mid; $inipay_signkey = $this->module_info->inipay_signkey; } $timestamp = $SignatureUtil->getTimestamp(); Context::set('timestamp', $timestamp); Context::set('pay_mid', $inipay_mid); $mKey = $SignatureUtil->makeHash($inipay_signkey, "sha256"); Context::set('mKey', $mKey); $params = array("oid" => $reviewOutput->order_srl, "price" => $reviewOutput->price, "timestamp" => $timestamp); $sign = $SignatureUtil->makeSignature($params, "sha256"); Context::set('sign', $sign); //template $template_path = sprintf("%sskins/%s/", $this->module_path, $this->module_info->skin); if (!is_dir($template_path) || !$this->module_info->skin) { $this->module_info->skin = 'default'; $template_path = sprintf("%sskins/%s/", $this->module_path, $this->module_info->skin); } $this->setTemplatePath($template_path); $this->setTemplateFile('pay'); }
// 취소 요청 tid에 따라서 유동적(가맹점 수정후 고정) $authUrl = $_REQUEST["authUrl"]; // 승인요청 API url(수신 받은 값으로 설정, 임의 세팅 금지) $netCancel = $_REQUEST["netCancelUrl"]; // 망취소 API url(수신 받은f값으로 설정, 임의 세팅 금지) $ackUrl = $_REQUEST["checkAckUrl"]; // 가맹점 내부 로직 처리후 최종 확인 API URL(수신 받은 값으로 설정, 임의 세팅 금지) //##################### // 2.signature 생성 //##################### $signParam["authToken"] = $authToken; // 필수 $signParam["timestamp"] = $timestamp; // 필수 // signature 데이터 생성 (모듈에서 자동으로 signParam을 알파벳 순으로 정렬후 NVP 방식으로 나열해 hash) $signature = $util->makeSignature($signParam); $price = ""; // 가맹점에서 최종 결제 가격 표기 (필수입력) //##################### // 3.API 요청 전문 생성 //##################### $authMap["mid"] = $mid; // 필수 $authMap["authToken"] = $authToken; // 필수 $authMap["signature"] = $signature; // 필수 $authMap["timestamp"] = $timestamp; // 필수 $authMap["charset"] = $charset; // default=UTF-8