@tosspayments/tosspayments-sdk 2.7.1 → 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.
Files changed (2) hide show
  1. package/package.json +9 -11
  2. package/types/index.d.ts +218 -11
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tosspayments/tosspayments-sdk",
3
3
  "description": "TossPayments.js Tosspayments SDK.",
4
- "version": "2.7.1",
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",
@@ -19,12 +19,6 @@
19
19
  "url": "git+https://github.com/tosspayments/browser-sdk.git",
20
20
  "directory": "packages/tosspayments-sdk"
21
21
  },
22
- "scripts": {
23
- "build": "rm -rf dist && rollup -c",
24
- "prepack": "yarn build",
25
- "test": "vitest",
26
- "typecheck": "tsc --noEmit"
27
- },
28
22
  "license": "MIT",
29
23
  "devDependencies": {
30
24
  "@babel/core": "^7.11.6",
@@ -33,8 +27,6 @@
33
27
  "@rollup/plugin-babel": "^5.3.0",
34
28
  "@rollup/plugin-commonjs": "^21.0.1",
35
29
  "@rollup/plugin-typescript": "^8.3.0",
36
- "@tosspayments/sdk-loader": "workspace:^",
37
- "@tosspayments/standard-public-interfaces": "2.9.0",
38
30
  "happy-dom": "^14.12.3",
39
31
  "prettier": "^2.0.2",
40
32
  "rollup": "^2.60.0",
@@ -42,7 +34,8 @@
42
34
  "rollup-plugin-dts": "^6.1.1",
43
35
  "tslib": "^1.11.1",
44
36
  "typescript": "5.2.2",
45
- "vitest": "^1.6.0"
37
+ "vitest": "^1.6.0",
38
+ "@tosspayments/sdk-loader": "^2.1.0"
46
39
  },
47
40
  "files": [
48
41
  "dist",
@@ -50,5 +43,10 @@
50
43
  ],
51
44
  "publishConfig": {
52
45
  "access": "public"
46
+ },
47
+ "scripts": {
48
+ "build": "rm -rf dist && rollup -c",
49
+ "test": "vitest",
50
+ "typecheck": "tsc --noEmit"
53
51
  }
54
- }
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 {