@chevre/domain 21.33.0-alpha.20 → 21.33.0-alpha.21

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.
@@ -21,6 +21,7 @@ import { IAcceptedOfferMovieTicketUsed } from './pay/potentialActions';
21
21
  export interface IStartOperationRepos {
22
22
  accountingReport: AccountingReportRepo;
23
23
  action: ActionRepo;
24
+ actionRecipe: ActionRecipeRepo;
24
25
  event: EventRepo;
25
26
  paymentAccepted: PaymentAcceptedRepo;
26
27
  paymentService: PaymentServiceRepo;
@@ -10,7 +10,7 @@ declare function handlePrePublishedPaymentMethodIdOnAuthorizing(params: {
10
10
  transaction: Pick<ITransactionInProgress<factory.transactionType.PlaceOrder>, 'agent' | 'expires' | 'id' | 'typeOf' | 'project' | 'seller'>;
11
11
  }): (repos: {
12
12
  action: ActionRepo;
13
- actionRecipe?: ActionRecipeRepo;
13
+ actionRecipe: ActionRecipeRepo;
14
14
  transaction: TransactionRepo;
15
15
  }) => Promise<{
16
16
  authorizeParams?: {
@@ -49,7 +49,6 @@ function recipe2paymentAgencyTransaction(actionRecipe) {
49
49
  }
50
50
  function handlePrePublishedPaymentMethodIdOnAuthorizing(params) {
51
51
  return (repos) => __awaiter(this, void 0, void 0, function* () {
52
- var _a;
53
52
  let pendingPaymentAgencyTransaction;
54
53
  let existingCompletedAuthorizeAction;
55
54
  // transaction.objectへのアクセス回避(2024-05-30~)
@@ -74,10 +73,10 @@ function handlePrePublishedPaymentMethodIdOnAuthorizing(params) {
74
73
  }
75
74
  debug('acceptPayAction found:', acceptPayAction.id);
76
75
  // find recipe(2024-06-02~)
77
- const actionRecipe = yield ((_a = repos.actionRecipe) === null || _a === void 0 ? void 0 : _a.findByAction({
76
+ const actionRecipe = yield repos.actionRecipe.findByAction({
78
77
  project: { id: params.transaction.project.id },
79
78
  recipeFor: { id: acceptPayAction.id }
80
- }));
79
+ });
81
80
  debug('actionRecipe found:', actionRecipe === null || actionRecipe === void 0 ? void 0 : actionRecipe.recipeCategory);
82
81
  // 検証強化(2024-01-04~)
83
82
  validatePaymentMethodByTransaction({
@@ -0,0 +1,19 @@
1
+ import * as GMO from '@motionpicture/gmo-service';
2
+ import * as factory from '../../../factory';
3
+ interface IProcessAlterTranResult {
4
+ searchTradeArgs: GMO.factory.credit.ISearchTradeArgs & GMO.factory.credit.IOptionalSiteArgs;
5
+ searchTradeResult: GMO.factory.credit.ISearchTradeResult;
6
+ alterTranArgs?: GMO.factory.credit.IAlterTranArgs & GMO.factory.credit.IOptionalSiteArgs;
7
+ alterTranResult: GMO.factory.credit.IAlterTranResult;
8
+ }
9
+ declare function processAlterTranResult2recipe(params: {
10
+ processAlterTranResults: IProcessAlterTranResult[];
11
+ project: {
12
+ id: string;
13
+ };
14
+ action: {
15
+ id: string;
16
+ typeOf: factory.actionType;
17
+ };
18
+ }): factory.action.trade.pay.IPayCreditCardRecipe;
19
+ export { IProcessAlterTranResult, processAlterTranResult2recipe };
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.processAlterTranResult2recipe = void 0;
4
+ const factory = require("../../../factory");
5
+ function processAlterTranResult2recipe(params) {
6
+ const { processAlterTranResults, project, action } = params;
7
+ return {
8
+ project: { id: project.id, typeOf: factory.organizationType.Project },
9
+ typeOf: 'Recipe',
10
+ recipeCategory: factory.recipe.RecipeCategory.payCreditCard,
11
+ recipeFor: { id: action.id, typeOf: action.typeOf },
12
+ step: processAlterTranResults.map(({ searchTradeArgs, searchTradeResult, alterTranArgs, alterTranResult }) => {
13
+ return {
14
+ typeOf: 'HowToSection',
15
+ itemListElement: [
16
+ {
17
+ typeOf: 'HowToStep',
18
+ identifier: factory.recipe.StepIdentifier.searchTrade,
19
+ itemListElement: [{
20
+ typeOf: 'HowToDirection',
21
+ beforeMedia: searchTradeArgs,
22
+ afterMedia: searchTradeResult
23
+ // text: 'entryTran'
24
+ }]
25
+ },
26
+ {
27
+ typeOf: 'HowToStep',
28
+ identifier: factory.recipe.StepIdentifier.alterTran,
29
+ itemListElement: [Object.assign({ typeOf: 'HowToDirection', afterMedia: alterTranResult }, (alterTranArgs !== undefined) ? { beforeMedia: alterTranArgs } : undefined
30
+ // text: 'execTran'
31
+ )]
32
+ }
33
+ ]
34
+ };
35
+ })
36
+ };
37
+ }
38
+ exports.processAlterTranResult2recipe = processAlterTranResult2recipe;
@@ -58,7 +58,7 @@ declare function voidTransaction(params: factory.task.voidPayment.IData): (repos
58
58
  */
59
59
  declare function payCreditCard(params: factory.task.pay.IPayActionData): (repos: {
60
60
  action: ActionRepo;
61
- actionRecipe?: ActionRecipeRepo;
61
+ actionRecipe: ActionRecipeRepo;
62
62
  accountingReport: AccountingReportRepo;
63
63
  paymentAccepted: PaymentAcceptedRepo;
64
64
  paymentService: PaymentServiceRepo;
@@ -21,6 +21,7 @@ const factory = require("../../factory");
21
21
  const settings_1 = require("../../settings");
22
22
  const onPaid_1 = require("./any/onPaid");
23
23
  const onRefund_1 = require("./any/onRefund");
24
+ const factory_1 = require("./creditCard/factory");
24
25
  const debug = createDebug('chevre-domain:service:payment');
25
26
  /**
26
27
  * クレジットカード決済承認
@@ -301,7 +302,7 @@ exports.voidTransaction = voidTransaction;
301
302
  */
302
303
  function payCreditCard(params) {
303
304
  return (repos) => __awaiter(this, void 0, void 0, function* () {
304
- var _a, _b;
305
+ var _a;
305
306
  const payObject = params.object;
306
307
  // CreditCard系統の決済方法タイプは動的
307
308
  const paymentMethodType = payObject[0].paymentMethod.typeOf;
@@ -337,11 +338,11 @@ function payCreditCard(params) {
337
338
  })));
338
339
  // add recipe(2024-06-03~)
339
340
  if (settings_1.USE_EXPERIMENTAL_FEATURE) {
340
- yield ((_b = repos.actionRecipe) === null || _b === void 0 ? void 0 : _b.saveOne(processAlterTranResult2recipe({
341
+ yield repos.actionRecipe.saveOne((0, factory_1.processAlterTranResult2recipe)({
341
342
  processAlterTranResults,
342
343
  project: { id: params.project.id },
343
344
  action: { id: action.id, typeOf: action.typeOf }
344
- })));
345
+ }));
345
346
  }
346
347
  }
347
348
  catch (error) {
@@ -437,42 +438,6 @@ function processAlterTran(params) {
437
438
  return { searchTradeArgs, searchTradeResult, alterTranArgs, alterTranResult };
438
439
  });
439
440
  }
440
- function processAlterTranResult2recipe(params) {
441
- const { processAlterTranResults, project, action } = params;
442
- return {
443
- project: { id: project.id, typeOf: factory.organizationType.Project },
444
- typeOf: 'Recipe',
445
- recipeCategory: 'payCreditCard',
446
- recipeFor: { id: action.id, typeOf: action.typeOf },
447
- step: processAlterTranResults.map(({ searchTradeArgs, searchTradeResult, alterTranArgs, alterTranResult }) => {
448
- return {
449
- typeOf: 'HowToSection',
450
- itemListElement: [
451
- {
452
- typeOf: 'HowToStep',
453
- identifier: 'searchTrade',
454
- itemListElement: [{
455
- typeOf: 'HowToDirection',
456
- beforeMedia: searchTradeArgs,
457
- afterMedia: searchTradeResult
458
- // text: 'entryTran'
459
- }]
460
- },
461
- {
462
- typeOf: 'HowToStep',
463
- identifier: 'alterTran',
464
- itemListElement: [{
465
- typeOf: 'HowToDirection',
466
- beforeMedia: alterTranArgs,
467
- afterMedia: alterTranResult
468
- // text: 'execTran'
469
- }]
470
- }
471
- ]
472
- };
473
- })
474
- };
475
- }
476
441
  /**
477
442
  * クレジットカード返金
478
443
  */
@@ -1,7 +1,7 @@
1
1
  import * as surfrock from '@surfrock/sdk';
2
2
  import * as factory from '../../../factory';
3
3
  import { IMinimizedIndividualEvent } from '../../../factory/event';
4
- export declare function createSeatInfoSyncIn(params: {
4
+ declare function createSeatInfoSyncIn(params: {
5
5
  paymentMethodType: string;
6
6
  paymentMethodId: string;
7
7
  movieTickets: factory.action.trade.pay.IMovieTicket[];
@@ -12,3 +12,19 @@ export declare function createSeatInfoSyncIn(params: {
12
12
  stCd: string;
13
13
  };
14
14
  }): surfrock.factory.service.seat.seatInfoSync.ISeatInfoSyncIn;
15
+ declare function createStartingPayAction(params: factory.task.pay.IPayActionData, seatInfoSyncIn: surfrock.factory.service.seat.seatInfoSync.ISeatInfoSyncIn): factory.action.trade.pay.IAttributes;
16
+ interface IProcessSeatInfoSyncResult {
17
+ seatInfoSyncIn: factory.action.trade.pay.ISeatInfoSyncIn;
18
+ seatInfoSyncResult: factory.action.trade.pay.ISeatInfoSyncResult;
19
+ }
20
+ declare function processSeatInfoSyncResult2recipe(params: {
21
+ processSeatInfoSyncResult: IProcessSeatInfoSyncResult;
22
+ project: {
23
+ id: string;
24
+ };
25
+ action: {
26
+ id: string;
27
+ typeOf: factory.actionType;
28
+ };
29
+ }): factory.action.trade.pay.IPayMovieTicketRecipe;
30
+ export { createSeatInfoSyncIn, createStartingPayAction, processSeatInfoSyncResult2recipe };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createSeatInfoSyncIn = void 0;
3
+ exports.processSeatInfoSyncResult2recipe = exports.createStartingPayAction = exports.createSeatInfoSyncIn = void 0;
4
4
  const surfrock = require("@surfrock/sdk");
5
5
  const moment = require("moment-timezone");
6
6
  const factory = require("../../../factory");
@@ -73,3 +73,47 @@ function createSeatInfoSyncIn(params) {
73
73
  };
74
74
  }
75
75
  exports.createSeatInfoSyncIn = createSeatInfoSyncIn;
76
+ function createStartingPayAction(params, seatInfoSyncIn) {
77
+ const instrument = {
78
+ typeOf: factory.service.paymentService.PaymentServiceType.MovieTicket,
79
+ seatInfoSyncIn
80
+ };
81
+ return Object.assign(Object.assign({}, params), { object: params.object.map((o) => {
82
+ const movieTicketsWithMaskedAccessCode = (Array.isArray(o.movieTickets))
83
+ ? o.movieTickets.map((movieTicket) => {
84
+ return Object.assign(Object.assign({}, movieTicket), { accessCode: '****' // accessCodeを隠蔽(2023-02-08~)
85
+ });
86
+ })
87
+ : [];
88
+ return Object.assign(Object.assign({}, o), { movieTickets: movieTicketsWithMaskedAccessCode });
89
+ }),
90
+ // アクション開始前にseatInfoSyncInを生成してアクションに保管する
91
+ instrument });
92
+ }
93
+ exports.createStartingPayAction = createStartingPayAction;
94
+ function processSeatInfoSyncResult2recipe(params) {
95
+ const { processSeatInfoSyncResult, project, action } = params;
96
+ const { seatInfoSyncIn, seatInfoSyncResult } = processSeatInfoSyncResult;
97
+ return {
98
+ project: { id: project.id, typeOf: factory.organizationType.Project },
99
+ typeOf: 'Recipe',
100
+ recipeCategory: factory.recipe.RecipeCategory.payMovieTicket,
101
+ recipeFor: { id: action.id, typeOf: action.typeOf },
102
+ step: [{
103
+ typeOf: 'HowToSection',
104
+ itemListElement: [
105
+ {
106
+ typeOf: 'HowToStep',
107
+ identifier: factory.recipe.StepIdentifier.seatInfoSync,
108
+ itemListElement: [{
109
+ typeOf: 'HowToDirection',
110
+ beforeMedia: seatInfoSyncIn,
111
+ afterMedia: seatInfoSyncResult
112
+ // text: 'entryTran'
113
+ }]
114
+ }
115
+ ]
116
+ }]
117
+ };
118
+ }
119
+ exports.processSeatInfoSyncResult2recipe = processSeatInfoSyncResult2recipe;
@@ -1,5 +1,6 @@
1
1
  import type { MongoRepository as AccountingReportRepo } from '../../repo/accountingReport';
2
2
  import type { MongoRepository as ActionRepo } from '../../repo/action';
3
+ import type { ActionRecipeRepo } from '../../repo/actionRecipe';
3
4
  import type { MongoRepository as EventRepo } from '../../repo/event';
4
5
  import type { MongoRepository as PaymentServiceRepo } from '../../repo/paymentService';
5
6
  import type { MongoRepository as PaymentServiceProviderRepo } from '../../repo/paymentServiceProvider';
@@ -17,6 +18,7 @@ interface ICheckOperationRepos {
17
18
  type ICheckOperation<T> = (repos: ICheckOperationRepos) => Promise<T>;
18
19
  interface IPayOperationRepos {
19
20
  action: ActionRepo;
21
+ actionRecipe: ActionRecipeRepo;
20
22
  accountingReport: AccountingReportRepo;
21
23
  event: EventRepo;
22
24
  paymentAccepted: PaymentAcceptedRepo;
@@ -49,6 +51,7 @@ interface IAuthorizeResult {
49
51
  */
50
52
  declare function authorize(params: factory.assetTransaction.pay.IStartParamsWithoutDetail, transaction: factory.assetTransaction.pay.ITransaction, paymentServiceId: string, useCheckMovieTicketBeforePay: boolean, useCheckByIdentifierIfNotYet: boolean): (repos: {
51
53
  action: ActionRepo;
54
+ actionRecipe: ActionRecipeRepo;
52
55
  accountingReport: AccountingReportRepo;
53
56
  event: EventRepo;
54
57
  paymentAccepted: PaymentAcceptedRepo;
@@ -17,6 +17,7 @@ const surfrock = require("@surfrock/sdk");
17
17
  const http_status_1 = require("http-status");
18
18
  const credentials_1 = require("../../credentials");
19
19
  const factory = require("../../factory");
20
+ const settings_1 = require("../../settings");
20
21
  const checkByIdentifier_1 = require("./movieTicket/checkByIdentifier");
21
22
  const factory_1 = require("./movieTicket/factory");
22
23
  const getCredentials_1 = require("./movieTicket/getCredentials");
@@ -244,22 +245,7 @@ function payMovieTicket(params) {
244
245
  const paymentMethodId = (_a = params.object[0]) === null || _a === void 0 ? void 0 : _a.paymentMethod.paymentMethodId;
245
246
  const paymentServiceId = (_b = params.object[0]) === null || _b === void 0 ? void 0 : _b.id;
246
247
  const seatInfoSyncIn = yield payActionParams2seatInfoSyncIn(params)(repos);
247
- const instrument = {
248
- typeOf: factory.service.paymentService.PaymentServiceType.MovieTicket,
249
- seatInfoSyncIn
250
- };
251
- const startingAction = Object.assign(Object.assign({}, params), { object: params.object.map((o) => {
252
- const movieTicketsWithMaskedAccessCode = (Array.isArray(o.movieTickets))
253
- ? o.movieTickets.map((movieTicket) => {
254
- return Object.assign(Object.assign({}, movieTicket), { accessCode: '****' // accessCodeを隠蔽(2023-02-08~)
255
- });
256
- })
257
- : [];
258
- return Object.assign(Object.assign({}, o), { movieTickets: movieTicketsWithMaskedAccessCode });
259
- }),
260
- // アクション開始前にseatInfoSyncInを生成してアクションに保管する
261
- instrument });
262
- // アクション開始
248
+ const startingAction = (0, factory_1.createStartingPayAction)(params, seatInfoSyncIn);
263
249
  let action = yield repos.action.start(startingAction);
264
250
  let seatInfoSyncResult;
265
251
  try {
@@ -267,9 +253,9 @@ function payMovieTicket(params) {
267
253
  // その他のアクションとしての振る舞いは実行される必要もある
268
254
  const completedPayAction = yield repos.action.findPayAction({ project: { id: params.project.id }, paymentMethodId });
269
255
  // すでに決済済であれば、何もしない(決済開始時の着券)
270
- if (completedPayAction !== undefined) {
271
- seatInfoSyncResult = (_c = completedPayAction.result) === null || _c === void 0 ? void 0 : _c.seatInfoSyncResult;
272
- // return payAction;
256
+ const seatInfoSyncResultFromCompletedAction = (_c = completedPayAction === null || completedPayAction === void 0 ? void 0 : completedPayAction.result) === null || _c === void 0 ? void 0 : _c.seatInfoSyncResult;
257
+ if (seatInfoSyncResultFromCompletedAction !== undefined) {
258
+ seatInfoSyncResult = seatInfoSyncResultFromCompletedAction;
273
259
  }
274
260
  else {
275
261
  const availableChannel = yield repos.paymentService.findAvailableChannel({
@@ -287,6 +273,14 @@ function payMovieTicket(params) {
287
273
  const movieTicketSeatService = new surfrock.service.seat.SeatService({ endpoint: String(availableChannel.serviceUrl), auth: mvtkReserveAuthClient }, { timeout: credentials_1.credentials.movieticketReserve.timeout });
288
274
  seatInfoSyncResult = yield movieTicketSeatService.seatInfoSync(seatInfoSyncIn);
289
275
  }
276
+ // add recipe(2024-06-03~)
277
+ if (settings_1.USE_EXPERIMENTAL_FEATURE) {
278
+ yield repos.actionRecipe.saveOne((0, factory_1.processSeatInfoSyncResult2recipe)({
279
+ processSeatInfoSyncResult: { seatInfoSyncIn, seatInfoSyncResult },
280
+ project: { id: params.project.id },
281
+ action: { id: action.id, typeOf: action.typeOf }
282
+ }));
283
+ }
290
284
  }
291
285
  catch (error) {
292
286
  let throwsError = true;
@@ -306,12 +300,11 @@ function payMovieTicket(params) {
306
300
  catch (__) {
307
301
  // 失敗したら仕方ない
308
302
  }
309
- // error = handleMvtkReserveError(error);
310
303
  throw errors;
311
304
  }
312
305
  }
313
- const actionResult = { seatInfoSyncResult };
314
- action = (yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult }));
306
+ const result = { seatInfoSyncResult };
307
+ action = (yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result }));
315
308
  yield (0, onPaid_1.onPaid)(action)(repos);
316
309
  return action;
317
310
  });
@@ -22,7 +22,7 @@ import * as factory from '../factory';
22
22
  export declare function pay(params: factory.task.pay.IData): (repos: {
23
23
  acceptedOffer: AcceptedOfferRepo;
24
24
  action: ActionRepo;
25
- actionRecipe?: ActionRecipeRepo;
25
+ actionRecipe: ActionRecipeRepo;
26
26
  accountingReport: AccountingReportRepo;
27
27
  assetTransaction: AssetTransactionRepo;
28
28
  event: EventRepo;
package/package.json CHANGED
@@ -10,8 +10,8 @@
10
10
  ],
11
11
  "dependencies": {
12
12
  "@aws-sdk/credential-providers": "3.433.0",
13
- "@chevre/factory": "4.374.0-alpha.0",
14
- "@cinerino/sdk": "7.0.0-alpha.12",
13
+ "@chevre/factory": "4.374.0-alpha.1",
14
+ "@cinerino/sdk": "7.0.0",
15
15
  "@motionpicture/coa-service": "9.4.0",
16
16
  "@motionpicture/gmo-service": "5.3.0",
17
17
  "@sendgrid/mail": "6.4.0",
@@ -110,5 +110,5 @@
110
110
  "postversion": "git push origin --tags",
111
111
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
112
112
  },
113
- "version": "21.33.0-alpha.20"
113
+ "version": "21.33.0-alpha.21"
114
114
  }