Mobile API integration


API integration

In API integration section, API type integration guide is provided.

Call Payment Window – Authentication Data Receive – Payment Request – Payment Result Process
Please check the PC Standard Web Payment Integration Guide through 4 STEP

API Download

Refer to Download menu for library and integration sample codes.


Transaction Registration

Transaction registration is required to call NHN KCP Mobile standard payment page.

Transaction registration is used to receive configurations and transaction data from the merchant
and by doing so NHN KCP will be able to check validity of the request and create redirect URL to call mobile payment page.

If the request is sent as json format the response will be as json.

Authentication request data is sent as Json String

<!-- Call Transaction registration -->

1https://spl.kcp.co.kr/std/tradeReg/register

Test : https://stg-spl.kcp.co.kr/std/tradeReg/register


Transaction registration parameter

Registration Parameter

stringvar

kcp_cert_info

Serialized KCP Server Certificate


string5

site_cd

Merchant ID


string40

ordr_idxx

Merchant order number


string12

good_mny

Payment Amount


string12

pay_method

Payment Method Code (Capital letter)
- Credit Card : CARD
- Bank Transfer : BANK
- Virtual Account : VCNT
- Mobile Billing : MOBX


string100

good_name

Product Name


string256

Ret_URL

Return Merchant page url


string1

escw_used

escw_used Y/N


string40

user_agent

OS user agent value

registration response

string4

Result code

Result code


string100

Message

Result message


stringvar

approvalKey

approvalKey value


stringvar

PayUrl

KCP Hosted Page URL


stringvar

hashData

HashData


stringvar

traceNo

Trace mumber


stringvar

paymentMethod

Payment Method Code (Capital letter)
- Credit Card : CARD
- Bank Transfer : BANK
- Virtual Account : VCNT
- Mobile Billing : MOBX


stringvar

request_URI

Request url

Registration code sample

<%@ page language="java" contentType="text/html;charset=euc-kr"%>
<%!
    /* null */
        public String f_get_parm( String val )
        {
          if ( val == null ) val = "";
          return  val;
        }
%>
<%
    request.setCharacterEncoding( "euc-kr" );
    /*
    ==========================================================================
     API URL
    --------------------------------------------------------------------------
    */
    String target_URL = "https://stg-spl.kcp.co.kr/std/tradeReg/register"; //dev
    //String target_URL = "https://spl.kcp.co.kr/std/tradeReg/register"; //prod
    /*
    ==========================================================================
    request
    --------------------------------------------------------------------------
    */
    String site_cd              = f_get_parm( request.getParameter( "site_cd"  ));

    String kcp_cert_info        = "-----BEGIN CERTIFICATE-----MIIDgTCCAmmgAwIBAgIHBy4lYNG7ojANBgkqhkiG9w0BAQsFADBzMQswCQYDVQQGEwJLUjEOMAwGA1UECAwFU2VvdWwxEDAOBgNVBAcMB0d1cm8tZ3UxFTATBgNVBAoMDE5ITktDUCBDb3JwLjETMBEGA1UECwwKSVQgQ2VudGVyLjEWMBQGA1UEAwwNc3BsLmtjcC5jby5rcjAeFw0yMTA2MjkwMDM0MzdaFw0yNjA2MjgwMDM0MzdaMHAxCzAJBgNVBAYTAktSMQ4wDAYDVQQIDAVTZW91bDEQMA4GA1UEBwwHR3Vyby1ndTERMA8GA1UECgwITG9jYWxXZWIxETAPBgNVBAsMCERFVlBHV0VCMRkwFwYDVQQDDBAyMDIxMDYyOTEwMDAwMDI0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAppkVQkU4SwNTYbIUaNDVhu2w1uvG4qip0U7h9n90cLfKymIRKDiebLhLIVFctuhTmgY7tkE7yQTNkD+jXHYufQ/qj06ukwf1BtqUVru9mqa7ysU298B6l9v0Fv8h3ztTYvfHEBmpB6AoZDBChMEua7Or/L3C2vYtU/6lWLjBT1xwXVLvNN/7XpQokuWq0rnjSRThcXrDpWMbqYYUt/CL7YHosfBazAXLoN5JvTd1O9C3FPxLxwcIAI9H8SbWIQKhap7JeA/IUP1Vk4K/o3Yiytl6Aqh3U1egHfEdWNqwpaiHPuM/jsDkVzuS9FV4RCdcBEsRPnAWHz10w8CX7e7zdwIDAQABox0wGzAOBgNVHQ8BAf8EBAMCB4AwCQYDVR0TBAIwADANBgkqhkiG9w0BAQsFAAOCAQEAg9lYy+dM/8Dnz4COc+XIjEwr4FeC9ExnWaaxH6GlWjJbB94O2L26arrjT2hGl9jUzwd+BdvTGdNCpEjOz3KEq8yJhcu5mFxMskLnHNo1lg5qtydIID6eSgew3vm6d7b3O6pYd+NHdHQsuMw5S5z1m+0TbBQkb6A9RKE1md5/Yw+NymDy+c4NaKsbxepw+HtSOnma/R7TErQ/8qVioIthEpwbqyjgIoGzgOdEFsF9mfkt/5k6rR0WX8xzcro5XSB3T+oecMS54j0+nHyoS96/llRLqFDBUfWn5Cay7pJNWXCnw4jIiBsTBa3q95RVRyMEcDgPwugMXPXGBwNoMOOpuQ==-----END CERTIFICATE-----";
    String ordr_idxx            = f_get_parm( request.getParameter( "ordr_idxx" ));
    String good_mny             = f_get_parm( request.getParameter( "good_mny" ));
    String good_name            = f_get_parm( request.getParameter( "good_name" ));
    String pay_method           = f_get_parm( request.getParameter( "pay_method" ));
    String Ret_URL              = f_get_parm( request.getParameter( "Ret_URL" ));
    /* ============================================================================== */
    String actionResult         = f_get_parm( request.getParameter( "ActionResult" ));
    String van_code             = f_get_parm( request.getParameter( "van_code" ));

    JSONObject json_req = new JSONObject();

    json_req.put("site_cd", site_cd);
    json_req.put("kcp_cert_info", kcp_cert_info);
    json_req.put("ordr_idxx", ordr_idxx);
    json_req.put("good_mny", good_mny);
    json_req.put("good_name", good_name);
    json_req.put("pay_method", pay_method);
    json_req.put("Ret_URL", Ret_URL);
    json_req.put("escw_used", "N");
    json_req.put("user_agent", "");

    String temp_req_param = json_req.toString();
    String req_param = temp_req_param.replace(",",",\r\n");

    String inputLine = null;
    StringBuffer outResult = new StringBuffer();

    try
    {
        // API REQ
        URL url = new URL(target_URL);
        HttpURLConnection conn = (HttpURLConnection)url.openConnection();
        conn.setDoOutput(true);
        conn.setRequestMethod("POST");
        conn.setRequestProperty("Content-Type", "application/json");
        conn.setRequestProperty("Accept-Charset", "UTF-8");

        OutputStream os = conn.getOutputStream();
        os.write(req_param.getBytes("UTF-8"));
        os.flush();

        // API RES
        BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
        while ((inputLine = in.readLine()) != null)
        {
            outResult.append(inputLine);
        }
        conn.disconnect();
    }
    catch(Exception e)
    {
        e.printStackTrace();
    }

    String temp_result = outResult.toString();
    String res_param = temp_result.replace(",",",\r\n");


    String res_cd      = "";
    String res_msg     = "";
    String approvalKey = "";
    String traceNo     = "";
    String PayUrl      = ""; //  PAY URL

    // RES JSON DATA Parsing
    JSONParser parser = new JSONParser();
    JSONObject json_res = (JSONObject)parser.parse(temp_result);

    res_cd      = (String)json_res.get("Code");
    res_msg     = (String)json_res.get("Message");
    approvalKey = (String)json_res.get("approvalKey");
    traceNo     = (String)json_res.get("traceNo");
    PayUrl      = (String)json_res.get("PayUrl");

%>
<?php
    header("Content-type: text/html; charset=utf-8");
    /*
     ==========================================================================
          API URL
     --------------------------------------------------------------------------
     */
    $target_URL = "https://stg-spl.kcp.co.kr/std/tradeReg/register"; //dev
    //$target_URL = "https://spl.kcp.co.kr/std/tradeReg/register"; //prod
    /*
    ==========================================================================
    request
    --------------------------------------------------------------------------
    */
    $site_cd            = $_POST[ "site_cd"  ];

    $kcp_cert_info      = "-----BEGIN CERTIFICATE-----MIIDgTCCAmmgAwIBAgIHBy4lYNG7ojANBgkqhkiG9w0BAQsFADBzMQswCQYDVQQGEwJLUjEOMAwGA1UECAwFU2VvdWwxEDAOBgNVBAcMB0d1cm8tZ3UxFTATBgNVBAoMDE5ITktDUCBDb3JwLjETMBEGA1UECwwKSVQgQ2VudGVyLjEWMBQGA1UEAwwNc3BsLmtjcC5jby5rcjAeFw0yMTA2MjkwMDM0MzdaFw0yNjA2MjgwMDM0MzdaMHAxCzAJBgNVBAYTAktSMQ4wDAYDVQQIDAVTZW91bDEQMA4GA1UEBwwHR3Vyby1ndTERMA8GA1UECgwITG9jYWxXZWIxETAPBgNVBAsMCERFVlBHV0VCMRkwFwYDVQQDDBAyMDIxMDYyOTEwMDAwMDI0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAppkVQkU4SwNTYbIUaNDVhu2w1uvG4qip0U7h9n90cLfKymIRKDiebLhLIVFctuhTmgY7tkE7yQTNkD+jXHYufQ/qj06ukwf1BtqUVru9mqa7ysU298B6l9v0Fv8h3ztTYvfHEBmpB6AoZDBChMEua7Or/L3C2vYtU/6lWLjBT1xwXVLvNN/7XpQokuWq0rnjSRThcXrDpWMbqYYUt/CL7YHosfBazAXLoN5JvTd1O9C3FPxLxwcIAI9H8SbWIQKhap7JeA/IUP1Vk4K/o3Yiytl6Aqh3U1egHfEdWNqwpaiHPuM/jsDkVzuS9FV4RCdcBEsRPnAWHz10w8CX7e7zdwIDAQABox0wGzAOBgNVHQ8BAf8EBAMCB4AwCQYDVR0TBAIwADANBgkqhkiG9w0BAQsFAAOCAQEAg9lYy+dM/8Dnz4COc+XIjEwr4FeC9ExnWaaxH6GlWjJbB94O2L26arrjT2hGl9jUzwd+BdvTGdNCpEjOz3KEq8yJhcu5mFxMskLnHNo1lg5qtydIID6eSgew3vm6d7b3O6pYd+NHdHQsuMw5S5z1m+0TbBQkb6A9RKE1md5/Yw+NymDy+c4NaKsbxepw+HtSOnma/R7TErQ/8qVioIthEpwbqyjgIoGzgOdEFsF9mfkt/5k6rR0WX8xzcro5XSB3T+oecMS54j0+nHyoS96/llRLqFDBUfWn5Cay7pJNWXCnw4jIiBsTBa3q95RVRyMEcDgPwugMXPXGBwNoMOOpuQ==-----END CERTIFICATE-----";
    $ordr_idxx          = $_POST[ "ordr_idxx" ];
    $good_mny           = $_POST[ "good_mny" ];
    $good_name          = $_POST[ "good_name" ];
    $pay_method         = $_POST[ "pay_method" ];
    $Ret_URL            = $_POST[ "Ret_URL" ];
    /* ============================================================================== */
    $actionResult       = $_POST[ "ActionResult" ];
    $van_code           = $_POST[ "van_code" ];

    $data = [
        'site_cd'        => $site_cd,
        'kcp_cert_info'  => $kcp_cert_info,
        'ordr_idxx'      => $ordr_idxx,
        'good_mny'       => $good_mny,
        'good_name'      => $$good_name,
        'pay_method'     => $pay_method,
        'Ret_URL'        => $Ret_URL,
        'escw_used'      => 'N',
        'user_agent'     => ''
    ];

    $req_data = json_encode($data);

    $header_data = array( "Content-Type: application/json", "charset=utf-8" );

    // API REQ
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $target_URL);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header_data);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($ch, CURLOPT_POSTFIELDS, $req_data);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

    // API RES
    $res_data  = curl_exec($ch);

    $res_cd      = "";
    $res_msg     = "";
    $approvalKey = "";
    $traceNo     = "";
    $PayUrl      = ""; //  PAY URL

    // RES JSON DATA Parsing
    $json_res = json_decode($res_data, true);

    $res_cd      = $json_res["Code"];
    $res_msg     = $json_res["Message"];
    $approvalKey = $json_res["approvalKey"];
    $traceNo     = $json_res["traceNo"];
    $PayUrl      = $json_res["PayUrl"];

    curl_close($ch);
?>
using System;
namespace Payment
{
    public partial class Kcp_api_trade_reg : System.Web.UI.Page
    {
        protected string site_cd;
        protected string kcp_cert_info;
        protected string ordr_idxx;
        protected string good_mny;
        protected string good_name;
        protected string pay_method;
        protected string Ret_URL;       // URL

        protected string actionResult;
        protected string van_code;

        protected string target_URL;

        protected string req_data;
        protected string res_data;

        protected string res_cd;
        protected string res_msg;
        protected string approvalKey;
        protected string traceNo;
        protected string PayUrl;      // PAY URL

        protected void Page_Load(object sender, EventArgs e)
        {
            /* ============================================================================== */
            /* =    API URL                                                         = */
            /* = -------------------------------------------------------------------------- = */
            target_URL = "https://stg-spl.kcp.co.kr/std/tradeReg/register"; // dev
            //target_URL = "https://spl.kcp.co.kr/std/tradeReg/register"; // prod
            /* ============================================================================== */
            /* =  request                                                                  = */
            /* = -------------------------------------------------------------------------- = */
            site_cd = Request.Form["site_cd"];

            kcp_cert_info = "-----BEGIN CERTIFICATE-----MIIDgTCCAmmgAwIBAgIHBy4lYNG7ojANBgkqhkiG9w0BAQsFADBzMQswCQYDVQQGEwJLUjEOMAwGA1UECAwFU2VvdWwxEDAOBgNVBAcMB0d1cm8tZ3UxFTATBgNVBAoMDE5ITktDUCBDb3JwLjETMBEGA1UECwwKSVQgQ2VudGVyLjEWMBQGA1UEAwwNc3BsLmtjcC5jby5rcjAeFw0yMTA2MjkwMDM0MzdaFw0yNjA2MjgwMDM0MzdaMHAxCzAJBgNVBAYTAktSMQ4wDAYDVQQIDAVTZW91bDEQMA4GA1UEBwwHR3Vyby1ndTERMA8GA1UECgwITG9jYWxXZWIxETAPBgNVBAsMCERFVlBHV0VCMRkwFwYDVQQDDBAyMDIxMDYyOTEwMDAwMDI0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAppkVQkU4SwNTYbIUaNDVhu2w1uvG4qip0U7h9n90cLfKymIRKDiebLhLIVFctuhTmgY7tkE7yQTNkD+jXHYufQ/qj06ukwf1BtqUVru9mqa7ysU298B6l9v0Fv8h3ztTYvfHEBmpB6AoZDBChMEua7Or/L3C2vYtU/6lWLjBT1xwXVLvNN/7XpQokuWq0rnjSRThcXrDpWMbqYYUt/CL7YHosfBazAXLoN5JvTd1O9C3FPxLxwcIAI9H8SbWIQKhap7JeA/IUP1Vk4K/o3Yiytl6Aqh3U1egHfEdWNqwpaiHPuM/jsDkVzuS9FV4RCdcBEsRPnAWHz10w8CX7e7zdwIDAQABox0wGzAOBgNVHQ8BAf8EBAMCB4AwCQYDVR0TBAIwADANBgkqhkiG9w0BAQsFAAOCAQEAg9lYy+dM/8Dnz4COc+XIjEwr4FeC9ExnWaaxH6GlWjJbB94O2L26arrjT2hGl9jUzwd+BdvTGdNCpEjOz3KEq8yJhcu5mFxMskLnHNo1lg5qtydIID6eSgew3vm6d7b3O6pYd+NHdHQsuMw5S5z1m+0TbBQkb6A9RKE1md5/Yw+NymDy+c4NaKsbxepw+HtSOnma/R7TErQ/8qVioIthEpwbqyjgIoGzgOdEFsF9mfkt/5k6rR0WX8xzcro5XSB3T+oecMS54j0+nHyoS96/llRLqFDBUfWn5Cay7pJNWXCnw4jIiBsTBa3q95RVRyMEcDgPwugMXPXGBwNoMOOpuQ==-----END CERTIFICATE-----";
            ordr_idxx     = Request.Form["ordr_idxx"];
            good_mny      = Request.Form["good_mny"];
            good_name     = Request.Form["good_name"];
            pay_method    = Request.Form["pay_method"];
            Ret_URL       = Request.Form["Ret_URL"];
            /* ============================================================================== */
            actionResult  = Request.Form["ActionResult"];
            van_code      = Request.Form["van_code"];

            req_data = "{\"site_cd\" : \"" + site_cd + "\"," +
                                  "\"kcp_cert_info\":\"" + kcp_cert_info + "\"," +
                                  "\"ordr_idxx\":\"" + ordr_idxx + "\"," +
                                  "\"good_mny\":\"" + good_mny + "\"," +
                                  "\"good_name\":\"" + good_name + "\"," +
                                  "\"pay_method\":\"" + pay_method + "\"," +
                                  "\"Ret_URL\":\"" + Ret_URL + "\"," +
                                  "\"escw_used\":\"N\"," +
                                  "\"user_agent\":\"\"}";

            Console.WriteLine(req_data);
            // SSL/ TLS
            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
            ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

            // API REQ
            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(target_URL);
            req.Method         = "POST";
            req.ContentType    = "application/json";

            byte[] byte_req = Encoding.UTF8.GetBytes(req_data);
            req.ContentLength = byte_req.Length;

            Stream st = req.GetRequestStream();
            st.Write(byte_req, 0, byte_req.Length);
            st.Close();

            // API RES
            HttpWebResponse res = (HttpWebResponse)req.GetResponse();
            StreamReader st_read = new StreamReader(res.GetResponseStream(), Encoding.GetEncoding("utf-8"));
            res_data = st_read.ReadToEnd();

            st_read.Close();
            res.Close();

            // RES JSON DATA Parsing
            JObject json_data = JObject.Parse(res_data);

            res_cd      = json_data["Code"].ToString();
            res_msg     = json_data["Message"].ToString();
            approvalKey = json_data["approvalKey"].ToString();
            traceNo     = json_data["traceNo"].ToString();
            PayUrl      = json_data["PayUrl"].ToString();

        }
    }
}
<!--#include file="../lib/json2.asp"-->
<%
    Response.CharSet = "UTF-8"

    '==========================================================================
    ' API URL
    '--------------------------------------------------------------------------

    target_URL = "https://stg-spl.kcp.co.kr/std/tradeReg/register" 'dev
    'target_URL = "https://spl.kcp.co.kr/std/tradeReg/register" 'prod



    site_cd              = trim(request( "site_cd"  ))

    kcp_cert_info        = "-----BEGIN CERTIFICATE-----MIIDgTCCAmmgAwIBAgIHBy4lYNG7ojANBgkqhkiG9w0BAQsFADBzMQswCQYDVQQGEwJLUjEOMAwGA1UECAwFU2VvdWwxEDAOBgNVBAcMB0d1cm8tZ3UxFTATBgNVBAoMDE5ITktDUCBDb3JwLjETMBEGA1UECwwKSVQgQ2VudGVyLjEWMBQGA1UEAwwNc3BsLmtjcC5jby5rcjAeFw0yMTA2MjkwMDM0MzdaFw0yNjA2MjgwMDM0MzdaMHAxCzAJBgNVBAYTAktSMQ4wDAYDVQQIDAVTZW91bDEQMA4GA1UEBwwHR3Vyby1ndTERMA8GA1UECgwITG9jYWxXZWIxETAPBgNVBAsMCERFVlBHV0VCMRkwFwYDVQQDDBAyMDIxMDYyOTEwMDAwMDI0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAppkVQkU4SwNTYbIUaNDVhu2w1uvG4qip0U7h9n90cLfKymIRKDiebLhLIVFctuhTmgY7tkE7yQTNkD+jXHYufQ/qj06ukwf1BtqUVru9mqa7ysU298B6l9v0Fv8h3ztTYvfHEBmpB6AoZDBChMEua7Or/L3C2vYtU/6lWLjBT1xwXVLvNN/7XpQokuWq0rnjSRThcXrDpWMbqYYUt/CL7YHosfBazAXLoN5JvTd1O9C3FPxLxwcIAI9H8SbWIQKhap7JeA/IUP1Vk4K/o3Yiytl6Aqh3U1egHfEdWNqwpaiHPuM/jsDkVzuS9FV4RCdcBEsRPnAWHz10w8CX7e7zdwIDAQABox0wGzAOBgNVHQ8BAf8EBAMCB4AwCQYDVR0TBAIwADANBgkqhkiG9w0BAQsFAAOCAQEAg9lYy+dM/8Dnz4COc+XIjEwr4FeC9ExnWaaxH6GlWjJbB94O2L26arrjT2hGl9jUzwd+BdvTGdNCpEjOz3KEq8yJhcu5mFxMskLnHNo1lg5qtydIID6eSgew3vm6d7b3O6pYd+NHdHQsuMw5S5z1m+0TbBQkb6A9RKE1md5/Yw+NymDy+c4NaKsbxepw+HtSOnma/R7TErQ/8qVioIthEpwbqyjgIoGzgOdEFsF9mfkt/5k6rR0WX8xzcro5XSB3T+oecMS54j0+nHyoS96/llRLqFDBUfWn5Cay7pJNWXCnw4jIiBsTBa3q95RVRyMEcDgPwugMXPXGBwNoMOOpuQ==-----END CERTIFICATE-----"
    ordr_idxx            = trim(request( "ordr_idxx" ))
    good_mny             = trim(request( "good_mny" ))
    good_name            = trim(request( "good_name" ))
    pay_method           = trim(request( "pay_method" ))
    Ret_URL              = trim(request( "Ret_URL" ))
    '==========================================================================
    actionResult         = trim(request( "ActionResult" ))
    van_code             = trim(request( "van_code" ))


    req_data = "{""site_cd"":""" & site_cd & """,""kcp_cert_info"":""" & kcp_cert_info & """,""ordr_idxx"":""" & ordr_idxx & """,""good_mny"":""" & good_mny & """,""ordr_mony"":""" & ordr_mony & """,""good_name"":""" & good_name & """,""pay_method"":""" & pay_method & """,""Ret_URL"":""" & Ret_URL & """,""escw_used"":""N"",""user_agent"":""""}"

    ' API REQ
    set req = Server.CreateObject("MSXML2.ServerXMLHTTP")
    req.open "POST", target_URL, false
    req.setRequestHeader "Content-Type", "application/json;charset=UTF-8"
    req.send req_data

    ' API RES
    if req.status = 200 then
        res_data = req.ResponseText
    else
        res_data = "http error code : " & req.status
    end if

    set req = nothing

    res_cd      = ""
    res_msg     = ""
    approvalKey = ""
    traceNo     = ""
    PayUrl      = "" 'PAY URL

    ' RES JSON DATA Parsing
    '' RES JSON DATA Parsing
    set json_data = JSON.parse(res_data)

    res_cd      = json_data.Code
    res_msg     = json_data.Message
    approvalKey = json_data.approvalKey
    traceNo     = json_data.traceNo
    PayUrl      = json_data.PayUrl

%>

//MOBILE PAGE
router.get('/mobile_sample/trade_reg', function(req, res) {
  res.render('mobile_sample/trade_reg');
});

// MOBILE API
router.post('/mobile_sample/kcp_api_trade_reg', function(req, res) {
  // POST DATA
  var actionResult = f_get_parm(req.body.ActionResult); // pay_method
  var van_code = f_get_parm(req.body.van_code);

  var post_data = {
    actionResult : actionResult,
    van_code : van_code
  };

  // API REQ DATA
  var req_data = {
    site_cd : f_get_parm(req.body.site_cd),
    kcp_cert_info : KCP_CERT_INFO,
    ordr_idxx : f_get_parm(req.body.ordr_idxx),
    good_mny : f_get_parm(req.body.good_mny),
    good_name : f_get_parm(req.body.good_name),
    pay_method : f_get_parm(req.body.pay_method),
    Ret_URL : f_get_parm(req.body.Ret_URL),
    escw_used : 'N',
    user_agent : ''
  };

  // API URL
  // dev : https://stg-spl.kcp.co.kr/std/tradeReg/register
  // prod : https://spl.kcp.co.kr/std/tradeReg/register
  fetch("https://stg-spl.kcp.co.kr/std/tradeReg/register", {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      body: JSON.stringify(req_data),
    })
    // API RES
    .then(response => {
      return response.json();
    })
    .then(data => {
      res.render('mobile_sample/kcp_api_trade_reg', {
        req_data : req_data,
        res_data : data,
        post_data : post_data
    });
  });
});

#MOBILE PAGE
@app.route('/mobile_sample/trade_reg')
def trade_reg():
    return render_template('/mobile_sample/trade_reg.html')

# MOBILE API
@app.route('/mobile_sample/kcp_api_trade_reg', methods=['POST'])
def kcp_api_trade_reg():
#POST DATA
actionResult = f_get_parm(request.form['ActionResult']) # pay_method
van_code = f_get_parm(request.form['van_code'])

post_data = {
    'actionResult' : actionResult,
    'van_code': van_code
}
# API
target_URL = 'https://stg-spl.kcp.co.kr/std/tradeReg/register' #dev
#target_URL = 'https://spl.kcp.co.kr/std/tradeReg/register' #prod
headers = {'Content-Type': 'application/json', 'charset': 'UTF-8'}

#  API REQ DATA

req_data = {
    'site_cd' : f_get_parm(request.form['site_cd']),
    'kcp_cert_info' : KCP_CERT_INFO,
    'ordr_idxx' : f_get_parm(request.form['ordr_idxx']),
    'good_mny' : f_get_parm(request.form['good_mny']),
    'good_name' :f_get_parm(request.form['good_name']),
    'pay_method' : f_get_parm(request.form['pay_method']),
    'Ret_URL' : f_get_parm(request.form['Ret_URL']),
    'escw_used' : 'N',
    'user_agent' : ''
}

res = requests.post(target_URL, headers=headers, data=json.dumps(req_data, ensure_ascii=False, indent="\t").encode('utf8'))
return render_template('mobile_sample/kcp_api_trade_reg.html', res_data=json.loads(res.text), req_data=req_data, post_data=post_data)

Function Call Pay

Define detailed parameter required for calling mobile payment window.

<!-- call pay example-->

1<script type="text/javascript">
2 /* kcp web call */
3 function call_pay_form()
4 {
5     var v_frm = document.order_info;
6     var PayUrl = v_frm.PayUrl.value;
7     //  Start
8     if(v_frm.encoding_trans == undefined)
9     {
10          v_frm.action = PayUrl;
11      }
12      else
13      {
14          // encoding_trans "UTF-8"
15          if(v_frm.encoding_trans.value == "UTF-8")
16          {
17              v_frm.action = PayUrl.substring(0,PayUrl.lastIndexOf("/"))  + "/jsp/encodingFilter/encodingFilter.jsp";
18              v_frm.PayUrl.value = PayUrl;
19          }
20          else
21          {
22              v_frm.action = PayUrl;
23          }
24      }
25
26      if (v_frm.Ret_URL.value == "")
27      {
28          /* Ret_URL */
29          alert("Ret_URL");
30          return false;
31      }
32      else
33      {
34          v_frm.submit();
35      }
36  }
37</script>
Type : text/javascript

ret_url Authentication Data Return

ret_url is the URL of the merchant’s order page that will receive encrypted data that can request payment after communication with KCP.

After requesting the authentication data received through Ret_URL to SPL URL, it is possible to proceed with the approval process

<!-- ret_URL setting example -->

1Ret_URL="http://test.kcp.co.kr/returnpage"

Order Request Parameter Guide

Required Parameter

string5

site_cd

Merchant ID


string40

ordr_idxx

Merchant order number


string12

pay_method

Payment Method Code (Capital letter)
- Credit Card : CARD
- Bank Transfer : BANK
- Virtual Account : VCNT
- Mobile Billing : MOBX


string4

ActionResult

Authentication Method (Small letter)
- Credit Card : card
- Bank Transfer : acnt
- Virtual Account : vcnt
- Mobile Billing : mobx


string256

Ret_URL

Return URL upon completion of auth. on the NHN KCP Smartphone Payment window.


stringvar

approval_key

Transaction authorization code(Do not modify)


stringvar

PayUrl

KCP Hosted Page URL


string100

good_name

Product Name


number12

good_mny

Payment Amount


string3

currency

WON : 410 / USD : 840


string20

shop_user_id

Shop user ID

Optional Parameter

string20

shop_name

Setting value in cfg page


string30

buyr_name

Buyer name


string50

buyr_mail

Buyer e-mail


string20

buyr_tel2

Buyer mobile number


string1000

param_opt_1

Additional parameter


string1000

param_opt_2

Additional parameter


string1000

param_opt_3

Additional parameter

Conditional Parameter

Credit card conditional parameter


number2

quotaopt

Install payment option for transaction amount over 50,000 KRW.


string1

kcp_noint

“” : As stated in Merchant Portal configuration
“Y” : no interest option configured in the ‘no interest’ setup (kcp_noint_quota) in Merchant Portal
“N” : Ignores Merchant Portal configuration, general install payment is set in place.


string256

kcp_noint_quota

In case that kcp_noint is set as ‘Y,’ no interest installment option will be shown on the payment window.
Configurable by each card issuer


string1

used_card_YN

Set the parameter value as “Y”, and enter the code corresponding to the desired credit card company in the used_card.


string256

used_card

In case that user_card_YN is set as ‘Y’, enter the code corresponding to the desired credit card company.


View Card Code ▼

cardcodeCard Name cardcodeCard Name
CCLGShinhanCCKJKwangju
CCDIHyundaiCCSUSuhyup
CCLOLotteCCJBJeonbuk
CCKEKEBCCCJJeju
CCSSSamsungCCKDKDB
CCKMKB KookminCCSBSavings
CCBCBCCCCUShinhyup
CCNHNHCCPBKorea Post
CCHNHanaCCSMSMG
CCCTCitiCCKAKakaobank
CCPHWooriCCXBMaster
BC81HanaBCCCXCJCB
CCKKK bank
CCUFUnionPay
CCXAVISA

string2

fix_inst

Fix Install payment option to one of the values from 0~12 for transaction amount over 50,000 KRW.



Virtual Account optional parameter


number8

ipgm_date

Input expected deposit date into issued virtual account
Example: 20211231 or 20211231235959


string50

used_bank

You can select the desired bank(s) among the available banks on NHN KCP payment module.


string6

vcnt_expire_term_time

Expiration time of the virtual account

<!-- Setting virtual account option example -->
<input type=”hidden” name=”ipgm_date” value=”20200131”> // Virtual account expiration date
<input type=”hidden” name=”used_bank” value=”BK03:BK04”> // IBK, KB only in payment window

Payment(Request/Authorization Retrun) code sample

<%@ page language="java" contentType="text/html;charset=euc-kr"%>
<%!
    public String f_get_parm( String val )
    {
        if ( val == null ) val = "";
        return  val;
    }
    /* ============================================================================== */
%>
<%
    request.setCharacterEncoding( "euc-kr" );


    String approvalKey = f_get_parm( request.getParameter( "approvalKey"    ) );
    String traceNo     = f_get_parm( request.getParameter( "traceNo"        ) );
    String PayUrl      = f_get_parm( request.getParameter( "PayUrl"         ) ); //  PAY URL

    String pay_method   = f_get_parm( request.getParameter( "pay_method"   ) );
    String actionResult = f_get_parm( request.getParameter( "actionResult" ) );
    String van_code     = f_get_parm( request.getParameter( "van_code" ) );
    // Ret_URL
    String Ret_URL      = f_get_parm( request.getParameter( "Ret_URL"     ) );

    String req_tx          = f_get_parm( request.getParameter( "req_tx"         ) );
    String res_cd          = f_get_parm( request.getParameter( "res_cd"         ) );
    String site_cd         = f_get_parm( request.getParameter( "site_cd"        ) );
    String tran_cd         = f_get_parm( request.getParameter( "tran_cd"        ) );
    String ordr_idxx       = f_get_parm( request.getParameter( "ordr_idxx"      ) );
    String good_name       = f_get_parm( request.getParameter( "good_name"      ) );
    String good_mny        = f_get_parm( request.getParameter( "good_mny"       ) );
    String buyr_name       = f_get_parm( request.getParameter( "buyr_name"      ) );
    String buyr_tel2       = f_get_parm( request.getParameter( "buyr_tel2"      ) );
    String buyr_mail       = f_get_parm( request.getParameter( "buyr_mail"      ) );
    String use_pay_method  = f_get_parm( request.getParameter( "use_pay_method" ) );
    String enc_info        = f_get_parm( request.getParameter( "enc_info"       ) );
    String enc_data        = f_get_parm( request.getParameter( "enc_data"       ) );
    String cash_yn         = f_get_parm( request.getParameter( "cash_yn"        ) );
    String cash_tr_code    = f_get_parm( request.getParameter( "cash_tr_code"   ) );

    String param_opt_1    = f_get_parm( request.getParameter( "param_opt_1"     ) );
    String param_opt_2    = f_get_parm( request.getParameter( "param_opt_2"     ) );
    String param_opt_3    = f_get_parm( request.getParameter( "param_opt_3"     ) );


%>

<!DOCTYPE>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=euc-kr" />
    <meta http-equiv="x-ua-compatible" content="ie=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=yes, target-densitydpi=medium-dpi">
    <script type="text/javascript">

        function call_pay_form()
        {
          var v_frm = document.order_info;
          var PayUrl = v_frm.PayUrl.value;

          if(v_frm.encoding_trans == undefined)
          {
            v_frm.action = PayUrl;
          }
          else
          {
            // encoding_trans "UTF-8"
            if(v_frm.encoding_trans.value == "UTF-8")
            {
              v_frm.action = PayUrl.substring(0,PayUrl.lastIndexOf("/"))  + "/jsp/encodingFilter/encodingFilter.jsp";
              v_frm.PayUrl.value = PayUrl;
            }
            else
            {
              v_frm.action = PayUrl;
            }
          }

          if (v_frm.Ret_URL.value == "")
          {
            /* Ret_URL */
            alert(" Ret_URL");
            return false;
          }
          else
          {
            v_frm.submit();
          }
        }

        function chk_pay()
        {
          self.name = "tar_opener";
          var pay_form = document.pay_form;

          if (pay_form.res_cd.value != "" )
          {
            if (pay_form.res_cd.value != "0000" )
            {
              if (pay_form.res_cd.value == "3001")
              {
                alert("user cancel");
              }
              pay_form.res_cd.value = "";
              location.href = "./trade_reg.html";
            }
          }
          if (pay_form.enc_info.value)
            pay_form.submit();
        }
    </script>
</head>
<body onload="chk_pay();">
<div class="wrap">
<!-- order_info -->
<form name="order_info" method="post">
    <input type="text" name="ordr_idxx" value="<%=ordr_idxx %>" maxlength="40" readonly />
    <input type="text" name="good_name" value="<%=good_name %>" readonly />
    <input type="text" name="good_mny" value="<%=good_mny %>" maxlength="9" readonly />
    <input type="text" name="buyr_name" value="jhon doe" />
    <input type="text" name="buyr_tel2" value="010-0000-0000" />
    <input type="text" name="buyr_mail" value="test@test.co.kr" />
    <a href="#none" onclick="call_pay_form();" class="btn-type-2 pc-wd-3">action</a>

    <input type="hidden" name="req_tx"          value="pay" />
    <input type="hidden" name="shop_name"       value="TEST SITE" />
    <input type="hidden" name="site_cd"         value="<%=site_cd %>" />
    <input type="hidden" name="currency"        value="410"/>

    <input type="hidden" name="escw_used"       value="N" />
    <input type="hidden" name="pay_method"      value="<%=pay_method %>" />
    <input type="hidden" name="ActionResult"    value="<%=actionResult %>" />
    <input type="hidden" name="van_code"        value="<%=van_code %>" />

    <input type="hidden" name="quotaopt"        value="12"/>

    <input type="hidden" name="ipgm_date"       value="" />

    <input type="hidden" name="Ret_URL"         value="<%=Ret_URL %>" />

    <input type="hidden" name="tablet_size"     value="1.0 " />

    <input type="hidden" name="param_opt_1"     value="" />
    <input type="hidden" name="param_opt_2"     value="" />
    <input type="hidden" name="param_opt_3"     value="" />

    <input type="hidden" name="approval_key" id="approval" value="<%=approvalKey%>"/>
    <input type="hidden" name="traceNo"                    value="<%=traceNo%>" />
    <input type="hidden" name="PayUrl"                     value="<%=PayUrl%>" />
    <!-- <input type="hidden" name="encoding_trans" value="UTF-8" />  -->
</form>
</div>
    <form name="pay_form" method="post" action="../kcp_api_pay.jsp">
    <input type="hidden" name="req_tx"         value="<%=req_tx%>" />
    <input type="hidden" name="res_cd"         value="<%=res_cd%>" />
    <input type="hidden" name="site_cd"        value="<%=site_cd%>" />
    <input type="hidden" name="tran_cd"        value="<%=tran_cd%>" />
    <input type="hidden" name="ordr_idxx"      value="<%=ordr_idxx%>" />
    <input type="hidden" name="good_mny"       value="<%=good_mny%>" />
    <input type="hidden" name="good_name"      value="<%=good_name%>" />
    <input type="hidden" name="buyr_name"      value="<%=buyr_name%>" />
    <input type="hidden" name="buyr_tel2"      value="<%=buyr_tel2%>" />
    <input type="hidden" name="buyr_mail"      value="<%=buyr_mail%>" />
    <input type="hidden" name="enc_info"       value="<%=enc_info%>" />
    <input type="hidden" name="enc_data"       value="<%=enc_data%>" />
    <input type="hidden" name="use_pay_method" value="<%=use_pay_method%>" />
    <input type="hidden" name="cash_yn"        value="<%=cash_yn%>" />
    <input type="hidden" name="cash_tr_code"   value="<%=cash_tr_code%>" />

    <input type="hidden" name="param_opt_1"    value="<%=param_opt_1%>" />
    <input type="hidden" name="param_opt_2"    value="<%=param_opt_2%>" />
    <input type="hidden" name="param_opt_3"    value="<%=param_opt_3%>" />
</form>
<!--//wrap-->
</body>
</html>
<?php
    header("Content-type: text/html; charset=utf-8");

    $approvalKey    = $_POST[ "approvalKey"    ];
    $traceNo        = $_POST[ "traceNo"        ];
    $PayUrl         = $_POST[ "PayUrl"         ]; //  PAY URL

    $pay_method     = $_POST[ "pay_method"   ];
    $actionResult   = $_POST[ "actionResult" ];
    $van_code       = $_POST[ "van_code" ];
    // Ret_URL
    $Ret_URL        = $_POST[ "Ret_URL"     ];

    $req_tx          = $_POST[ "req_tx"         ];
    $res_cd          = $_POST[ "res_cd"         ];
    $site_cd         = $_POST[ "site_cd"        ];
    $tran_cd         = $_POST[ "tran_cd"        ];
    $ordr_idxx       = $_POST[ "ordr_idxx"      ];
    $good_name       = $_POST[ "good_name"      ];
    $good_mny        = $_POST[ "good_mny"       ];
    $buyr_name       = $_POST[ "buyr_name"      ];
    $buyr_tel2       = $_POST[ "buyr_tel2"      ];
    $buyr_mail       = $_POST[ "buyr_mail"      ];
    $use_pay_method  = $_POST[ "use_pay_method" ];
    $enc_info        = $_POST[ "enc_info"       ];
    $enc_data        = $_POST[ "enc_data"       ];
    $cash_yn         = $_POST[ "cash_yn"        ];
    $cash_tr_code    = $_POST[ "cash_tr_code"   ];
    /*  - Start - */
    $param_opt_1    = $_POST[ "param_opt_1"     ];
    $param_opt_2    = $_POST[ "param_opt_2"     ];
    $param_opt_3    = $_POST[ "param_opt_3"     ];
    /* - End -   */

?>

<!DOCTYPE>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=euc-kr" />
    <meta http-equiv="x-ua-compatible" content="ie=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=yes, target-densitydpi=medium-dpi">
    <script type="text/javascript">
        /* kcp web  */
        function call_pay_form()
        {
          var v_frm = document.order_info;
          var PayUrl = v_frm.PayUrl.value;

          if(v_frm.encoding_trans == undefined)
          {
            v_frm.action = PayUrl;
          }
          else
          {
            // encoding_trans "UTF-8"
            if(v_frm.encoding_trans.value == "UTF-8")
            {
              v_frm.action = PayUrl.substring(0,PayUrl.lastIndexOf("/"))  + "/jsp/encodingFilter/encodingFilter.jsp";
              v_frm.PayUrl.value = PayUrl;
            }
            else
            {
              v_frm.action = PayUrl;
            }
          }

          if (v_frm.Ret_URL.value == "")
          {
            /* Ret_URL */
            alert("Ret_URL");
            return false;
          }
          else
          {
            v_frm.submit();
          }
        }

        function chk_pay()
        {
          self.name = "tar_opener";
          var pay_form = document.pay_form;

          if (pay_form.res_cd.value != "" )
          {
            if (pay_form.res_cd.value != "0000" )
            {
              if (pay_form.res_cd.value == "3001")
              {
                alert("user cancel");
              }
              pay_form.res_cd.value = "";
              location.href = "./trade_reg.html";
            }
          }
          if (pay_form.enc_info.value)
            pay_form.submit();
        }
    </script>
</head>
<body onload="chk_pay();">
<div class="wrap">
<!-- order_info -->
<form name="order_info" method="post">
            <input type="text" name="ordr_idxx" value="<%=ordr_idxx %>" maxlength="40" readonly />
            <input type="text" name="good_name" value="<%=good_name %>" readonly />
            <input type="text" name="good_mny" value="<%=good_mny %>" maxlength="9" readonly />
            <input type="text" name="buyr_name" value="jhon doe" />
            <input type="text" name="buyr_tel2" value="010-0000-0000" />
            <input type="text" name="buyr_mail" value="test@test.co.kr" />
            <a href="#none" onclick="call_pay_form();" class="btn-type-2 pc-wd-3">action</a>

            <input type="hidden" name="req_tx"          value="pay" />
            <input type="hidden" name="shop_name"       value="TEST SITE" />
            <input type="hidden" name="site_cd"         value="<%=site_cd %>" />
            <input type="hidden" name="currency"        value="410"/>

            <input type="hidden" name="escw_used"       value="N" />
            <input type="hidden" name="pay_method"      value="<%=pay_method %>" />
            <input type="hidden" name="ActionResult"    value="<%=actionResult %>" />
            <input type="hidden" name="van_code"        value="<%=van_code %>" />

            <input type="hidden" name="quotaopt"        value="12"/>

            <input type="hidden" name="ipgm_date"       value="" />

            <input type="hidden" name="Ret_URL"         value="<%=Ret_URL %>" />

            <input type="hidden" name="tablet_size"     value="1.0 " />

            <input type="hidden" name="param_opt_1"     value="" />
            <input type="hidden" name="param_opt_2"     value="" />
            <input type="hidden" name="param_opt_3"     value="" />

            <input type="hidden" name="approval_key" id="approval" value="<%=approvalKey%>"/>
            <input type="hidden" name="traceNo"                    value="<%=traceNo%>" />
            <input type="hidden" name="PayUrl"                     value="<%=PayUrl%>" />
          <!-- <input type="hidden" name="encoding_trans" value="UTF-8" />  -->
        </form>
    </div>
    <form name="pay_form" method="post" action="../kcp_api_pay.jsp">
        <input type="hidden" name="req_tx"         value="<%=req_tx%>" />
        <input type="hidden" name="res_cd"         value="<%=res_cd%>" />
        <input type="hidden" name="site_cd"        value="<%=site_cd%>" />
        <input type="hidden" name="tran_cd"        value="<%=tran_cd%>" />
        <input type="hidden" name="ordr_idxx"      value="<%=ordr_idxx%>" />
        <input type="hidden" name="good_mny"       value="<%=good_mny%>" />
        <input type="hidden" name="good_name"      value="<%=good_name%>" />
        <input type="hidden" name="buyr_name"      value="<%=buyr_name%>" />
        <input type="hidden" name="buyr_tel2"      value="<%=buyr_tel2%>" />
        <input type="hidden" name="buyr_mail"      value="<%=buyr_mail%>" />
        <input type="hidden" name="enc_info"       value="<%=enc_info%>" />
        <input type="hidden" name="enc_data"       value="<%=enc_data%>" />
        <input type="hidden" name="use_pay_method" value="<%=use_pay_method%>" />
        <input type="hidden" name="cash_yn"        value="<%=cash_yn%>" />
        <input type="hidden" name="cash_tr_code"   value="<%=cash_tr_code%>" />

        <input type="hidden" name="param_opt_1"    value="<%=param_opt_1%>" />
        <input type="hidden" name="param_opt_2"    value="<%=param_opt_2%>" />
        <input type="hidden" name="param_opt_3"    value="<%=param_opt_3%>" />
    </form>
    <!--//wrap-->
</body>
</html>
<%@ Page Language="C#" %>
<%
    String approvalKey = Request.Form[ "approvalKey"    ];
    String traceNo     = Request.Form[ "traceNo"        ];
    String PayUrl      = Request.Form[ "PayUrl"         ]; //  PAY URL

    String pay_method   = Request.Form[ "pay_method"   ];
    String actionResult = Request.Form[ "actionResult" ];
    String van_code     = Request.Form[ "van_code" ];
    // Ret_URL
    String Ret_URL      = Request.Form[ "Ret_URL"     ];

    String req_tx          = Request.Form[ "req_tx"         ];
    String res_cd          = Request.Form[ "res_cd"         ];
    String site_cd         = Request.Form[ "site_cd"        ];
    String tran_cd         = Request.Form[ "tran_cd"        ];
    String ordr_idxx       = Request.Form[ "ordr_idxx"      ];
    String good_name       = Request.Form[ "good_name"      ];
    String good_mny        = Request.Form[ "good_mny"       ];
    String buyr_name       = Request.Form[ "buyr_name"      ];
    String buyr_tel2       = Request.Form[ "buyr_tel2"      ];
    String buyr_mail       = Request.Form[ "buyr_mail"      ];
    String use_pay_method  = Request.Form[ "use_pay_method" ];
    String enc_info        = Request.Form[ "enc_info"       ];
    String enc_data        = Request.Form[ "enc_data"       ];
    String cash_yn         = Request.Form[ "cash_yn"        ];
    String cash_tr_code    = Request.Form[ "cash_tr_code"   ];

    String param_opt_1    = Request.Form[ "param_opt_1"     ];
    String param_opt_2    = Request.Form[ "param_opt_2"     ];
    String param_opt_3    = Request.Form[ "param_opt_3"     ];


%>

<!DOCTYPE>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=euc-kr" />
    <meta http-equiv="x-ua-compatible" content="ie=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=yes, target-densitydpi=medium-dpi">
    <script type="text/javascript">

        function call_pay_form()
        {
          var v_frm = document.order_info;
          var PayUrl = v_frm.PayUrl.value;
          //  Start
          if(v_frm.encoding_trans == undefined)
          {
            v_frm.action = PayUrl;
          }
          else
          {
            // encoding_trans "UTF-8"
            if(v_frm.encoding_trans.value == "UTF-8")
            {
              v_frm.action = PayUrl.substring(0,PayUrl.lastIndexOf("/"))  + "/jsp/encodingFilter/encodingFilter.jsp";
              v_frm.PayUrl.value = PayUrl;
            }
            else
            {
              v_frm.action = PayUrl;
            }
          }

          if (v_frm.Ret_URL.value == "")
          {

            alert("Ret_URL");
            return false;
          }
          else
          {
            v_frm.submit();
          }
        }

        function chk_pay()
        {
          self.name = "tar_opener";
          var pay_form = document.pay_form;

          if (pay_form.res_cd.value != "" )
          {
            if (pay_form.res_cd.value != "0000" )
            {
              if (pay_form.res_cd.value == "3001")
              {
                alert("user cancel.");
              }
              pay_form.res_cd.value = "";
              location.href = "./trade_reg.html";
            }
          }
          if (pay_form.enc_info.value)
            pay_form.submit();
        }
    </script>
</head>
<body onload="chk_pay();">
<div class="wrap">
<!-- order_info -->
<form name="order_info" method="post">
            <input type="text" name="ordr_idxx" value="<%=ordr_idxx %>" maxlength="40" readonly />
            <input type="text" name="good_name" value="<%=good_name %>" readonly />
            <input type="text" name="good_mny" value="<%=good_mny %>" maxlength="9" readonly />
            <input type="text" name="buyr_name" value="jhon doe" />
            <input type="text" name="buyr_tel2" value="010-0000-0000" />
            <input type="text" name="buyr_mail" value="test@test.co.kr" />
            <a href="#none" onclick="call_pay_form();" class="btn-type-2 pc-wd-3">action</a>

            <input type="hidden" name="req_tx"          value="pay" />
            <input type="hidden" name="shop_name"       value="TEST SITE" />
            <input type="hidden" name="site_cd"         value="<%=site_cd %>" />
            <input type="hidden" name="currency"        value="410"/>

            <input type="hidden" name="escw_used"       value="N" />
            <input type="hidden" name="pay_method"      value="<%=pay_method %>" />
            <input type="hidden" name="ActionResult"    value="<%=actionResult %>" />
            <input type="hidden" name="van_code"        value="<%=van_code %>" />

            <input type="hidden" name="quotaopt"        value="12"/>

            <input type="hidden" name="ipgm_date"       value="" />

            <input type="hidden" name="Ret_URL"         value="<%=Ret_URL %>" />

            <input type="hidden" name="tablet_size"     value="1.0 " />

            <input type="hidden" name="param_opt_1"     value="" />
            <input type="hidden" name="param_opt_2"     value="" />
            <input type="hidden" name="param_opt_3"     value="" />

            <input type="hidden" name="approval_key" id="approval" value="<%=approvalKey%>"/>
            <input type="hidden" name="traceNo"                    value="<%=traceNo%>" />
            <input type="hidden" name="PayUrl"                     value="<%=PayUrl%>" />
          <!-- <input type="hidden" name="encoding_trans" value="UTF-8" />  -->
        </form>
    </div>
    <form name="pay_form" method="post" action="../kcp_api_pay.jsp">
        <input type="hidden" name="req_tx"         value="<%=req_tx%>" />
        <input type="hidden" name="res_cd"         value="<%=res_cd%>" />
        <input type="hidden" name="site_cd"        value="<%=site_cd%>" />
        <input type="hidden" name="tran_cd"        value="<%=tran_cd%>" />
        <input type="hidden" name="ordr_idxx"      value="<%=ordr_idxx%>" />
        <input type="hidden" name="good_mny"       value="<%=good_mny%>" />
        <input type="hidden" name="good_name"      value="<%=good_name%>" />
        <input type="hidden" name="buyr_name"      value="<%=buyr_name%>" />
        <input type="hidden" name="buyr_tel2"      value="<%=buyr_tel2%>" />
        <input type="hidden" name="buyr_mail"      value="<%=buyr_mail%>" />
        <input type="hidden" name="enc_info"       value="<%=enc_info%>" />
        <input type="hidden" name="enc_data"       value="<%=enc_data%>" />
        <input type="hidden" name="use_pay_method" value="<%=use_pay_method%>" />
        <input type="hidden" name="cash_yn"        value="<%=cash_yn%>" />
        <input type="hidden" name="cash_tr_code"   value="<%=cash_tr_code%>" />

        <input type="hidden" name="param_opt_1"    value="<%=param_opt_1%>" />
        <input type="hidden" name="param_opt_2"    value="<%=param_opt_2%>" />
        <input type="hidden" name="param_opt_3"    value="<%=param_opt_3%>" />
    </form>
    <!--//wrap-->
</body>
</html>
<!--#include file="../lib/json2.asp"-->
<%
    Response.CharSet = "UTF-8"


    approvalKey = trim(request( "approvalKey"    ) )
    traceNo     = trim(request( "traceNo"        ) )
    PayUrl      = trim(request( "PayUrl"         ) ) '  PAY URL

    pay_method   = trim(request( "pay_method"   ) )
    actionResult = trim(request( "actionResult" ) )
    van_code     = trim(request( "van_code" ) )
    '  Ret_URL
    Ret_URL      = trim(request( "Ret_URL"     ) )

    req_tx          = trim(request( "req_tx"         ) )
    res_cd          = trim(request( "res_cd"         ) )
    site_cd         = trim(request( "site_cd"        ) )
    tran_cd         = trim(request( "tran_cd"        ) )
    ordr_idxx       = trim(request( "ordr_idxx"      ) )
    good_name       = trim(request( "good_name"      ) )
    good_mny        = trim(request( "good_mny"       ) )
    buyr_name       = trim(request( "buyr_name"      ) )
    buyr_tel2       = trim(request( "buyr_tel2"      ) )
    buyr_mail       = trim(request( "buyr_mail"      ) )
    use_pay_method  = trim(request( "use_pay_method" ) )
    enc_info        = trim(request( "enc_info"       ) )
    enc_data        = trim(request( "enc_data"       ) )
    cash_yn         = trim(request( "cash_yn"        ) )
    cash_tr_code    = trim(request( "cash_tr_code"   ) )

    param_opt_1    = trim(request( "param_opt_1"     ) )
    param_opt_2    = trim(request( "param_opt_2"     ) )
    param_opt_3    = trim(request( "param_opt_3"     ) )


%>

<!DOCTYPE>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=euc-kr" />
    <meta http-equiv="x-ua-compatible" content="ie=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=yes, target-densitydpi=medium-dpi">
    <script type="text/javascript">
        /* kcp web  */
        function call_pay_form()
        {
          var v_frm = document.order_info;
          var PayUrl = v_frm.PayUrl.value;
          //  -- Start
          if(v_frm.encoding_trans == undefined)
          {
            v_frm.action = PayUrl;
          }
          else
          {
            // encoding_trans "UTF-8"
            if(v_frm.encoding_trans.value == "UTF-8")
            {
              v_frm.action = PayUrl.substring(0,PayUrl.lastIndexOf("/"))  + "/jsp/encodingFilter/encodingFilter.jsp";
              v_frm.PayUrl.value = PayUrl;
            }
            else
            {
              v_frm.action = PayUrl;
            }
          }

          if (v_frm.Ret_URL.value == "")
          {
            /* Ret_URL */
            alert("Ret_URL");
            return false;
          }
          else
          {
            v_frm.submit();
          }
        }

        function chk_pay()
        {
          self.name = "tar_opener";
          var pay_form = document.pay_form;

          if (pay_form.res_cd.value != "" )
          {
            if (pay_form.res_cd.value != "0000" )
            {
              if (pay_form.res_cd.value == "3001")
              {
                alert("user cancel");
              }
              pay_form.res_cd.value = "";
              location.href = "./trade_reg.html";
            }
          }
          if (pay_form.enc_info.value)
            pay_form.submit();
        }
    </script>
</head>
<body onload="chk_pay();">
<div class="wrap">
<!-- order_info -->
<form name="order_info" method="post">
            <input type="text" name="ordr_idxx" value="<%=ordr_idxx %>" maxlength="40" readonly />
            <input type="text" name="good_name" value="<%=good_name %>" readonly />
            <input type="text" name="good_mny" value="<%=good_mny %>" maxlength="9" readonly />
            <input type="text" name="buyr_name" value="jhon doe" />
            <input type="text" name="buyr_tel2" value="010-0000-0000" />
            <input type="text" name="buyr_mail" value="test@test.co.kr" />
            <a href="#none" onclick="call_pay_form();" class="btn-type-2 pc-wd-3">action</a>

            <input type="hidden" name="req_tx"          value="pay" />
            <input type="hidden" name="shop_name"       value="TEST SITE" />
            <input type="hidden" name="site_cd"         value="<%=site_cd %>" />
            <input type="hidden" name="currency"        value="410"/>

            <input type="hidden" name="escw_used"       value="N" />
            <input type="hidden" name="pay_method"      value="<%=pay_method %>" />
            <input type="hidden" name="ActionResult"    value="<%=actionResult %>" />
            <input type="hidden" name="van_code"        value="<%=van_code %>" />

            <input type="hidden" name="quotaopt"        value="12"/>

            <input type="hidden" name="ipgm_date"       value="" />

            <input type="hidden" name="Ret_URL"         value="<%=Ret_URL %>" />

            <input type="hidden" name="tablet_size"     value="1.0 " />

            <input type="hidden" name="param_opt_1"     value="" />
            <input type="hidden" name="param_opt_2"     value="" />
            <input type="hidden" name="param_opt_3"     value="" />

            <input type="hidden" name="approval_key" id="approval" value="<%=approvalKey%>"/>
            <input type="hidden" name="traceNo"                    value="<%=traceNo%>" />
            <input type="hidden" name="PayUrl"                     value="<%=PayUrl%>" />
          <!-- <input type="hidden" name="encoding_trans" value="UTF-8" />  -->
        </form>
    </div>
    <form name="pay_form" method="post" action="../kcp_api_pay.jsp">
        <input type="hidden" name="req_tx"         value="<%=req_tx%>" />
        <input type="hidden" name="res_cd"         value="<%=res_cd%>" />
        <input type="hidden" name="site_cd"        value="<%=site_cd%>" />
        <input type="hidden" name="tran_cd"        value="<%=tran_cd%>" />
        <input type="hidden" name="ordr_idxx"      value="<%=ordr_idxx%>" />
        <input type="hidden" name="good_mny"       value="<%=good_mny%>" />
        <input type="hidden" name="good_name"      value="<%=good_name%>" />
        <input type="hidden" name="buyr_name"      value="<%=buyr_name%>" />
        <input type="hidden" name="buyr_tel2"      value="<%=buyr_tel2%>" />
        <input type="hidden" name="buyr_mail"      value="<%=buyr_mail%>" />
        <input type="hidden" name="enc_info"       value="<%=enc_info%>" />
        <input type="hidden" name="enc_data"       value="<%=enc_data%>" />
        <input type="hidden" name="use_pay_method" value="<%=use_pay_method%>" />
        <input type="hidden" name="cash_yn"        value="<%=cash_yn%>" />
        <input type="hidden" name="cash_tr_code"   value="<%=cash_tr_code%>" />

        <input type="hidden" name="param_opt_1"    value="<%=param_opt_1%>" />
        <input type="hidden" name="param_opt_2"    value="<%=param_opt_2%>" />
        <input type="hidden" name="param_opt_3"    value="<%=param_opt_3%>" />
    </form>
    <!--//wrap-->
</body>
</html>
<!DOCTYPE>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=euc-kr" />
    <meta http-equiv="x-ua-compatible" content="ie=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=yes, target-densitydpi=medium-dpi">
    <script type="text/javascript">

        function call_pay_form()
        {
          var v_frm = document.order_info;
          var PayUrl = v_frm.PayUrl.value;
          //  -- Start
          if(v_frm.encoding_trans == undefined)
          {
            v_frm.action = PayUrl;
          }
          else
          {
            // encoding_trans "UTF-8"
            if(v_frm.encoding_trans.value == "UTF-8")
            {
              v_frm.action = PayUrl.substring(0,PayUrl.lastIndexOf("/"))  + "/jsp/encodingFilter/encodingFilter.jsp";
              v_frm.PayUrl.value = PayUrl;
            }
            else
            {
              v_frm.action = PayUrl;
            }
          }

          if (v_frm.Ret_URL.value == "")
          {
            /* Ret_URL */
            alert("Ret_URL);
            return false;
          }
          else
          {
            v_frm.submit();
          }
        }

        function chk_pay()
        {
          self.name = "tar_opener";
          var pay_form = document.pay_form;

          if (pay_form.res_cd.value != "" )
          {
            if (pay_form.res_cd.value != "0000" )
            {
              if (pay_form.res_cd.value == "3001")
              {
                alert("user cancel");
              }
              pay_form.res_cd.value = "";
              location.href = "./trade_reg.html";
            }
          }
          if (pay_form.enc_info.value)
            pay_form.submit();
        }
    </script>
</head>
<body onload="chk_pay();">
<div class="wrap">
<!-- order_info -->
<form name="order_info" method="post">
            <input type="text" name="ordr_idxx" value="<%=ordr_idxx %>" maxlength="40" readonly />
            <input type="text" name="good_name" value="<%=good_name %>" readonly />
            <input type="text" name="good_mny" value="<%=good_mny %>" maxlength="9" readonly />
            <input type="text" name="buyr_name" value="jhon doe" />
            <input type="text" name="buyr_tel2" value="010-0000-0000" />
            <input type="text" name="buyr_mail" value="test@test.co.kr" />
            <a href="#none" onclick="call_pay_form();" class="btn-type-2 pc-wd-3">action</a>

            <input type="hidden" name="req_tx"          value="pay" />
            <input type="hidden" name="shop_name"       value="TEST SITE" />
            <input type="hidden" name="site_cd"         value="<%=site_cd %>" />
            <input type="hidden" name="currency"        value="410"/>

            <input type="hidden" name="escw_used"       value="N" />
            <input type="hidden" name="pay_method"      value="<%=pay_method %>" />
            <input type="hidden" name="ActionResult"    value="<%=actionResult %>" />
            <input type="hidden" name="van_code"        value="<%=van_code %>" />

            <input type="hidden" name="quotaopt"        value="12"/>

            <input type="hidden" name="ipgm_date"       value="" />

            <input type="hidden" name="Ret_URL"         value="<%=Ret_URL %>" />

            <input type="hidden" name="tablet_size"     value="1.0 " />

            <input type="hidden" name="param_opt_1"     value="" />
            <input type="hidden" name="param_opt_2"     value="" />
            <input type="hidden" name="param_opt_3"     value="" />

            <input type="hidden" name="approval_key" id="approval" value="<%=approvalKey%>"/>
            <input type="hidden" name="traceNo"                    value="<%=traceNo%>" />
            <input type="hidden" name="PayUrl"                     value="<%=PayUrl%>" />
          <!-- <input type="hidden" name="encoding_trans" value="UTF-8" />  -->
        </form>
    </div>
    <form name="pay_form" method="post" action="../kcp_api_pay.jsp">
        <input type="hidden" name="req_tx"         value="<%=req_tx%>" />
        <input type="hidden" name="res_cd"         value="<%=res_cd%>" />
        <input type="hidden" name="site_cd"        value="<%=site_cd%>" />
        <input type="hidden" name="tran_cd"        value="<%=tran_cd%>" />
        <input type="hidden" name="ordr_idxx"      value="<%=ordr_idxx%>" />
        <input type="hidden" name="good_mny"       value="<%=good_mny%>" />
        <input type="hidden" name="good_name"      value="<%=good_name%>" />
        <input type="hidden" name="buyr_name"      value="<%=buyr_name%>" />
        <input type="hidden" name="buyr_tel2"      value="<%=buyr_tel2%>" />
        <input type="hidden" name="buyr_mail"      value="<%=buyr_mail%>" />
        <input type="hidden" name="enc_info"       value="<%=enc_info%>" />
        <input type="hidden" name="enc_data"       value="<%=enc_data%>" />
        <input type="hidden" name="use_pay_method" value="<%=use_pay_method%>" />
        <input type="hidden" name="cash_yn"        value="<%=cash_yn%>" />
        <input type="hidden" name="cash_tr_code"   value="<%=cash_tr_code%>" />

        <input type="hidden" name="param_opt_1"    value="<%=param_opt_1%>" />
        <input type="hidden" name="param_opt_2"    value="<%=param_opt_2%>" />
        <input type="hidden" name="param_opt_3"    value="<%=param_opt_3%>" />
    </form>
    <!--//wrap-->
</body>
</html>
<!DOCTYPE>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=euc-kr" />
    <meta http-equiv="x-ua-compatible" content="ie=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=yes, target-densitydpi=medium-dpi">
    <script type="text/javascript">

        function call_pay_form()
        {
          var v_frm = document.order_info;
          var PayUrl = v_frm.PayUrl.value;
          //  -- Start
          if(v_frm.encoding_trans == undefined)
          {
            v_frm.action = PayUrl;
          }
          else
          {
            // encoding_trans "UTF-8"
            if(v_frm.encoding_trans.value == "UTF-8")
            {
              v_frm.action = PayUrl.substring(0,PayUrl.lastIndexOf("/"))  + "/jsp/encodingFilter/encodingFilter.jsp";
              v_frm.PayUrl.value = PayUrl;
            }
            else
            {
              v_frm.action = PayUrl;
            }
          }

          if (v_frm.Ret_URL.value == "")
          {
            /* Ret_URL */
            alert("Ret_URL");
            return false;
          }
          else
          {
            v_frm.submit();
          }
        }

        function chk_pay()
        {
          self.name = "tar_opener";
          var pay_form = document.pay_form;

          if (pay_form.res_cd.value != "" )
          {
            if (pay_form.res_cd.value != "0000" )
            {
              if (pay_form.res_cd.value == "3001")
              {
                alert("user cancel");
              }
              pay_form.res_cd.value = "";
              location.href = "./trade_reg.html";
            }
          }
          if (pay_form.enc_info.value)
            pay_form.submit();
        }
    </script>
</head>
<body onload="chk_pay();">
<div class="wrap">
<!-- order_info -->
<form name="order_info" method="post">
            <input type="text" name="ordr_idxx" value="<%=ordr_idxx %>" maxlength="40" readonly />
            <input type="text" name="good_name" value="<%=good_name %>" readonly />
            <input type="text" name="good_mny" value="<%=good_mny %>" maxlength="9" readonly />
            <input type="text" name="buyr_name" value="jhon doe" />
            <input type="text" name="buyr_tel2" value="010-0000-0000" />
            <input type="text" name="buyr_mail" value="test@test.co.kr" />
            <a href="#none" onclick="call_pay_form();" class="btn-type-2 pc-wd-3">action</a>

            <input type="hidden" name="req_tx"          value="pay" />
            <input type="hidden" name="shop_name"       value="TEST SITE" />
            <input type="hidden" name="site_cd"         value="<%=site_cd %>" />
            <input type="hidden" name="currency"        value="410"/>

            <input type="hidden" name="escw_used"       value="N" />
            <input type="hidden" name="pay_method"      value="<%=pay_method %>" />
            <input type="hidden" name="ActionResult"    value="<%=actionResult %>" />
            <input type="hidden" name="van_code"        value="<%=van_code %>" />

            <input type="hidden" name="quotaopt"        value="12"/>

            <input type="hidden" name="ipgm_date"       value="" />

            <input type="hidden" name="Ret_URL"         value="<%=Ret_URL %>" />

            <input type="hidden" name="tablet_size"     value="1.0 " />

            <input type="hidden" name="param_opt_1"     value="" />
            <input type="hidden" name="param_opt_2"     value="" />
            <input type="hidden" name="param_opt_3"     value="" />

            <input type="hidden" name="approval_key" id="approval" value="<%=approvalKey%>"/>
            <input type="hidden" name="traceNo"                    value="<%=traceNo%>" />
            <input type="hidden" name="PayUrl"                     value="<%=PayUrl%>" />
          <!-- <input type="hidden" name="encoding_trans" value="UTF-8" />  -->
        </form>
    </div>
    <form name="pay_form" method="post" action="../kcp_api_pay.jsp">
        <input type="hidden" name="req_tx"         value="<%=req_tx%>" />
        <input type="hidden" name="res_cd"         value="<%=res_cd%>" />
        <input type="hidden" name="site_cd"        value="<%=site_cd%>" />
        <input type="hidden" name="tran_cd"        value="<%=tran_cd%>" />
        <input type="hidden" name="ordr_idxx"      value="<%=ordr_idxx%>" />
        <input type="hidden" name="good_mny"       value="<%=good_mny%>" />
        <input type="hidden" name="good_name"      value="<%=good_name%>" />
        <input type="hidden" name="buyr_name"      value="<%=buyr_name%>" />
        <input type="hidden" name="buyr_tel2"      value="<%=buyr_tel2%>" />
        <input type="hidden" name="buyr_mail"      value="<%=buyr_mail%>" />
        <input type="hidden" name="enc_info"       value="<%=enc_info%>" />
        <input type="hidden" name="enc_data"       value="<%=enc_data%>" />
        <input type="hidden" name="use_pay_method" value="<%=use_pay_method%>" />
        <input type="hidden" name="cash_yn"        value="<%=cash_yn%>" />
        <input type="hidden" name="cash_tr_code"   value="<%=cash_tr_code%>" />

        <input type="hidden" name="param_opt_1"    value="<%=param_opt_1%>" />
        <input type="hidden" name="param_opt_2"    value="<%=param_opt_2%>" />
        <input type="hidden" name="param_opt_3"    value="<%=param_opt_3%>" />
    </form>
    <!--//wrap-->
</body>
</html>

Returned Authentication Parameter Guide

Returned Parameter

stringvar

enc_data

Encrypted data retuned by the payment UI.


stringvar

enc_info

Encrypted data retuned by the payment UI.


stringvar

tran_cd

Transaction code

callback Data Received Example

<!-- callback Data Received Example -->

1<input type="hidden" name="enc_info"        value=""/>
2<input type="hidden" name="enc_data"        value=""/>
3<input type="hidden" name="tran_cd"         value=""/>

Authorization Request

Request Authorization of authentication data with API URL.

<!-- API Call -->

1https://spl.kcp.co.kr/gw/enc/v1/payment

Test : https://stg-spl.kcp.co.kr/gw/enc/v1/payment


Authorization Request Data

Authorization Request Data needs to be as Json String method.

Refer to server certificate section for issurance of kcp_cert_infocertificate data that is required for authorization.

<!-- Authorization Request Data -->

1{
2 "tran_cd":”00100000”,
3 "ordr_mony":"1004",
4 "kcp_cert_info":"-----BEGIN CERTIFICATE-----MIID3DCCAsSgAwIBAgIJAM...=-----END CERTIFICATE-----",
5 "site_cd":"T1234",
6 "enc_data":"SnvXdGftIEjAequorkpNhJXc4u3GRuotLHW9vyDDOhdeorM4DPXMJgJlIEoRo6divo=",
7 "enc_info":"A12345B12345"
8}

Response is returned in the same form of Json


Server Certificate

Extraction of data values from NHN KCP issued certificate,
For Merchant authentication, the certificate information issued by KCP must be delivered in text format.
The text value within the certificate must be serialized and delivered as the value of kcp_cert_info.

the parameter kcp_cert_info is needed for requesting Authorization cancel(mod) trade registration inquery


Authorization Request Parameter

Required Parameter

string5

site_cd

Merchant ID


stringvar

kcp_cert_info

Serialized KCP Server Certificate


stringvar

enc_data

Encrypted data retuned by the payment UI.


stringvar

enc_info

Encrypted data retuned by the payment UI.


stringvar

tran_cd

Transaction code


numbervar

ordr_mony

Actual payment request money

API Authorization sample

String target_URL = "https://stg-spl.kcp.co.kr/gw/enc/v1/payment";  //dev

JSONObject json_req = new JSONObject();

json_req.put("tran_cd", tran_cd);
json_req.put("site_cd", site_cd);
json_req.put("kcp_cert_info", kcp_cert_info);
json_req.put("enc_data", enc_data);
json_req.put("enc_info", enc_info);
json_req.put("ordr_mony",ordr_mony);

String temp_req_data = json_req.toString();
String req_data = temp_req_data.replace(",",",\r\n");

String inputLine = null;
StringBuffer outResult = new StringBuffer();

// API REQ
URL url = new URL(target_URL);
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("Accept-Charset", "UTF-8");

OutputStream os = conn.getOutputStream();
os.write(req_data.getBytes("UTF-8"));
os.flush();

// API RES
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
while ((inputLine = in.readLine()) != null)
{
  outResult.append(inputLine);
}
conn.disconnect();

String temp_result = outResult.toString();
String res_data = temp_result.replace(",",",\r\n");
header("Content-type: text/html; charset=utf-8");

$target_URL = "https://stg-spl.kcp.co.kr/gw/enc/v1/payment"; //dev

$data = [
          'tran_cd'        => $tran_cd,
          'site_cd'        => $site_cd,
          'kcp_cert_info'  => $kcp_cert_info,
          'enc_data'       => $enc_data,
          'enc_info'       => $enc_info,
          'ordr_mony'      => $ordr_mony
        ];

$req_data = json_encode($data);

$header_data = array( "Content-Type: application/json", "charset=utf-8" );

// API REQ
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $target_URL);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header_data);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $req_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

// API RES
$res_data  = curl_exec($ch);

// RES JSON DATA Parsing
$json_res = json_decode($res_data, true);

$res_cd = $json_res["res_cd"];
$res_msg = $json_res["res_msg"];

curl_close($ch);
target_URL = "https://stg-spl.kcp.co.kr/gw/enc/v1/payment"; //dev

req_data = "{\"tran_cd\" : \"" + tran_cd + "\"," +
            "\"site_cd\":\"" + site_cd + "\"," +
            "\"kcp_cert_info\":\"" + KCP_CERT_INFO + "\"," +
            "\"enc_data\":\"" + enc_data + "\"," +
            "\"enc_info\":\"" + enc_info + "\"," +
            "\"ordr_mony\":\"" + ordr_mony + "\"}";
// API REQ
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(target_URL);
req.Method = "POST";
req.ContentType = "application/json";

byte[] byte_req = Encoding.UTF8.GetBytes(req_data);
req.ContentLength = byte_req.Length;

Stream st = req.GetRequestStream();
st.Write(byte_req, 0, byte_req.Length);
st.Close();

// API RES
HttpWebResponse res = (HttpWebResponse)req.GetResponse();
StreamReader st_read = new StreamReader(res.GetResponseStream(), Encoding.GetEncoding("utf-8"));
res_data = st_read.ReadToEnd();

st_read.Close();
res.Close();

// RES JSON DATA Parsing
JObject json_data = JObject.Parse(res_data);
res_cd = json_data["res_cd"].ToString();
res_msg = json_data["res_msg"].ToString();
target_URL = "https://stg-spl.kcp.co.kr/gw/enc/v1/payment" 'dev

req_data = "{""tran_cd"":""" & tran_cd & """,""site_cd"":""" & site_cd & """,""kcp_cert_info"":""" & kcp_cert_info & """,""enc_data"":""" & enc_data & """,""enc_info"":""" & enc_info & """,""ordr_mony"":""" & ordr_mony & """}"

' API REQ
set req = Server.CreateObject("MSXML2.ServerXMLHTTP")
req.open "POST", target_URL, false
req.setRequestHeader "Content-Type", "application/json;charset=UTF-8"
req.send req_data

if req.status = 200 then
    res_data = req.ResponseText
else
    res_data = "http error code : " & req.status
end if
set req = nothing

'' RES JSON DATA Parsing
set json_data = JSON.parse(res_data)

res_cd = json_data.res_cd
res_msg = json_data.res_msg
//REQ DATA
  var req_data = {
    tran_cd : f_get_parm(req.body.tran_cd),
    site_cd : site_cd,
    kcp_cert_info : KCP_CERT_INFO,
    enc_data : f_get_parm(req.body.enc_data),
    enc_info : f_get_parm(req.body.enc_info),
    ordr_mony : '1'
  };

  fetch("https://stg-spl.kcp.co.kr/gw/enc/v1/payment", {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      body: JSON.stringify(req_data),
    })
    //  API RES
    .then(response => {
      return response.json();
    })
    .then(data => {

  res.render('kcp_api_pay', {
    req_data : JSON.stringify(req_data),
    res_data : JSON.stringify(data),
    });
});
# API
target_URL = 'https://stg-spl.kcp.co.kr/gw/enc/v1/payment' #dev
headers = {'Content-Type': 'application/json', 'charset': 'UTF-8'}

site_cd = f_get_parm(request.form['site_cd'])

# REQ DATA
req_data = {
  'tran_cd' : f_get_parm(request.form['tran_cd']),
  'site_cd' : site_cd,
  'kcp_cert_info' : KCP_CERT_INFO,
  'enc_data' : f_get_parm(request.form['enc_data']),
  'enc_info' : f_get_parm(request.form['enc_info']),
  'ordr_mony' : '1'
}

res = requests.post(target_URL, headers=headers, data=json.dumps(req_data, ensure_ascii=False, indent="\t").encode('utf8'))

Authorization Result

Common Return Paramter

Authorization Success Parameter


string5

res_cd

Result code
If the request is approved, ‘0000’ will return.


string100

res_msg

Result message


string100

res_en_msg

Result message in English


string14

tno

transaction number


number12

amount

Payment Amount


Authorization Failure Parameter


string5

res_cd

Result code
If the request is failed, an error code will return.


string100

res_msg

Result message

Authorization response Parameter

Credit Card Payment Response Parameter


string4

card_cd

The issuer code


string32

card_name

The name of the issuer


string16

card_no

The card number used for the purchase.


string8

app_no

The authorization number of the purchase


number14

app_time

The time of payment (approval) using Credit Card


string1

noinf

No interest option for the purchase. (Y/N)


number12

quota

Installment period.


number12

card_mny

Credit Card portion of the payment amount


number8

coupon_mny

The coupon discount amount or the payment amount using PAYCO Point will be returned.


string1

partcanc_yn

A partial refund availability indicator.


string4

isp_issuer_cd

The issuer code for ISP-Card


string32

isp_issuer_nm

The name of the issuer for ISP-Card


number12

payco_point_mny

Amount of PAYCO point used for the transaction


Bank Transfer Response Parameter


string20

bankname

The name of the bank used


string4

bankcode

The bank code


number9

cash_authno

The Case Receipt Authorization Number


number14

cash_no

The Cash Receipt Transaction Number


number12

bk_mny

The amount transferred for the purchase


number14

app_time

The time of payment (approval) for the purchase


Virtual Account Response Parameter


string20

bankname

The name of the bank used


string4

bankcode

The Bank Code


string20

account

The virtual account number for the purchase


number14

va_date

Deposit deadline for virtual account


number14

app_time

The time of payment (approval) for the purchase


Mobile Billing Response Parameter


string4

van_cd

Mobile Payment Issuer (Carrier) Code


string4

van_id

Product/Contents classification


string3

commid

The Mobile Carrier code


number11

mobile_no

Mobile number for the purchase.


string4

pnt_issue

Points Settlement Company Code


string20

pnt_app_no

Points Authorization Number


number14

pnt_app_time

The time of payment using points


string1

pnt_receipt_gubn

Cash Receipt registered (Y/N)


number9

cash_authno

Cash receipt approval number for the purchase


number12

add_pnt

Earned/usable points for the purchase


number12

use_pnt

The used points for the purchase


number12

rsv_pnt

The total points available for use


string4

tk_van_code

Voucher company code


number20

tk_app_no

Voucher authorization number


number14

tk_app_time

The time of payment using voucher


Cash Receipt Response Parameter


number9

cash_authno

Cash Receipt authorization number


number14

cash_no

Cash Receipt transaction number

Authorization Page Configuration

When configuring the Authorization page Authorization Generate Signature Auto Cancel Result function can be included.

For Auto Cancel function, refer to Transaction Modification page.

For Singaure Generation function, refer to Server Certificate page.

Call payment window, Download if an entire sample source including Call payment window, and Authorization is needed