From e30a5d101ab7daaf260a4db7de3d37981b0f3ce1 Mon Sep 17 00:00:00 2001 From: guhyeon Date: Sun, 5 Jun 2022 00:37:31 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B2=B0=EC=A0=9C=20=ED=99=98=EB=B6=88=20Reque?= =?UTF-8?q?st=20=ED=83=80=EC=9E=85=20=EB=AC=B8=EC=84=9C=EC=99=80=20?= =?UTF-8?q?=EB=A7=9E=EC=B6=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/request/Payments.ts | 52 +++++++++++++++++++++++++++++++++-------- lib/typeUtil.ts | 5 ++++ 2 files changed, 47 insertions(+), 10 deletions(-) create mode 100644 lib/typeUtil.ts diff --git a/lib/request/Payments.ts b/lib/request/Payments.ts index 232b8d8..8110239 100644 --- a/lib/request/Payments.ts +++ b/lib/request/Payments.ts @@ -4,6 +4,7 @@ import { PaymentResponse, PaymentAmountResponse } from '../response'; import { StatusEnum, SortingEnum } from '../enum'; import { ImpUidParams, Headers } from '../Interfaces'; +import {RequireAtLeastOne} from "../typeUtil"; interface ImpUidsParams { imp_uid: string[], @@ -27,18 +28,49 @@ interface MerchantUidParams { status: StatusEnum, sorting: SortingEnum, }; -interface CancelData { - imp_uid: string, - merchant_uid: string, - amount: number, - tax_free: number, - checksum: number, - reason: string, - refund_holder: string, - refund_bank: string, - refund_account: string, + +interface CancelRequest { + /** + * 환불 unique key(imp_uid 또는 merchant_id) + * imp_uid의 값이 우선순위를 갖게되며 유효하지 않는 imp_uid값을 입력하면 merchant_uid값과 무관하게 환불요청이 실패합니다 + */ + imp_uid?: string, + /** + * 환불 unique key(imp_uid 또는 merchant_id) + * imp_uid의 값이 우선순위를 갖게되며 유효하지 않는 imp_uid값을 입력하면 merchant_uid값과 무관하게 환불요청이 실패합니다 + */ + merchant_uid?: string, + /** + * 환불 금액(amount) + * 요청한 환불금액을 입력합니다. 미입력시 전액이 환불됩니다. + */ + amount?: number, + tax_free?: number, + /** + * 환불 가능 금액(checksum) + */ + checksum?: number, + /** + * 환불 사유 + */ + reason?: string, + /** + * 가상계좌 환불 수령계좌 예금주 + */ + refund_holder?: string, + /** + * 가상계좌 환불 수령계좌 은행코드 + */ + refund_bank?: string, + /** + * 가상계좌 환불 수령계좌 번호 + */ + refund_account?: string, }; +type CancelData = RequireAtLeastOne + + /* 일반결제 */ class Payments extends RequestBase { constructor() { diff --git a/lib/typeUtil.ts b/lib/typeUtil.ts new file mode 100644 index 0000000..2f0a5de --- /dev/null +++ b/lib/typeUtil.ts @@ -0,0 +1,5 @@ +export type RequireAtLeastOne = + Pick> + & { + [K in Keys]-?: Required> & Partial>> +}[Keys]