fake-iamport-server
Version:
Fake iamport server for testing
595 lines (594 loc) • 76.4 kB
JavaScript
"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.FakeIamportVbanksController = void 0;
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 tstl_1 = require("tstl");
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 AdvancedRandomGenerator_1 = require("../utils/AdvancedRandomGenerator");
var FakeIamportVbanksController = /** @class */ (function () {
function FakeIamportVbanksController() {
}
/**
* 가상 계좌 발급하기.
*
* @param input 가상 계좌 입력 정보
* @returns 가상 계좌 결제 정보
*
* @security bearer
* @author Samchon
*/
FakeIamportVbanksController.prototype.create = function (_user, input) {
// CONSTRUCTION
var pg_id = (0, uuid_1.v4)();
var payment = {
// VIRTUAL-BANK INFO
vbank_code: input.vbank_code,
vbank_name: AdvancedRandomGenerator_1.AdvancedRandomGenerator.name(2) + "은행",
vbank_num: (0, tstl_1.randint)(100000000, 999999999).toString(),
vbank_holder: AdvancedRandomGenerator_1.AdvancedRandomGenerator.name(),
vbank_date: input.vbank_due,
vbank_issued_at: Date.now(),
// ORDER INFO
pay_method: "vbank",
currency: "KRW",
merchant_uid: input.merchant_uid,
imp_uid: (0, uuid_1.v4)(),
name: input.name || null,
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: (0, uuid_1.v4)(),
customer_uid_usage: "issue",
custom_data: input.custom_data || null,
user_agent: "Test Automation",
// TIMESTAMPS
status: "ready",
started_at: Date.now() / 1000,
paid_at: 0,
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);
// RETURNS
return FakeIamportResponseProvider_1.FakeIamportResponseProvider.success(payment);
};
/**
* 가상 계좌 편집하기.
*
* @param input 가상 계좌 편집 입력 정보
* @returns 편집된 가상 계좌 결제 정보
*
* @security bearer
* @author Samchon
*/
FakeIamportVbanksController.prototype.update = function (_user, input) {
// GET PAYMENT RECORD
var payment = FakeIamportStorage_1.FakeIamportStorage.payments.get(input.imp_uid);
if (payment.pay_method !== "vbank")
throw new common_1.UnprocessableEntityException("Not a virtual bank payment.");
// MODIFY
if (input.amount)
payment.amount = input.amount;
if (input.vbank_due)
payment.vbank_date = input.vbank_due;
// RETURNS WITH INFORM
FakeIamportPaymentProvider_1.FakeIamportPaymentProvider.webhook(payment).catch(function () { });
return FakeIamportResponseProvider_1.FakeIamportResponseProvider.success(payment);
};
__decorate([
core_1.default.TypedRoute.Post({ 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.vbank_code && "string" === typeof input.vbank_name && "string" === typeof input.vbank_num && "string" === typeof input.vbank_holder && ("number" === typeof input.vbank_date && !Number.isNaN(input.vbank_date)) && ("number" === typeof input.vbank_issued_at && !Number.isNaN(input.vbank_issued_at)) && "vbank" === 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: "IIamportVBankPayment",
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: "IIamportVBankPayment",
value: input.response
}, _errorFactory));
}; var _ao1 = function (input, _path, _exceptionable) {
if (_exceptionable === void 0) { _exceptionable = true; }
return ("string" === typeof input.vbank_code || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, {
method: "core.TypedRoute.Post",
path: _path + ".vbank_code",
expected: "string",
value: input.vbank_code
}, _errorFactory)) && ("string" === typeof input.vbank_name || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, {
method: "core.TypedRoute.Post",
path: _path + ".vbank_name",
expected: "string",
value: input.vbank_name
}, _errorFactory)) && ("string" === typeof input.vbank_num || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, {
method: "core.TypedRoute.Post",
path: _path + ".vbank_num",
expected: "string",
value: input.vbank_num
}, _errorFactory)) && ("string" === typeof input.vbank_holder || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, {
method: "core.TypedRoute.Post",
path: _path + ".vbank_holder",
expected: "string",
value: input.vbank_holder
}, _errorFactory)) && ("number" === typeof input.vbank_date && !Number.isNaN(input.vbank_date) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, {
method: "core.TypedRoute.Post",
path: _path + ".vbank_date",
expected: "number",
value: input.vbank_date
}, _errorFactory)) && ("number" === typeof input.vbank_issued_at && !Number.isNaN(input.vbank_issued_at) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, {
method: "core.TypedRoute.Post",
path: _path + ".vbank_issued_at",
expected: "number",
value: input.vbank_issued_at
}, _errorFactory)) && ("vbank" === input.pay_method || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, {
method: "core.TypedRoute.Post",
path: _path + ".pay_method",
expected: "\"vbank\"",
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 "{\"vbank_code\":".concat(__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.vbank_code), ",\"vbank_name\":").concat(__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.vbank_name), ",\"vbank_num\":").concat(__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.vbank_num), ",\"vbank_holder\":").concat(__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.vbank_holder), ",\"vbank_date\":").concat(input.vbank_date, ",\"vbank_issued_at\":").concat(input.vbank_issued_at, ",\"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<IIamportVBankPayment>",
value: input
}, _errorFactory)) && _ao0(input, _path + "", true) || __nestia_core_transform_assertGuard._assertGuard(true, {
method: "core.TypedRoute.Post",
path: _path + "",
expected: "IIamportResponse<IIamportVBankPayment>",
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 "string" === typeof input.merchant_uid && "number" === typeof input.amount && "string" === typeof input.vbank_code && "number" === typeof input.vbank_due && "string" === typeof input.vbank_holder && (undefined === input.name || "string" === typeof input.name) && (undefined === input.buyer_name || "string" === typeof input.buyer_name) && (undefined === input.buyer_email || "string" === typeof 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.pg || "string" === typeof input.pg) && (undefined === input.notice_url || "string" === typeof input.notice_url) && (undefined === input.custom_data || "string" === typeof input.custom_data) && (undefined === input.pg_api_key || "string" === typeof input.pg_api_key); }; var _vo0 = function (input, _path, _exceptionable) {
if (_exceptionable === void 0) { _exceptionable = true; }
return ["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.vbank_code || _report(_exceptionable, {
path: _path + ".vbank_code",
expected: "string",
value: input.vbank_code
}), "number" === typeof input.vbank_due || _report(_exceptionable, {
path: _path + ".vbank_due",
expected: "number",
value: input.vbank_due
}), "string" === typeof input.vbank_holder || _report(_exceptionable, {
path: _path + ".vbank_holder",
expected: "string",
value: input.vbank_holder
}), undefined === input.name || "string" === typeof input.name || _report(_exceptionable, {
path: _path + ".name",
expected: "(string | undefined)",
value: input.name
}), 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 || _report(_exceptionable, {
path: _path + ".buyer_email",
expected: "(string | undefined)",
value: input.buyer_email
}), undefined === input.buyer_tel || "string" === typeof input.buyer_tel || _report(_exceptionable, {
path: _path + ".buyer_tel",
expected: "(string | undefined)",
value: input.buyer_tel
}), undefined === input.buyer_addr || "string" === typeof input.buyer_addr || _report(_exceptionable, {
path: _path + ".buyer_addr",
expected: "(string | undefined)",
value: input.buyer_addr
}), undefined === input.buyer_postcode || "string" === typeof input.buyer_postcode || _report(_exceptionable, {
path: _path + ".buyer_postcode",
expected: "(string | undefined)",
value: input.buyer_postcode
}), undefined === input.pg || "string" === typeof input.pg || _report(_exceptionable, {
path: _path + ".pg",
expected: "(string | undefined)",
value: input.pg
}), undefined === input.notice_url || "string" === typeof input.notice_url || _report(_exceptionable, {
path: _path + ".notice_url",
expected: "(string | undefined)",
value: input.notice_url
}), undefined === input.custom_data || "string" === typeof input.custom_data || _report(_exceptionable, {
path: _path + ".custom_data",
expected: "(string | undefined)",
value: input.custom_data
}), undefined === input.pg_api_key || "string" === typeof input.pg_api_key || _report(_exceptionable, {
path: _path + ".pg_api_key",
expected: "(string | undefined)",
value: input.pg_api_key
})].every(function (flag) { return flag; });
}; var __is = function (input) { return "object" === typeof input && null !== input && _io0(input); }; var errors; var _report; return function (input) {
if (false === __is(input)) {
errors = [];
_report = __nestia_core_transform_validateReport._validateReport(errors);
(function (input, _path, _exceptionable) {
if (_exceptionable === void 0) { _exceptionable = true; }
return ("object" === typeof input && null !== input || _report(true, {
path: _path + "",
expected: "IIamportVBankPayment.ICreate",
value: input
})) && _vo0(input, _path + "", true) || _report(true, {
path: _path + "",
expected: "IIamportVBankPayment.ICreate",
value: input
});
})(input, "$input", true);
var success = 0 === errors.length;
return success ? {
success: success,
data: input
} : {
success: success,
errors: errors,
data: input
};
}
return {
success: true,
data: input
};
}; })() })),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object]),
__metadata("design:returntype", Object)
], FakeIamportVbanksController.prototype, "create", null);
__decorate([
core_1.default.TypedRoute.Put({ 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.vbank_code && "string" === typeof input.vbank_name && "string" === typeof input.vbank_num && "string" === typeof input.vbank_holder && ("number" === typeof input.vbank_date && !Number.isNaN(input.vbank_date)) && ("number" === typeof input.vbank_issued_at && !Number.isNaN(input.vbank_issued_at)) && "vbank" === 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.Put",
path: _path + ".code",
expected: "number",
value: input.code
}, _errorFactory)) && ("string" === typeof input.message || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, {
method: "core.TypedRoute.Put",
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.Put",
path: _path + ".response",
expected: "IIamportVBankPayment",
value: input.response
}, _errorFactory)) && _ao1(input.response, _path + ".response", true && _exceptionable) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, {
method: "core.TypedRoute.Put",
path: _path + ".response",
expected: "IIamportVBankPayment",
value: input.response
}, _errorFactory));
}; var _ao1 = function (input, _path, _exceptionable) {
if (_exceptionable === void 0) { _exceptionable = true; }
return ("string" === typeof input.vbank_code || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, {
method: "core.TypedRoute.Put",
path: _path + ".vbank_code",
expected: "string",
value: input.vbank_code
}, _errorFactory)) && ("string" === typeof input.vbank_name || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, {
method: "core.TypedRoute.Put",
path: _path + ".vbank_name",
expected: "string",
value: input.vbank_name
}, _errorFactory)) && ("string" === typeof input.vbank_num || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, {
method: "core.TypedRoute.Put",
path: _path + ".vbank_num",
expected: "string",
value: input.vbank_num
}, _errorFactory)) && ("string" === typeof input.vbank_holder || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, {
method: "core.TypedRoute.Put",
path: _path + ".vbank_holder",
expected: "string",
value: input.vbank_holder
}, _errorFactory)) && ("number" === typeof input.vbank_date && !Number.isNaN(input.vbank_date) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, {
method: "core.TypedRoute.Put",