UNPKG

fake-iamport-server

Version:
620 lines (619 loc) 94.5 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __decorate = (this && this.__decorate) || function (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; }; var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var __param = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.FakeIampotSubscribePaymentsController = void 0; var __nestia_core_transform_isTypeUint32 = __importStar(require("typia/lib/internal/_isTypeUint32.js")); var __nestia_core_transform_isFormatUri = __importStar(require("typia/lib/internal/_isFormatUri.js")); var __nestia_core_transform_isFormatEmail = __importStar(require("typia/lib/internal/_isFormatEmail.js")); var __nestia_core_transform_assertGuard = __importStar(require("typia/lib/internal/_assertGuard.js")); var __nestia_core_transform_jsonStringifyString = __importStar(require("typia/lib/internal/_jsonStringifyString.js")); var __nestia_core_transform_validateReport = __importStar(require("typia/lib/internal/_validateReport.js")); var core_1 = __importDefault(require("@nestia/core")); var common_1 = require("@nestjs/common"); var uuid_1 = require("uuid"); var FakeIamportUserAuth_1 = require("../../decorators/FakeIamportUserAuth"); var FakeIamportPaymentProvider_1 = require("../../providers/FakeIamportPaymentProvider"); var FakeIamportResponseProvider_1 = require("../../providers/FakeIamportResponseProvider"); var FakeIamportStorage_1 = require("../../providers/FakeIamportStorage"); var FakeIamportSubscriptionProvider_1 = require("../../providers/FakeIamportSubscriptionProvider"); var AdvancedRandomGenerator_1 = require("../../utils/AdvancedRandomGenerator"); var FakeIampotSubscribePaymentsController = /** @class */ (function () { function FakeIampotSubscribePaymentsController() { } /** * 카드로 결제하기, 더불어 간편 결제용으로 등록 가능. * * `subscribe.payments.onetime` 은 카드를 매개로 한 결제를 하고자 할 때 호출하는 API * 함수이다. 더하여 입력 값에 {@link IIamportSubscription.IOnetime.customer_uid} 를 * 기입하는 경우, 결제에 사용한 카드를 그대로 간편 결제용 카드 * {@link IIamportSubscription} 로 등록해버린다. * * 다만, 정히 간편 카드 등록과 결제를 동시에 하고 싶다면, * `subscribe.payments.onetime` 에 {@link IIamportSubscription.IOnetime.customer_uid} * 를 더하기보다, {@link subscribe.customers.create} 와 {@link subscribe.payments.again} * 을 각각 호출하는 것을 권장한다. 그것이 예외적인 상황에 보다 안전하게 대처할 수 있기 * 때문이다. * * 더하여 `subscribe.payments.onetime` 은 클라이언트 어플리케이션이 아임포트가 제공하는 * 결제 창을 그대로 사용하는 경우, 귀하의 백엔드 서버가 이를 실 서비스에서 호출하는 일은 * 없을 것이다. 다만, 고객이 카드를 통하여 결제하는 상황을 시뮬레이션하기 위하여, 테스트 * 자동화 프로그램 수준에서 사용될 수는 있다. * * @param input 카드 결제 신청 정보 * @returns 카드 결제 정보 * * @security bearer * @author Samchon */ FakeIampotSubscribePaymentsController.prototype.onetime = function (_user, input) { if (input.customer_uid) FakeIamportSubscriptionProvider_1.FakeIamportSubscriptionProvider.create(input.customer_uid, input); var pg_id = (0, uuid_1.v4)(); var payment = { card_code: (0, uuid_1.v4)(), card_name: AdvancedRandomGenerator_1.AdvancedRandomGenerator.name(), card_number: input.card_number, card_quota: input.card_quota || 0, apply_num: (0, uuid_1.v4)(), // ORDER INFO pay_method: "card", currency: input.currency || "KRW", merchant_uid: input.merchant_uid, imp_uid: (0, uuid_1.v4)(), name: input.name, amount: input.amount, cancel_amount: 0, receipt_url: "https://github.com/samchon/fake-iamport-server", cash_receipt_issue: true, // PAYMENT PROVIDER INFO channel: Math.random() < 0.5 ? "pc" : "mobile", pg_provider: "somewhere", emb_pg_provider: null, pg_id: pg_id, pg_tid: pg_id, escrow: false, // BUYER buyer_name: input.buyer_name || null, buyer_tel: input.buyer_tel || null, buyer_email: input.buyer_email || null, buyer_addr: input.buyer_addr || null, buyer_postcode: input.buyer_postcode || null, customer_uid: input.customer_uid || null, customer_uid_usage: input.customer_uid ? "issue" : null, custom_data: input.custom_data || null, user_agent: "Test Automation", // TIMESTAMPS status: "paid", started_at: Date.now() / 1000, paid_at: Date.now() / 1000, failed_at: 0, fail_reason: null, cancelled_at: 0, cancel_reason: null, cancel_history: [], // HIDDEN notice_url: input.notice_url, }; FakeIamportPaymentProvider_1.FakeIamportPaymentProvider.create(payment); return FakeIamportResponseProvider_1.FakeIamportResponseProvider.success(payment); }; /** * 간편 결제에 등록된 카드로 결제하기. * * `subscribe.payments.again` 은 고객이 간편 결제에 등록한 카드로 결제를 진행하고자 할 때 * 호출하는 API 함수이다. 이는 간편하고 불편하고를 떠나, 본질적으로 카드 결제의 일환이기에, * 리턴값은 일반적인 카드 결제 때와 동일한 {@link IIamportCardPayment} 이다. * * 그리고 `subscribe.payments.again` 은 결제 수단 중 유일하게, 클라이언트 어플리케이션이 * 아임포트가 제공하는 결체 창을 사용할 수 없어, 오직 귀하의 백엔드 서버가 아임포트의 API * 함수를 직접 호출해야하는 경우에 해당한다. 따라서 간편 결제에 관하여 아임포트 서버와 * 연동하는 백엔드 서버 및 프론트 어플리케이션을 개발할 때, 반드시 이 상황에 대한 별도의 * 설계 및 개발이 필요하니, 이 점을 염두에 두기 바란다. * * @param input 미리 등록한 카드를 이용한 결제 신청 정보 * @returns 카드 결제 정보 * * @security bearer * @author Samchon */ FakeIampotSubscribePaymentsController.prototype.again = function (_user, input) { var subscription = FakeIamportStorage_1.FakeIamportStorage.subscriptions.get(input.customer_uid); var pg_id = (0, uuid_1.v4)(); var payment = { card_code: subscription.card_code, card_name: subscription.card_name, card_number: subscription.card_number, card_quota: input.card_quota || 0, apply_num: (0, uuid_1.v4)(), // ORDER INFO pay_method: "card", currency: input.currency || "KRW", merchant_uid: input.merchant_uid, imp_uid: (0, uuid_1.v4)(), name: input.name, amount: input.amount, cancel_amount: 0, receipt_url: "https://github.com/samchon/fake-iamport-server", cash_receipt_issue: true, // PAYMENT PROVIDER INFO channel: Math.random() < 0.5 ? "pc" : "mobile", pg_provider: "somewhere", emb_pg_provider: null, pg_id: pg_id, pg_tid: pg_id, escrow: false, // BUYER buyer_name: input.buyer_name || subscription.customer_name || null, buyer_tel: input.buyer_tel || subscription.customer_tel || null, buyer_email: input.buyer_email || subscription.customer_email || null, buyer_addr: input.buyer_addr || subscription.customer_addr || null, buyer_postcode: input.buyer_postcode || subscription.customer_postcode || null, customer_uid: subscription.customer_uid, customer_uid_usage: "issue", custom_data: input.custom_data || null, user_agent: "Test Automation", // TIMESTAMPS status: "paid", started_at: Date.now() / 1000, paid_at: Date.now() / 1000, failed_at: 0, fail_reason: null, cancelled_at: 0, cancel_reason: null, cancel_history: [], // HIDDEN notice_url: input.notice_url, }; FakeIamportPaymentProvider_1.FakeIamportPaymentProvider.create(payment); return FakeIamportResponseProvider_1.FakeIamportResponseProvider.success(payment); }; __decorate([ core_1.default.TypedRoute.Post("onetime", { type: "assert", assert: (function () { var _io0 = function (input) { return "number" === typeof input.code && !Number.isNaN(input.code) && "string" === typeof input.message && ("object" === typeof input.response && null !== input.response && _io1(input.response)); }; var _io1 = function (input) { return "string" === typeof input.card_code && "string" === typeof input.card_name && ("string" === typeof input.card_number && RegExp("\\d{4}-\\d{4}-\\d{4}-\\d{4}").test(input.card_number)) && ("number" === typeof input.card_quota && __nestia_core_transform_isTypeUint32._isTypeUint32(input.card_quota)) && "string" === typeof input.apply_num && ("card" === input.pay_method || "samsung" === input.pay_method) && "string" === typeof input.imp_uid && "string" === typeof input.merchant_uid && (null === input.name || "string" === typeof input.name) && ("number" === typeof input.amount && !Number.isNaN(input.amount)) && ("number" === typeof input.cancel_amount && !Number.isNaN(input.cancel_amount)) && ("KRW" === input.currency || "USD" === input.currency || "EUR" === input.currency || "JPY" === input.currency) && ("string" === typeof input.receipt_url && __nestia_core_transform_isFormatUri._isFormatUri(input.receipt_url)) && "boolean" === typeof input.cash_receipt_issue && "string" === typeof input.channel && "string" === typeof input.pg_provider && (null === input.emb_pg_provider || "string" === typeof input.emb_pg_provider) && "string" === typeof input.pg_id && "string" === typeof input.pg_tid && "boolean" === typeof input.escrow && (null === input.buyer_name || "string" === typeof input.buyer_name) && (null === input.buyer_email || "string" === typeof input.buyer_email && __nestia_core_transform_isFormatEmail._isFormatEmail(input.buyer_email)) && (null === input.buyer_tel || "string" === typeof input.buyer_tel) && (null === input.buyer_addr || "string" === typeof input.buyer_addr) && (null === input.buyer_postcode || "string" === typeof input.buyer_postcode) && (null === input.customer_uid || "string" === typeof input.customer_uid) && (null === input.customer_uid_usage || "string" === typeof input.customer_uid_usage) && (null === input.custom_data || "string" === typeof input.custom_data) && (null === input.user_agent || "string" === typeof input.user_agent) && ("paid" === input.status || "ready" === input.status || "failed" === input.status || "cancelled" === input.status) && ("number" === typeof input.started_at && !Number.isNaN(input.started_at)) && ("number" === typeof input.paid_at && !Number.isNaN(input.paid_at)) && ("number" === typeof input.failed_at && !Number.isNaN(input.failed_at)) && ("number" === typeof input.cancelled_at && !Number.isNaN(input.cancelled_at)) && (null === input.fail_reason || "string" === typeof input.fail_reason) && (null === input.cancel_reason || "string" === typeof input.cancel_reason) && (Array.isArray(input.cancel_history) && input.cancel_history.every(function (elem) { return "object" === typeof elem && null !== elem && _io2(elem); })); }; var _io2 = function (input) { return "string" === typeof input.pg_id && "string" === typeof input.pg_tid && ("number" === typeof input.amount && !Number.isNaN(input.amount)) && ("number" === typeof input.cancelled_at && !Number.isNaN(input.cancelled_at)) && "string" === typeof input.reason && ("string" === typeof input.receipt_url && __nestia_core_transform_isFormatUri._isFormatUri(input.receipt_url)); }; var _ao0 = function (input, _path, _exceptionable) { if (_exceptionable === void 0) { _exceptionable = true; } return ("number" === typeof input.code && !Number.isNaN(input.code) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".code", expected: "number", value: input.code }, _errorFactory)) && ("string" === typeof input.message || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".message", expected: "string", value: input.message }, _errorFactory)) && (("object" === typeof input.response && null !== input.response || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".response", expected: "IIamportCardPayment", value: input.response }, _errorFactory)) && _ao1(input.response, _path + ".response", true && _exceptionable) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".response", expected: "IIamportCardPayment", value: input.response }, _errorFactory)); }; var _ao1 = function (input, _path, _exceptionable) { if (_exceptionable === void 0) { _exceptionable = true; } return ("string" === typeof input.card_code || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".card_code", expected: "string", value: input.card_code }, _errorFactory)) && ("string" === typeof input.card_name || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".card_name", expected: "string", value: input.card_name }, _errorFactory)) && ("string" === typeof input.card_number && (RegExp("\\d{4}-\\d{4}-\\d{4}-\\d{4}").test(input.card_number) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".card_number", expected: "string & Pattern<\"\\\\d{4}-\\\\d{4}-\\\\d{4}-\\\\d{4}\">", value: input.card_number }, _errorFactory)) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".card_number", expected: "(string & Pattern<\"\\\\d{4}-\\\\d{4}-\\\\d{4}-\\\\d{4}\">)", value: input.card_number }, _errorFactory)) && ("number" === typeof input.card_quota && (__nestia_core_transform_isTypeUint32._isTypeUint32(input.card_quota) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".card_quota", expected: "number & Type<\"uint32\">", value: input.card_quota }, _errorFactory)) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".card_quota", expected: "(number & Type<\"uint32\">)", value: input.card_quota }, _errorFactory)) && ("string" === typeof input.apply_num || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".apply_num", expected: "string", value: input.apply_num }, _errorFactory)) && ("card" === input.pay_method || "samsung" === input.pay_method || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".pay_method", expected: "(\"card\" | \"samsung\")", value: input.pay_method }, _errorFactory)) && ("string" === typeof input.imp_uid || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".imp_uid", expected: "string", value: input.imp_uid }, _errorFactory)) && ("string" === typeof input.merchant_uid || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".merchant_uid", expected: "string", value: input.merchant_uid }, _errorFactory)) && (null === input.name || "string" === typeof input.name || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".name", expected: "(null | string)", value: input.name }, _errorFactory)) && ("number" === typeof input.amount && !Number.isNaN(input.amount) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".amount", expected: "number", value: input.amount }, _errorFactory)) && ("number" === typeof input.cancel_amount && !Number.isNaN(input.cancel_amount) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".cancel_amount", expected: "number", value: input.cancel_amount }, _errorFactory)) && ("KRW" === input.currency || "USD" === input.currency || "EUR" === input.currency || "JPY" === input.currency || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".currency", expected: "(\"EUR\" | \"JPY\" | \"KRW\" | \"USD\")", value: input.currency }, _errorFactory)) && ("string" === typeof input.receipt_url && (__nestia_core_transform_isFormatUri._isFormatUri(input.receipt_url) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".receipt_url", expected: "string & Format<\"uri\">", value: input.receipt_url }, _errorFactory)) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".receipt_url", expected: "(string & Format<\"uri\">)", value: input.receipt_url }, _errorFactory)) && ("boolean" === typeof input.cash_receipt_issue || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".cash_receipt_issue", expected: "boolean", value: input.cash_receipt_issue }, _errorFactory)) && ("string" === typeof input.channel || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".channel", expected: "string", value: input.channel }, _errorFactory)) && ("string" === typeof input.pg_provider || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".pg_provider", expected: "string", value: input.pg_provider }, _errorFactory)) && (null === input.emb_pg_provider || "string" === typeof input.emb_pg_provider || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".emb_pg_provider", expected: "(null | string)", value: input.emb_pg_provider }, _errorFactory)) && ("string" === typeof input.pg_id || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".pg_id", expected: "string", value: input.pg_id }, _errorFactory)) && ("string" === typeof input.pg_tid || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".pg_tid", expected: "string", value: input.pg_tid }, _errorFactory)) && ("boolean" === typeof input.escrow || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".escrow", expected: "boolean", value: input.escrow }, _errorFactory)) && (null === input.buyer_name || "string" === typeof input.buyer_name || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".buyer_name", expected: "(null | string)", value: input.buyer_name }, _errorFactory)) && (null === input.buyer_email || "string" === typeof input.buyer_email && (__nestia_core_transform_isFormatEmail._isFormatEmail(input.buyer_email) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".buyer_email", expected: "string & Format<\"email\">", value: input.buyer_email }, _errorFactory)) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".buyer_email", expected: "((string & Format<\"email\">) | null)", value: input.buyer_email }, _errorFactory)) && (null === input.buyer_tel || "string" === typeof input.buyer_tel || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".buyer_tel", expected: "(null | string)", value: input.buyer_tel }, _errorFactory)) && (null === input.buyer_addr || "string" === typeof input.buyer_addr || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".buyer_addr", expected: "(null | string)", value: input.buyer_addr }, _errorFactory)) && (null === input.buyer_postcode || "string" === typeof input.buyer_postcode || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".buyer_postcode", expected: "(null | string)", value: input.buyer_postcode }, _errorFactory)) && (null === input.customer_uid || "string" === typeof input.customer_uid || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".customer_uid", expected: "(null | string)", value: input.customer_uid }, _errorFactory)) && (null === input.customer_uid_usage || "string" === typeof input.customer_uid_usage || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".customer_uid_usage", expected: "(null | string)", value: input.customer_uid_usage }, _errorFactory)) && (null === input.custom_data || "string" === typeof input.custom_data || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".custom_data", expected: "(null | string)", value: input.custom_data }, _errorFactory)) && (null === input.user_agent || "string" === typeof input.user_agent || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".user_agent", expected: "(null | string)", value: input.user_agent }, _errorFactory)) && ("paid" === input.status || "ready" === input.status || "failed" === input.status || "cancelled" === input.status || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".status", expected: "(\"cancelled\" | \"failed\" | \"paid\" | \"ready\")", value: input.status }, _errorFactory)) && ("number" === typeof input.started_at && !Number.isNaN(input.started_at) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".started_at", expected: "number", value: input.started_at }, _errorFactory)) && ("number" === typeof input.paid_at && !Number.isNaN(input.paid_at) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".paid_at", expected: "number", value: input.paid_at }, _errorFactory)) && ("number" === typeof input.failed_at && !Number.isNaN(input.failed_at) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".failed_at", expected: "number", value: input.failed_at }, _errorFactory)) && ("number" === typeof input.cancelled_at && !Number.isNaN(input.cancelled_at) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".cancelled_at", expected: "number", value: input.cancelled_at }, _errorFactory)) && (null === input.fail_reason || "string" === typeof input.fail_reason || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".fail_reason", expected: "(null | string)", value: input.fail_reason }, _errorFactory)) && (null === input.cancel_reason || "string" === typeof input.cancel_reason || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".cancel_reason", expected: "(null | string)", value: input.cancel_reason }, _errorFactory)) && ((Array.isArray(input.cancel_history) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".cancel_history", expected: "Array<IIamportPaymentCancel>", value: input.cancel_history }, _errorFactory)) && input.cancel_history.every(function (elem, _index2) { return ("object" === typeof elem && null !== elem || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".cancel_history[" + _index2 + "]", expected: "IIamportPaymentCancel", value: elem }, _errorFactory)) && _ao2(elem, _path + ".cancel_history[" + _index2 + "]", true && _exceptionable) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".cancel_history[" + _index2 + "]", expected: "IIamportPaymentCancel", value: elem }, _errorFactory); }) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".cancel_history", expected: "Array<IIamportPaymentCancel>", value: input.cancel_history }, _errorFactory)); }; var _ao2 = function (input, _path, _exceptionable) { if (_exceptionable === void 0) { _exceptionable = true; } return ("string" === typeof input.pg_id || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".pg_id", expected: "string", value: input.pg_id }, _errorFactory)) && ("string" === typeof input.pg_tid || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".pg_tid", expected: "string", value: input.pg_tid }, _errorFactory)) && ("number" === typeof input.amount && !Number.isNaN(input.amount) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".amount", expected: "number", value: input.amount }, _errorFactory)) && ("number" === typeof input.cancelled_at && !Number.isNaN(input.cancelled_at) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".cancelled_at", expected: "number", value: input.cancelled_at }, _errorFactory)) && ("string" === typeof input.reason || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".reason", expected: "string", value: input.reason }, _errorFactory)) && ("string" === typeof input.receipt_url && (__nestia_core_transform_isFormatUri._isFormatUri(input.receipt_url) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".receipt_url", expected: "string & Format<\"uri\">", value: input.receipt_url }, _errorFactory)) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".receipt_url", expected: "(string & Format<\"uri\">)", value: input.receipt_url }, _errorFactory)); }; var _so0 = function (input) { return "{\"code\":".concat(input.code, ",\"message\":").concat(__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.message), ",\"response\":").concat(_so1(input.response), "}"); }; var _so1 = function (input) { return "{\"card_code\":".concat(__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.card_code), ",\"card_name\":").concat(__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.card_name), ",\"card_number\":").concat(__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.card_number), ",\"card_quota\":").concat(input.card_quota, ",\"apply_num\":").concat(__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.apply_num), ",\"pay_method\":").concat("\"" + input.pay_method + "\"", ",\"imp_uid\":").concat(__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.imp_uid), ",\"merchant_uid\":").concat(__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.merchant_uid), ",\"name\":").concat(null !== input.name ? __nestia_core_transform_jsonStringifyString._jsonStringifyString(input.name) : "null", ",\"amount\":").concat(input.amount, ",\"cancel_amount\":").concat(input.cancel_amount, ",\"currency\":").concat("\"" + input.currency + "\"", ",\"receipt_url\":").concat(__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.receipt_url), ",\"cash_receipt_issue\":").concat(input.cash_receipt_issue, ",\"channel\":").concat(__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.channel), ",\"pg_provider\":").concat(__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.pg_provider), ",\"emb_pg_provider\":").concat(null !== input.emb_pg_provider ? __nestia_core_transform_jsonStringifyString._jsonStringifyString(input.emb_pg_provider) : "null", ",\"pg_id\":").concat(__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.pg_id), ",\"pg_tid\":").concat(__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.pg_tid), ",\"escrow\":").concat(input.escrow, ",\"buyer_name\":").concat(null !== input.buyer_name ? __nestia_core_transform_jsonStringifyString._jsonStringifyString(input.buyer_name) : "null", ",\"buyer_email\":").concat(null !== input.buyer_email ? __nestia_core_transform_jsonStringifyString._jsonStringifyString(input.buyer_email) : "null", ",\"buyer_tel\":").concat(null !== input.buyer_tel ? __nestia_core_transform_jsonStringifyString._jsonStringifyString(input.buyer_tel) : "null", ",\"buyer_addr\":").concat(null !== input.buyer_addr ? __nestia_core_transform_jsonStringifyString._jsonStringifyString(input.buyer_addr) : "null", ",\"buyer_postcode\":").concat(null !== input.buyer_postcode ? __nestia_core_transform_jsonStringifyString._jsonStringifyString(input.buyer_postcode) : "null", ",\"customer_uid\":").concat(null !== input.customer_uid ? __nestia_core_transform_jsonStringifyString._jsonStringifyString(input.customer_uid) : "null", ",\"customer_uid_usage\":").concat(null !== input.customer_uid_usage ? __nestia_core_transform_jsonStringifyString._jsonStringifyString(input.customer_uid_usage) : "null", ",\"custom_data\":").concat(null !== input.custom_data ? __nestia_core_transform_jsonStringifyString._jsonStringifyString(input.custom_data) : "null", ",\"user_agent\":").concat(null !== input.user_agent ? __nestia_core_transform_jsonStringifyString._jsonStringifyString(input.user_agent) : "null", ",\"status\":").concat("\"" + input.status + "\"", ",\"started_at\":").concat(input.started_at, ",\"paid_at\":").concat(input.paid_at, ",\"failed_at\":").concat(input.failed_at, ",\"cancelled_at\":").concat(input.cancelled_at, ",\"fail_reason\":").concat(null !== input.fail_reason ? __nestia_core_transform_jsonStringifyString._jsonStringifyString(input.fail_reason) : "null", ",\"cancel_reason\":").concat(null !== input.cancel_reason ? __nestia_core_transform_jsonStringifyString._jsonStringifyString(input.cancel_reason) : "null", ",\"cancel_history\":").concat("[".concat(input.cancel_history.map(function (elem) { return _so2(elem); }).join(","), "]"), "}"); }; var _so2 = function (input) { return "{\"pg_id\":".concat(__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.pg_id), ",\"pg_tid\":").concat(__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.pg_tid), ",\"amount\":").concat(input.amount, ",\"cancelled_at\":").concat(input.cancelled_at, ",\"reason\":").concat(__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.reason), ",\"receipt_url\":").concat(__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.receipt_url), "}"); }; var __is = function (input) { return "object" === typeof input && null !== input && _io0(input); }; var _errorFactory; var __assert = function (input, errorFactory) { if (false === __is(input)) { _errorFactory = errorFactory; (function (input, _path, _exceptionable) { if (_exceptionable === void 0) { _exceptionable = true; } return ("object" === typeof input && null !== input || __nestia_core_transform_assertGuard._assertGuard(true, { method: "core.TypedRoute.Post", path: _path + "", expected: "IIamportResponse<IIamportCardPayment>", value: input }, _errorFactory)) && _ao0(input, _path + "", true) || __nestia_core_transform_assertGuard._assertGuard(true, { method: "core.TypedRoute.Post", path: _path + "", expected: "IIamportResponse<IIamportCardPayment>", value: input }, _errorFactory); })(input, "$input", true); } return input; }; var __stringify = function (input) { return _so0(input); }; return function (input, errorFactory) { __assert(input, errorFactory); return __stringify(input); }; })() }), __param(0, (0, FakeIamportUserAuth_1.FakeIamportUserAuth)()), __param(1, core_1.default.TypedBody({ type: "validate", validate: (function () { var _io0 = function (input) { return (undefined === input.customer_uid || "string" === typeof input.customer_uid) && ("string" === typeof input.card_number && RegExp("\\d{4}-\\d{4}-\\d{4}-\\d{4}").test(input.card_number)) && ("string" === typeof input.expiry && RegExp("^([0-9]{4})-(0[1-9]|1[012])$").test(input.expiry)) && ("string" === typeof input.birth && RegExp("^(([0-9]{2})(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01]))|(\\d{10})$").test(input.birth)) && (undefined === input.pwd_2digit || "string" === typeof input.pwd_2digit && RegExp("\\d{2}").test(input.pwd_2digit)) && (undefined === input.cvc || "string" === typeof input.cvc && RegExp("\\d{2}").test(input.cvc)) && (undefined === input.customer_name || "string" === typeof input.customer_name) && (undefined === input.customer_tel || "string" === typeof input.customer_tel) && (undefined === input.customer_email || "string" === typeof input.customer_email && __nestia_core_transform_isFormatEmail._isFormatEmail(input.customer_email)) && (undefined === input.customr_addr || "string" === typeof input.customr_addr) && (undefined === input.customer_postcode || "string" === typeof input.customer_postcode) && "string" === typeof input.merchant_uid && "number" === typeof input.amount && "string" === typeof input.name && (undefined === input.currency || "KRW" === input.currency || "USD" === input.currency || "EUR" === input.currency || "JPY" === input.currency) && (undefined === input.tax_free || "number" === typeof input.tax_free) && (undefined === input.card_quota || "number" === typeof input.card_quota) && (undefined === input.buyer_name || "string" === typeof input.buyer_name) && (undefined === input.buyer_email || "string" === typeof input.buyer_email && __nestia_core_transform_isFormatEmail._isFormatEmail(input.buyer_email)) && (undefined === input.buyer_tel || "string" === typeof input.buyer_tel) && (undefined === input.buyer_addr || "string" === typeof input.buyer_addr) && (undefined === input.buyer_postcode || "string" === typeof input.buyer_postcode) && (undefined === input.interest_free_by_merchant || "boolean" === typeof input.interest_free_by_merchant) && (undefined === input.use_card_point || "boolean" === typeof input.use_card_point) && (undefined === input.custom_data || "string" === typeof input.custom_data) && (undefined === input.notice_url || "string" === typeof input.notice_url && __nestia_core_transform_isFormatUri._isFormatUri(input.notice_url)); }; var _vo0 = function (input, _path, _exceptionable) { if (_exceptionable === void 0) { _exceptionable = true; } return [undefined === input.customer_uid || "string" === typeof input.customer_uid || _report(_exceptionable, { path: _path + ".customer_uid", expected: "(string | undefined)", value: input.customer_uid }), "string" === typeof input.card_number && (RegExp("\\d{4}-\\d{4}-\\d{4}-\\d{4}").test(input.card_number) || _report(_exceptionable, { path: _path + ".card_number", expected: "string & Pattern<\"\\\\d{4}-\\\\d{4}-\\\\d{4}-\\\\d{4}\">", value: input.card_number })) || _report(_exceptionable, { path: _path + ".card_number", expected: "(string & Pattern<\"\\\\d{4}-\\\\d{4}-\\\\d{4}-\\\\d{4}\">)", value: input.card_number }), "string" === typeof input.expiry && (RegExp("^([0-9]{4})-(0[1-9]|1[012])$").test(input.expiry) || _report(_exceptionable, { path: _path + ".expiry", expected: "string & Pattern<\"^([0-9]{4})-(0[1-9]|1[012])$\">", value: input.expiry })) || _report(_exceptionable, { path: _path + ".expiry", expected: "(string & Pattern<\"^([0-9]{4})-(0[1-9]|1[012])$\">)", value: input.expiry }), "string" === typeof input.birth && (RegExp("^(([0-9]{2})(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01]))|(\\d{10})$").test(input.birth) || _report(_exceptionable, { path: _path + ".birth", expected: "string & Pattern<\"^(([0-9]{2})(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01]))|(\\\\d{10})$\">", value: input.birth })) || _report(_exceptionable, { path: _path + ".birth", expected: "(string & Pattern<\"^(([0-9]{2})(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01]))|(\\\\d{10})$\">)", value: input.birth }), undefined === input.pwd_2digit || "string" === typeof input.pwd_2digit && (RegExp("\\d{2}").test(input.pwd_2digit) || _report(_exceptionable, { path: _path + ".pwd_2digit", expected: "string & Pattern<\"\\\\d{2}\">", value: input.pwd_2digit })) || _report(_exceptionable, { path: _path + ".pwd_2digit", expected: "((string & Pattern<\"\\\\d{2}\">) | undefined)", value: input.pwd_2digit }), undefined === input.cvc || "string" === typeof input.cvc && (RegExp("\\d{2}").test(input.cvc) || _report(_exceptionable, { path: _path + ".cvc", expected: "string & Pattern<\"\\\\d{2}\">", value: input.cvc })) || _report(_exceptionable, { path: _path + ".cvc", expected: "((string & Pattern<\"\\\\d{2}\">) | undefined)", value: input.cvc }), undefined === input.customer_name || "string" === typeof input.customer_name || _report(_exceptionable, { path: _path + ".customer_name", expected: "(string | undefined)", value: input.customer_name }), undefined === input.customer_tel || "string" === typeof input.customer_tel || _report(_exceptionable, { path: _path + ".customer_tel", expected: "(string | undefined)", value: input.customer_tel }), undefined === input.customer_email || "string" === typeof input.customer_email && (__nestia_core_transform_isFormatEmail._isFormatEmail(input.customer_email) || _report(_exceptionable, { path: _path + ".customer_email", expected: "string & Format<\"email\">", value: input.customer_email })) || _report(_exceptionable, { path: _path + ".customer_email", expected: "((string & Format<\"email\">) | undefined)", value: input.customer_email }), undefined === input.customr_addr || "string" === typeof input.customr_addr || _report(_exceptionable, { path: _path + ".customr_addr", expected: "(string | undefined)", value: input.customr_addr }), undefined === input.customer_postcode || "string" === typeof input.customer_postcode || _report(_exceptionable, { path: _path + ".customer_postcode", expected: "(string | undefined)", value: input.customer_postcode }), "string" === typeof input.merchant_uid || _report(_exceptionable, { path: _path + ".merchant_uid", expected: "string", value: input.merchant_uid }), "number" === typeof input.amount || _report(_exceptionable, { path: _path + ".amount", expected: "number", value: input.amount }), "string" === typeof input.name || _report(_exceptionable, { path: _path + ".name", expected: "string", value: input.name }), undefined === input.currency || "KRW" === input.currency || "USD" === input.currency || "EUR" === input.currency || "JPY" === input.currency || _report(_exceptionable, { path: _path + ".currency", expected: "(\"EUR\" | \"JPY\" | \"KRW\" | \"USD\" | undefined)", value: input.currency }), undefined === input.tax_free || "number" === typeof input.tax_free || _report(_exceptionable, { path: _path + ".tax_free", expected: "(number | undefined)", value: input.tax_free }), undefined === input.card_quota || "number" === typeof input.card_quota || _report(_exceptionable, { path: _path + ".card_quota", expected: "(number | undefined)", value: input.card_quota }), undefined === input.buyer_name || "string" === typeof input.buyer_name || _report(_exceptionable, { path: _path + ".buyer_name", expected: "(string | undefined)", value: input.buyer_name }), undefined === input.buyer_email || "string" === typeof input.buyer_email && (__nestia_core_transform_isFormatEmail._isFormatEmail(input.buyer_email) || _report(_exceptionable, { path: _path + ".buyer_email", expected: "string & Format<\"email\">", value: input.buyer_email })) || _report(_exceptionable, { path: _path + ".buyer_email",