UNPKG

fake-toss-payments-server

Version:
708 lines (669 loc) 587 kB
import { NestFactory } from "@nestjs/core"; import { FastifyAdapter } from "@nestjs/platform-fastify"; import core from "@nestia/core"; import { NotFoundException, ConflictException, UnprocessableEntityException, InternalServerErrorException, createParamDecorator, ForbiddenException, Controller, Module } from "@nestjs/common"; import { OutOfRange, InvalidArgument, DomainError, Singleton, HashMap, TreeMap, hash, equal_to } from "tstl"; import * as __nestia_core_transform_isFormatDateTime from "typia/lib/internal/_isFormatDateTime.js"; import * as __nestia_core_transform_assertGuard from "typia/lib/internal/_assertGuard.js"; import * as __nestia_core_transform_jsonStringifyString from "typia/lib/internal/_jsonStringifyString.js"; import * as __nestia_core_transform_isFormatEmail from "typia/lib/internal/_isFormatEmail.js"; import * as __nestia_core_transform_validateReport from "typia/lib/internal/_validateReport.js"; import * as __nestia_core_transform_httpParameterReadString from "typia/lib/internal/_httpParameterReadString.js"; import * as __nestia_core_transform_isFormatDate from "typia/lib/internal/_isFormatDate.js"; import * as __nestia_core_transform_isFormatUri from "typia/lib/internal/_isFormatUri.js"; import * as __nestia_core_transform_throwTypeGuardError from "typia/lib/internal/_throwTypeGuardError.js"; import { v4 } from "uuid"; import atob from "atob"; const EXTENSION = __filename.substring(__filename.length - 2); if (EXTENSION === "js") require("source-map-support").install(); var FakeTossConfiguration; (function(FakeTossConfiguration) { FakeTossConfiguration.ASSETS = __dirname + "/../assets"; FakeTossConfiguration.EXPIRATION = { time: 3 * 60 * 1e3, capacity: 1e3 }; FakeTossConfiguration.API_PORT = 30771; FakeTossConfiguration.WEBHOOK_URL = `http://127.0.0.1:${FakeTossConfiguration.API_PORT}/internal/webhook`; FakeTossConfiguration.authorize = token => token === "test_ak_ZORzdMaqN3wQd5k6ygr5AkYXQGwy"; })(FakeTossConfiguration || (FakeTossConfiguration = {})); core.ExceptionManager.insert(OutOfRange, (exp => new NotFoundException(exp.message))); core.ExceptionManager.insert(InvalidArgument, (exp => new ConflictException(exp.message))); core.ExceptionManager.insert(DomainError, (exp => new UnprocessableEntityException(exp.message))); core.ExceptionManager.insert(Error, (exp => new InternalServerErrorException({ message: exp.message, name: exp.name, stack: exp.stack }))); function __decorate(decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; } function __param(paramIndex, decorator) { return function(target, key) { decorator(target, key, paramIndex); }; } function __metadata(metadataKey, metadataValue) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); } typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) { var e = new Error(message); return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; }; function FakeTossUserAuth() { return singleton.get()(); } (function(FakeTossUserAuth) { function authorize(request) { let token = request.headers.authorization; if (token === undefined) throw new ForbiddenException("No authorization token exists."); else if (token.indexOf("Basic ") !== 0) throw new ForbiddenException("Invalid authorization token."); token = token.substring("Basic ".length); token = atob(token); if (FakeTossConfiguration.authorize(token.substring(0, token.length - 1)) === false) throw new ForbiddenException("Wrong authorization token."); } FakeTossUserAuth.authorize = authorize; })(FakeTossUserAuth || (FakeTossUserAuth = {})); const singleton = new Singleton((() => createParamDecorator((async (_0, ctx) => { const request = ctx.switchToHttp().getRequest(); return FakeTossUserAuth.authorize(request); })))); var FakeTossPaymentProvider; (function(FakeTossPaymentProvider) { function get_common_props(input) { return { mId: "tosspayments", version: "1.3", paymentKey: v4(), transactionKey: v4(), orderId: input.orderId, orderName: "test", currency: "KRW", totalAmount: input.amount, balanceAmount: input.amount, suppliedAmount: input.amount, taxFreeAmount: 0, vat: 0, useEscrow: false, cultureExpense: false, requestedAt: (new Date).toISOString(), cancels: null, cashReceipt: null }; } FakeTossPaymentProvider.get_common_props = get_common_props; })(FakeTossPaymentProvider || (FakeTossPaymentProvider = {})); class VolatileMap { constructor(expiration, hasher = hash, pred = equal_to) { this.expiration = expiration; this.dict_ = new HashMap(hasher, pred); this.timepoints_ = new TreeMap; } size() { return this.dict_.size(); } get(key) { return this.dict_.get(key); } clear() { this.dict_.clear(); this.timepoints_.clear(); } set(key, value) { this._Clean_up(); this.dict_.set(key, value); this.timepoints_.set(Date.now(), key); } _Clean_up() { const bound = Date.now() - this.expiration.time; const last = this.timepoints_.upper_bound(bound); for (let it = this.timepoints_.begin(); it.equals(last) === false; ) { this.dict_.erase(it.second); it = this.timepoints_.erase(it); } if (this.timepoints_.size() < this.expiration.capacity) return; let left = this.timepoints_.size() - this.expiration.capacity; while (left-- === 0) { const it = this.timepoints_.begin(); this.dict_.erase(it.second); this.timepoints_.erase(it); } } } var FakeTossStorage; (function(FakeTossStorage) { FakeTossStorage.payments = new VolatileMap(FakeTossConfiguration.EXPIRATION); FakeTossStorage.billings = new VolatileMap(FakeTossConfiguration.EXPIRATION); FakeTossStorage.cash_receipts = new VolatileMap(FakeTossConfiguration.EXPIRATION); FakeTossStorage.webhooks = new VolatileMap(FakeTossConfiguration.EXPIRATION); })(FakeTossStorage || (FakeTossStorage = {})); let FakeTossBillingController = class FakeTossBillingController { create(_0, input) { const billing = { mId: "tosspyaments", method: "카드", billingKey: v4(), customerKey: input.customerKey, cardCompany: "신한", cardNumber: input.cardNumber, authenticatedAt: (new Date).toISOString() }; FakeTossStorage.billings.set(billing.billingKey, [ billing, input ]); return billing; } at(_0, billingKey, input) { const tuple = FakeTossStorage.billings.get(billingKey); if (tuple[0].customerKey !== input.customerKey) throw new ForbiddenException("Different customer."); return tuple[0]; } pay(_0, billingKey, input) { const tuple = FakeTossStorage.billings.get(billingKey); const card = tuple[1]; const payment = { ...FakeTossPaymentProvider.get_common_props(input), method: "카드", type: "NORMAL", status: "DONE", approvedAt: (new Date).toISOString(), discount: null, card: { company: "신한카드", number: card.cardNumber, installmentPlanMonths: 0, isInterestFree: true, approveNo: "temporary-card-approval-number", useCardPoint: false, cardType: "신용", ownerType: "개인", acquireStatus: "READY", receiptUrl: "https://github.com/samchon/fake-toss-payments-server" }, easyPay: null }; FakeTossStorage.payments.set(payment.paymentKey, payment); return payment; } }; __decorate([ core.TypedRoute.Post("authorizations/card", { type: "assert", assert: (() => { const _io0 = input => "string" === typeof input.mId && "string" === typeof input.billingKey && "카드" === input.method && "string" === typeof input.cardCompany && ("string" === typeof input.cardNumber && RegExp("[0-9]{16}").test(input.cardNumber)) && ("string" === typeof input.authenticatedAt && __nestia_core_transform_isFormatDateTime._isFormatDateTime(input.authenticatedAt)) && "string" === typeof input.customerKey; const _ao0 = (input, _path, _exceptionable = true) => ("string" === typeof input.mId || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".mId", expected: "string", value: input.mId }, _errorFactory)) && ("string" === typeof input.billingKey || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".billingKey", expected: "string", value: input.billingKey }, _errorFactory)) && ("카드" === input.method || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".method", expected: '"카드"', value: input.method }, _errorFactory)) && ("string" === typeof input.cardCompany || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".cardCompany", expected: "string", value: input.cardCompany }, _errorFactory)) && ("string" === typeof input.cardNumber && (RegExp("[0-9]{16}").test(input.cardNumber) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".cardNumber", expected: 'string & Pattern<"[0-9]{16}">', value: input.cardNumber }, _errorFactory)) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".cardNumber", expected: '(string & Pattern<"[0-9]{16}">)', value: input.cardNumber }, _errorFactory)) && ("string" === typeof input.authenticatedAt && (__nestia_core_transform_isFormatDateTime._isFormatDateTime(input.authenticatedAt) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".authenticatedAt", expected: 'string & Format<"date-time">', value: input.authenticatedAt }, _errorFactory)) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".authenticatedAt", expected: '(string & Format<"date-time">)', value: input.authenticatedAt }, _errorFactory)) && ("string" === typeof input.customerKey || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".customerKey", expected: "string", value: input.customerKey }, _errorFactory)); const _so0 = input => `{"mId":${__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.mId)},"billingKey":${__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.billingKey)},"method":${'"' + input.method + '"'},"cardCompany":${__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.cardCompany)},"cardNumber":${__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.cardNumber)},"authenticatedAt":${__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.authenticatedAt)},"customerKey":${__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.customerKey)}}`; const __is = input => "object" === typeof input && null !== input && _io0(input); let _errorFactory; const __assert = (input, errorFactory) => { if (false === __is(input)) { _errorFactory = errorFactory; ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || __nestia_core_transform_assertGuard._assertGuard(true, { method: "core.TypedRoute.Post", path: _path + "", expected: "ITossBilling", value: input }, _errorFactory)) && _ao0(input, _path + "", true) || __nestia_core_transform_assertGuard._assertGuard(true, { method: "core.TypedRoute.Post", path: _path + "", expected: "ITossBilling", value: input }, _errorFactory))(input, "$input", true); } return input; }; const __stringify = input => _so0(input); return (input, errorFactory) => { __assert(input, errorFactory); return __stringify(input); }; })() }), __param(0, FakeTossUserAuth()), __param(1, core.TypedBody({ type: "validate", validate: (() => { const _io0 = input => "string" === typeof input.cardNumber && RegExp("[0-9]{16}").test(input.cardNumber) && ("string" === typeof input.cardExpirationYear && RegExp("\\d{2}").test(input.cardExpirationYear)) && ("string" === typeof input.cardExpirationMonth && RegExp("^(0[1-9]|1[012])$").test(input.cardExpirationMonth)) && "string" === typeof input.cardPassword && ("string" === typeof input.customerBirthday && RegExp("^([0-9]{2})(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])$").test(input.customerBirthday)) && (undefined === input.consumerName || "string" === typeof input.consumerName) && (undefined === input.customerEmail || "string" === typeof input.customerEmail && __nestia_core_transform_isFormatEmail._isFormatEmail(input.customerEmail)) && (undefined === input.vbv || "object" === typeof input.vbv && null !== input.vbv && _io1(input.vbv)) && "string" === typeof input.customerKey; const _io1 = input => "string" === typeof input.cavv && "string" === typeof input.xid && "string" === typeof input.eci; const _vo0 = (input, _path, _exceptionable = true) => [ "string" === typeof input.cardNumber && (RegExp("[0-9]{16}").test(input.cardNumber) || _report(_exceptionable, { path: _path + ".cardNumber", expected: 'string & Pattern<"[0-9]{16}">', value: input.cardNumber })) || _report(_exceptionable, { path: _path + ".cardNumber", expected: '(string & Pattern<"[0-9]{16}">)', value: input.cardNumber }), "string" === typeof input.cardExpirationYear && (RegExp("\\d{2}").test(input.cardExpirationYear) || _report(_exceptionable, { path: _path + ".cardExpirationYear", expected: 'string & Pattern<"\\\\d{2}">', value: input.cardExpirationYear })) || _report(_exceptionable, { path: _path + ".cardExpirationYear", expected: '(string & Pattern<"\\\\d{2}">)', value: input.cardExpirationYear }), "string" === typeof input.cardExpirationMonth && (RegExp("^(0[1-9]|1[012])$").test(input.cardExpirationMonth) || _report(_exceptionable, { path: _path + ".cardExpirationMonth", expected: 'string & Pattern<"^(0[1-9]|1[012])$">', value: input.cardExpirationMonth })) || _report(_exceptionable, { path: _path + ".cardExpirationMonth", expected: '(string & Pattern<"^(0[1-9]|1[012])$">)', value: input.cardExpirationMonth }), "string" === typeof input.cardPassword || _report(_exceptionable, { path: _path + ".cardPassword", expected: "string", value: input.cardPassword }), "string" === typeof input.customerBirthday && (RegExp("^([0-9]{2})(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])$").test(input.customerBirthday) || _report(_exceptionable, { path: _path + ".customerBirthday", expected: 'string & Pattern<"^([0-9]{2})(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])$">', value: input.customerBirthday })) || _report(_exceptionable, { path: _path + ".customerBirthday", expected: '(string & Pattern<"^([0-9]{2})(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])$">)', value: input.customerBirthday }), undefined === input.consumerName || "string" === typeof input.consumerName || _report(_exceptionable, { path: _path + ".consumerName", expected: "(string | undefined)", value: input.consumerName }), undefined === input.customerEmail || "string" === typeof input.customerEmail && (__nestia_core_transform_isFormatEmail._isFormatEmail(input.customerEmail) || _report(_exceptionable, { path: _path + ".customerEmail", expected: 'string & Format<"email">', value: input.customerEmail })) || _report(_exceptionable, { path: _path + ".customerEmail", expected: '((string & Format<"email">) | undefined)', value: input.customerEmail }), undefined === input.vbv || ("object" === typeof input.vbv && null !== input.vbv || _report(_exceptionable, { path: _path + ".vbv", expected: "(__type | undefined)", value: input.vbv })) && _vo1(input.vbv, _path + ".vbv", _exceptionable) || _report(_exceptionable, { path: _path + ".vbv", expected: "(__type | undefined)", value: input.vbv }), "string" === typeof input.customerKey || _report(_exceptionable, { path: _path + ".customerKey", expected: "string", value: input.customerKey }) ].every((flag => flag)); const _vo1 = (input, _path, _exceptionable = true) => [ "string" === typeof input.cavv || _report(_exceptionable, { path: _path + ".cavv", expected: "string", value: input.cavv }), "string" === typeof input.xid || _report(_exceptionable, { path: _path + ".xid", expected: "string", value: input.xid }), "string" === typeof input.eci || _report(_exceptionable, { path: _path + ".eci", expected: "string", value: input.eci }) ].every((flag => flag)); const __is = input => "object" === typeof input && null !== input && _io0(input); let errors; let _report; return input => { if (false === __is(input)) { errors = []; _report = __nestia_core_transform_validateReport._validateReport(errors); ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, { path: _path + "", expected: "ITossBilling.ICreate", value: input })) && _vo0(input, _path + "", true) || _report(true, { path: _path + "", expected: "ITossBilling.ICreate", value: input }))(input, "$input", true); const success = 0 === errors.length; return success ? { success, data: input } : { success, errors, data: input }; } return { success: true, data: input }; }; })() })), __metadata("design:type", Function), __metadata("design:paramtypes", [ void 0, Object ]), __metadata("design:returntype", Object) ], FakeTossBillingController.prototype, "create", null); __decorate([ core.TypedRoute.Post("authorizations/:billingKey", { type: "assert", assert: (() => { const _io0 = input => "string" === typeof input.mId && "string" === typeof input.billingKey && "카드" === input.method && "string" === typeof input.cardCompany && ("string" === typeof input.cardNumber && RegExp("[0-9]{16}").test(input.cardNumber)) && ("string" === typeof input.authenticatedAt && __nestia_core_transform_isFormatDateTime._isFormatDateTime(input.authenticatedAt)) && "string" === typeof input.customerKey; const _ao0 = (input, _path, _exceptionable = true) => ("string" === typeof input.mId || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".mId", expected: "string", value: input.mId }, _errorFactory)) && ("string" === typeof input.billingKey || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".billingKey", expected: "string", value: input.billingKey }, _errorFactory)) && ("카드" === input.method || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".method", expected: '"카드"', value: input.method }, _errorFactory)) && ("string" === typeof input.cardCompany || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".cardCompany", expected: "string", value: input.cardCompany }, _errorFactory)) && ("string" === typeof input.cardNumber && (RegExp("[0-9]{16}").test(input.cardNumber) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".cardNumber", expected: 'string & Pattern<"[0-9]{16}">', value: input.cardNumber }, _errorFactory)) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".cardNumber", expected: '(string & Pattern<"[0-9]{16}">)', value: input.cardNumber }, _errorFactory)) && ("string" === typeof input.authenticatedAt && (__nestia_core_transform_isFormatDateTime._isFormatDateTime(input.authenticatedAt) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".authenticatedAt", expected: 'string & Format<"date-time">', value: input.authenticatedAt }, _errorFactory)) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".authenticatedAt", expected: '(string & Format<"date-time">)', value: input.authenticatedAt }, _errorFactory)) && ("string" === typeof input.customerKey || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".customerKey", expected: "string", value: input.customerKey }, _errorFactory)); const _so0 = input => `{"mId":${__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.mId)},"billingKey":${__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.billingKey)},"method":${'"' + input.method + '"'},"cardCompany":${__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.cardCompany)},"cardNumber":${__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.cardNumber)},"authenticatedAt":${__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.authenticatedAt)},"customerKey":${__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.customerKey)}}`; const __is = input => "object" === typeof input && null !== input && _io0(input); let _errorFactory; const __assert = (input, errorFactory) => { if (false === __is(input)) { _errorFactory = errorFactory; ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || __nestia_core_transform_assertGuard._assertGuard(true, { method: "core.TypedRoute.Post", path: _path + "", expected: "ITossBilling", value: input }, _errorFactory)) && _ao0(input, _path + "", true) || __nestia_core_transform_assertGuard._assertGuard(true, { method: "core.TypedRoute.Post", path: _path + "", expected: "ITossBilling", value: input }, _errorFactory))(input, "$input", true); } return input; }; const __stringify = input => _so0(input); return (input, errorFactory) => { __assert(input, errorFactory); return __stringify(input); }; })() }), __param(0, FakeTossUserAuth()), __param(1, core.TypedParam("billingKey", (input => { const assert = (() => { const __is = input => "string" === typeof input; let _errorFactory; return (input, errorFactory) => { if (false === __is(input)) { _errorFactory = errorFactory; ((input, _path, _exceptionable = true) => "string" === typeof input || __nestia_core_transform_assertGuard._assertGuard(true, { method: "core.TypedParam", path: _path + "", expected: "string", value: input }, _errorFactory))(input, "$input", true); } return input; }; })(); const value = __nestia_core_transform_httpParameterReadString._httpParameterReadString(input); return assert(value); }))), __param(2, core.TypedBody({ type: "validate", validate: (() => { const _io0 = input => "string" === typeof input.customerKey; const _vo0 = (input, _path, _exceptionable = true) => [ "string" === typeof input.customerKey || _report(_exceptionable, { path: _path + ".customerKey", expected: "string", value: input.customerKey }) ].every((flag => flag)); const __is = input => "object" === typeof input && null !== input && _io0(input); let errors; let _report; return input => { if (false === __is(input)) { errors = []; _report = __nestia_core_transform_validateReport._validateReport(errors); ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, { path: _path + "", expected: "ITossBilling.ICustomerKey", value: input })) && _vo0(input, _path + "", true) || _report(true, { path: _path + "", expected: "ITossBilling.ICustomerKey", value: input }))(input, "$input", true); const success = 0 === errors.length; return success ? { success, data: input } : { success, errors, data: input }; } return { success: true, data: input }; }; })() })), __metadata("design:type", Function), __metadata("design:paramtypes", [ void 0, String, Object ]), __metadata("design:returntype", Object) ], FakeTossBillingController.prototype, "at", null); __decorate([ core.TypedRoute.Post(":billingKey", { type: "assert", assert: (() => { const _io0 = input => "object" === typeof input.giftCertificate && null !== input.giftCertificate && _io1(input.giftCertificate) && "상품권" === input.method && "NORMAL" === input.type && ("READY" === input.status || "IN_PROGRESS" === input.status || "WAITING_FOR_DEPOSIT" === input.status || "DONE" === input.status || "CANCELED" === input.status || "PARTIAL_CANCELED" === input.status || "ABORTED" === input.status || "EXPIRED" === input.status) && "string" === typeof input.mId && "string" === typeof input.version && "string" === typeof input.paymentKey && "string" === typeof input.orderId && "string" === typeof input.transactionKey && "string" === typeof input.orderName && "string" === typeof input.currency && ("number" === typeof input.totalAmount && !Number.isNaN(input.totalAmount)) && ("number" === typeof input.balanceAmount && !Number.isNaN(input.balanceAmount)) && ("number" === typeof input.suppliedAmount && !Number.isNaN(input.suppliedAmount)) && ("number" === typeof input.taxFreeAmount && !Number.isNaN(input.taxFreeAmount)) && ("number" === typeof input.vat && !Number.isNaN(input.vat)) && "boolean" === typeof input.useEscrow && "boolean" === typeof input.cultureExpense && ("string" === typeof input.requestedAt && __nestia_core_transform_isFormatDateTime._isFormatDateTime(input.requestedAt)) && (null === input.approvedAt || "string" === typeof input.approvedAt && __nestia_core_transform_isFormatDateTime._isFormatDateTime(input.approvedAt)) && (null === input.cancels || Array.isArray(input.cancels) && input.cancels.every((elem => "object" === typeof elem && null !== elem && _io2(elem)))) && (null === input.cashReceipt || "object" === typeof input.cashReceipt && null !== input.cashReceipt && _io3(input.cashReceipt)); const _io1 = input => "string" === typeof input.approveNo && ("COMPLETE" === input.settlementStatus || "INCOMPLETE" === input.settlementStatus); const _io2 = input => "number" === typeof input.cancelAmount && !Number.isNaN(input.cancelAmount) && "string" === typeof input.cancelReason && ("number" === typeof input.taxFreeAmount && !Number.isNaN(input.taxFreeAmount)) && ("number" === typeof input.taxAmount && !Number.isNaN(input.taxAmount)) && ("number" === typeof input.refundableAmount && !Number.isNaN(input.refundableAmount)) && ("string" === typeof input.canceledAt && __nestia_core_transform_isFormatDateTime._isFormatDateTime(input.canceledAt)); const _io3 = input => ("소득공제" === input.type || "지출증빙" === input.type) && ("number" === typeof input.amount && !Number.isNaN(input.amount)) && ("number" === typeof input.taxFreeAmount && !Number.isNaN(input.taxFreeAmount)) && "string" === typeof input.issueNumber && "string" === typeof input.receiptUrl; const _io4 = input => "object" === typeof input.mobilePhone && null !== input.mobilePhone && _io5(input.mobilePhone) && "휴대폰" === input.method && "NORMAL" === input.type && ("READY" === input.status || "IN_PROGRESS" === input.status || "WAITING_FOR_DEPOSIT" === input.status || "DONE" === input.status || "CANCELED" === input.status || "PARTIAL_CANCELED" === input.status || "ABORTED" === input.status || "EXPIRED" === input.status) && "string" === typeof input.mId && "string" === typeof input.version && "string" === typeof input.paymentKey && "string" === typeof input.orderId && "string" === typeof input.transactionKey && "string" === typeof input.orderName && "string" === typeof input.currency && ("number" === typeof input.totalAmount && !Number.isNaN(input.totalAmount)) && ("number" === typeof input.balanceAmount && !Number.isNaN(input.balanceAmount)) && ("number" === typeof input.suppliedAmount && !Number.isNaN(input.suppliedAmount)) && ("number" === typeof input.taxFreeAmount && !Number.isNaN(input.taxFreeAmount)) && ("number" === typeof input.vat && !Number.isNaN(input.vat)) && "boolean" === typeof input.useEscrow && "boolean" === typeof input.cultureExpense && ("string" === typeof input.requestedAt && __nestia_core_transform_isFormatDateTime._isFormatDateTime(input.requestedAt)) && (null === input.approvedAt || "string" === typeof input.approvedAt && __nestia_core_transform_isFormatDateTime._isFormatDateTime(input.approvedAt)) && (null === input.cancels || Array.isArray(input.cancels) && input.cancels.every((elem => "object" === typeof elem && null !== elem && _io2(elem)))) && (null === input.cashReceipt || "object" === typeof input.cashReceipt && null !== input.cashReceipt && _io3(input.cashReceipt)); const _io5 = input => "string" === typeof input.carrier && "string" === typeof input.customerMobilePhone && ("INCOMPLETED" === input.settlementStatus || "COMPLETED" === input.settlementStatus); const _io6 = input => "object" === typeof input.transfer && null !== input.transfer && _io7(input.transfer) && "계좌이체" === input.method && "NORMAL" === input.type && ("READY" === input.status || "IN_PROGRESS" === input.status || "WAITING_FOR_DEPOSIT" === input.status || "DONE" === input.status || "CANCELED" === input.status || "PARTIAL_CANCELED" === input.status || "ABORTED" === input.status || "EXPIRED" === input.status) && "string" === typeof input.mId && "string" === typeof input.version && "string" === typeof input.paymentKey && "string" === typeof input.orderId && "string" === typeof input.transactionKey && "string" === typeof input.orderName && "string" === typeof input.currency && ("number" === typeof input.totalAmount && !Number.isNaN(input.totalAmount)) && ("number" === typeof input.balanceAmount && !Number.isNaN(input.balanceAmount)) && ("number" === typeof input.suppliedAmount && !Number.isNaN(input.suppliedAmount)) && ("number" === typeof input.taxFreeAmount && !Number.isNaN(input.taxFreeAmount)) && ("number" === typeof input.vat && !Number.isNaN(input.vat)) && "boolean" === typeof input.useEscrow && "boolean" === typeof input.cultureExpense && ("string" === typeof input.requestedAt && __nestia_core_transform_isFormatDateTime._isFormatDateTime(input.requestedAt)) && (null === input.approvedAt || "string" === typeof input.approvedAt && __nestia_core_transform_isFormatDateTime._isFormatDateTime(input.approvedAt)) && (null === input.cancels || Array.isArray(input.cancels) && input.cancels.every((elem => "object" === typeof elem && null !== elem && _io2(elem)))) && (null === input.cashReceipt || "object" === typeof input.cashReceipt && null !== input.cashReceipt && _io3(input.cashReceipt)); const _io7 = input => "string" === typeof input.bank && ("INCOMPLETED" === input.settlementStatus || "COMPLETED" === input.settlementStatus); const _io8 = input => "string" === typeof input.secret && ("object" === typeof input.virtualAccount && null !== input.virtualAccount && _io9(input.virtualAccount)) && "가상계좌" === input.method && "NORMAL" === input.type && ("READY" === input.status || "IN_PROGRESS" === input.status || "WAITING_FOR_DEPOSIT" === input.status || "DONE" === input.status || "CANCELED" === input.status || "PARTIAL_CANCELED" === input.status || "ABORTED" === input.status || "EXPIRED" === input.status) && "string" === typeof input.mId && "string" === typeof input.version && "string" === typeof input.paymentKey && "string" === typeof input.orderId && "string" === typeof input.transactionKey && "string" === typeof input.orderName && "string" === typeof input.currency && ("number" === typeof input.totalAmount && !Number.isNaN(input.totalAmount)) && ("number" === typeof input.balanceAmount && !Number.isNaN(input.balanceAmount)) && ("number" === typeof input.suppliedAmount && !Number.isNaN(input.suppliedAmount)) && ("number" === typeof input.taxFreeAmount && !Number.isNaN(input.taxFreeAmount)) && ("number" === typeof input.vat && !Number.isNaN(input.vat)) && "boolean" === typeof input.useEscrow && "boolean" === typeof input.cultureExpense && ("string" === typeof input.requestedAt && __nestia_core_transform_isFormatDateTime._isFormatDateTime(input.requestedAt)) && (null === input.approvedAt || "string" === typeof input.approvedAt && __nestia_core_transform_isFormatDateTime._isFormatDateTime(input.approvedAt)) && (null === input.cancels || Array.isArray(input.cancels) && input.cancels.every((elem => "object" === typeof elem && null !== elem && _io2(elem)))) && (null === input.cashReceipt || "object" === typeof input.cashReceipt && null !== input.cashReceipt && _io3(input.cashReceipt)); const _io9 = input => "string" === typeof input.accountNumber && ("일반" === input.accountType || "고정" === input.accountType) && "string" === typeof input.bank && "string" === typeof input.customerName && ("string" === typeof input.dueDate && __nestia_core_transform_isFormatDate._isFormatDate(input.dueDate)) && "boolean" === typeof input.expired && ("INCOMPLETED" === input.settlementStatus || "COMPLETED" === input.settlementStatus) && ("COMPLETED" === input.refundStatus || "NONE" === input.refundStatus || "FAILED" === input.refundStatus || "PENDING" === input.refundStatus || "PARTIAL_FAILED" === input.refundStatus); const _io10 = input => "object" === typeof input.card && null !== input.card && _io11(input.card) && (null === input.discount || "object" === typeof input.discount && null !== input.discount && _io12(input.discount)) && (null === input.easyPay || "토스결제" === input.easyPay || "페이코" === input.easyPay || "삼성페이" === input.easyPay) && "카드" === input.method && ("NORMAL" === input.type || "BILLING" === input.type) && ("READY" === input.status || "IN_PROGRESS" === input.status || "WAITING_FOR_DEPOSIT" === input.status || "DONE" === input.status || "CANCELED" === input.status || "PARTIAL_CANCELED" === input.status || "ABORTED" === input.status || "EXPIRED" === input.status) && "string" === typeof input.mId && "string" === typeof input.version && "string" === typeof input.paymentKey && "string" === typeof input.orderId && "string" === typeof input.transactionKey && "string" === typeof input.orderName && "string" === typeof input.currency && ("number" === typeof input.totalAmount && !Number.isNaN(input.totalAmount)) && ("number" === typeof input.balanceAmount && !Number.isNaN(input.balanceAmount)) && ("number" === typeof input.suppliedAmount && !Number.isNaN(input.suppliedAmount)) && ("number" === typeof input.taxFreeAmount && !Number.isNaN(input.taxFreeAmount)) && ("number" === typeof input.vat && !Number.isNaN(input.vat)) && "boolean" === typeof input.useEscrow && "boolean" === typeof input.cultureExpense && ("string" === typeof input.requestedAt && __nestia_core_transform_isFormatDateTime._isFormatDateTime(input.requestedAt)) && (null === input.approvedAt || "string" === typeof input.approvedAt && __nestia_core_transform_isFormatDateTime._isFormatDateTime(input.approvedAt)) && (null === input.cancels || Array.isArray(input.cancels) && input.cancels.every((elem => "object" === typeof elem && null !== elem && _io2(elem)))) && (null === input.cashReceipt || "object" === typeof input.cashReceipt && null !== input.cashReceipt && _io3(input.cashReceipt)); const _io11 = input => "string" === typeof input.company && ("string" === typeof input.number && RegExp("[0-9]{16}").test(input.number)) && ("number" === typeof input.installmentPlanMonths && !Number.isNaN(input.installmentPlanMonths)) && "boolean" === typeof input.isInterestFree && "string" === typeof input.approveNo && false === input.useCardPoint && ("신용" === input.cardType || "체크" === input.cardType || "기프트" === input.cardType) && ("개인" === input.ownerType || "법인" === input.ownerType) && ("READY" === input.acquireStatus || "CANCELED" === input.acquireStatus || "COMPLETED" === input.acquireStatus || "REQUESTED" === input.acquireStatus || "CANCEL_REQUESTED" === input.acquireStatus) && ("string" === typeof input.receiptUrl && __nestia_core_transform_isFormatUri._isFormatUri(input.receiptUrl)); const _io12 = input => "number" === typeof input.amount && !Number.isNaN(input.amount); const _iu0 = input => (() => { if ("상품권" === input.method) return _io0(input); else if ("휴대폰" === input.method) return _io4(input); else if ("계좌이체" === input.method) return _io6(input); else if ("가상계좌" === input.method) return _io8(input); else if (undefined !== input.easyPay) return _io10(input); else return false; })(); const _ao0 = (input, _path, _exceptionable = true) => (("object" === typeof input.giftCertificate && null !== input.giftCertificate || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".giftCertificate", expected: "ITossGiftCertificatePayment.IGiftCertificate", value: input.giftCertificate }, _errorFactory)) && _ao1(input.giftCertificate, _path + ".giftCertificate", _exceptionable) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".giftCertificate", expected: "ITossGiftCertificatePayment.IGiftCertificate", value: input.giftCertificate }, _errorFactory)) && ("상품권" === input.method || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".method", expected: '"상품권"', value: input.method }, _errorFactory)) && ("NORMAL" === input.type || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".type", expected: '"NORMAL"', value: input.type }, _errorFactory)) && ("READY" === input.status || "IN_PROGRESS" === input.status || "WAITING_FOR_DEPOSIT" === input.status || "DONE" === input.status || "CANCELED" === input.status || "PARTIAL_CANCELED" === input.status || "ABORTED" === input.status || "EXPIRED" === input.status || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".status", expected: '("ABORTED" | "CANCELED" | "DONE" | "EXPIRED" | "IN_PROGRESS" | "PARTIAL_CANCELED" | "READY" | "WAITING_FOR_DEPOSIT")', value: input.status }, _errorFactory)) && ("string" === typeof input.mId || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".mId", expected: "string", value: input.mId }, _errorFactory)) && ("string" === typeof input.version || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".version", expected: "string", value: input.version }, _errorFactory)) && ("string" === typeof input.paymentKey || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".paymentKey", expected: "string", value: input.paymentKey }, _errorFactory)) && ("string" === typeof input.orderId || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".orderId", expected: "string", value: input.orderId }, _errorFactory)) && ("string" === typeof input.transactionKey || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".transactionKey", expected: "string", value: input.transactionKey }, _errorFactory)) && ("string" === typeof input.orderName || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".orderName", expected: "string", value: input.orderName }, _errorFactory)) && ("string" === typeof input.currency || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".currency", expected: "string", value: input.currency }, _errorFactory)) && ("number" === typeof input.totalAmount && !Number.isNaN(input.totalAmount) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".totalAmount", expected: "number", value: input.totalAmount }, _errorFactory)) && ("number" === typeof input.balanceAmount && !Number.isNaN(input.balanceAmount) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".balanceAmount", expected: "number", value: input.balanceAmount }, _errorFactory)) && ("number" === typeof input.suppliedAmount && !Number.isNaN(input.suppliedAmount) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".suppliedAmount", expected: "number", value: input.suppliedAmount }, _errorFactory)) && ("number" === typeof input.taxFreeAmount && !Number.isNaN(input.taxFreeAmount) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".taxFreeAmount", expected: "number", value: input.taxFreeAmount }, _errorFactory)) && ("number" === typeof input.vat && !Number.isNaN(input.vat) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".vat", expected: "number", value: input.vat }, _errorFactory)) && ("boolean" === typeof input.useEscrow || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".useEscrow", expected: "boolean", value: input.useEscrow }, _errorFactory)) && ("boolean" === typeof input.cultureExpense || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".cultureExpense", expected: "boolean", value: input.cultureExpense }, _errorFactory)) && ("string" === typeof input.requestedAt && (__nestia_core_transform_isFormatDateTime._isFormatDateTime(input.requestedAt) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".requestedAt", expected: 'string & Format<"date-time">', value: input.requestedAt }, _errorFactory)) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".requestedAt", expected: '(string & Format<"date-time">)', value: input.requestedAt }, _errorFactory)) && (null === input.approvedAt || "string" === typeof input.approvedAt && (__nestia_core_transform_isFormatDateTime._isFormatDateTime(input.approvedAt) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".approvedAt", expected: 'string & Format<"date-time">', value: input.approvedAt }, _errorFactory)) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".approvedAt", expected: '((string & Format<"date-time">) | null)', value: input.approvedAt }, _errorFactory)) && (null === input.cancels || (Array.isArray(input.cancels) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".cancels", expected: "(Array<ITossPaymentCancel> | null)", value: input.cancels }, _errorFactory)) && input.cancels.every(((elem, _index6) => ("object" === typeof elem && null !== elem || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".cancels[" + _index6 + "]", expected: "ITossPaymentCancel", value: elem }, _errorFactory)) && _ao2(elem, _path + ".cancels[" + _index6 + "]", _exceptionable) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".cancels[" + _index6 + "]", expected: "ITossPaymentCancel", value: elem }, _errorFactory))) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".cancels", expected: "(Array<ITossPaymentCancel> | null)", value: input.cancels }, _errorFactory)) && (null === input.cashReceipt || ("object" === typeof input.cashReceipt && null !== input.cashReceipt || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".cashReceip