@tosspayments/tosspayments-sdk 2.5.0 → 2.6.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/package.json +2 -2
- package/types/index.d.ts +115 -0
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.
|
|
4
|
+
"version": "2.6.0",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
7
7
|
"types": "types/index.d.ts",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@rollup/plugin-commonjs": "^21.0.1",
|
|
27
27
|
"@rollup/plugin-typescript": "^8.3.0",
|
|
28
28
|
"@tosspayments/sdk-loader": "workspace:packages/sdk-loader",
|
|
29
|
-
"@tosspayments/standard-public-interfaces": "2.
|
|
29
|
+
"@tosspayments/standard-public-interfaces": "2.6.0",
|
|
30
30
|
"happy-dom": "^14.12.3",
|
|
31
31
|
"prettier": "^2.0.2",
|
|
32
32
|
"rollup": "^2.60.0",
|
package/types/index.d.ts
CHANGED
|
@@ -421,6 +421,28 @@ type WidgetPaymentResult = {
|
|
|
421
421
|
amount: Amount;
|
|
422
422
|
};
|
|
423
423
|
|
|
424
|
+
interface WidgetPaymentRequestWindow extends WidgetPaymentRequest {
|
|
425
|
+
/**
|
|
426
|
+
* 결제 금액 정보입니다.
|
|
427
|
+
*/
|
|
428
|
+
amount: Amount;
|
|
429
|
+
}
|
|
430
|
+
interface WidgetPaymentRequestWindowOptions {
|
|
431
|
+
/**
|
|
432
|
+
* 결제위젯 UI의 variantKey 정보입니다. [결제위젯 어드민](https://dashboard.tosspayments.com/payment-widget-service/)에서 확인할 수 있어요.
|
|
433
|
+
*/
|
|
434
|
+
variantKey?: {
|
|
435
|
+
/**
|
|
436
|
+
* 결제수단 UI의 variantKey입니다.
|
|
437
|
+
*/
|
|
438
|
+
paymentMethod?: string | null;
|
|
439
|
+
/**
|
|
440
|
+
* 약관 UI의 variantKey입니다.
|
|
441
|
+
*/
|
|
442
|
+
agreement?: string | null;
|
|
443
|
+
} | null;
|
|
444
|
+
}
|
|
445
|
+
|
|
424
446
|
/**
|
|
425
447
|
* 결제 UI 위젯을 렌더링합니다
|
|
426
448
|
* @param {object} params 결제 UI 렌더링 정보입니다.
|
|
@@ -584,6 +606,95 @@ type RequestPaymentWithRedirection$1 = (paymentRequest: WithRedirection<WidgetPa
|
|
|
584
606
|
*/
|
|
585
607
|
type SetAmount = (amount: Amount) => Promise<void>;
|
|
586
608
|
|
|
609
|
+
/**
|
|
610
|
+
* 결제창을 통해 결제를 요청합니다
|
|
611
|
+
* @docsDefaultSignature RequestPaymentWindowWithRedirection
|
|
612
|
+
*
|
|
613
|
+
* @param {WidgetPaymentRequestWindow} paymentRequest - 결제 요청 정보입니다.
|
|
614
|
+
* @param {WidgetPaymentRequestWindowOptions} options - 위젯 결제창 옵션입니다.
|
|
615
|
+
*
|
|
616
|
+
* @returns 결제 결과
|
|
617
|
+
*
|
|
618
|
+
*
|
|
619
|
+
* @throws {@link PublicError.Widgets.UserCancelError} 사용자가 결제를 취소한 경우
|
|
620
|
+
* @throws {@link PublicError.Widgets.InvalidVariantKeyError} variantKey 가 유효하지 않은 경우
|
|
621
|
+
* @throws {@link PublicError.Widgets.ProviderStatusUnhealthyError} 결제 기관의 시스템에 문제가 있을 때
|
|
622
|
+
* @throws {@link PublicError.Widgets.UnsupportedTestPhasePaymentMethodError} 테스트 환경을 지원하지 않는 결제수단을 선택한 경우
|
|
623
|
+
* @throws {@link PublicError.Widgets.IncorrectSuccessUrlFormatError} successUrl이 유효하지 않은 경우
|
|
624
|
+
* @throws {@link PublicError.Widgets.IncorrectFailUrlFormatError} failUrl이 유효하지 않은 경우
|
|
625
|
+
* @throws {@link PublicError.Widgets.PaymentRequestFailError} 결제 요청에 실패한 경우
|
|
626
|
+
* @throws {@link PublicError.Widgets.NotSupportedPromiseError} promise 방식을 지원하지 않는 환경인 경우
|
|
627
|
+
* @throws {@link PublicError.Widgets.InvalidMethodTransactionError} 이미 다른 명령을 수행 중인 경우
|
|
628
|
+
* @throws {@link PublicError.Widgets.InvalidMetadataError} metadata가 올바르지 않은 경우
|
|
629
|
+
* @throws {@link PublicError.Widgets.InvalidParametersError} 파라미터가 올바르지 않은 경우
|
|
630
|
+
* @throws {@link PublicError.Widgets.BelowZeroAmountError} 결제 금액이 0원 미만인 경우
|
|
631
|
+
* @throws {@link PublicError.Widgets.UnknownError} 알 수 없는 오류가 발생한 경우
|
|
632
|
+
*/
|
|
633
|
+
type RequestPaymentWindow = RequestPaymentWindowWithPromise & RequestPaymentWindowWithRedirection;
|
|
634
|
+
/**
|
|
635
|
+
* @docsAlias Promise 방식
|
|
636
|
+
* @returns `WidgetPaymentResult` 객체가 응답됩니다. 객체 필드를 확인하고 [결제 승인 API](/reference#결제-승인)를 호출해야 결제가 최종적으로 완료돼요.
|
|
637
|
+
* @param {WidgetPaymentRequestWindow} paymentRequest 결제 요청 정보입니다.
|
|
638
|
+
* @param {WidgetPaymentRequestWindowOptions} options 위젯 결제창 옵션입니다.
|
|
639
|
+
*
|
|
640
|
+
* @example
|
|
641
|
+
* ```js
|
|
642
|
+
* widgets.requestPaymentWindow(
|
|
643
|
+
* {
|
|
644
|
+
* orderId: generateRandomString(),
|
|
645
|
+
* orderName: "토스 티셔츠 외 2건",
|
|
646
|
+
* customerEmail: "customer123@gmail.com",
|
|
647
|
+
* customerName: "김토스",
|
|
648
|
+
* },
|
|
649
|
+
* {
|
|
650
|
+
* variantKey: {
|
|
651
|
+
* paymentMethod: "CUSTOM-1",
|
|
652
|
+
* agreement: "AGREEMENT",
|
|
653
|
+
* },
|
|
654
|
+
* }
|
|
655
|
+
* );
|
|
656
|
+
* ```
|
|
657
|
+
*
|
|
658
|
+
*/
|
|
659
|
+
type RequestPaymentWindowWithPromise = (paymentRequest: WidgetPaymentRequestWindow, options?: WidgetPaymentRequestWindowOptions) => Promise<WidgetPaymentResult>;
|
|
660
|
+
/**
|
|
661
|
+
* @docsAlias Redirect 방식
|
|
662
|
+
*
|
|
663
|
+
* @returns 결제 요청이 성공하면 파라미터로 설정한 `successUrl`로 이동해요. 쿼리 파라미터의 `amount` 값이 메서드 파라미터로 설정한 `amount`와 같은지 반드시 확인하고 [결제 승인 API](/reference#결제-승인)를 호출해서 결제를 완료하세요.
|
|
664
|
+
* ```plain theme="grey" copyable="false"
|
|
665
|
+
* {successUrl}?paymentType={PAYMENT_TYPE}&amount={AMOUNT}&orderId={ORDER_ID}&paymentKey={PAYMENT_KEY}
|
|
666
|
+
* ```
|
|
667
|
+
* 결제 요청이 실패하면 파라미터로 설정한 `failUrl`로 이동해요. 쿼리 파라미터로 에러 코드와 메시지를 확인하세요.
|
|
668
|
+
* ```plain theme="grey" copyable="false"
|
|
669
|
+
* {failUrl}?code={ERROR_CODE}&message={ERROR_MESSAGE}&orderId={ORDER_ID}
|
|
670
|
+
* ```
|
|
671
|
+
* Redirect 방식에서는 URL이 이동하기 때문에 `void`가 응답됩니다.
|
|
672
|
+
|
|
673
|
+
* @param {WidgetPaymentRequestWindow} paymentRequest 결제 요청 정보입니다.
|
|
674
|
+
* @param {WidgetPaymentRequestWindowOptions} options 위젯 결제창 옵션입니다.
|
|
675
|
+
*
|
|
676
|
+
* @example
|
|
677
|
+
* ```js
|
|
678
|
+
* widgets.requestPaymentWindow(
|
|
679
|
+
* {
|
|
680
|
+
* orderId: generateRandomString(),
|
|
681
|
+
* orderName: "토스 티셔츠 외 2건",
|
|
682
|
+
* successUrl: window.location.origin + "/success.html",
|
|
683
|
+
* failUrl: window.location.origin + "/fail.html",
|
|
684
|
+
* customerEmail: "customer123@gmail.com",
|
|
685
|
+
* customerName: "김토스",
|
|
686
|
+
* },
|
|
687
|
+
* {
|
|
688
|
+
* variantKey: {
|
|
689
|
+
* paymentMethod: "CUSTOM-1",
|
|
690
|
+
* agreement: "AGREEMENT",
|
|
691
|
+
* },
|
|
692
|
+
* }
|
|
693
|
+
* );
|
|
694
|
+
* ```
|
|
695
|
+
*/
|
|
696
|
+
type RequestPaymentWindowWithRedirection = (paymentRequest: WithRedirection<WidgetPaymentRequestWindow>, options?: WidgetPaymentRequestWindowOptions) => Promise<void>;
|
|
697
|
+
|
|
587
698
|
interface TossPaymentsWidgets {
|
|
588
699
|
/**
|
|
589
700
|
* 주문의 결제 금액을 설정합니다. [자세히 >](#widgetssetamount)
|
|
@@ -597,6 +708,10 @@ interface TossPaymentsWidgets {
|
|
|
597
708
|
* 결제를 요청합니다. 구매자가 결제 UI에서 선택한 결제수단의 결제창을 띄워요. [자세히 >](#widgetsrequestpayment)
|
|
598
709
|
*/
|
|
599
710
|
requestPayment: RequestPayment$2;
|
|
711
|
+
/**
|
|
712
|
+
* 위젯 결제창으로 결제를 요청합니다. [자세히 >](#widgetsrequestpaymentwindow)
|
|
713
|
+
*/
|
|
714
|
+
requestPaymentWindow: RequestPaymentWindow;
|
|
600
715
|
/**
|
|
601
716
|
* 약관 UI를 렌더링합니다. [자세히 >](#widgetsrenderagreement)
|
|
602
717
|
*/
|