1.4.0 • Published 2 months ago

iamport-typings v1.4.0

Weekly downloads
39
License
MIT
Repository
github
Last release
2 months ago

국내 PG 결제연동 서비스, 포트원(구 아임포트)를 위한 타입스크립트 타입 선언을 제공합니다.

⚔️ 사용하는 곳

📦 설치

npm install -D iamport-typings
# Or using yarn
yarn add -D iamport-typings

패키지를 설치합니다.

📌 로드맵

메소드별 지원 상황입니다. PR은 언제나 환영! 🙌

  • init
  • request_pay
  • agency
  • certification
  • close
  • communicate
  • naver_zzim

🚀 사용 방법

// tsconfig.json
{
  "compilerOptions": {
    "types": ["iamport-typings"]
  }
}

사용할 프로젝트 루트 디렉토리에 있는 tsconfig.json 파일의 compilerOptions.typesiamport-typings를 추가하기만 하면 끝!

const { IMP } = window;

Window 인터페이스를 확장하기 때문에, 기존처럼 위와 같이 바로 사용할 수 있답니다! 😋

import Iamport from 'iamport-typings';

declare global {
  interface Window {
    IMP?: Iamport;
  }
}
import { RequestPayParams, RequestPayResponse } from 'iamport-typings';

const onClickPayment = () => {
  const { IMP } = window;
  IMP.init('your_imp_uid');

  const params: RequestPayParams = {
    ...
  };

  IMP.request_pay(params, onPaymentAccepted);
};

const onPaymentAccepted = (response: RequestPayResponse) => {
  const { imp_uid, merchant_uid } = response;
  console.log(imp_uid, merchant_uid);
};

위와 같이 각각의 인터페이스를 가져와 사용하는 것도 가능합니다.

아임포트 객체

인터페이스 이름설명
Iamport아임포트 객체

결제요청 파라미터

인터페이스 이름설명
RequestPayParamsrequest_pay 메소드를 위한 결제 승인에 필요한 정보를 담고 있는 객체로, RequestPayAdditionalParams에서 확장됨
RequestPayAdditionalParamsrequest_pay 메소드를 위한 추가 속성
인터페이스 이름설명
RequestPayNaverAdditionalParams네이버페이 연동 시 RequestPayParams 에 추가되는 파라미터
RequestPayNaverParamsRequestPayParams & RequestPayNaverAdditionalParams

기타

타입 이름설명Codegen
PgCodegen
PaymentMethodCodegen
PayPalSupportedCurrencyPayPal 지원 결제통화의 유니언 타입(union type)Codegen
Currency결제통화 구분코드 ('KRW' \| 'USD' \| 'EUR' \| 'JPY' \| PayPalSupportedCurrency)
CardCode카드사 금융결제원 표준 코드의 유니언 타입(union type)Codegen
Language'en' \| 'ko' \| 'zh'
EscrowProduct
타입 이름설명
NaverProductCategoryType
NaverProductCategoryId
NaverPayReferrer
NaverProduct네이버페이 상품 정보

결제응답 파라미터

인터페이스 이름설명
RequestPayResponse결제 결과의 정보를 담고 있는 객체로, request_pay 메소드에 지정되는 콜백 함수의 인자로, RequestPayAdditionalResponse에서 확장됨
RequestPayAdditionalResponserequest_pay 메소드의 콜백을 위한 추가 속성
RequestPayResponseCallbackrequest_pay 메소드의 함수 타입 리터럴
1.4.0

2 months ago

1.3.1

1 year ago

1.3.0

2 years ago

1.2.0

3 years ago

1.0.2

3 years ago

1.1.0

3 years ago

1.0.3

3 years ago

1.0.1

4 years ago

1.0.0

4 years ago