Tutorial
Following is an example to implement cash receipt issuance (RegistIssue) API by adding the POPBiLL SDK within Java setting.
1. Add POPBiLL SDK
To add POPBiLL Java SDK, input POPBiLL Java SDK dependency information on “pom.xml” file of Spring project and update the Maven.
<dependency>
<groupId>kr.co.linkhub</groupId>
<artifactId>popbill-sdk</artifactId>
<version>1.64.0</version>
</dependency>
2. POPBiLL SDK Setting
Add Cash Receipt class into Spring Bean. By referring to the code below, edit “servlet-context.xml” file.
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
<annotation-driven/>
<resources mapping="/resources/**" location="/resources/"/>
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/"/>
<beans:property name="suffix" value=".jsp"/>
</beans:bean>
<context:component-scan base-package="com.popbill.example"/>
<util:properties id="EXAMPLE_CONFIG">
<!-- LinkID -->
<beans:prop key="LinkID">TESTER</beans:prop>
<!-- SecretKey -->
<beans:prop key="SecretKey">SwWxqU+0TErBXy/9TVjIPEnI0VTUMMSQZtJf3Ed8q3I=</beans:prop>
<!-- Stage setting value , true(TEST), false(PRODUCTION) -->
<beans:prop key="IsTest">true</beans:prop>
<!-- Whether to recommend use of authentication token IP restriction function or not, -->
<!-- recommended to use (true) -->
<beans:prop key="IsIPRestrictOnOff">true</beans:prop>
<!-- Whether to use POPBiLL API service static IP or not, -->
<!-- true – use, false- do not use, default(false) -->
<beans:prop key="UseStaticIP">false</beans:prop>
<!-- Whether to use local system time or not, -->
<!-- true – use(default – recommended), false – do not use -->
<beans:prop key="UseLocalTimeYN">true</beans:prop>
</util:properties>
<beans:beans>
<!-- Cash Receipt Service Implementation Bean registration. -->
<beans:bean id="cashbillService"
class="com.popbill.api.cashbill.CashbillServiceImp">
<beans:property name="linkID" value="#{EXAMPLE_CONFIG.LinkID}"/>
<beans:property name="secretKey" value="#{EXAMPLE_CONFIG.SecretKey}"/>
<beans:property name="test" value="#{EXAMPLE_CONFIG.IsTest}"/>
<beans:property name="IPRestrictOnOff" value="#{EXAMPLE_CONFIG.IsIPRestrictOnOff}"/>
<beans:property name="useStaticIP" value="#{EXAMPLE_CONFIG.UseStaticIP}"/>
<beans:property name="useLocalTimeYN" value="#{EXAMPLE_CONFIG.UseLocalTimeYN}"/>
</beans:bean>
</beans:beans>
</beans:beans>
3. Implement RegistIssue Function
① To add Service Class Bean object, add @Autowired annotation and registIssue API code.
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.popbill.api.CashbillService;
import com.popbill.api.PopbillException;
import com.popbill.api.CBIssueResponse;
import com.popbill.api.cashbill.Cashbill;
@Controller
@RequestMapping(value = "CashbillService")
public class CashbillServiceExample {
@Autowired
private CashbillService cashbillService;
@RequestMapping(value = "registIssue", method = RequestMethod.GET)
public String registIssue(Model m) {
// [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("20220101-001");
// 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 deduction 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");
try {
CBIssueResponse response = cashbillService.registIssue(corpNum, cashbill, Memo);
m.addAttribute("Response", response);
} catch (PopbillException e) {
// If an exceptional error occurs,
// check the error code with e.getCode()
// and check the error message with e.getMessage()
System.out.println("Error Code : " + e.getCode());
System.out.println("Error Message : " + e.getMessage());
}
return "response";
}
}
② Add response.jsp file that outputs the code and message of the API calling result.
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Popbill SDK Response</title>
</head>
<body>
<p>Response code (Response.code) : ${Response.code}</p>
<p>Response message (Response.message) : ${Response.message}</p>
<li>NTS confirmation number (Response.ntsConfirmNum) : ${Response.ntsConfirmNum}</p>
<li>TradeDate (Response.tradeDate) : ${Response.tradeDate}</p>
</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]

