@chevre/domain 23.0.0-alpha.29 → 23.0.0-alpha.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
1
  // tslint:disable:no-console no-magic-numbers
2
2
  import { webcrypto } from 'crypto';
3
+ // import * as moment from 'moment';
3
4
  import * as mongoose from 'mongoose';
4
5
 
5
6
  import { chevre } from '../../../../lib/index';
@@ -43,6 +44,10 @@ async function main() {
43
44
  {
44
45
  // _id: { $eq: '68f5d32176b5f6b689ff24a6' },
45
46
  // 'project.id': { $eq: project.id },
47
+ // startDate: {
48
+ // $lte: moment('2025-05-01T10:00:00Z')
49
+ // .toDate()
50
+ // },
46
51
  'additionalProperty.name': { $exists: true, $eq: PROPERTY_NAME }
47
52
  },
48
53
  {
@@ -1,7 +1,7 @@
1
1
  import { AnyExpression, Connection, FilterQuery, Types } from 'mongoose';
2
2
  import * as factory from '../factory';
3
3
  type IUnset = {
4
- [key in keyof Pick<factory.categoryCode.ICategoryCode, 'additionalProperty' | 'color' | 'image' | 'paymentMethod'>]?: 1;
4
+ [key in keyof Pick<factory.categoryCode.ICategoryCode, 'additionalProperty' | 'color' | 'image'>]?: 1;
5
5
  };
6
6
  export type CategorySetIdentifierExceptMovieTicketType = factory.categoryCode.CategorySetIdentifier;
7
7
  export type ICategoryCodeExceptMovieTicketType = Pick<factory.categoryCode.ICategoryCode, 'additionalProperty' | 'codeValue' | 'color' | 'id' | 'image' | 'name' | 'project' | 'typeOf' | 'inCodeSet'>;
@@ -26,7 +26,7 @@ export declare class CategoryCodeRepo {
26
26
  /**
27
27
  * 区分検索
28
28
  */
29
- projectCategoryCodeFields(params: Omit<factory.categoryCode.ISearchConditions, 'inCodeSet' | 'paymentMethod'> & {
29
+ projectCategoryCodeFields(params: Omit<factory.categoryCode.ISearchConditions, 'inCodeSet'> & {
30
30
  inCodeSet?: {
31
31
  identifier?: {
32
32
  $eq?: CategorySetIdentifierExceptMovieTicketType;
@@ -26,7 +26,7 @@ const categoryCode_1 = require("./mongoose/schemas/categoryCode");
26
26
  const factory = require("../factory");
27
27
  const settings_1 = require("../settings");
28
28
  const AVAILABLE_PROJECT_FIELDS = [
29
- 'additionalProperty', 'codeValue', 'color', 'image', 'inCodeSet', 'name', 'paymentMethod', 'project', 'typeOf'
29
+ 'additionalProperty', 'codeValue', 'color', 'image', 'inCodeSet', 'name', 'project', 'typeOf'
30
30
  ];
31
31
  /**
32
32
  * 区分(決済カード区分を除く)リポジトリ
@@ -174,8 +174,8 @@ class CategoryCodeRepo {
174
174
  image: '$image',
175
175
  codeValue: '$codeValue',
176
176
  inCodeSet: '$inCodeSet',
177
- name: '$name',
178
- paymentMethod: '$paymentMethod'
177
+ name: '$name'
178
+ // paymentMethod: '$paymentMethod' // discontinue(2025-11-08~)
179
179
  };
180
180
  if (inclusion.length > 0) {
181
181
  projectStage = { _id: 0 };
@@ -9,20 +9,14 @@ const modelName = 'CategoryCode';
9
9
  exports.modelName = modelName;
10
10
  const schemaDefinition = {
11
11
  project: { type: mongoose_1.SchemaTypes.Mixed, required: true },
12
- typeOf: {
13
- type: String,
14
- required: true
15
- },
12
+ typeOf: { type: String, required: true },
16
13
  additionalProperty: [mongoose_1.SchemaTypes.Mixed],
17
14
  color: String,
18
15
  image: String,
19
- codeValue: {
20
- type: String,
21
- required: true
22
- },
16
+ codeValue: { type: String, required: true },
23
17
  inCodeSet: { type: mongoose_1.SchemaTypes.Mixed, required: true },
24
- name: mongoose_1.SchemaTypes.Mixed,
25
- paymentMethod: mongoose_1.SchemaTypes.Mixed
18
+ name: mongoose_1.SchemaTypes.Mixed
19
+ // paymentMethod: SchemaTypes.Mixed // discontinue(2025-11-08~)
26
20
  };
27
21
  const schemaOptions = {
28
22
  autoIndex: settings_1.MONGO_AUTO_INDEX,
@@ -75,15 +69,16 @@ const indexes = [
75
69
  }
76
70
  }
77
71
  ],
78
- [
79
- { 'paymentMethod.typeOf': 1, codeValue: 1 },
80
- {
81
- name: 'searchByPaymentMethodTypeOf',
82
- partialFilterExpression: {
83
- 'paymentMethod.typeOf': { $exists: true }
84
- }
85
- }
86
- ],
72
+ // discontinue(2025-11-08~)
73
+ // [
74
+ // { 'paymentMethod.typeOf': 1, codeValue: 1 },
75
+ // {
76
+ // name: 'searchByPaymentMethodTypeOf',
77
+ // partialFilterExpression: {
78
+ // 'paymentMethod.typeOf': { $exists: true }
79
+ // }
80
+ // }
81
+ // ],
87
82
  [
88
83
  { 'project.id': 1, codeValue: 1 },
89
84
  {
@@ -1,11 +1,10 @@
1
1
  import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
2
2
  import * as factory from '../../../factory';
3
- type IMovieTicketType = Pick<factory.movieTicketType.IMovieTicketType, 'codeValue' | 'color' | 'id' | 'image' | 'name' | 'project' | 'typeOf' | 'inCodeSet' | 'paymentMethod'>;
4
- type IDocType = factory.categoryCode.ICategoryCode;
3
+ type IDocType = factory.movieTicketType.IMovieTicketType;
5
4
  type IModel = Model<IDocType>;
6
5
  type ISchemaDefinition = SchemaDefinition<IDocType>;
7
6
  type ISchema = Schema<IDocType, IModel, {}, {}, {}, {}, ISchemaDefinition, IDocType>;
8
7
  declare const modelName = "MovieTicketType";
9
8
  declare const indexes: [d: IndexDefinition, o: IndexOptions][];
10
9
  declare function createSchema(): ISchema;
11
- export { createSchema, IModel, IMovieTicketType, indexes, modelName };
10
+ export { createSchema, IModel, IDocType, indexes, modelName };
@@ -1,17 +1,17 @@
1
1
  import { AnyExpression, Connection, FilterQuery } from 'mongoose';
2
- import { IMovieTicketType } from './mongoose/schemas/movieTicketTypes';
2
+ import { IDocType } from './mongoose/schemas/movieTicketTypes';
3
3
  import * as factory from '../factory';
4
4
  type IUnset = {
5
- [key in keyof Pick<factory.movieTicketType.IMovieTicketType, 'color' | 'image'>]?: 1;
5
+ [key in keyof Pick<IDocType, 'color' | 'image'>]?: 1;
6
6
  };
7
- type IKeyOfProjection = keyof IMovieTicketType;
7
+ type IKeyOfProjection = keyof IDocType;
8
8
  /**
9
9
  * 決済カード区分リポジトリ
10
10
  */
11
11
  export declare class MovieTicketTypeRepo {
12
12
  private readonly categoryCodeModel;
13
13
  constructor(connection: Connection);
14
- static CREATE_MONGO_CONDITIONS(params: factory.movieTicketType.ISearchConditions): FilterQuery<IMovieTicketType>[];
14
+ static CREATE_MONGO_CONDITIONS(params: factory.movieTicketType.ISearchConditions): FilterQuery<IDocType>[];
15
15
  static CREATE_AGGREGATE_PROJECTION(inclusion: IKeyOfProjection[]): {
16
16
  [field: string]: AnyExpression;
17
17
  };
@@ -28,12 +28,12 @@ export declare class MovieTicketTypeRepo {
28
28
  /**
29
29
  * 空の場合無効
30
30
  */
31
- inclusion: IKeyOfProjection[]): Promise<(IMovieTicketType & {
31
+ inclusion: IKeyOfProjection[]): Promise<(IDocType & {
32
32
  id: string;
33
33
  })[]>;
34
34
  saveMovieTicketType(params: {
35
35
  id?: string;
36
- attributes: IMovieTicketType & {
36
+ attributes: IDocType & {
37
37
  $unset?: IUnset;
38
38
  };
39
39
  }): Promise<{
@@ -53,7 +53,5 @@ export declare class MovieTicketTypeRepo {
53
53
  id: string;
54
54
  };
55
55
  }): Promise<void>;
56
- migrateCollections(connection: Connection): Promise<void>;
57
- deleteOldMovieTicketTypes(connection: Connection): Promise<void>;
58
56
  }
59
57
  export {};
@@ -23,7 +23,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.MovieTicketTypeRepo = void 0;
24
24
  // tslint:disable-next-line:no-implicit-dependencies
25
25
  const mongoose_1 = require("mongoose");
26
- const categoryCode_1 = require("./mongoose/schemas/categoryCode");
26
+ // import { createSchema, modelName } from './mongoose/schemas/categoryCode';
27
27
  const movieTicketTypes_1 = require("./mongoose/schemas/movieTicketTypes");
28
28
  const factory = require("../factory");
29
29
  const settings_1 = require("../settings");
@@ -139,15 +139,6 @@ class MovieTicketTypeRepo {
139
139
  }
140
140
  });
141
141
  }
142
- // const additionalPropertyElemMatch = params.additionalProperty?.$elemMatch;
143
- // if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
144
- // andConditions.push({
145
- // additionalProperty: {
146
- // $exists: true,
147
- // $elemMatch: additionalPropertyElemMatch
148
- // }
149
- // });
150
- // }
151
142
  return andConditions;
152
143
  }
153
144
  static CREATE_AGGREGATE_PROJECTION(inclusion) {
@@ -156,7 +147,6 @@ class MovieTicketTypeRepo {
156
147
  id: { $toString: '$_id' },
157
148
  project: '$project',
158
149
  typeOf: '$typeOf',
159
- // additionalProperty: '$additionalProperty',
160
150
  color: '$color',
161
151
  image: '$image',
162
152
  codeValue: '$codeValue',
@@ -259,47 +249,5 @@ class MovieTicketTypeRepo {
259
249
  .exec();
260
250
  });
261
251
  }
262
- // tslint:disable-next-line:prefer-function-over-method
263
- migrateCollections(connection) {
264
- return __awaiter(this, void 0, void 0, function* () {
265
- const oldCategoryCodeModel = connection.model(categoryCode_1.modelName, (0, categoryCode_1.createSchema)());
266
- const movieTicketTypeModel = connection.model(movieTicketTypes_1.modelName, (0, movieTicketTypes_1.createSchema)());
267
- const cursor = oldCategoryCodeModel.find({
268
- 'inCodeSet.identifier': { $eq: factory.movieTicketType.CategorySetIdentifier.MovieTicketType }
269
- })
270
- .sort({ codeValue: factory.sortType.Ascending })
271
- .cursor();
272
- let i = 0;
273
- yield cursor.eachAsync((doc) => __awaiter(this, void 0, void 0, function* () {
274
- i += 1;
275
- const movieTicketType = doc.toObject();
276
- const { additionalProperty } = movieTicketType, docWithoutAdditinalProperty = __rest(movieTicketType, ["additionalProperty"]);
277
- // tslint:disable-next-line:no-console
278
- console.log('upserting...', docWithoutAdditinalProperty, i);
279
- const result = yield movieTicketTypeModel.findOneAndReplace({ _id: { $eq: doc._id } }, docWithoutAdditinalProperty, {
280
- upsert: true,
281
- projection: { _id: 1 }
282
- })
283
- .exec();
284
- // await additionalPropertyRepo.save({ attributes: additionalProperty });
285
- // tslint:disable-next-line:no-console
286
- console.log('upserted', result, movieTicketType.id, movieTicketType.project.id, movieTicketType.codeValue, i);
287
- }));
288
- // tslint:disable-next-line:no-console
289
- console.log(i, 'docs checked');
290
- });
291
- }
292
- // tslint:disable-next-line:prefer-function-over-method
293
- deleteOldMovieTicketTypes(connection) {
294
- return __awaiter(this, void 0, void 0, function* () {
295
- const oldCategoryCodeModel = connection.model(categoryCode_1.modelName, (0, categoryCode_1.createSchema)());
296
- const result = yield oldCategoryCodeModel.deleteMany({
297
- 'inCodeSet.identifier': { $eq: factory.movieTicketType.CategorySetIdentifier.MovieTicketType }
298
- })
299
- .exec();
300
- // tslint:disable-next-line:no-console
301
- console.log(result);
302
- });
303
- }
304
252
  }
305
253
  exports.MovieTicketTypeRepo = MovieTicketTypeRepo;
@@ -0,0 +1,39 @@
1
+ import * as factory from '../../../../factory';
2
+ import type { ActionRepo } from '../../../../repo/action';
3
+ import type { AuthorizationRepo } from '../../../../repo/authorization';
4
+ import type { TicketRepo } from '../../../../repo/ticket';
5
+ import type { ITransactionInProgress, TransactionRepo } from '../../../../repo/transaction';
6
+ import type { TransactionNumberRepo } from '../../../../repo/transactionNumber';
7
+ import * as PayTransactionService from '../../../assetTransaction/pay';
8
+ import { IPermitOrInvoice } from '../verifyTicketTokenAsNeeded';
9
+ interface IFixTransactionNumberRepos {
10
+ action: ActionRepo;
11
+ authorization: AuthorizationRepo;
12
+ ticket: TicketRepo;
13
+ transaction: TransactionRepo;
14
+ transactionNumber: TransactionNumberRepo;
15
+ }
16
+ type IFixTransactionNumberOperation<T> = (repos: IFixTransactionNumberRepos) => Promise<T>;
17
+ type IObjectWithoutDetail = factory.action.authorize.paymentMethod.any.IObjectWithoutDetail & {
18
+ ticketToken?: string;
19
+ };
20
+ /**
21
+ * 決済承認時の取引番号を決定する
22
+ */
23
+ declare function fixTransactionNumber(params: {
24
+ object: IObjectWithoutDetail;
25
+ transaction: Pick<ITransactionInProgress<factory.transactionType.PlaceOrder>, 'agent' | 'expires' | 'id' | 'typeOf' | 'project' | 'seller'>;
26
+ paymentServiceType: factory.service.paymentService.PaymentServiceType;
27
+ }): IFixTransactionNumberOperation<{
28
+ transactionNumber: string;
29
+ pendingPaymentAgencyTransaction?: PayTransactionService.IPaymentAgencyTransaction;
30
+ creditCard?: factory.action.authorize.paymentMethod.any.ICreditCard;
31
+ permitOrInvoice?: IPermitOrInvoice;
32
+ id?: never;
33
+ } | {
34
+ /**
35
+ * 完了済の決済承認アクションID
36
+ */
37
+ id: string;
38
+ }>;
39
+ export { fixTransactionNumber };
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.fixTransactionNumber = fixTransactionNumber;
13
+ const factory = require("../../../../factory");
14
+ const verifyTicketTokenAsNeeded_1 = require("../verifyTicketTokenAsNeeded");
15
+ const handlePrePublishedPaymentMethodIdOnAuthorizing_1 = require("./handlePrePublishedPaymentMethodIdOnAuthorizing");
16
+ /**
17
+ * 決済承認時の取引番号を決定する
18
+ */
19
+ function fixTransactionNumber(params) {
20
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
21
+ const { paymentServiceType, transaction, object } = params;
22
+ // 取引番号生成
23
+ let transactionNumber;
24
+ let pendingPaymentAgencyTransaction;
25
+ let creditCard = object.creditCard;
26
+ // ticketTokenを解釈(2024-08-13~)
27
+ const { permitOrInvoice } = yield (0, verifyTicketTokenAsNeeded_1.verifyTicketTokenAsNeeded)({
28
+ project: { id: transaction.project.id },
29
+ object: object,
30
+ paymentServiceType,
31
+ purpose: { id: transaction.id }
32
+ })(repos);
33
+ /**
34
+ * ticketTokenによって指定された決済方法ID
35
+ */
36
+ let paymentMethodIdByTicketToken;
37
+ if ((permitOrInvoice === null || permitOrInvoice === void 0 ? void 0 : permitOrInvoice.typeOf) === factory.permit.PermitType.Permit) {
38
+ paymentMethodIdByTicketToken = permitOrInvoice === null || permitOrInvoice === void 0 ? void 0 : permitOrInvoice.identifier;
39
+ if (typeof paymentMethodIdByTicketToken === 'string') {
40
+ transactionNumber = paymentMethodIdByTicketToken; // メンバーシップ指定の場合、取引番号に適用(2024-08-13~)
41
+ }
42
+ }
43
+ else if ((permitOrInvoice === null || permitOrInvoice === void 0 ? void 0 : permitOrInvoice.typeOf) === 'Invoice') {
44
+ // support paymentServiceType.MovieTicket(2024-11-23~)
45
+ if (typeof (permitOrInvoice === null || permitOrInvoice === void 0 ? void 0 : permitOrInvoice.paymentMethodId) === 'string') {
46
+ paymentMethodIdByTicketToken = permitOrInvoice === null || permitOrInvoice === void 0 ? void 0 : permitOrInvoice.paymentMethodId;
47
+ if (typeof paymentMethodIdByTicketToken === 'string') {
48
+ transactionNumber = paymentMethodIdByTicketToken;
49
+ }
50
+ }
51
+ }
52
+ // リクエストでpaymentMethodIdを指定された場合、取引に保管されたpaymentMethodIdに一致すればそちらを適用(外部サイト決済対応)
53
+ if (typeof object.paymentMethodId === 'string' && object.paymentMethodId.length > 0) {
54
+ if (typeof paymentMethodIdByTicketToken === 'string') {
55
+ // 指定されたpaymentMethodIdとチケットから読み取った決済方法IDは一致しなければいけない
56
+ if (paymentMethodIdByTicketToken !== object.paymentMethodId) {
57
+ throw new factory.errors.Argument('ticketToken', 'not matched with paymentMethodId');
58
+ }
59
+ }
60
+ const { authorizeParams, existingCompletedAuthorizeAction } = yield (0, handlePrePublishedPaymentMethodIdOnAuthorizing_1.handlePrePublishedPaymentMethodIdOnAuthorizing)({
61
+ object: object,
62
+ prePublishedPaymentMethodId: object.paymentMethodId,
63
+ transaction
64
+ })(repos);
65
+ if (existingCompletedAuthorizeAction !== undefined) {
66
+ return { id: existingCompletedAuthorizeAction.id };
67
+ }
68
+ else if (authorizeParams !== undefined) {
69
+ // creditCardを決済URL発行時の情報で上書き(2024-01-08~)
70
+ // creditCard = authorizeParams.paymentMethodByTransaction.paymentMethod?.creditCard;
71
+ creditCard = authorizeParams.creditCard;
72
+ transactionNumber = object.paymentMethodId;
73
+ pendingPaymentAgencyTransaction = authorizeParams.pendingPaymentAgencyTransaction;
74
+ }
75
+ else {
76
+ throw new factory.errors.NotImplemented('pendingPaymentAgencyTransaction required on paymentMethodId specified');
77
+ }
78
+ }
79
+ // 取引番号発行済でなければ発行
80
+ if (typeof transactionNumber !== 'string') {
81
+ const publishTransactionNumberResult = yield repos.transactionNumber.publishByTimestamp({ startDate: new Date() });
82
+ transactionNumber = publishTransactionNumberResult.transactionNumber;
83
+ }
84
+ return Object.assign(Object.assign(Object.assign({ transactionNumber }, (pendingPaymentAgencyTransaction !== undefined) ? { pendingPaymentAgencyTransaction } : undefined), (creditCard !== undefined) ? { creditCard } : undefined), (permitOrInvoice !== undefined) ? { permitOrInvoice } : undefined);
85
+ });
86
+ }
@@ -1,7 +1,7 @@
1
- import * as factory from '../../../factory';
2
- import type { ActionRepo } from '../../../repo/action';
3
- import type { ITransactionInProgress, TransactionRepo } from '../../../repo/transaction';
4
- import * as PayTransactionService from '../../assetTransaction/pay';
1
+ import * as factory from '../../../../factory';
2
+ import type { ActionRepo } from '../../../../repo/action';
3
+ import type { ITransactionInProgress, TransactionRepo } from '../../../../repo/transaction';
4
+ import * as PayTransactionService from '../../../assetTransaction/pay';
5
5
  type IObjectWithoutDetail = factory.action.authorize.paymentMethod.any.IObjectWithoutDetail;
6
6
  declare function handlePrePublishedPaymentMethodIdOnAuthorizing(params: {
7
7
  object: Pick<IObjectWithoutDetail, 'amount' | 'issuedThrough' | 'paymentMethod'>;
@@ -11,7 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.handlePrePublishedPaymentMethodIdOnAuthorizing = handlePrePublishedPaymentMethodIdOnAuthorizing;
13
13
  const createDebug = require("debug");
14
- const factory = require("../../../factory");
14
+ const factory = require("../../../../factory");
15
15
  const debug = createDebug('chevre-domain:service:payment');
16
16
  function recipe2paymentAgencyTransaction(actionRecipe) {
17
17
  var _a;
@@ -0,0 +1,25 @@
1
+ import * as factory from '../../../../factory';
2
+ import type { AuthorizationRepo } from '../../../../repo/authorization';
3
+ import type { TicketRepo } from '../../../../repo/ticket';
4
+ import type { ITransactionInProgress } from '../../../../repo/transaction';
5
+ import type { TransactionNumberRepo } from '../../../../repo/transactionNumber';
6
+ interface IFixTransactionNumberRepos {
7
+ authorization: AuthorizationRepo;
8
+ ticket: TicketRepo;
9
+ transactionNumber: TransactionNumberRepo;
10
+ }
11
+ type IFixTransactionNumberOperation<T> = (repos: IFixTransactionNumberRepos) => Promise<T>;
12
+ type IObjectWithoutDetail = factory.action.authorize.paymentMethod.any.IObjectWithoutDetail & {
13
+ ticketToken?: string;
14
+ };
15
+ /**
16
+ * 外部決済ロケーション発行時の取引番号を決定する
17
+ */
18
+ declare function fixTransactionNumberOnPublishPaymentUrl(params: {
19
+ object: IObjectWithoutDetail;
20
+ transaction: Pick<ITransactionInProgress<factory.transactionType.PlaceOrder>, 'id' | 'project'>;
21
+ paymentServiceType: factory.service.paymentService.PaymentServiceType;
22
+ }): IFixTransactionNumberOperation<{
23
+ transactionNumber: string;
24
+ }>;
25
+ export { fixTransactionNumberOnPublishPaymentUrl };
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.fixTransactionNumberOnPublishPaymentUrl = fixTransactionNumberOnPublishPaymentUrl;
13
+ const factory = require("../../../../factory");
14
+ const verifyTicketTokenAsNeeded_1 = require("../verifyTicketTokenAsNeeded");
15
+ /**
16
+ * 外部決済ロケーション発行時の取引番号を決定する
17
+ */
18
+ function fixTransactionNumberOnPublishPaymentUrl(params) {
19
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
20
+ const { paymentServiceType, transaction, object } = params;
21
+ // 取引番号生成
22
+ let transactionNumber;
23
+ // support ticketToken(2024-08-21~)
24
+ const { permitOrInvoice } = yield (0, verifyTicketTokenAsNeeded_1.verifyTicketTokenAsNeeded)({
25
+ project: { id: transaction.project.id },
26
+ object,
27
+ paymentServiceType,
28
+ purpose: { id: transaction.id }
29
+ })(repos);
30
+ if ((permitOrInvoice === null || permitOrInvoice === void 0 ? void 0 : permitOrInvoice.typeOf) === factory.permit.PermitType.Permit) {
31
+ const paymentMethodIdByPermit = permitOrInvoice === null || permitOrInvoice === void 0 ? void 0 : permitOrInvoice.identifier;
32
+ if (typeof paymentMethodIdByPermit === 'string') {
33
+ transactionNumber = paymentMethodIdByPermit;
34
+ }
35
+ }
36
+ else if ((permitOrInvoice === null || permitOrInvoice === void 0 ? void 0 : permitOrInvoice.typeOf) === 'Invoice') {
37
+ // support Invoice ticket(2025-11-09~)
38
+ if (typeof (permitOrInvoice === null || permitOrInvoice === void 0 ? void 0 : permitOrInvoice.paymentMethodId) === 'string') {
39
+ transactionNumber = permitOrInvoice.paymentMethodId;
40
+ }
41
+ }
42
+ if (typeof transactionNumber !== 'string') {
43
+ const publishTransactionNumberResult = yield repos.transactionNumber.publishByTimestamp({ startDate: new Date() });
44
+ transactionNumber = publishTransactionNumberResult.transactionNumber;
45
+ }
46
+ return {
47
+ transactionNumber
48
+ // ...(permitOrInvoice !== undefined) ? { permitOrInvoice } : undefined
49
+ };
50
+ });
51
+ }
@@ -8,11 +8,11 @@ declare function verifyTicketTokenAsNeeded(params: {
8
8
  };
9
9
  object: Pick<factory.action.authorize.paymentMethod.any.IObjectWithoutDetail, 'issuedThrough' | 'ticketToken'>;
10
10
  paymentServiceType: factory.service.paymentService.PaymentServiceType;
11
- purpose: factory.action.authorize.paymentMethod.any.IPurpose;
11
+ purpose: Pick<factory.action.authorize.paymentMethod.any.IPurpose, 'id'>;
12
12
  }): (repos: {
13
13
  authorization: AuthorizationRepo;
14
14
  ticket: TicketRepo;
15
15
  }) => Promise<{
16
16
  permitOrInvoice?: IPermitOrInvoice;
17
17
  }>;
18
- export { verifyTicketTokenAsNeeded };
18
+ export { IPermitOrInvoice, verifyTicketTokenAsNeeded };
@@ -23,14 +23,14 @@ const factory = require("../../factory");
23
23
  // import type { TransactionProcessRepo } from '../../repo/transactionProcess';
24
24
  const PayTransactionService = require("../assetTransaction/pay");
25
25
  const publishOrderNumberIfNotExist_1 = require("../transaction/placeOrder/publishOrderNumberIfNotExist");
26
+ const fixTransactionNumber_1 = require("./any/authorize/fixTransactionNumber");
27
+ const fixTransactionNumberOnPublishPaymentUrl_1 = require("./any/publishPaymentUrl/fixTransactionNumberOnPublishPaymentUrl");
26
28
  const factory_1 = require("./any/factory");
27
29
  const fixOrderAsNeeded_1 = require("./any/fixOrderAsNeeded");
28
- const handlePrePublishedPaymentMethodIdOnAuthorizing_1 = require("./any/handlePrePublishedPaymentMethodIdOnAuthorizing");
29
30
  const onPaymentStatusChanged_1 = require("./any/onPaymentStatusChanged");
30
31
  Object.defineProperty(exports, "onPaymentStatusChanged", { enumerable: true, get: function () { return onPaymentStatusChanged_1.onPaymentStatusChanged; } });
31
32
  const person2username_1 = require("./any/person2username");
32
33
  Object.defineProperty(exports, "person2username", { enumerable: true, get: function () { return person2username_1.person2username; } });
33
- const verifyTicketTokenAsNeeded_1 = require("./any/verifyTicketTokenAsNeeded");
34
34
  /**
35
35
  * 決済承認中止
36
36
  * タスクから決済承認を取り消す
@@ -319,7 +319,9 @@ function processVoidPayTransaction(params) {
319
319
  /**
320
320
  * 外部決済ロケーションを発行する
321
321
  */
322
+ // tslint:disable-next-line:max-func-body-length
322
323
  function publishPaymentUrl(params) {
324
+ // tslint:disable-next-line:max-func-body-length
323
325
  return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
324
326
  var _a;
325
327
  const { paymentServiceType, purpose, project } = params;
@@ -328,6 +330,9 @@ function publishPaymentUrl(params) {
328
330
  }
329
331
  try {
330
332
  const transaction = yield repos.transaction.projectFieldsInProgressById({ typeOf: purpose.typeOf, id: purpose.id }, ['expires', 'seller', 'project']);
333
+ if (project.id !== transaction.project.id) {
334
+ throw new factory.errors.NotFound(factory.transactionType.PlaceOrder);
335
+ }
331
336
  // publishOrderNumber(2025-03-11~)
332
337
  yield (0, publishOrderNumberIfNotExist_1.publishOrderNumberIfNotExist)({
333
338
  project: { id: transaction.project.id },
@@ -335,19 +340,25 @@ function publishPaymentUrl(params) {
335
340
  object: { orderDate: new Date() }
336
341
  })(repos);
337
342
  // 取引番号生成
338
- let transactionNumber;
339
- // support ticketToken(2024-08-21~)
340
- const { permitOrInvoice } = yield (0, verifyTicketTokenAsNeeded_1.verifyTicketTokenAsNeeded)({ project, object: params.object, paymentServiceType, purpose })(repos);
341
- if ((permitOrInvoice === null || permitOrInvoice === void 0 ? void 0 : permitOrInvoice.typeOf) === factory.permit.PermitType.Permit) {
342
- const paymentMethodIdByPermit = permitOrInvoice === null || permitOrInvoice === void 0 ? void 0 : permitOrInvoice.identifier;
343
- if (typeof paymentMethodIdByPermit === 'string') {
344
- transactionNumber = paymentMethodIdByPermit;
345
- }
346
- }
347
- if (typeof transactionNumber !== 'string') {
348
- const publishTransactionNumberResult = yield repos.transactionNumber.publishByTimestamp({ startDate: new Date() });
349
- transactionNumber = publishTransactionNumberResult.transactionNumber;
350
- }
343
+ const { transactionNumber } = yield (0, fixTransactionNumberOnPublishPaymentUrl_1.fixTransactionNumberOnPublishPaymentUrl)({
344
+ object: params.object,
345
+ transaction,
346
+ paymentServiceType
347
+ })(repos);
348
+ // let transactionNumber: string | undefined;
349
+ // // support ticketToken(2024-08-21~)
350
+ // const { permitOrInvoice } =
351
+ // await verifyTicketTokenAsNeeded({ project, object: params.object, paymentServiceType, purpose })(repos);
352
+ // if (permitOrInvoice?.typeOf === factory.permit.PermitType.Permit) {
353
+ // const paymentMethodIdByPermit = permitOrInvoice?.identifier;
354
+ // if (typeof paymentMethodIdByPermit === 'string') {
355
+ // transactionNumber = paymentMethodIdByPermit;
356
+ // }
357
+ // }
358
+ // if (typeof transactionNumber !== 'string') {
359
+ // const publishTransactionNumberResult = await repos.transactionNumber.publishByTimestamp({ startDate: new Date() });
360
+ // transactionNumber = publishTransactionNumberResult.transactionNumber;
361
+ // }
351
362
  let result;
352
363
  // URL発行
353
364
  const authorizeObject = Object.assign(Object.assign({}, params.object), { accountId: '', paymentMethodId: transactionNumber, typeOf: factory.action.authorize.paymentMethod.any.ResultType.Payment });
@@ -411,67 +422,77 @@ function authorize(params) {
411
422
  throw new factory.errors.NotImplemented(`purpose.typeOf '${purpose.typeOf} not implemented'`);
412
423
  }
413
424
  const transaction = yield repos.transaction.projectFieldsInProgressById({ typeOf: purpose.typeOf, id: purpose.id }, ['agent', 'expires', 'typeOf', 'project', 'seller']);
425
+ if (project.id !== transaction.project.id) {
426
+ throw new factory.errors.NotFound(factory.transactionType.PlaceOrder);
427
+ }
414
428
  const { confirmationNumber, orderNumber } = yield (0, fixOrderAsNeeded_1.fixOrderAsNeeded)({
415
429
  project: { id: transaction.project.id },
416
430
  purpose
417
431
  // paymentServiceType
418
432
  })(repos);
419
433
  // 取引番号生成
420
- let transactionNumber;
421
- let pendingPaymentAgencyTransaction;
422
- let creditCard = params.object.creditCard;
423
- // ticketTokenを解釈(2024-08-13~)
424
- const { permitOrInvoice } = yield (0, verifyTicketTokenAsNeeded_1.verifyTicketTokenAsNeeded)({ project, object: params.object, paymentServiceType, purpose })(repos);
425
- /**
426
- * ticketTokenによって指定された決済方法ID
427
- */
428
- let paymentMethodIdByTicketToken;
429
- if ((permitOrInvoice === null || permitOrInvoice === void 0 ? void 0 : permitOrInvoice.typeOf) === factory.permit.PermitType.Permit) {
430
- paymentMethodIdByTicketToken = permitOrInvoice === null || permitOrInvoice === void 0 ? void 0 : permitOrInvoice.identifier;
431
- if (typeof paymentMethodIdByTicketToken === 'string') {
432
- transactionNumber = paymentMethodIdByTicketToken; // メンバーシップ指定の場合、取引番号に適用(2024-08-13~)
433
- }
434
- }
435
- else if ((permitOrInvoice === null || permitOrInvoice === void 0 ? void 0 : permitOrInvoice.typeOf) === 'Invoice') {
436
- // support paymentServiceType.MovieTicket(2024-11-23~)
437
- if (typeof (permitOrInvoice === null || permitOrInvoice === void 0 ? void 0 : permitOrInvoice.paymentMethodId) === 'string') {
438
- paymentMethodIdByTicketToken = permitOrInvoice === null || permitOrInvoice === void 0 ? void 0 : permitOrInvoice.paymentMethodId;
439
- if (typeof paymentMethodIdByTicketToken === 'string') {
440
- transactionNumber = paymentMethodIdByTicketToken;
441
- }
442
- }
443
- }
444
- // リクエストでpaymentMethodIdを指定された場合、取引に保管されたpaymentMethodIdに一致すればそちらを適用(外部サイト決済対応)
445
- if (typeof params.object.paymentMethodId === 'string' && params.object.paymentMethodId.length > 0) {
446
- if (typeof paymentMethodIdByTicketToken === 'string') {
447
- if (paymentMethodIdByTicketToken !== params.object.paymentMethodId) {
448
- throw new factory.errors.Argument('ticketToken', 'not matched with paymentMethodId');
449
- }
450
- }
451
- const { authorizeParams, existingCompletedAuthorizeAction } = yield (0, handlePrePublishedPaymentMethodIdOnAuthorizing_1.handlePrePublishedPaymentMethodIdOnAuthorizing)({
452
- object: params.object,
453
- prePublishedPaymentMethodId: params.object.paymentMethodId,
454
- transaction
455
- })(repos);
456
- if (existingCompletedAuthorizeAction !== undefined) {
457
- return { id: existingCompletedAuthorizeAction.id };
458
- }
459
- else if (authorizeParams !== undefined) {
460
- // creditCardを決済URL発行時の情報で上書き(2024-01-08~)
461
- // creditCard = authorizeParams.paymentMethodByTransaction.paymentMethod?.creditCard;
462
- creditCard = authorizeParams.creditCard;
463
- transactionNumber = params.object.paymentMethodId;
464
- pendingPaymentAgencyTransaction = authorizeParams.pendingPaymentAgencyTransaction;
465
- }
466
- else {
467
- throw new factory.errors.NotImplemented('pendingPaymentAgencyTransaction requied on paymentMethodId specified');
468
- }
469
- }
470
- // 取引番号発行済でなければ発行
471
- if (typeof transactionNumber !== 'string') {
472
- const publishTransactionNumberResult = yield repos.transactionNumber.publishByTimestamp({ startDate: new Date() });
473
- transactionNumber = publishTransactionNumberResult.transactionNumber;
474
- }
434
+ const fixTransactionNumberResult = yield (0, fixTransactionNumber_1.fixTransactionNumber)({
435
+ object: params.object,
436
+ transaction,
437
+ paymentServiceType
438
+ })(repos);
439
+ if (typeof fixTransactionNumberResult.id === 'string') {
440
+ return { id: fixTransactionNumberResult.id };
441
+ }
442
+ const { transactionNumber, pendingPaymentAgencyTransaction, creditCard, permitOrInvoice } = fixTransactionNumberResult;
443
+ // let transactionNumber: string | undefined;
444
+ // let pendingPaymentAgencyTransaction: PayTransactionService.IPaymentAgencyTransaction | undefined;
445
+ // let creditCard: factory.action.authorize.paymentMethod.any.ICreditCard | undefined = params.object.creditCard;
446
+ // // ticketTokenを解釈(2024-08-13~)
447
+ // const { permitOrInvoice } =
448
+ // await verifyTicketTokenAsNeeded({ project, object: params.object, paymentServiceType, purpose })(repos);
449
+ // /**
450
+ // * ticketTokenによって指定された決済方法ID
451
+ // */
452
+ // let paymentMethodIdByTicketToken: string | undefined;
453
+ // if (permitOrInvoice?.typeOf === factory.permit.PermitType.Permit) {
454
+ // paymentMethodIdByTicketToken = permitOrInvoice?.identifier;
455
+ // if (typeof paymentMethodIdByTicketToken === 'string') {
456
+ // transactionNumber = paymentMethodIdByTicketToken; // メンバーシップ指定の場合、取引番号に適用(2024-08-13~)
457
+ // }
458
+ // } else if (permitOrInvoice?.typeOf === 'Invoice') {
459
+ // // support paymentServiceType.MovieTicket(2024-11-23~)
460
+ // if (typeof permitOrInvoice?.paymentMethodId === 'string') {
461
+ // paymentMethodIdByTicketToken = permitOrInvoice?.paymentMethodId;
462
+ // if (typeof paymentMethodIdByTicketToken === 'string') {
463
+ // transactionNumber = paymentMethodIdByTicketToken;
464
+ // }
465
+ // }
466
+ // }
467
+ // // リクエストでpaymentMethodIdを指定された場合、取引に保管されたpaymentMethodIdに一致すればそちらを適用(外部サイト決済対応)
468
+ // if (typeof params.object.paymentMethodId === 'string' && params.object.paymentMethodId.length > 0) {
469
+ // if (typeof paymentMethodIdByTicketToken === 'string') {
470
+ // if (paymentMethodIdByTicketToken !== params.object.paymentMethodId) {
471
+ // throw new factory.errors.Argument('ticketToken', 'not matched with paymentMethodId');
472
+ // }
473
+ // }
474
+ // const { authorizeParams, existingCompletedAuthorizeAction } = await handlePrePublishedPaymentMethodIdOnAuthorizing({
475
+ // object: params.object,
476
+ // prePublishedPaymentMethodId: params.object.paymentMethodId,
477
+ // transaction
478
+ // })(repos);
479
+ // if (existingCompletedAuthorizeAction !== undefined) {
480
+ // return { id: existingCompletedAuthorizeAction.id };
481
+ // } else if (authorizeParams !== undefined) {
482
+ // // creditCardを決済URL発行時の情報で上書き(2024-01-08~)
483
+ // // creditCard = authorizeParams.paymentMethodByTransaction.paymentMethod?.creditCard;
484
+ // creditCard = authorizeParams.creditCard;
485
+ // transactionNumber = params.object.paymentMethodId;
486
+ // pendingPaymentAgencyTransaction = authorizeParams.pendingPaymentAgencyTransaction;
487
+ // } else {
488
+ // throw new factory.errors.NotImplemented('pendingPaymentAgencyTransaction requied on paymentMethodId specified');
489
+ // }
490
+ // }
491
+ // // 取引番号発行済でなければ発行
492
+ // if (typeof transactionNumber !== 'string') {
493
+ // const publishTransactionNumberResult = await repos.transactionNumber.publishByTimestamp({ startDate: new Date() });
494
+ // transactionNumber = publishTransactionNumberResult.transactionNumber;
495
+ // }
475
496
  const movieTickets = (Array.isArray(params.object.movieTickets)) ? params.object.movieTickets.map(factory_1.createMovieTicket) : undefined;
476
497
  const { accountId } = yield fixAccountIdIfPossible({
477
498
  object: params.object, project: { id: transaction.project.id }
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "dependencies": {
12
12
  "@aws-sdk/client-cognito-identity-provider": "3.600.0",
13
13
  "@aws-sdk/credential-providers": "3.600.0",
14
- "@chevre/factory": "5.2.0-alpha.4",
14
+ "@chevre/factory": "5.2.0-alpha.5",
15
15
  "@cinerino/sdk": "12.7.0-alpha.1",
16
16
  "@motionpicture/coa-service": "9.6.0",
17
17
  "@motionpicture/gmo-service": "5.4.0-alpha.1",
@@ -115,5 +115,5 @@
115
115
  "postversion": "git push origin --tags",
116
116
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
117
117
  },
118
- "version": "23.0.0-alpha.29"
118
+ "version": "23.0.0-alpha.30"
119
119
  }
@@ -1,15 +0,0 @@
1
- // tslint:disable:no-console no-magic-numbers
2
- import * as mongoose from 'mongoose';
3
-
4
- import { chevre } from '../../../../lib/index';
5
-
6
- async function main() {
7
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
8
-
9
- const movieTicketTypeRepo = await chevre.repository.MovieTicketType.createInstance(mongoose.connection);
10
- await movieTicketTypeRepo.deleteOldMovieTicketTypes(mongoose.connection);
11
- }
12
-
13
- main()
14
- .then()
15
- .catch(console.error);
@@ -1,15 +0,0 @@
1
- // tslint:disable:no-console no-magic-numbers
2
- import * as mongoose from 'mongoose';
3
-
4
- import { chevre } from '../../../../lib/index';
5
-
6
- async function main() {
7
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
8
-
9
- const movieTicketTypeRepo = await chevre.repository.MovieTicketType.createInstance(mongoose.connection);
10
- await movieTicketTypeRepo.migrateCollections(mongoose.connection);
11
- }
12
-
13
- main()
14
- .then()
15
- .catch(console.error);