@tosspayments/tosspayments-sdk 2.7.0 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -2,18 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var SCRIPT_URL = 'https://js.tosspayments.com/v2/standard';
6
-
7
- function clearTossPayments() {
8
- var _script$parentElement;
9
-
10
- var script = document.querySelector("script[src=\"".concat(SCRIPT_URL, "\"]"));
11
- script === null || script === void 0 ? void 0 : (_script$parentElement = script.parentElement) === null || _script$parentElement === void 0 ? void 0 : _script$parentElement.removeChild(script); // TODO: public interface에서 TossPayments의 global declaration 추가한 뒤 제거 예정입니다
12
- // @ts-ignore
13
-
14
- window.TossPayments = undefined;
15
- }
16
-
17
5
  function _classCallCheck(instance, Constructor) {
18
6
  if (!(instance instanceof Constructor)) {
19
7
  throw new TypeError("Cannot call a class as a function");
@@ -156,13 +144,23 @@ function _createSuper(Derived) {
156
144
  };
157
145
  }
158
146
 
159
- var cachedPromise = null;
147
+ // `${src}::${namespace}` 조합으로 캐싱하여 서로 다른 src/namespace 가 같은 캐시를 공유하지 않도록 합니다.
148
+ // (이전 구현은 module-level 단일 promise라 첫 호출만 기억되어, 두 번째 호출이 다른 src 를 전달해도
149
+ // 기존 promise 가 반환되던 문제가 있었습니다.)
150
+ var cache = new Map();
151
+
152
+ function cacheKey(src, namespace) {
153
+ return "".concat(src, "::").concat(namespace);
154
+ }
155
+
160
156
  function loadScript(src, namespace) {
161
157
  var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
158
+ var key = cacheKey(src, namespace); // Return the cached Promise if it exists for this src/namespace combination
159
+
160
+ var hit = cache.get(key);
162
161
 
163
- // Return the cached Promise if it exists
164
- if (cachedPromise != null) {
165
- return cachedPromise;
162
+ if (hit != null) {
163
+ return hit;
166
164
  }
167
165
 
168
166
  var promise = new Promise(function (resolve, reject) {
@@ -215,13 +213,32 @@ function loadScript(src, namespace) {
215
213
  reject(error);
216
214
  return;
217
215
  }
218
- }); // Reset the cache if the Promise is rejected
216
+ }); // Reset the cache entry if the Promise is rejected so the next call can retry
219
217
 
220
- cachedPromise = promise["catch"](function (error) {
221
- cachedPromise = null;
218
+ var cached = promise["catch"](function (error) {
219
+ cache["delete"](key);
222
220
  return Promise.reject(error);
223
221
  });
224
- return cachedPromise;
222
+ cache.set(key, cached);
223
+ return cached;
224
+ }
225
+ /**
226
+ * 캐싱된 loadScript Promise 를 비웁니다.
227
+ *
228
+ * - 인자 없이 호출하면 전체 캐시를 비웁니다.
229
+ * - src 와 namespace 를 모두 전달하면 해당 조합의 캐시만 제거합니다.
230
+ *
231
+ * 외부 SDK 의 reset/cleanup 로직에서 namespace 와 script 를 함께 정리할 때 호출하여
232
+ * 다음 loadScript 호출이 stale promise 를 반환하지 않도록 합니다.
233
+ */
234
+
235
+ function clearCache(src, namespace) {
236
+ if (src != null && namespace != null) {
237
+ cache["delete"](cacheKey(src, namespace));
238
+ return;
239
+ }
240
+
241
+ cache.clear();
225
242
  }
226
243
 
227
244
  function getNamespace(name) {
@@ -264,6 +281,13 @@ var ScriptLoadFailedError = /*#__PURE__*/function (_Error2) {
264
281
  return ScriptLoadFailedError;
265
282
  }( /*#__PURE__*/_wrapNativeSuper(Error));
266
283
 
284
+ var SCRIPT_URL = 'https://js.tosspayments.com/v2/standard';
285
+
286
+ var NAMESPACE = 'TossPayments'; // loadTossPayments 가 시도한 (src, namespace) 를 모듈 내부에 추적하여, clearTossPayments 가
287
+ // 호출 시점에 정확히 동일한 스크립트와 sdk-loader 의 cache entry 를 정리할 수 있도록 합니다.
288
+ // key 는 src 만 사용 (namespace 는 현재 고정), 같은 src 의 중복 load 는 자연스럽게 dedupe 됩니다.
289
+
290
+ var loadedRequests = new Map();
267
291
  function loadTossPayments(clientKey) {
268
292
  var loadOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
269
293
  var _loadOptions$src = loadOptions.src,
@@ -272,14 +296,44 @@ function loadTossPayments(clientKey) {
272
296
  if (typeof window === 'undefined') {
273
297
  // XXX(@HyunSeob): SSR할 때 생성자가 사용되는 경우 에러를 발생시키지 않는대신 정상적인 인스턴스를 반환하지 않는다.
274
298
  return Promise.resolve({});
275
- } // regenerator-runtime 의존성을 없애기 위해 `async` 키워드를 사용하지 않는다
299
+ }
276
300
 
301
+ loadedRequests.set(src, {
302
+ src: src,
303
+ namespace: NAMESPACE
304
+ }); // regenerator-runtime 의존성을 없애기 위해 `async` 키워드를 사용하지 않는다
277
305
 
278
- return loadScript(src, 'TossPayments').then(function (TossPayments) {
306
+ return loadScript(src, NAMESPACE).then(function (TossPayments) {
279
307
  return TossPayments(clientKey);
280
308
  });
281
309
  }
282
310
 
311
+ function clearTossPayments() {
312
+ var _defaultScript$parent;
313
+
314
+ if (typeof document === 'undefined' || typeof window === 'undefined') {
315
+ return;
316
+ }
317
+
318
+ loadedRequests.forEach(function (_ref) {
319
+ var _script$parentElement;
320
+
321
+ var src = _ref.src,
322
+ namespace = _ref.namespace;
323
+ var script = document.querySelector("script[src=\"".concat(src, "\"]"));
324
+ script === null || script === void 0 ? void 0 : (_script$parentElement = script.parentElement) === null || _script$parentElement === void 0 ? void 0 : _script$parentElement.removeChild(script);
325
+ clearCache(src, namespace);
326
+ });
327
+ loadedRequests.clear(); // fallback: loadTossPayments 를 거치지 않고 HTML inline / SSR / 다른 코드 경로로 직접 inject 된
328
+ // default SCRIPT_URL 스크립트도 함께 정리합니다. (기존 동작 호환)
329
+
330
+ var defaultScript = document.querySelector("script[src=\"".concat(SCRIPT_URL, "\"]"));
331
+ defaultScript === null || defaultScript === void 0 ? void 0 : (_defaultScript$parent = defaultScript.parentElement) === null || _defaultScript$parent === void 0 ? void 0 : _defaultScript$parent.removeChild(defaultScript); // TODO: public interface에서 TossPayments의 global declaration 추가한 뒤 제거 예정입니다
332
+ // @ts-ignore
333
+
334
+ delete window.TossPayments;
335
+ }
336
+
283
337
  var ANONYMOUS = '@@ANONYMOUS';
284
338
 
285
339
  exports.ANONYMOUS = ANONYMOUS;
package/dist/index.esm.js CHANGED
@@ -1,15 +1,3 @@
1
- var SCRIPT_URL = 'https://js.tosspayments.com/v2/standard';
2
-
3
- function clearTossPayments() {
4
- var _script$parentElement;
5
-
6
- var script = document.querySelector("script[src=\"".concat(SCRIPT_URL, "\"]"));
7
- script === null || script === void 0 ? void 0 : (_script$parentElement = script.parentElement) === null || _script$parentElement === void 0 ? void 0 : _script$parentElement.removeChild(script); // TODO: public interface에서 TossPayments의 global declaration 추가한 뒤 제거 예정입니다
8
- // @ts-ignore
9
-
10
- window.TossPayments = undefined;
11
- }
12
-
13
1
  function _classCallCheck(instance, Constructor) {
14
2
  if (!(instance instanceof Constructor)) {
15
3
  throw new TypeError("Cannot call a class as a function");
@@ -152,13 +140,23 @@ function _createSuper(Derived) {
152
140
  };
153
141
  }
154
142
 
155
- var cachedPromise = null;
143
+ // `${src}::${namespace}` 조합으로 캐싱하여 서로 다른 src/namespace 가 같은 캐시를 공유하지 않도록 합니다.
144
+ // (이전 구현은 module-level 단일 promise라 첫 호출만 기억되어, 두 번째 호출이 다른 src 를 전달해도
145
+ // 기존 promise 가 반환되던 문제가 있었습니다.)
146
+ var cache = new Map();
147
+
148
+ function cacheKey(src, namespace) {
149
+ return "".concat(src, "::").concat(namespace);
150
+ }
151
+
156
152
  function loadScript(src, namespace) {
157
153
  var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
154
+ var key = cacheKey(src, namespace); // Return the cached Promise if it exists for this src/namespace combination
155
+
156
+ var hit = cache.get(key);
158
157
 
159
- // Return the cached Promise if it exists
160
- if (cachedPromise != null) {
161
- return cachedPromise;
158
+ if (hit != null) {
159
+ return hit;
162
160
  }
163
161
 
164
162
  var promise = new Promise(function (resolve, reject) {
@@ -211,13 +209,32 @@ function loadScript(src, namespace) {
211
209
  reject(error);
212
210
  return;
213
211
  }
214
- }); // Reset the cache if the Promise is rejected
212
+ }); // Reset the cache entry if the Promise is rejected so the next call can retry
215
213
 
216
- cachedPromise = promise["catch"](function (error) {
217
- cachedPromise = null;
214
+ var cached = promise["catch"](function (error) {
215
+ cache["delete"](key);
218
216
  return Promise.reject(error);
219
217
  });
220
- return cachedPromise;
218
+ cache.set(key, cached);
219
+ return cached;
220
+ }
221
+ /**
222
+ * 캐싱된 loadScript Promise 를 비웁니다.
223
+ *
224
+ * - 인자 없이 호출하면 전체 캐시를 비웁니다.
225
+ * - src 와 namespace 를 모두 전달하면 해당 조합의 캐시만 제거합니다.
226
+ *
227
+ * 외부 SDK 의 reset/cleanup 로직에서 namespace 와 script 를 함께 정리할 때 호출하여
228
+ * 다음 loadScript 호출이 stale promise 를 반환하지 않도록 합니다.
229
+ */
230
+
231
+ function clearCache(src, namespace) {
232
+ if (src != null && namespace != null) {
233
+ cache["delete"](cacheKey(src, namespace));
234
+ return;
235
+ }
236
+
237
+ cache.clear();
221
238
  }
222
239
 
223
240
  function getNamespace(name) {
@@ -260,6 +277,13 @@ var ScriptLoadFailedError = /*#__PURE__*/function (_Error2) {
260
277
  return ScriptLoadFailedError;
261
278
  }( /*#__PURE__*/_wrapNativeSuper(Error));
262
279
 
280
+ var SCRIPT_URL = 'https://js.tosspayments.com/v2/standard';
281
+
282
+ var NAMESPACE = 'TossPayments'; // loadTossPayments 가 시도한 (src, namespace) 를 모듈 내부에 추적하여, clearTossPayments 가
283
+ // 호출 시점에 정확히 동일한 스크립트와 sdk-loader 의 cache entry 를 정리할 수 있도록 합니다.
284
+ // key 는 src 만 사용 (namespace 는 현재 고정), 같은 src 의 중복 load 는 자연스럽게 dedupe 됩니다.
285
+
286
+ var loadedRequests = new Map();
263
287
  function loadTossPayments(clientKey) {
264
288
  var loadOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
265
289
  var _loadOptions$src = loadOptions.src,
@@ -268,14 +292,44 @@ function loadTossPayments(clientKey) {
268
292
  if (typeof window === 'undefined') {
269
293
  // XXX(@HyunSeob): SSR할 때 생성자가 사용되는 경우 에러를 발생시키지 않는대신 정상적인 인스턴스를 반환하지 않는다.
270
294
  return Promise.resolve({});
271
- } // regenerator-runtime 의존성을 없애기 위해 `async` 키워드를 사용하지 않는다
295
+ }
272
296
 
297
+ loadedRequests.set(src, {
298
+ src: src,
299
+ namespace: NAMESPACE
300
+ }); // regenerator-runtime 의존성을 없애기 위해 `async` 키워드를 사용하지 않는다
273
301
 
274
- return loadScript(src, 'TossPayments').then(function (TossPayments) {
302
+ return loadScript(src, NAMESPACE).then(function (TossPayments) {
275
303
  return TossPayments(clientKey);
276
304
  });
277
305
  }
278
306
 
307
+ function clearTossPayments() {
308
+ var _defaultScript$parent;
309
+
310
+ if (typeof document === 'undefined' || typeof window === 'undefined') {
311
+ return;
312
+ }
313
+
314
+ loadedRequests.forEach(function (_ref) {
315
+ var _script$parentElement;
316
+
317
+ var src = _ref.src,
318
+ namespace = _ref.namespace;
319
+ var script = document.querySelector("script[src=\"".concat(src, "\"]"));
320
+ script === null || script === void 0 ? void 0 : (_script$parentElement = script.parentElement) === null || _script$parentElement === void 0 ? void 0 : _script$parentElement.removeChild(script);
321
+ clearCache(src, namespace);
322
+ });
323
+ loadedRequests.clear(); // fallback: loadTossPayments 를 거치지 않고 HTML inline / SSR / 다른 코드 경로로 직접 inject 된
324
+ // default SCRIPT_URL 스크립트도 함께 정리합니다. (기존 동작 호환)
325
+
326
+ var defaultScript = document.querySelector("script[src=\"".concat(SCRIPT_URL, "\"]"));
327
+ defaultScript === null || defaultScript === void 0 ? void 0 : (_defaultScript$parent = defaultScript.parentElement) === null || _defaultScript$parent === void 0 ? void 0 : _defaultScript$parent.removeChild(defaultScript); // TODO: public interface에서 TossPayments의 global declaration 추가한 뒤 제거 예정입니다
328
+ // @ts-ignore
329
+
330
+ delete window.TossPayments;
331
+ }
332
+
279
333
  var ANONYMOUS = '@@ANONYMOUS';
280
334
 
281
335
  export { ANONYMOUS, clearTossPayments, loadTossPayments };
package/package.json CHANGED
@@ -1,22 +1,24 @@
1
1
  {
2
2
  "name": "@tosspayments/tosspayments-sdk",
3
3
  "description": "TossPayments.js Tosspayments SDK.",
4
- "version": "2.7.0",
4
+ "version": "2.8.0",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
7
7
  "types": "types/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./types/index.d.ts",
11
+ "import": "./dist/index.esm.js",
12
+ "require": "./dist/index.cjs.js"
13
+ },
14
+ "./package.json": "./package.json"
15
+ },
8
16
  "author": "Toss Payments",
9
17
  "repository": {
10
18
  "type": "git",
11
19
  "url": "git+https://github.com/tosspayments/browser-sdk.git",
12
20
  "directory": "packages/tosspayments-sdk"
13
21
  },
14
- "scripts": {
15
- "build": "rm -rf dist && rollup -c",
16
- "prepack": "yarn build",
17
- "test": "vitest",
18
- "typecheck": "tsc --noEmit"
19
- },
20
22
  "license": "MIT",
21
23
  "devDependencies": {
22
24
  "@babel/core": "^7.11.6",
@@ -25,8 +27,6 @@
25
27
  "@rollup/plugin-babel": "^5.3.0",
26
28
  "@rollup/plugin-commonjs": "^21.0.1",
27
29
  "@rollup/plugin-typescript": "^8.3.0",
28
- "@tosspayments/sdk-loader": "workspace:packages/sdk-loader",
29
- "@tosspayments/standard-public-interfaces": "2.9.0",
30
30
  "happy-dom": "^14.12.3",
31
31
  "prettier": "^2.0.2",
32
32
  "rollup": "^2.60.0",
@@ -34,7 +34,8 @@
34
34
  "rollup-plugin-dts": "^6.1.1",
35
35
  "tslib": "^1.11.1",
36
36
  "typescript": "5.2.2",
37
- "vitest": "^1.6.0"
37
+ "vitest": "^1.6.0",
38
+ "@tosspayments/sdk-loader": "^2.1.0"
38
39
  },
39
40
  "files": [
40
41
  "dist",
@@ -42,5 +43,10 @@
42
43
  ],
43
44
  "publishConfig": {
44
45
  "access": "public"
46
+ },
47
+ "scripts": {
48
+ "build": "rm -rf dist && rollup -c",
49
+ "test": "vitest",
50
+ "typecheck": "tsc --noEmit"
45
51
  }
46
- }
52
+ }
package/types/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  declare function clearTossPayments(): void;
2
2
 
3
+ // standard-public-interfaces 2.17.1 — 자동 생성 파일입니다. 직접 수정하지 마세요.
4
+
3
5
  type WidgetSelectedPaymentMethod = {
4
6
  /**
5
7
  * 구매자가 결제 UI에서 선택한 결제수단입니다. 예를 들어, 신용・체크카드를 선택하면 `CARD` 코드가 응답됩니다. [ENUM 코드](/codes/enum-codes) 및 [기관 코드](/codes/org-codes)를 참고하세요.
@@ -173,6 +175,17 @@ interface WidgetPaymentRequest {
173
175
  * 페이북/ISP 앱에서 상점 앱으로 돌아올 때 사용됩니다. 상점의 앱 스킴을 지정하면 됩니다. 예를 들면 testapp://같은 형태입니다.
174
176
  */
175
177
  appScheme?: string | null;
178
+ /**
179
+ * 해외카드 결제의 3D Secure 인증 옵션입니다.
180
+ */
181
+ threeDS?: {
182
+ /**
183
+ * 3D Secure 인증에서 구매자에게 챌린지(추가 인증)를 요구할지 여부입니다.
184
+ * `CHALLENGE_REQUIRED`로 설정하면 챌린지 인증을 필수로 요청하고, 카드 발급사가 챌린지 없이 인증을 완료하면 인증을 거절하고 `failUrl`로 이동해요.
185
+ * 값을 설정하지 않으면 챌린지 여부를 카드 발급사 판단에 맡겨요.
186
+ */
187
+ challengeMode?: 'CHALLENGE_REQUIRED' | null;
188
+ } | null;
176
189
  } | null;
177
190
  /**
178
191
  * 구매자가 계좌이체를 선택하면 결제에 적용되는 옵션입니다.
@@ -447,23 +460,14 @@ interface WidgetPaymentWindow {
447
460
  /**
448
461
  * 결제창의 이벤트를 구독합니다.
449
462
  *
450
- * @param {'paymentRequest'} eventName 구독할 이벤트입니다. `paymentRequest` 이벤트로 구매자의 결제 요청을 수신하세요.
463
+ * @param {'paymentRequest' | 'cancel'} eventName 구독할 이벤트입니다.
451
464
  * @param {function} callback 이벤트가 일어나면 호출되는 콜백 함수입니다.
452
465
  *
453
- * @example
454
- * ```javascript
455
- * paymentWindow.on('paymentRequest', ({ paymentMethod }) => {
456
- * // 결제 요청 처리
457
- * });
458
- * ```
459
- *
460
466
  * @throws {@link PublicError.Widgets.InvalidEventParameterError} eventName이 유효하지 않은 경우
461
467
  * @throws {@link PublicError.Widgets.InvalidCallbackParameterError} callback이 유효하지 않은 경우
462
468
  * @throws {@link PublicError.Widgets.UnknownError} 알 수 없는 오류가 발생한 경우
463
469
  */
464
- on: (eventName: 'paymentRequest', callback: (params: {
465
- paymentMethod: WidgetSelectedPaymentMethod;
466
- }) => Promise<void>) => void;
470
+ on: WidgetPaymentWindowOnPaymentRequest & WidgetPaymentWindowOnCancel;
467
471
  /**
468
472
  * 결제창을 제거합니다.
469
473
  *
@@ -476,6 +480,36 @@ interface WidgetPaymentWindow {
476
480
  */
477
481
  destroy: () => Promise<void>;
478
482
  }
483
+ /**
484
+ * @docsAlias paymentRequest 이벤트
485
+ *
486
+ * @param {'paymentRequest'} eventName 구독할 이벤트입니다. `paymentRequest` 이벤트로 구매자의 결제 요청을 수신하세요.
487
+ * @param {function} callback 이벤트가 일어나면 호출되는 콜백 함수입니다.
488
+ *
489
+ * @example
490
+ * ```javascript
491
+ * paymentWindow.on('paymentRequest', ({ paymentMethod }) => {
492
+ * // 결제 요청 처리
493
+ * });
494
+ * ```
495
+ */
496
+ type WidgetPaymentWindowOnPaymentRequest = (eventName: 'paymentRequest', callback: (params: {
497
+ paymentMethod: WidgetSelectedPaymentMethod;
498
+ }) => Promise<void>) => void;
499
+ /**
500
+ * @docsAlias cancel 이벤트
501
+ *
502
+ * @param {'cancel'} eventName 구독할 이벤트입니다. `cancel` 이벤트로 구매자가 결제를 포기했는지 확인하세요. 구매자가 결제창을 닫으면 결제창이 사라진 뒤에 콜백이 호출돼요. `paymentWindow.destroy()`로 결제창을 닫은 경우에는 호출되지 않아요.
503
+ * @param {function} callback 이벤트가 일어나면 호출되는 콜백 함수입니다.
504
+ *
505
+ * @example
506
+ * ```javascript
507
+ * paymentWindow.on('cancel', async () => {
508
+ * // 구매자가 결제를 포기했을 때 처리
509
+ * });
510
+ * ```
511
+ */
512
+ type WidgetPaymentWindowOnCancel = (eventName: 'cancel', callback: () => Promise<void>) => void;
479
513
 
480
514
  /**
481
515
  * 결제 UI 위젯을 렌더링합니다
@@ -839,6 +873,10 @@ interface BrandpayPaymentRequest {
839
873
  * 결제 관련 정보를 추가할 수 있는 객체입니다. 최대 5개의 키-값(key-value) 쌍을 자유롭게 추가해주세요. 키는 `[` , `]` 를 사용하지 않는 최대 40자의 문자열, 값은 최대 2000자의 문자열입니다.
840
874
  */
841
875
  metadata?: Record<string | symbol | number, unknown> | null;
876
+ /**
877
+ * @ignore
878
+ */
879
+ shippingAddress?: string | null;
842
880
  /**
843
881
  * 구매자가 카드를 선택하면 결제에 적용되는 옵션입니다.
844
882
  */
@@ -861,6 +899,26 @@ interface BrandpayPaymentRequest {
861
899
  * [카드 프로모션 조회 API](https://docs.tosspayments.com/reference/brandpay#%EC%B9%B4%EB%93%9C-%ED%94%84%EB%A1%9C%EB%AA%A8%EC%85%98-%EC%A1%B0%ED%9A%8C)로 적용할 수 있는 할인 코드의 목록을 조회할 수 있습니다.
862
900
  */
863
901
  discountCode?: string | null;
902
+ /**
903
+ * @ignore
904
+ */
905
+ affiliateCards?: Array<{
906
+ issuerCode: string;
907
+ cardProductCode: string;
908
+ }> | null;
909
+ /**
910
+ * @ignore
911
+ */
912
+ orderProductCode?: string | null;
913
+ /**
914
+ * @ignore
915
+ */
916
+ dividedSettlements?: Array<{
917
+ subMid: string;
918
+ amount: number;
919
+ taxFreeAmount: number;
920
+ productInfo: string;
921
+ }> | null;
864
922
  } | null;
865
923
  /**
866
924
  * 구매자가 계좌를 선택하면 결제에 적용되는 옵션입니다.
@@ -879,6 +937,19 @@ interface BrandpayPaymentRequest {
879
937
  * [계좌 프로모션 조회 API](https://docs.tosspayments.com/reference/brandpay#%EA%B3%84%EC%A2%8C-%ED%94%84%EB%A1%9C%EB%AA%A8%EC%85%98-%EC%A1%B0%ED%9A%8C)로 적용할 수 있는 할인 코드의 목록을 조회할 수 있습니다.
880
938
  */
881
939
  discountCode?: string | null;
940
+ /**
941
+ * @ignore
942
+ */
943
+ orderProductCode?: string | null;
944
+ /**
945
+ * @ignore
946
+ */
947
+ dividedSettlements?: Array<{
948
+ subMid: string;
949
+ amount: number;
950
+ taxFreeAmount: number;
951
+ productInfo: string;
952
+ }> | null;
882
953
  } | null;
883
954
  }
884
955
  interface BasicCashReceipt {
@@ -1140,6 +1211,21 @@ interface TossPaymentsBrandpay {
1140
1211
  requestBillingAuth: RequestBillingAuth$1;
1141
1212
  }
1142
1213
 
1214
+ /**
1215
+ * 열려있는 결제창을 닫습니다.
1216
+ *
1217
+ * 진행 중인 `requestPayment()` Promise 가 `PaymentRequestAbortedError` 로 reject 됩니다.
1218
+ *
1219
+ * @throws {@link PublicError.Payment.NoActivePaymentRequestError} 진행 중인 결제 요청이 없는 경우
1220
+ * @throws {@link PublicError.Payment.UnknownError} 알 수 없는 오류가 발생한 경우
1221
+ *
1222
+ * @example
1223
+ * ```javascript
1224
+ * await payment.destroy();
1225
+ * ```
1226
+ */
1227
+ type Destroy = () => Promise<void>;
1228
+
1143
1229
  interface PaymentRequest {
1144
1230
  /**
1145
1231
  * 결제 금액 정보입니다.
@@ -1185,6 +1271,10 @@ interface PaymentRequest {
1185
1271
  * 결제 관련 정보를 추가할 수 있는 객체입니다. 최대 5개의 키-값(key-value) 쌍을 자유롭게 추가해주세요. 키는 `[` , `]` 를 사용하지 않는 최대 40자의 문자열, 값은 최대 2000자의 문자열입니다.
1186
1272
  */
1187
1273
  metadata?: Record<string | symbol | number, unknown> | null;
1274
+ /**
1275
+ * @ignore
1276
+ */
1277
+ orderProductCode?: string | null;
1188
1278
  /**
1189
1279
  * @ignore
1190
1280
  */
@@ -1320,6 +1410,27 @@ interface CardPaymentRequest extends PaymentRequest {
1320
1410
  * 해외카드(Visa, MasterCard, JCB, UnionPay 등) 결제 여부입니다. `true`로 설정하면 해외카드 결제가 가능한 [다국어 결제창](/resources/glossary/payment-window#다국어-결제창)이 열립니다.
1321
1411
  */
1322
1412
  useInternationalCardOnly?: boolean | null;
1413
+ /**
1414
+ * 결제창 초기 언어입니다. `KO`(한국어), `EN`(영어), `JA`(일본어), `ZH`(중국어) 중 하나로 설정할 수 있어요.
1415
+ * 값을 설정하지 않으면 결제 통화에 따라 자동으로 결정됩니다.
1416
+ */
1417
+ language?: 'KO' | 'EN' | 'JA' | 'ZH' | null;
1418
+ /**
1419
+ * 다국어 결제창에서 결제 금액 영역에 함께 표시되는 자국 통화 환산 추정 금액(예: `Estimated amount in USD $ 0.07`)의 노출 여부입니다.
1420
+ * `false`로 설정하면 환산 추정 금액이 표시되지 않아요. 값을 설정하지 않으면 `true`로 동작하며, 다국어 결제창이 아닌 경우에는 적용되지 않습니다.
1421
+ */
1422
+ showEstimatedAmount?: boolean | null;
1423
+ /**
1424
+ * 해외카드 결제의 3D Secure 인증 옵션입니다.
1425
+ */
1426
+ threeDS?: {
1427
+ /**
1428
+ * 3D Secure 인증에서 구매자에게 챌린지(추가 인증)를 요구할지 여부입니다.
1429
+ * `CHALLENGE_REQUIRED`로 설정하면 챌린지 인증을 필수로 요청하고, 카드 발급사가 챌린지 없이 인증을 완료하면 인증을 거절하고 `failUrl`로 이동해요.
1430
+ * 값을 설정하지 않으면 챌린지 여부를 카드 발급사 판단에 맡겨요.
1431
+ */
1432
+ challengeMode?: 'CHALLENGE_REQUIRED' | null;
1433
+ } | null;
1323
1434
  /**
1324
1435
  * 페이북/ISP 앱에서 상점 앱으로 돌아올 때 사용됩니다. 상점의 앱 스킴을 지정하면 됩니다. 예를 들면 testapp://같은 형태입니다.
1325
1436
  */
@@ -1333,6 +1444,27 @@ interface CardPaymentRequest extends PaymentRequest {
1333
1444
  */
1334
1445
  selectableCardTypes?: Array<'PERSONAL' | 'CORPORATE' | 'FOREIGN'> | null;
1335
1446
  } | null;
1447
+ /**
1448
+ * 모바일 결제창 상단 헤더의 노출 여부입니다. `false`로 설정하면 헤더가 표시되지 않아요.
1449
+ * 값을 설정하지 않으면 `true`로 동작합니다.
1450
+ */
1451
+ showMobileAppHeader?: boolean | null;
1452
+ /**
1453
+ * @ignore
1454
+ */
1455
+ affiliateCards?: Array<{
1456
+ issuerCode: string;
1457
+ cardProductCode: string;
1458
+ }> | null;
1459
+ /**
1460
+ * @ignore
1461
+ */
1462
+ dividedSettlements?: Array<{
1463
+ subMid: string;
1464
+ amount: number;
1465
+ taxFreeAmount: number;
1466
+ productInfo: string;
1467
+ }> | null;
1336
1468
  } | null;
1337
1469
  }
1338
1470
 
@@ -1402,6 +1534,27 @@ interface VirtualAccountPaymentRequest extends PaymentRequest {
1402
1534
  * 문화비(도서, 공연 티켓, 박물관·미술관 입장권 등) 지출 여부입니다.
1403
1535
  */
1404
1536
  isCulturalExpenses?: boolean | null;
1537
+ /**
1538
+ * 결제창에 구매자 휴대폰 번호 입력란을 노출할지 여부입니다.
1539
+ */
1540
+ showCustomerMobilePhone?: boolean | null;
1541
+ /**
1542
+ * @ignore
1543
+ */
1544
+ refundReceiveAccount?: {
1545
+ /**
1546
+ * @ignore
1547
+ */
1548
+ bankCode: string;
1549
+ /**
1550
+ * @ignore
1551
+ */
1552
+ accountNumber: string;
1553
+ /**
1554
+ * @ignore
1555
+ */
1556
+ holderName: string;
1557
+ } | null;
1405
1558
  } | null;
1406
1559
  }
1407
1560
 
@@ -1476,6 +1629,23 @@ interface TransferPaymentRequest extends PaymentRequest {
1476
1629
  * @ignore
1477
1630
  */
1478
1631
  encryptedCustomerCi?: string | null;
1632
+ /**
1633
+ * @ignore
1634
+ */
1635
+ showSecuritiesAccount?: boolean | null;
1636
+ /**
1637
+ * @ignore
1638
+ */
1639
+ provider?: 'OPENBANKING' | 'BANKPAY' | null;
1640
+ /**
1641
+ * @ignore
1642
+ */
1643
+ dividedSettlements?: Array<{
1644
+ subMid: string;
1645
+ amount: number;
1646
+ taxFreeAmount: number;
1647
+ productInfo: string;
1648
+ }> | null;
1479
1649
  } | null;
1480
1650
  }
1481
1651
 
@@ -1484,6 +1654,18 @@ interface MobilePhonePaymentRequest extends PaymentRequest {
1484
1654
  * 결제수단입니다. `MOBILE_PHONE`으로 설정하면 휴대폰 결제창이 열려요.
1485
1655
  */
1486
1656
  method: 'MOBILE_PHONE';
1657
+ /**
1658
+ * 휴대폰 결제 정보입니다.
1659
+ */
1660
+ mobilePhone?: {
1661
+ /**
1662
+ * 휴대폰 결제창에서 선택할 수 있는 통신사를 제한합니다.
1663
+ * `SKT`(SK텔레콤), `KT`(KT), `LGU`(LG유플러스), `HELLO`(LG헬로모바일), `KCT`(티플러스), `SK7`(SK세븐모바일) 값을 배열 형태로 전달할 수 있습니다.
1664
+ * 예를 들어 `['KT', 'SKT']`로 설정하면 두 통신사만 선택할 수 있어요. 값을 설정하지 않으면 모든 통신사가 노출됩니다.
1665
+ * 전체 목록은 [통신사 코드](https://docs.tosspayments.com/codes/org-codes#통신사-코드)에서 확인하세요.
1666
+ */
1667
+ mobileCarriers?: Array<'KT' | 'LGU' | 'SKT' | 'HELLO' | 'KCT' | 'SK7'> | null;
1668
+ } | null;
1487
1669
  }
1488
1670
 
1489
1671
  interface GiftCertificatePaymentRequest extends PaymentRequest {
@@ -1699,6 +1881,7 @@ type BillingAuthRequest = CardBillingAuthRequest | TransferBillingAuthRequest;
1699
1881
  /**
1700
1882
  *
1701
1883
  * @throws {@link PublicError.Payment.UserCancelError} 사용자가 결제창을 닫은 경우
1884
+ * @throws {@link PublicError.Payment.PaymentRequestAbortedError} `payment.destroy()` 호출로 결제 요청이 중단된 경우
1702
1885
  * @throws {@link PublicError.Payment.InvalidAmountValueError} 결제 금액이 유효하지 않은 경우
1703
1886
  * @throws {@link PublicError.Payment.InvalidAmountCurrencyError} 결제 금액의 통화가 유효하지 않은 경우
1704
1887
  * @throws {@link PublicError.Payment.BelowZeroAmountError} 결제 금액이 0원 미만인 경우
@@ -2073,6 +2256,7 @@ type RequestForeignEasyPayPaymentWithRedirection = (paymentRequest: WithRedirect
2073
2256
  * ```
2074
2257
  *
2075
2258
  * @throws {@link PublicError.Payment.UserCancelError} 사용자가 자동결제 인증창을 닫은 경우
2259
+ * @throws {@link PublicError.Payment.PaymentRequestAbortedError} `payment.destroy()` 호출로 자동결제 인증 요청이 중단된 경우
2076
2260
  * @throws {@link PublicError.Payment.NotSupportedMethodError} 가맹점에서 정의되지 않은 method를 넘겨준 경우
2077
2261
  * @throws {@link PublicError.Payment.IncorrectSuccessUrlFormatError} 가맹점에서 유효하지 않은 successUrl을 넘겨준 경우
2078
2262
  * @throws {@link PublicError.Payment.IncorrectFailUrlFormatError} 가맹점에서 유효하지 않은 failUrl을 넘겨준 경우
@@ -2091,6 +2275,11 @@ interface TossPaymentsPayment {
2091
2275
  * 자동결제(빌링) 카드 등록창을 띄웁니다. [자세히 >](#paymentrequestbillingauth)
2092
2276
  */
2093
2277
  requestBillingAuth: RequestBillingAuth;
2278
+ /**
2279
+ * 현재 열려있는 결제창/인증창을 닫고 launcher 자원을 해제합니다.
2280
+ * 열려있는 창이 없을 때 호출해도 안전합니다.
2281
+ */
2282
+ destroy: Destroy;
2094
2283
  }
2095
2284
  interface TossPaymentsSDK {
2096
2285
  /**
@@ -2190,6 +2379,15 @@ interface BrandpayInitParams {
2190
2379
  * \* 브랜드페이 메뉴에 두 개 이상의 리다이렉트 URL을 등록한 상점은 각 도메인에 맞는 `redirectUrl` 값을 필수로 추가하세요.
2191
2380
  */
2192
2381
  redirectUrl?: string;
2382
+ /**
2383
+ * @ignore
2384
+ */
2385
+ features?: {
2386
+ cardOCR?: {
2387
+ active: boolean;
2388
+ autoStart?: boolean;
2389
+ };
2390
+ };
2193
2391
  }
2194
2392
  /**
2195
2393
  * @returns 아래 메서드를 호출할 수 있는 토스페이먼츠 객체를 반환합니다.
@@ -2211,6 +2409,15 @@ interface WidgetInitParams {
2211
2409
  * \* 브랜드페이 메뉴에 두 개 이상의 리다이렉트 URL을 등록한 상점은 각 도메인에 맞는 `redirectUrl` 값을 필수로 추가하세요.
2212
2410
  */
2213
2411
  redirectUrl?: string;
2412
+ /**
2413
+ * @ignore
2414
+ */
2415
+ features?: {
2416
+ cardOCR?: {
2417
+ active: boolean;
2418
+ autoStart?: boolean;
2419
+ };
2420
+ };
2214
2421
  };
2215
2422
  }
2216
2423
  interface PaymentInitParams {