POPBill Developers
SDK Reference
Java

Tutorial

Following is an example to implement e-Commercial Invoice 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 e-Commercial Invoice 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 e-Commercical Invoice Service Class  Bean --%>
<jsp:useBean id="statementService" scope="application" class="com.popbill.api.statement.StatementServiceImp" />

<%-- LinkID – enter the provided API credentials information --%>
<jsp:setProperty name="statementService" property="linkID" value="TESTER" />

<%-- SecretKey– enter the provided API credentials information --%>
<jsp:setProperty name="statementService" property="secretKey" value="SwWxqU+0TErBXy/9TVjIPEnI0VTUMMSQZtJf3Ed8q3I=" />

<%-- STAGE configuration setting, true – TEST , false – PRODUCTION --%>
<jsp:setProperty name="statementService" 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="statementService" 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="statementService" property="useStaticIP" value="false"/>

<%-- Whether to use local system time or not, --%>
<%-- true – use (default – recommended), false – do not use --%>
<jsp:setProperty name="statementService" 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 Statement Example</title>
    </head>
<%@ include file="common.jsp" %>
<%@page import="java.util.Map"%>
<%@page import="java.util.HashMap"%>
<%@page import="java.util.ArrayList"%>
<%@page import="com.popbill.api.Response"%>
<%@page import="com.popbill.api.PopbillException"%>
<%@page import="com.popbill.api.statement.Statement"%>
<%@page import="com.popbill.api.statement.StatementDetail"%>
<%

    // [Seller] business registration number
    String corpNum = "1234567890";

    // [Seller] POPBiLL ID
    String testUserID = "testkorea";

    // Title of a notification mail, default if not entered
    String emailSubject = "Email Subject";

    // Memo
    String memo = "Memo";

    // E-Commercial invoice information object
    Statement statement = new Statement();

    // [Mandatory] date of preparation, format : yyyyMMdd
    statement.setWriteDate("20220101");

    // [Mandatory] payments received or not, select either [영수(paid), 청구(charge),없음(none)]
    statement.setPurposeType("영수");

    // [Mandatory] tax type, enter either {과세,영세,면세}.
    // *과세 : taxable, 영세 : zero-rated, 면세 : exempted
    statement.setTaxType("과세");

    // Custom form code, default if not entered.
    statement.setFormCode("");

    // [Mandatory] types of invoice,
    // [121 – transaction details], [122- bill],
    // [123 – estimate], [124 – purchase order],
    // [125 – deposit slip], [126 – receipt]
    statement.setItemCode((short) 121);

    // [Mandatory] document ID,
    // combination of 1~24 alphanumeric characters(number, alphabet, ‘-’, ‘_’)
    statement.setMgtKey("ABC0226-TEST001");

    /***************************************************************************
    *                           Sender Information
    ****************************************************************************/

    // [Sender] business registration number
    statement.setSenderCorpNum(testCorpNum);

    // [Sender] company name
    statement.setSenderCorpName("Sender Company Name");

    // [Sender] company address
    statement.setSenderAddr("Sender Address");

    // [Sender] CEO name
    statement.setSenderCEOName("Sender Company's CEO Name");

    // [Sender] branch number, 4-digits, optional entry
    statement.setSenderTaxRegID("");

    // [Sender] items of business
    statement.setSenderBizClass("Sender Business Class");

    // [Sender] type of business
    statement.setSenderBizType(Sender Business Type");

    // [Sender] name of the person in charge
    statement.setSenderContactName("Sender Contactor Name");

    // [Sender] email of the person in charge
    statement.setSenderEmail("test@test.com");

    // [Sender] contact number of the person in charge
    statement.setSenderTEL("070-7070-0707");

    // [Sender] cell phone number of the person in charge
    statement.setSenderHP("010-000-2222");

    /***************************************************************************
    *                         Receiver Information
    ****************************************************************************/

    // [Receiver] business registration number
    statement.setReceiverCorpNum("8888888888");

    // [Receiver] company name
    statement.setReceiverCorpName("Receiver Company Name");

    // [Receiver] CEO name
    statement.setReceiverCEOName("Receiver Company's CEO Name");

    // [Receiver] company address
    statement.setReceiverAddr("Receiver Address");

    // [Receiver] items of business
    statement.setReceiverBizClass("Receiver Business Class");

    // [Receiver] type of business
    statement.setReceiverBizType("Receiver Business Type");

    // [Receiver] name of the person in charge
    statement.setReceiverContactName("Receiver Contactor Name");

    // [Receiver] email
    // Do not include the email address of an actual customer
    // POPBiLL sends an instructional email in the TEST stage as well
    statement.setReceiverEmail("test@test.com");

    /***************************************************************************
    *                   Information of e-Commercial Invoice
    ****************************************************************************/

    // [Mandatory] total amount of supply value
    statement.setSupplyCostTotal("400000");

    // [Mandatory] total amount of tax
    statement.setTaxTotal("40000");

    // [Mandatory] total amount. supply value + tax
    statement.setTotalAmount("440000");

    // Serial number
    statement.setSerialNum("123");

    // Remark
    statement.setRemark1("Remark1");
    statement.setRemark2("Remark2");
    statement.setRemark3("Remark3");

    /*********************************************************************
    *              Item Information of e-Commercial Invoice
    *********************************************************************/

    // Array of list of detailed item information
    statement.setDetailList(new ArrayList<StatementDetail>());

    StatementDetail detail = new StatementDetail();

        detail.setSerialNum((short) 1);  // Serial number, write sequentially starting from 1
        detail.setItemName("Item1");  // Item name
        detail.setPurchaseDT("20211125");  // Date of trade
        detail.setQty("1");  // Quantity
        detail.setSupplyCost("200000");  // Supply value
        detail.setTax("20000");  // Tax

        statement.getDetailList().add(detail);

        detail = new StatementDetail();
        detail.setSerialNum((short) 2);  // Serial number, write sequentially starting from 1
        detail.setItemName("Item2");  // Item name
        detail.setPurchaseDT("20211125");  // Date of trade
        detail.setQty("1");  // Quantity
        detail.setSupplyCost("200000");  // Supply value
        detail.setTax("20000");  // Tax

    statement.getDetailList().add(detail);

    /***************************************************************************
    *               Additional properties of e-Commercial Invoice
    ****************************************************************************/

    Map<String, String> propertyBag = new HashMap<String, String>();

    propertyBag.put("Balance", "15000");   // Amount before deposit
    propertyBag.put("Deposit", "5000");    // Deposit amount
    propertyBag.put("CBalance", "20000");  // Remaining amount

    statement.setPropertyBag(propertyBag);

    Response CheckResponse = null;

    try {
        CheckResponse = statementService.registIssue(corpNum, statement, memo, testUserID, emailSubject);
    } 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>Statement Issuance</legend>
            <ul>
                <li>Response Code (Response.code) : <%=CheckResponse.getCode()%></li>
                <li>POPBiLL confirm number (Response.message) : <%=CheckResponse.getMessage()%></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]