JavaScript SDK Integration API
This document explains how to integrate the Checkout using the Hecto Financial JavaScript SDK (SettlePG).
Important Notes
Checkout Timeout
Loading the SDK Script
<!-- Sandbox environment -->
<script src="https://tbnpg.settlebank.co.kr/resources/js/v1/SettlePG_v1.2.js"></script>
<!-- Production environment -->
<script src="https://npg.settlebank.co.kr/resources/js/v1/SettlePG_v1.2.js"></script>
SETTLE_PG.pay()
SETTLE_PG.pay(options, callback);
| Parameter | Type | Required | Description |
|---|---|---|---|
options | Object | O | Payment request parameters (see details below) |
callback | Function | - | Callback to receive results in iframe mode |
Script Parameter Definitions
Parameters passed to the options object of SETTLE_PG.pay(). The SDK validates only env, mchtId, method, and ui; the remaining parameters are validated on the server.
Required Parameters
https://tbnpg.settlebank.co.krSandbox: https://tbnpg.settlebank.co.kr Production: https://npg.settlebank.co.krnxca_jt_ilCACA: Credit Card VA: Virtual Account RA: Bank Transfer MP: Mobile Payment20240101153045ORDER2024010115304510000https://example.com/api/payment/notihttps://example.com/payment/successabc123...{ type: "popup", width: 430, height: 660 }Optional Parameters
Hecto FinancialHecto FinancialLaptop PurchaseHong Gil-dongShinhan 1234-56-7890https://example.com/payment/cancelname=Hong&age=25127.0.0.1ui Object Parameters
popuppopup: Popup window iframe: Layer overlay self: Current window blank: New window430660UI Type Behavior
Specify the Checkout display mode using the SDK's ui.type option.
popup
SETTLE_PG.pay({
env: "https://tbnpg.settlebank.co.kr",
ui: { type: "popup", width: 430, height: 660 },
// ... payment method-specific parameters
}, null);
- Displays the Checkout in a separate popup window
- Shows a guidance message if the popup is blocked
- Redirects to
nextUrlafter payment completion
iframe (Layer) ⚠️
Avoid iframe method
SETTLE_PG.pay({
env: "https://tbnpg.settlebank.co.kr",
ui: { type: "iframe", width: 430, height: 660 },
// ... payment method-specific parameters
}, function(response) {
// Receive result
if (response.outStatCd === "0021") {
console.log("Success:", response.trdNo);
} else {
console.log("Failure:", response.outRsltMsg);
}
});
- Displays the Checkout as a dimmed layer overlay on the current page
- Receives payment result via callback function (iframe only)
iframe callback is for display purposes
Callback Response Parameters
Key parameters of the response object passed to the callback function in iframe mode.
| Parameter | Type | Description |
|---|---|---|
outStatCd | AN(4) | Transaction status code (0021: Success, 0031: Failure, 0041: Pending, 0051: In Progress) |
outRsltCd | AN(4) | Detailed result code |
outRsltMsg | AHN(200) | Result message |
trdNo | AN(40) | Hecto Financial transaction number |
mchtTrdNo | AN(100) | Merchant order number |
trdAmt | N(12) | Transaction amount |
method | A(10) | Payment method code |
For additional parameters per payment method (card company name, virtual account number, etc.), refer to the Checkout Integration document.
Order Processing Notice
self (Current Window)
SETTLE_PG.pay({
env: "https://tbnpg.settlebank.co.kr",
ui: { type: "self" },
// ... payment method-specific parameters
}, null);
- Navigates to the payment page within the current window
- Redirects to
nextUrlafter payment completion - Navigates to
cancUrlwhen going back
blank (New Window)
SETTLE_PG.pay({
env: "https://tbnpg.settlebank.co.kr",
ui: { type: "blank" },
// ... payment method-specific parameters
}, null);
- Displays the Checkout in a new tab/window
- Similar to popup but uses the browser's default new window behavior
Server-Side Processing
Before invoking the SDK, the backend must generate the transaction amount encryption (AES-256) and request signature hash (SHA-256).
Details: Before You Begin — Encryption and Request Signature (pktHash)
Error Handling
The SDK automatically detects errors and displays messages via browser alert. Below are examples of key error messages.
Popup Blocked
When a popup is blocked, the SDK automatically displays a guidance message.
[Hecto Financial] Popup blocking is enabled. Please disable it and try again.
How to unblock popups:
- Chrome: Click the popup blocked icon on the right side of the address bar → 'Always allow'
- Safari: Preferences → Websites → Pop-up Windows → 'Allow'
- Edge: Settings → Cookies and site permissions → Pop-ups and redirects → Allow
Missing Required Parameters
The SDK automatically validates basic common parameters (mchtId, env, ui, etc.) and displays an alert if any are missing.
Server-Side Validation
[Hecto Financial] Call parameter error (mchtId is null)
Payment Method-Specific Parameters
The SDK integration method is the same for all payment methods. Refer to the documents below for detailed parameters per payment method.
Details: Checkout Integration — Payment Method-Specific Parameters (Credit card, bank transfer, virtual account, mobile payment, and 16 other payment methods)
Need technical support?
Code Samples
HectoFinancial GitHub