@tosspayments/sdk-types
Advanced tools
Comparing version 1.1.2 to 1.1.3
{ | ||
"name": "@tosspayments/sdk-types", | ||
"description": "tosspayments.js TypeScript 타이핑", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"types": "types/tosspayments.d.ts", | ||
@@ -6,0 +6,0 @@ "author": "Toss Payments", |
import { RequestPaymentParams } from './openpay/requestPayment'; | ||
import { AuthenticateOptions } from './openpay/authenticate'; | ||
declare function OpenPay(clientKey: string, customerKey: string, options?: AuthenticateOptions): { | ||
authenticate(): Promise<string>; | ||
addPaymentMethod(_type: '카드'): Promise<import("./openpay/addPaymentMethod").CardMethod[]>; | ||
requestPayment(params: RequestPaymentParams): Promise<void>; | ||
import addPaymentMethod from './openpay/addPaymentMethod'; | ||
export interface OpenPayOptions { | ||
showNavigationBar?: boolean; | ||
redirectUrl?: string; | ||
theme?: 'musinsa'; | ||
} | ||
declare function OpenPay(clientKey: string, customerKey: string, options?: OpenPayOptions): { | ||
authenticate(): Promise<void>; | ||
addPaymentMethod(methodType?: Parameters<typeof addPaymentMethod>[2]['type']): Promise<import("./openpay/PaymentMethod").CardMethod[] | import("./openpay/PaymentMethod").AccountMethod[]>; | ||
requestPayment(params: RequestPaymentParams): Promise<never>; | ||
openSettings(): Promise<import("./openpay/PaymentMethod").CardMethod[]>; | ||
}; | ||
@@ -8,0 +14,0 @@ export declare type OpenPayConstructor = typeof OpenPay; |
@@ -1,10 +0,16 @@ | ||
export interface CardMethod { | ||
methodKey: string; | ||
cardCompany: string; | ||
cardNumber: string; | ||
ownerType: '개인' | '법인' | '미확인'; | ||
cardType: '신용' | '체크'; | ||
registeredAt: string; | ||
status: 'ENABLED' | 'DISABLED'; | ||
import { AccountMethod, CardMethod } from './PaymentMethod'; | ||
import { OpenIframeOptions } from './openIframe'; | ||
import { OpenPayOptions } from '../openpay'; | ||
export declare type AddMethodOptionsBase = OpenPayOptions & OpenIframeOptions; | ||
export interface AddMethodOptions extends AddMethodOptionsBase { | ||
type?: undefined; | ||
} | ||
export default function addPaymentMethod(clientKey: string, customerToken: string): Promise<CardMethod[]>; | ||
export interface AddCardMethodOptions extends AddMethodOptionsBase { | ||
type: `카드`; | ||
} | ||
export interface AddAccountMethodOptions extends AddMethodOptionsBase { | ||
type: `계좌`; | ||
} | ||
export declare function addPaymentMethod(clientKey: string, customerToken: string, options: AddCardMethodOptions): Promise<CardMethod[]>; | ||
export declare function addPaymentMethod(clientKey: string, customerToken: string, options: AddAccountMethodOptions): Promise<AccountMethod[]>; | ||
export default function addPaymentMethod(clientKey: string, customerToken: string, { container, type, ...options }: AddMethodOptions | AddCardMethodOptions | AddAccountMethodOptions): Promise<CardMethod[] | AccountMethod[]>; |
@@ -1,4 +0,4 @@ | ||
export interface AuthenticateOptions { | ||
redirectUrl?: string; | ||
} | ||
export default function authenticate(clientKey: string, customerKey: string, options?: AuthenticateOptions): Promise<string>; | ||
import { OpenPayOptions } from '../openpay'; | ||
export default function authenticate(clientKey: string, customerKey: string, { container, ...options }?: OpenPayOptions & { | ||
container?: HTMLElement; | ||
}): Promise<string>; |
interface Response { | ||
status: 'INVALID' | 'PENDING' | 'APPROVED' | 'EXPIRED'; | ||
/** | ||
* @see https://tosspayments.slack.com/archives/C014WH0NFNF/p1607686666157000 | ||
* @description | ||
* INVALID - 정상적인 Customer Session 이 존재하지 않음 (약관 미동의) | ||
* PENDING - access token 받아가기를 기다리는 중 | ||
* APPROVED - 유효한 customer token이 응답됨 | ||
* EXPIRED - PENDING 상태 진입 이후 10초 경과, 혹은 APPROVED 이후 만료 | ||
* FAILED - access token 요청중 오류발생한 경우 | ||
*/ | ||
status: 'PENDING' | 'EXPIRED' | 'APPROVED' | 'INVALID' | 'FAILED'; | ||
customerToken?: string; | ||
expiresIn?: number; | ||
} | ||
export default function getCustomerToken(clientKey: string, customerKey: string): Promise<Response>; | ||
interface ApprovedResponse extends Response { | ||
status: 'APPROVED'; | ||
customerToken: string; | ||
expiresIn: number; | ||
} | ||
interface OtherResponse extends Response { | ||
status: 'PENDING' | 'EXPIRED' | 'INVALID' | 'FAILED'; | ||
customerToken?: never; | ||
expiresIn?: never; | ||
} | ||
export default function getCustomerToken(clientKey: string, customerKey: string): Promise<ApprovedResponse | OtherResponse>; | ||
export {}; |
export declare const iPhone8DeviceSize: { | ||
width: string; | ||
height: string; | ||
width: number; | ||
height: number; | ||
}; | ||
export declare function getIframe(): HTMLIFrameElement; | ||
export declare function createIframe(): HTMLIFrameElement; | ||
export declare const IFRAME_ID_PREFIX = "__tosspayments_openpay_iframe_"; |
@@ -0,1 +1,3 @@ | ||
import { OpenIframeOptions } from './openIframe'; | ||
import { OpenPayOptions } from '../openpay'; | ||
export interface RequestPaymentParams { | ||
@@ -9,2 +11,2 @@ successUrl: string; | ||
} | ||
export default function requestPayment(clientKey: string, customerToken: string, params: RequestPaymentParams): Promise<void>; | ||
export default function requestPayment(clientKey: string, customerToken: string, params: RequestPaymentParams, { container, ...options }: OpenPayOptions & OpenIframeOptions): Promise<never>; |
@@ -35,2 +35,12 @@ import CardCompany from '../models/CardCompany'; | ||
export declare type CardPaymentRequest = DirectCardPaymentRequest | DefaultCardPaymentRequest; | ||
interface EscrowProduct { | ||
productId: string; | ||
productCode: string; | ||
productName: string; | ||
unitPrice: number; | ||
quantity: number; | ||
} | ||
interface CashReceipt { | ||
type?: '소득공제' | '지출증빙'; | ||
} | ||
export interface VirtualAccountPaymentRequest extends BasePaymentRequest { | ||
@@ -43,13 +53,8 @@ /** | ||
useEscrow?: boolean; | ||
escrowProductsInfo?: Array<{ | ||
productId: string; | ||
productCode: string; | ||
productName: string; | ||
unitPrice: number; | ||
quantity: number; | ||
}>; | ||
cashReceiptInfo?: { | ||
type?: '소득공제' | '지출증빙'; | ||
useSelfIssuance?: boolean; | ||
}; | ||
escrowProducts?: EscrowProduct[]; | ||
cashReceipt?: CashReceipt; | ||
/** | ||
* @deprecated 대신 `cashReceipt` 필드를 사용해주세요. | ||
*/ | ||
cashReceiptInfo?: CashReceipt; | ||
validHours?: number; | ||
@@ -56,0 +61,0 @@ virtualAccountCallbackUrl?: string; |
export declare function getClientId(): string; | ||
export declare function getSessionId(): string; |
export declare const IFRAME_ID = "___tosspayments_iframe___"; | ||
export declare const LOADING_IFRAME_ID = "___tosspayments_iframe__loading___"; | ||
export declare const DIMMER_ID = "___tosspayments_dimmer___"; | ||
export declare const FORM_ID = "___tosspayments_form___"; |
export default function createElementById<K extends keyof HTMLElementTagNameMap>(tagName: K, id: string): HTMLElementTagNameMap[K]; | ||
export declare function createVisuallyHiddenForm(): HTMLFormElement; | ||
export declare function createIframe(): HTMLIFrameElement; | ||
export declare function createCenteredIframe(styles?: Partial<CSSStyleDeclaration>): HTMLIFrameElement; | ||
export declare function createFullScreenIframe(): HTMLIFrameElement; | ||
export declare function createDimmer(): HTMLDivElement; | ||
export declare function createIframe({ id, styles, }: { | ||
id?: string; | ||
styles?: Partial<CSSStyleDeclaration>; | ||
}): HTMLIFrameElement; | ||
interface CreateCenteredIframeParams { | ||
width: number; | ||
height: number; | ||
id?: string; | ||
styles?: Partial<CSSStyleDeclaration>; | ||
} | ||
export declare function createCenteredIframe({ width, height, id, styles, }: CreateCenteredIframeParams): HTMLIFrameElement; | ||
export declare function createDimmer({ styles }?: { | ||
styles?: Partial<CSSStyleDeclaration>; | ||
}): HTMLDivElement; | ||
export declare function applyStyles(element: HTMLElement, styles: Partial<CSSStyleDeclaration>): void; | ||
export {}; |
@@ -7,2 +7,2 @@ export declare const STAGE: Stage; | ||
export declare const V3_CARD_URL: any; | ||
export declare type Stage = 'live' | 'beta' | 'alpha' | 'test'; | ||
export declare type Stage = 'v1' | 'beta' | 'alpha' | 'dev'; |
export default function openLegacyWindow(path: string, params: Record<string, string>, options?: { | ||
manipulateDesktopIframe?: (iframe: HTMLIFrameElement) => void; | ||
dimmer?: HTMLDivElement; | ||
iframe?: HTMLIFrameElement; | ||
}): Promise<void>; |
@@ -5,2 +5,2 @@ export declare enum V3ApplyVariant { | ||
} | ||
export default function getV3ApplyVariant(clientKey: string): Promise<V3ApplyVariant | null>; | ||
export default function getV3ApplyVariant(clientKey: string): Promise<V3ApplyVariant>; |
20888
69
473