Skip to content

iamport types module #10

@timo-kang

Description

@timo-kang

안녕하세요, react에서 아임포트를 사용하고있는 사용자입니다.

저는 typescript + react를 사용중이라 types.ts를 직접 만들어 사용하고 있는데요,
@types/iamport-client 모듈을 만든다면 다른 많은 분들이 사용하기 훨씬 편할 것 같아 제안해봅니다..

짧지만 제가 사용하고 있는 type을 예시로 보여드리겠습니다.


export interface ExtendedIamportWindow extends Window {
  IMP: IMP
}

export interface IMP {
  init: ( imp_uid: string ) => void;
  request_pay: ( params: IamportPaymentRequest, callback: ( res: IamportPaymentResponse ) => void ) => void;
}

export type IamportPaymentResponse = {
  success: true,
  imp_uid: string,
  merchant_uid: string,
  pay_method: string,
  status: string,
  name: string,
  card_name: string,
  card_quota: number,
  buyer_name: string,
  buyer_email: string,
  paid_amount: number,
  paid_at: string
  receipt_url: string,
} | {
  success: false,
  error_code: string
  error_msg: string,
}

export type IamportPaymentRequest = {
  pg: string,
  pay_method: "card" | "vbank",
  merchant_uid: string,
  name: string,
  amount: number,
  buyer_email: string,
  buyer_name: string,
  notice_url?: string,
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions