Tutorial
Following is an example to implement cash receipt issuance (RegistIssue) API by adding the POPBiLL SDK within Java setting.
1. Add POPBiLL SDK
① Download the Java – JSP SDK exemplary code from POPBiLL library and decompress it.
② Copy 3 jar files from the folder within the WEB-INF/lib/ of SDK exemplary code and paste it to the project library folder.
2. POPBiLL SDK Setting
For Cash Receipt service configuration setting, generate “$CATALINA_HOME?webapps/ROOT/common.jsp” file within the file path of the project. Then, complete the setting of the authentication information by referring to the code below.
<%-- Generate cash receipt Service Class Bean --%>
<jsp:useBean id="cashbillService" scope="application" class="com.popbill.api.cashbill.CashbillServiceImp" />
<%-- LinkID – enter the provided API credentials information --%>
<jsp:setProperty name="cashbillService" property="linkID" value="TESTER" />
<%-- SecretKey– enter the provided API credentials information --%>
<jsp:setProperty name="cashbillService" property="secretKey" value="SwWxqU+0TErBXy/9TVjIPEnI0VTUMMSQZtJf3Ed8q3I=" />
<%-- STAGE configuration setting, --%>
<%-- true – TEST, false – PRODUCTION --%>
<jsp:setProperty name="cashbillService" property="test" value="true" />
<%-- Whether to register the Authentication token registration IP or not (On/Off), --%>
<%-- true – On(default-recommended), false - Off – PRODUCTION --%>
<jsp:setProperty name="cashbillService" property="IPRestrictOnOff" value="true" />
<%-- Whether to use static IP or not, --%>
<%-- true – use static IP, false – do not use static IP(default) --%>
<jsp:setProperty name="cashbillService" property="useStaticIP" value="false"/>
<%-- Whether to use local system time or not, --%>
<%-- true – use (default – recommended), false – do not use --%>
<jsp:setProperty name="cashbillService" property="useLocalTimeYN" value="true"/>
3. Implement RegistIssue Function
Generate the “$CATALINA_HOME/webapps/ROOT/RegistIssue.jsp” file. Then, add the code to call API by referring to the example below.
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Popbill Cashbill Example</title>
</head>
<%@ include file="common.jsp" %>
<%@page import="com.popbill.api.Response"%>
<%@page import="com.popbill.api.PopbillException"%>
<%@page import="com.popbill.api.cashbill.Cashbill"%>
<%
// [Seller] business registration number
String corpNum = "1234567890";
// Memo
String memo = "Memo";
// Cash receipt information object
Cashbill cashbill = new Cashbill();
// Document ID
// combination of 1~24 alphanumeric characters(number, alphabet, ‘-’, ‘_’)
cashbill.setMgtKey("ABC0226-TEST001");
// Document type, enter either {승인거래, 취소거래}.
// *승인거래 : general cash receipt,
// *취소거래 : cash receipt for revocation
cashbill.setTradeType("승인거래");
// Original NTS confirmation number
// – enter the value of confirmNum via getInfo API.
// It is mandatory to enter for cash receipt for revocation.
cashbill.setOrgConfirmNum("");
// Date of trade on the original cash receipt
// – enter the value of tradeDate via getInfo API.
// It is mandatory to enter for cash receipt for revocation.
cashbill.setOrgTradeDate("");
// Taxation type, enter either {과세, 비과세}.
// *과세 : taxable, 비과세 : exempted
cashbill.setTaxationType("과세");
// [Buyer] identification number,
// enter according to the purpose of issuance.
// Income decduction usage
// – enter either resident registration number/phone number/card number.
// Proof of purchase usage
// – enter either business registration number/ resident registration number/phone number/card number.
cashbill.setIdentityNum("0101112222");
// Taxation type, enter either {소득공제용, 지출증빙용}.
// *소득공제용 : income deduction usage,
// *지출증빙용 : proof of purchase usage
cashbill.setTradeUsage("소득공제용");
// Trade type, enter either {일반, 도서공연, 대중교통}.
// *일반 : general,
// *도서공연 : book/performance,
// *대중교통 : public transportation
cashbill.setTradeOpt("일반");
// Supply value, enter digits only
cashbill.setSupplyCost("10000");
// Tax amount, enter digits only
cashbill.setTax("1000");
// Service fee, enter digits only
cashbill.setServiceFee("0");
// Total amount, enter digits only,
// sum of service fee + supply value + tax
cashbill.setTotalAmount("11000");
// [Seller] business registration number
// (10-digits except ‘-’)
cashbill.setFranchiseCorpNum(corpNum);
// [Seller] branch number
cashbill.setFranchiseTaxRegID("");
// [Seller] company name
cashbill.setFranchiseCorpName("Company Name");
// [Seller] CEO name
cashbill.setFranchiseCEOName("Company's CEO Name");
// [Seller] company address
cashbill.setFranchiseAddr("Company Address");
// [Seller] contact number
cashbill.setFranchiseTEL("07043042991");
// [Seller] whether to send a notification mail or not
cashbill.setSmssendYN(false);
// [Buyer] customer name
cashbill.setCustomerName("Customer Name");
// [Buyer] item name
cashbill.setItemName("Item Name");
// [Buyer] order number
cashbill.setOrderNumber("Order Number");
// [Buyer] email
// Do not include the email address of an actual customer
// POPBiLL sends an instructional email in the TEST stage as well
cashbill.setEmail("test@test.com");
// [Buyer] phone number
cashbill.setHp("010111222");
CBIssueResponse CheckResponse = null;
try {
CheckResponse = cashbillService.registIssue(corpNum, cashbill, memo);
} catch (PopbillException pe) {
// If an exceptional error occurs,
// check the error code with pe.getCode()
// and check the error message with pe.getMessage()
System.out.println("Error Code : " + pe.getCode());
System.out.println("Error Message : " + pe.getMessage());
throw pe;
}
%>
<body>
<p>Response</p>
<br/>
<fieldset>
<legend>Cashbill Issuance</legend>
<ul>
<li>Response code (Response.code) : <%=CheckResponse.getCode()%></li>
<li>Resonse Message (Response.message) : <%=CheckResponse.getMessage()%></li>
<li>NTS confirmation number (Response.ntsConfirmNum) : <%=CheckResponse.getNtsConfirmNum()%></li>
<li>TradeDate (Response.tradeDate) : <%=CheckResponse.getTradeDate()%></li>
</ul>
</fieldset>
</body>
</html>
4. Check the Result
If the API calling is being processed successfully, Response code will be returned as “1” and if it fails, an error code(8-digits that starts with “-”) and error message will be returned to POPBiLL Exception. [Error Code]

