react-native-toss-payments
Version:
리액트 네이티브용 토스페이먼츠 결제 연동 라이브러리
277 lines (276 loc) • 11.7 kB
TypeScript
export declare type TossPaymentApproveTypes = {
paymentKey: string;
orderId: string;
amount: number;
};
export declare type TossPaymentSuccessMessageFromWebTypes = {
type: 'success';
data: TossPaymentApproveTypes;
};
export declare type TossPaymentFailMessageFromWebTypes = {
type: 'fail';
data: TossPaymentFailMessageTypes;
};
export declare type TossPaymentResultMessageTypes = TossPaymentFailMessageFromWebTypes | TossPaymentSuccessMessageFromWebTypes;
export declare type TossPaymentFailMessageTypes = {
/**
* @description 결제 요청에 실패했을 때 failUrl로 전달되는 에러 목록입니다.
* @see https://docs.tosspayments.com/reference/error-codes#failurl%EB%A1%9C-%EC%A0%84%EB%8B%AC%EB%90%98%EB%8A%94-%EC%97%90%EB%9F%AC
*
* PAY_PROCESS_CANCELED - 사용자에 의해 결제가 취소되었습니다.
* PAY_PROCESS_ABORTED - 결제 진행 중 승인에 실패하여 결제가 중단되었습니다.
* REJECT_CARD_COMPANY - 결제 승인이 거절되었습니다.
*/
code: 'PAY_PROCESS_CANCELED' | 'PAY_PROCESS_ABORTED' | 'REJECT_CARD_COMPANY';
message: string;
orderId: string;
};
/**
* @description 계좌이체로 결제했을 때 이체 정보가 담기는 객체입니다.
*/
export declare type TossPaymentReceiptTransferTypes = {
/**
* @description 이체할 은행입니다. 은행 코드를 참고하세요.
* @see https://docs.tosspayments.com/reference/codes#%EC%9D%80%ED%96%89-%EC%BD%94%EB%93%9C
*/
bank: string;
settlementStatus: 'INCOMPLETE' | 'COMPLETE';
};
/**
* @description 휴대폰으로 결제하면 제공되는 휴대폰 결제 관련 정보입니다.
*/
export declare type TossPaymentReceiptMobilePhoneTypes = {
customerMobilePhone: string;
settlementStatus: 'INCOMPLETE' | 'COMPLETE';
receiptUrl: string;
};
/**
* @description 상품권으로 결제하면 제공되는 상품권 결제 관련 정보입니다.
*/
export declare type TossPaymentReceiptGiftCertificateTypes = {
approveNo: string;
settlementStatus: 'INCOMPLETE' | 'COMPLETE';
};
/**
* @description 현금영수증 정보입니다.
*/
export declare type TossPaymentReceiptCashReceiptTypes = {
type: '소득공제' | '지출증빙';
amount: number;
taxFreeAmount: number;
issueNumber: string;
receiptUrl: string;
};
/**
* @description 카드사의 즉시 할인 프로모션 정보입니다. 즉시 할인 프로모션이 적용됐을 때만 생성됩니다.
*/
export declare type TossPaymentReceiptDiscountTypes = {
amount: number;
};
/**
* @description 결제 취소 이력이 담기는 배열입니다.
*/
export declare type TossPaymentReceiptCancelTypes = {
cancelAmount: number;
cancelReason: string;
taxFreeAmount: number;
taxAmount: number | null;
refundableAmount: number;
canceledAt: string;
transactionKey: string;
};
/**
* @description 간편결제로 결제한 정보를 담은 객체입니다.
*/
export declare type TossPaymentReceiptEasyPayTypes = {
/**
* @description 간편결제 서비스 ENUM 코드입니다.
* @see https://docs.tosspayments.com/reference/enum-codes#%EA%B0%84%ED%8E%B8%EA%B2%B0%EC%A0%9C-%EC%84%9C%EB%B9%84%EC%8A%A4
* TOSSPAY - 토스페이
* NAVERPAY - 네이버페이
* SAMSUNGPAY - 삼성페이
* LPAY - 엘페이
* KAKAOPAY - 카카오페이
* PAYCO - 페이코
* LGPAY - LG페이
* SSG - SSG페이
*/
provider: 'TOSSPAY' | 'NAVERPAY' | 'SAMSUNGPAY' | 'LPAY' | 'KAKAOPAY' | 'PAYCO' | 'LGPAY' | 'SSG';
amount: number;
discountAmount: number;
};
/**
* @description 결제 실패 정보입니다.
*/
export declare type TossPaymentReceiptFailureTypes = {
code: string;
message: string;
};
/**
* @description 가상계좌로 결제하면 제공되는 가상계좌 관련 정보입니다.
*/
export declare type TossPaymentReceiptVirtualAccountTypes = {
accountType: '일반' | '고정';
accountNumber: string;
bank: string;
customerName: string;
dueDate: string;
refundStatus: 'NONE' | 'FAILED' | 'PENDING' | 'PARTIAL_FAILED' | 'COMPLETED';
/**
* 환불처리 상태입니다. 아래와 같은 상태값을 가질 수 있습니다.
* NONE - 해당 없음
* FAILED - 환불 실패
* PENDING - 환불 처리중
* PARTIAL_FAILED - 부분환불 실패
* COMPLETED - 환불 완료
*/
expired: boolean;
settlementStatus: 'INCOMPLETE' | 'INCOMPLETE';
};
/**
* @description 카드로 결제하면 제공되는 카드 관련 정보입니다.
*/
export declare type TossPaymentReceiptCardTypes = {
company: string;
number: string;
installmentPlanMonths: number;
isInterestFree: boolean;
interestPayer: 'BUYER' | 'CARD_COMPANY' | 'MERCHANT';
/**
* 무이자 할부가 적용된 결제일 때 할부 수수료를 부담하는 주체에 대한 정보입니다. BUYER, CARD_COMPANY, MERCHANT 중 하나입니다.
* BUYER - 상품을 구매한 고객
* CARD_COMPANY - 카드사
* MERCHANT - 상점
*/
approveNo: string;
useCardPoint: boolean;
cardType: '신용' | '체크' | '기프트';
ownerType: '개인' | '법인';
acquireStatus: 'READY' | 'REQUESTED' | 'COMPLETED' | 'CANCEL_REQUESTED' | 'CANCELED';
/**
* 카드 결제의 매입 상태입니다. 아래와 같은 상태값을 가질 수 있습니다.
* READY - 매입 대기
* REQUESTED - 매입 요청됨
* COMPLETED - 매입 완료
* CANCEL_REQUESTED - 매입 취소 요청됨
* CANCELED - 매입 취소 완료
*/
receiptUrl: string;
amount: number;
};
export declare type TossPaymentReceiptTypes = {
mId: string;
transactionKey: string;
lastTransactionKey: string;
paymentKey: string;
orderId: string;
orderName: string;
status: 'READY' | 'DONE' | 'IN_PROGRESS' | 'WAITING_FOR_DEPOSIT' | 'CANCELED' | 'PARTIAL_CANCELED' | 'EXPIRED' | 'ABORTED';
/**
* 결제 처리 상태입니다. 아래와 같은 상태값을 가질 수 있습니다.
* READY - 준비됨
* IN_PROGRESS - 진행중
* WAITING_FOR_DEPOSIT - 가상계좌 입금 대기 중
* DONE - 결제 완료됨
* CANCELED - 결제가 취소됨
* PARTIAL_CANCELED - 결제가 부분 취소됨
* ABORTED - 카드 자동 결제 혹은 키인 결제를 할 때 결제 승인에 실패함
* EXPIRED - 유효 시간(30분)이 지나 거래가 취소됨
*/
requestedAt: string;
approvedAt: string;
useEscrow: boolean;
cultureExpense: boolean;
card: TossPaymentReceiptCardTypes | null;
virtualAccount: TossPaymentReceiptVirtualAccountTypes | null;
transfer: TossPaymentReceiptTransferTypes | null;
mobilePhone: TossPaymentReceiptMobilePhoneTypes | null;
giftCertificate: TossPaymentReceiptGiftCertificateTypes | null;
cashReceipt: TossPaymentReceiptCashReceiptTypes | null;
discount: TossPaymentReceiptDiscountTypes | null;
cancels: TossPaymentReceiptCancelTypes[] | null;
/**
* @description 가상계좌 웹훅 요청이 정상적인 요청인지 검증하기 위한 값입니다. 이 값이 가상계좌 웹훅 이벤트 본문으로 돌아온 secret과 같으면 정상적인 요청입니다. 최대 길이는 50자 이하여야 합니다.
* @see https://docs.tosspayments.com/guides/webhook#%EC%9D%BC%EB%B0%98-%EA%B2%B0%EC%A0%9C---%EA%B0%80%EC%83%81%EA%B3%84%EC%A2%8C
*/
secret: string;
type: 'NORMAL' | 'BILLING' | 'BRANDPAY';
easyPay: TossPaymentReceiptEasyPayTypes | null;
/**
* @description 결제한 국가 정보입니다. ISO-3166의 두 자리 국가 코드 형식입니다.
* @see https://ko.wikipedia.org/wiki/ISO_3166-1_alpha-2
*/
country: 'KR';
failure: TossPaymentReceiptFailureTypes | null;
isPartialCancelable: boolean;
receipt: {
url: string;
};
/**
* @description 토스에서 정의되지않은 변수입니다. 추측상 결제상태를 조회하는 URL로 보입니다.
*/
checkout: {
url: string;
};
currency: 'KRW';
totalAmount: number;
balanceAmount: number;
suppliedAmount: number;
/**
* @description 부가세입니다. (결제 금액 amount - 면세 금액 taxFreeAmount) / 11 후 소수점 첫째 자리에서 반올림해서 계산합니다. (e.g. 결제 금액이 10,000원이고, 면세 금액이 3,000원이라면 부가세는 (10000-3000)/11 = 636.3636..을 반올림한 값 636원입니다.)
* @see https://docs.tosspayments.com/guides/tax
*/
vat: number;
/**
* @description 전체 결제 금액 중 면세 금액입니다. 값이 0으로 돌아왔다면 전체 결제 금액이 과세 대상입니다. [일반 상점일 때는 모든 결제 금액이 과세에 해당하기 때문에 0이 돌아옵니다. 면세 상점, 복합 과세 상점일 때만 면세 금액이 돌아옵니다. 더 자세한 내용은 복합 과세 처리하기에서 살펴보세요.]
* @see https://docs.tosspayments.com/guides/tax
*/
taxFreeAmount: number;
method: '카드' | '가상계좌' | '휴대폰' | '계좌이체' | '상품권' | '간편결제';
version: string;
};
export declare type TossPaymentRequestDataTypes = {
amount: number;
orderId: string;
orderName: string;
successUrl: string;
failUrl: string;
/**
* @description 카드사 코드입니다. 값이 있으면 카드사가 고정된 상태로 결제창이 열립니다. 예를 들어, BC라는 값을 주면 BC카드로 고정된 결제창이 열립니다. 카드사 코드를 참조하세요.
* @see https://docs.tosspayments.com/reference/codes#%EC%B9%B4%EB%93%9C%EC%82%AC-%EC%BD%94%EB%93%9C
*/
cardCompany?: string;
/**
* @description 할부 개월 수를 고정해 결제창을 열 때 사용합니다. 결제 금액(amount)이 5만원 이상일 때만 사용할 수 있습니다.
* 2부터 12사이의 값을 사용할 수 있고, 0이 들어가는 경우 할부가 아닌 일시불로 결제됩니다.
* 값을 넣지 않으면 결제창에서 전체 할부 개월 수를 선택할 수 있습니다.
*/
cardInstallmentPlan?: number;
/**
* @description 선택할 수 있는 최대 할부 개월 수를 제한하기 위해 사용합니다. 결제 금액(amount)이 5만원 이상일 때만 사용할 수 있습니다.
* 2부터 12사이의 값을 사용할 수 있고, 0이 들어가는 경우 할부가 아닌 일시불로 결제됩니다. 만약 값을 6으로 설정한다면 결제창에서 일시불~6개월 사이로 할부 개월을 선택할 수 있습니다.
* 할부 개월 수를 고정하는 cardInstallmentPlan와 같이 사용할 수 없습니다.
*/
maxCardInstallmentPlan?: number;
useCardPoint?: boolean;
useAppCardOnly?: boolean;
useInternationalCardOnly?: boolean;
flowMode?: 'DIRECT' | 'DEFAULT';
/**
* @description 간편결제 결제 수단 타입입니다. flowMode 값이 DIRECT여야 합니다.
* @see https://docs.tosspayments.com/reference/enum-codes#%EA%B0%84%ED%8E%B8%EA%B2%B0%EC%A0%9C-%EC%84%9C%EB%B9%84%EC%8A%A4
* TOSSPAY - 토스페이
* NAVERPAY - 네이버페이
* SAMSUNGPAY - 삼성페이
* LPAY - 엘페이
* KAKAOPAY - 카카오페이
* PAYCO - 페이코
* LGPAY - LG페이
* SSG - SSG페이
*/
easyPay?: 'TOSSPAY' | 'NAVERPAY' | 'SAMSUNGPAY' | 'LPAY' | 'KAKAOPAY' | 'PAYCO' | 'LGPAY' | 'SSG';
appScheme?: string;
customerName: string;
customerEmail: string;
taxFreeAmount?: number;
};