Etc

일본 카드결제 시스템 Zeus 연동

지오준 2021. 3. 4.
반응형

Zeus의 카드결제시스템 설명

 

1.카드결제기능

①가결제 : 본결제 처리전에 결제대기 상태를 진행함.

②본결제 : 가결제된 결제내역에 대해서 실제결제처리를 진행함.

③취소 : 가결제, 본결제가 처리된 결제내역에 대해서 취소처리함.

 

2.C#코드샘플

①가결제

/// <summary>
/// 카드결제
/// </summary>
/// <param name="clientip">제우스발행코드</param>
/// <param name="cardnumber">신용카드번호</param>
/// <param name="expyy">사용기한 : 년도 2자리</param>
/// <param name="expmm">사용기한 : 월 2자리</param>
/// <param name="telno">전화번호</param>
/// <param name="email">이메일</param>
/// <param name="sendid">예약번호</param>
/// <param name="username">예약자(영문이름)</param>
/// <param name="money">금액 : 단위는 무조건 엔화</param>
/// <param name="sendpoint">예약타입</param>
/// <returns></returns>
public static string CardPayment(string clientip, string cardnumber, string expyy, string expmm,
                                 string telno, string email, string sendid, string username,
                                 string money, string sendpoint)
{
    //가결제 주소 및 파라매터 설정
    Uri uri = new Uri("https://linkpt.cardservice.co.jp/cgi-bin/secure.cgi");
    HttpWebRequest https = (HttpWebRequest)WebRequest.Create(uri);
    https.Method = "POST";
    string param = "clientip=" + clientip
                  + "&cardnumber=" + cardnumber
                  + "&expyy=" + expyy
                  + "&expmm=" + expmm
                  + "&telno=" + telno
                  + "&email=" + email
                  + "&sendid=" + sendid
                  + "&username=" + username
                  + "&money=" + money
                  + "&sendpoint=" + sendpoint
                  + "&send=mall"
                  + "&printord=yes"
                  + "&pebsec=non";                       

    // 가결제 Request 및 Response 설정
    byte[] postBuffer = System.Text.Encoding.GetEncoding(1252).GetBytes(param);
    Stream postData = https.GetRequestStream();
    postData.Write(postBuffer, 0, postBuffer.Length);
    postData.Close();

    // 가결제 Response를 확인가능한 출력형태로 변환
    HttpWebResponse response = (HttpWebResponse)https.GetResponse();
    Encoding enc = System.Text.Encoding.GetEncoding(1252);
    StreamReader loResponseStream = new StreamReader(response.GetResponseStream(), enc);
    string retHtml = loResponseStream.ReadToEnd();
    response.Close();
    loResponseStream.Close();

    return retHtml;
}

②본결제 

 /// <summary>
 /// 카드가결제 및 실결제 처리
 /// </summary>
 /// <param name="clientip">제우스발행코드 </param>               
 /// <param name="king">금액 숫자만</param>
 /// <param name="date">매상처리일 8자리</param>
 /// <param name="ordd">가처리결제번호</param>
 /// <param name="autype">결제처리 선택코드 : sale(실결제), auth(가결제)</param>
 /// <returns></returns>
 public static string CardBatchProcess(string clientip, string king, string date, string ordd, string autype)
 {
        //본결제 서비스에 접속및 파라매터설정
        Uri uri = new Uri("https://linkpt.cardservice.co.jp/cgi-bin/secure.cgi");
        HttpWebRequest https = (HttpWebRequest)WebRequest.Create(uri);
        https.Method = "POST";
        string param = "clientip=" + clientip
                        + "&king=" + king
                        + "&date=" + date
                        + "&ordd=" + ordd
                        + "&autype=" + autype;          

        //본결제 Request 및 Response 확인
        byte[] postBuffer = System.Text.Encoding.GetEncoding(1252).GetBytes(param);
        Stream postData = https.GetRequestStream();
        postData.Write(postBuffer, 0, postBuffer.Length);
        postData.Close();

        //본결제 Response를 확인가능한 출력형태로 변환
        HttpWebResponse response = (HttpWebResponse)https.GetResponse();
        Encoding enc = System.Text.Encoding.GetEncoding(1252);
        StreamReader loResponseStream = new StreamReader(response.GetResponseStream(), enc);
        string retHtml = loResponseStream.ReadToEnd();
        response.Close();
        loResponseStream.Close();

        return retHtml;
}

③취소

/// <summary>
/// 결제취소
/// </summary>
/// <param name="clientip">제우스발행코드</param>
/// <param name="ordd">신용카드결제번호</param>
/// <returns></returns>
public static string CardCancel(string clientip, string ordd)
{
    // 취소 Url 및 파라매터 설정
    Uri uri = new Uri("https://linkpt.cardservice.co.jp/cgi-bin/secure.cgi");
    HttpWebRequest https = (HttpWebRequest)WebRequest.Create(uri);
    https.Method = "POST";
    string param = "clientip=" + clientip                   // 제우스에서 발행해준 코드값
                   + "&return=" + "yes"                     // 취소처리고정파라매터 yes값만 설정가능
                   + "&ordd=" + ordd;                       // 카드결제번호            

    // 취소 Request 및 Response 확인
    byte[] postBuffer = System.Text.Encoding.GetEncoding(1252).GetBytes(param);
    Stream postData = https.GetRequestStream();
    postData.Write(postBuffer, 0, postBuffer.Length);
    postData.Close();
    
    // 취소 Response를 확인가능한 출력형태로 변환
    HttpWebResponse response = (HttpWebResponse)https.GetResponse();
    Encoding enc = System.Text.Encoding.GetEncoding(1252);
    StreamReader loResponseStream = new StreamReader(response.GetResponseStream(), enc);
    string retHtml = loResponseStream.ReadToEnd();
    response.Close();
    loResponseStream.Close();          
    
    return retHtml;
}
반응형

댓글