@chevre/domain 21.8.0-alpha.18 → 21.8.0-alpha.19

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.
@@ -792,7 +792,12 @@ class MongoRepository {
792
792
  'project.id': { $eq: params.project.id },
793
793
  'paymentMethods.paymentMethodId': { $exists: true, $eq: params.invoice.paymentMethodId }
794
794
  }, {
795
- $set: { 'paymentMethods.$[invoice].paymentMethod.identifier': params.invoice.paymentMethod.identifier }
795
+ $set: {
796
+ 'paymentMethods.$[invoice].paymentMethod.identifier': params.invoice.paymentMethod.identifier,
797
+ // tslint:disable-next-line:no-suspicious-comment
798
+ // TODO 互換性維持対応としてtypeOfも変更しているが、そのうち廃止(2023-08-30)
799
+ 'paymentMethods.$[invoice].typeOf': params.invoice.paymentMethod.identifier
800
+ }
796
801
  }, {
797
802
  arrayFilters: [{ 'invoice.paymentMethodId': { $eq: params.invoice.paymentMethodId } }],
798
803
  new: true,
@@ -12,8 +12,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.searchGMOTrade = exports.exportTasksById = exports.cancel = exports.confirm = exports.start = exports.check = exports.invalidatePaymentUrl = exports.publishPaymentUrl = void 0;
13
13
  const moment = require("moment");
14
14
  const factory = require("../../factory");
15
- const settings_1 = require("../../settings");
16
- const payment_1 = require("../payment");
17
15
  const CreditCardPayment = require("../payment/creditCard");
18
16
  const MovieTicketPayment = require("../payment/movieTicket");
19
17
  const PaymentCardPayment = require("../payment/paymentCard");
@@ -346,21 +344,9 @@ function confirm(params) {
346
344
  potentialActions: params.potentialActions,
347
345
  order
348
346
  });
349
- yield repos.assetTransaction.confirm(Object.assign({ typeOf: factory.assetTransactionType.Pay, id: transaction.id, result: {},
350
- // sync対応(2023-01-14~)
351
- potentialActions: (settings_1.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING)
352
- ? { pay: [] }
353
- : potentialActions }, (typeof overwritingPaymentMethodIdentifier === 'string')
347
+ yield repos.assetTransaction.confirm(Object.assign({ typeOf: factory.assetTransactionType.Pay, id: transaction.id, result: {}, potentialActions: potentialActions }, (typeof overwritingPaymentMethodIdentifier === 'string')
354
348
  ? { object: { paymentMethod: { identifier: overwritingPaymentMethodIdentifier } } }
355
349
  : undefined));
356
- // sync対応(2023-01-14~)
357
- if (settings_1.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING) {
358
- if (Array.isArray(potentialActions.pay)) {
359
- for (const payAction of potentialActions.pay) {
360
- yield (0, payment_1.pay)(payAction)(repos);
361
- }
362
- }
363
- }
364
350
  });
365
351
  }
366
352
  exports.confirm = confirm;
@@ -393,23 +379,11 @@ function fixOrderAsPurpose(params, transaction) {
393
379
  */
394
380
  function cancel(params) {
395
381
  return (repos) => __awaiter(this, void 0, void 0, function* () {
396
- const transaction = yield repos.assetTransaction.cancel({
382
+ yield repos.assetTransaction.cancel({
397
383
  typeOf: factory.assetTransactionType.Pay,
398
384
  id: params.id,
399
385
  transactionNumber: params.transactionNumber
400
386
  });
401
- // sync対応(2023-01-14~)
402
- if (settings_1.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING) {
403
- const payTransactionAsObject = {
404
- project: transaction.project,
405
- typeOf: transaction.typeOf,
406
- id: transaction.id,
407
- transactionNumber: transaction.transactionNumber,
408
- object: transaction.object,
409
- recipient: transaction.recipient
410
- };
411
- yield (0, payment_1.voidPayment)({ object: payTransactionAsObject })(repos);
412
- }
413
387
  });
414
388
  }
415
389
  exports.cancel = cancel;
@@ -498,11 +472,7 @@ function exportTasksById(params) {
498
472
  }
499
473
  break;
500
474
  case factory.transactionStatusType.Canceled:
501
- // sync対応(2023-01-14~)
502
- if (!settings_1.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING) {
503
- taskAttributes.push(voidPaymentTasks);
504
- }
505
- taskAttributes.push(onAssetTransactionStatusChangedTask);
475
+ taskAttributes.push(voidPaymentTasks, onAssetTransactionStatusChangedTask);
506
476
  break;
507
477
  case factory.transactionStatusType.Expired:
508
478
  taskAttributes.push(voidPaymentTasks, onAssetTransactionStatusChangedTask);
@@ -26,6 +26,7 @@ exports.WebAPIIdentifier = factory.service.webAPI.Identifier;
26
26
  */
27
27
  function voidTransaction(params) {
28
28
  return (repos) => __awaiter(this, void 0, void 0, function* () {
29
+ var _a, _b;
29
30
  const transaction = yield repos.transaction.findById({
30
31
  typeOf: params.purpose.typeOf,
31
32
  id: params.purpose.id,
@@ -46,8 +47,12 @@ function voidTransaction(params) {
46
47
  throw new factory.errors.NotImplemented(`${transaction.status} not implemented`);
47
48
  // 確定取引に対応(2023-05-07~)
48
49
  case factory.transactionStatusType.Confirmed:
49
- // アクションステータスを検証する
50
- authorizeActions = authorizeActions.filter((a) => a.actionStatus !== factory.actionStatusType.CompletedActionStatus);
50
+ // OrderCancelledを考慮(2023-08-30~)
51
+ const orderCancelled = ((_b = (_a = params.purpose.result) === null || _a === void 0 ? void 0 : _a.order) === null || _b === void 0 ? void 0 : _b.orderStatus) === factory.orderStatus.OrderCancelled;
52
+ if (!orderCancelled) {
53
+ // 取り消すべきアクションに絞る
54
+ authorizeActions = authorizeActions.filter((a) => a.actionStatus !== factory.actionStatusType.CompletedActionStatus);
55
+ }
51
56
  break;
52
57
  default:
53
58
  // no op
@@ -37,4 +37,10 @@ export declare function createOnOrderSentTasksByTransaction(params: {
37
37
  export declare function createOnOrderReturnedTasksByTransaction(params: {
38
38
  potentialActions?: factory.action.transfer.returnAction.order.IPotentialActions;
39
39
  }): (import("@chevre/factory/lib/task").IAttributes | import("@chevre/factory/lib/task/confirmMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/confirmRegisterService").IAttributes | import("@chevre/factory/lib/task/confirmPayTransaction").IAttributes | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/confirmReserveTransaction").IAttributes | import("@chevre/factory/lib/task/createEvent").IAttributes | import("@chevre/factory/lib/task/deleteTransaction").IAttributes | import("@chevre/factory/lib/task/givePointAward").IAttributes | import("@chevre/factory/lib/task/onAssetTransactionStatusChanged").IAttributes | import("@chevre/factory/lib/task/onAuthorizationCreated").IAttributes | import("@chevre/factory/lib/task/onEventChanged").IAttributes | import("@chevre/factory/lib/task/onResourceUpdated").IAttributes | import("@chevre/factory/lib/task/onOrderPaymentCompleted").IAttributes | import("@chevre/factory/lib/task/placeOrder").IAttributes | import("@chevre/factory/lib/task/returnOrder").IAttributes | import("@chevre/factory/lib/task/returnMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/returnPayTransaction").IAttributes | import("@chevre/factory/lib/task/returnPointAward").IAttributes | import("@chevre/factory/lib/task/returnReserveTransaction").IAttributes | import("@chevre/factory/lib/task/sendEmailMessage").IAttributes | import("@chevre/factory/lib/task/sendOrder").IAttributes | import("@chevre/factory/lib/task/syncScreeningRooms").IAttributes | import("@chevre/factory/lib/task/triggerWebhook").IAttributes | import("@chevre/factory/lib/task/useReservation").IAttributes | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").IAttributes | import("@chevre/factory/lib/task/voidPayTransaction").IAttributes | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/voidReserveTransaction").IAttributes)[];
40
+ /**
41
+ * 注文中止時のアクション
42
+ */
43
+ export declare function createOnOrderCancelledTasksByTransaction(params: {
44
+ transaction?: factory.transaction.placeOrder.ITransaction;
45
+ }): (import("@chevre/factory/lib/task").IAttributes | import("@chevre/factory/lib/task/confirmMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/confirmRegisterService").IAttributes | import("@chevre/factory/lib/task/confirmPayTransaction").IAttributes | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/confirmReserveTransaction").IAttributes | import("@chevre/factory/lib/task/createEvent").IAttributes | import("@chevre/factory/lib/task/deleteTransaction").IAttributes | import("@chevre/factory/lib/task/givePointAward").IAttributes | import("@chevre/factory/lib/task/onAssetTransactionStatusChanged").IAttributes | import("@chevre/factory/lib/task/onAuthorizationCreated").IAttributes | import("@chevre/factory/lib/task/onEventChanged").IAttributes | import("@chevre/factory/lib/task/onResourceUpdated").IAttributes | import("@chevre/factory/lib/task/onOrderPaymentCompleted").IAttributes | import("@chevre/factory/lib/task/placeOrder").IAttributes | import("@chevre/factory/lib/task/returnOrder").IAttributes | import("@chevre/factory/lib/task/returnMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/returnPayTransaction").IAttributes | import("@chevre/factory/lib/task/returnPointAward").IAttributes | import("@chevre/factory/lib/task/returnReserveTransaction").IAttributes | import("@chevre/factory/lib/task/sendEmailMessage").IAttributes | import("@chevre/factory/lib/task/sendOrder").IAttributes | import("@chevre/factory/lib/task/syncScreeningRooms").IAttributes | import("@chevre/factory/lib/task/triggerWebhook").IAttributes | import("@chevre/factory/lib/task/useReservation").IAttributes | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").IAttributes | import("@chevre/factory/lib/task/voidPayTransaction").IAttributes | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/voidReserveTransaction").IAttributes)[];
40
46
  export {};
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  var _a;
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.createOnOrderReturnedTasksByTransaction = exports.createOnOrderSentTasksByTransaction = exports.createOnPlaceOrderTasksByTransaction = exports.createConfirmRegisterServiceActionObjectByOrder = exports.createConfirmReservationActionObject4COAByOrder = exports.createConfirmReservationActionObject4ChevreByOrder = exports.createInformTasks = exports.getOrderWithToken = void 0;
13
+ exports.createOnOrderCancelledTasksByTransaction = exports.createOnOrderReturnedTasksByTransaction = exports.createOnOrderSentTasksByTransaction = exports.createOnPlaceOrderTasksByTransaction = exports.createConfirmRegisterServiceActionObjectByOrder = exports.createConfirmReservationActionObject4COAByOrder = exports.createConfirmReservationActionObject4ChevreByOrder = exports.createInformTasks = exports.getOrderWithToken = void 0;
14
14
  const google_libphonenumber_1 = require("google-libphonenumber");
15
15
  const jwt = require("jsonwebtoken");
16
16
  const util_1 = require("util");
@@ -442,3 +442,50 @@ function createOnOrderReturnedTasksByTransaction(params) {
442
442
  return taskAttributes;
443
443
  }
444
444
  exports.createOnOrderReturnedTasksByTransaction = createOnOrderReturnedTasksByTransaction;
445
+ /**
446
+ * 注文中止時のアクション
447
+ */
448
+ function createOnOrderCancelledTasksByTransaction(params) {
449
+ var _a;
450
+ const now = new Date();
451
+ const taskAttributes = [];
452
+ if (typeof ((_a = params.transaction) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
453
+ const voidPaymentTaskAttributes = {
454
+ project: params.transaction.project,
455
+ name: factory.taskName.VoidPayTransaction,
456
+ status: factory.taskStatus.Ready,
457
+ runsAt: now,
458
+ remainingNumberOfTries: 10,
459
+ numberOfTried: 0,
460
+ executionResults: [],
461
+ data: {
462
+ project: params.transaction.project,
463
+ purpose: {
464
+ typeOf: params.transaction.typeOf,
465
+ id: params.transaction.id,
466
+ result: { order: { orderStatus: factory.orderStatus.OrderCancelled } }
467
+ }
468
+ }
469
+ };
470
+ const voidReserveTaskAttributes = {
471
+ project: params.transaction.project,
472
+ name: factory.taskName.VoidReserveTransaction,
473
+ status: factory.taskStatus.Ready,
474
+ runsAt: now,
475
+ remainingNumberOfTries: 10,
476
+ numberOfTried: 0,
477
+ executionResults: [],
478
+ data: {
479
+ project: params.transaction.project,
480
+ purpose: {
481
+ typeOf: params.transaction.typeOf,
482
+ id: params.transaction.id,
483
+ result: { order: { orderStatus: factory.orderStatus.OrderCancelled } }
484
+ }
485
+ }
486
+ };
487
+ taskAttributes.push(voidPaymentTaskAttributes, voidReserveTaskAttributes);
488
+ }
489
+ return taskAttributes;
490
+ }
491
+ exports.createOnOrderCancelledTasksByTransaction = createOnOrderCancelledTasksByTransaction;
@@ -118,8 +118,10 @@ function onOrderStatusChanged(params) {
118
118
  break;
119
119
  // OrderCancelled追加(2023-08-30~)
120
120
  case factory.orderStatus.OrderCancelled:
121
- // tslint:disable-next-line:no-suspicious-comment
122
- // TODO 注文取引中止時と同様の処理か
121
+ // 注文取引中止時と同様の処理か
122
+ tasks = [
123
+ ...(0, factory_1.createOnOrderCancelledTasksByTransaction)({ transaction: params.placeOrderTransaction })
124
+ ];
123
125
  break;
124
126
  default:
125
127
  }
@@ -104,7 +104,7 @@ exports.invalidatePaymentUrl = invalidatePaymentUrl;
104
104
  function processVoidPayTransaction(params) {
105
105
  // tslint:disable-next-line:max-func-body-length
106
106
  return (repos) => __awaiter(this, void 0, void 0, function* () {
107
- var _a, _b;
107
+ var _a, _b, _c, _d;
108
108
  let transaction;
109
109
  // アクションID指定の場合、進行中取引検証(2023-02-24~)
110
110
  if (typeof params.id === 'string') {
@@ -145,23 +145,27 @@ function processVoidPayTransaction(params) {
145
145
  throw new factory.errors.NotImplemented(`${transaction.status} not implemented`);
146
146
  // 確定取引に対応(2023-05-03~)
147
147
  case factory.transactionStatusType.Confirmed:
148
- // アクションステータスを検証する
149
- authorizeActions = authorizeActions.filter((a) => a.actionStatus !== factory.actionStatusType.CompletedActionStatus);
150
- if (transaction.typeOf === factory.transactionType.PlaceOrder) {
151
- const paymentMethodIds = (_b = (_a = transaction.result) === null || _a === void 0 ? void 0 : _a.order) === null || _b === void 0 ? void 0 : _b.paymentMethods.map((p) => {
152
- return p.paymentMethodId;
153
- });
154
- if (!Array.isArray(paymentMethodIds)) {
155
- throw new factory.errors.Argument('Transaction', `${transaction.id} must have result.order.paymentMethods`);
156
- }
157
- if (paymentMethodIds.length > 0) {
158
- authorizeActions = authorizeActions.filter((a) => {
159
- // paymentMethodIdが存在しない、あるいは、注文のpaymentMethodIdsに含まれなければ、アクション取消対象
160
- const paymentMethodIdByAction = a.object.paymentMethodId;
161
- const includedInOrder = typeof paymentMethodIdByAction === 'string'
162
- && paymentMethodIds.includes(paymentMethodIdByAction);
163
- return !includedInOrder;
148
+ // OrderCancelledを考慮(2023-08-30~)
149
+ const orderCancelled = ((_b = (_a = params.purpose.result) === null || _a === void 0 ? void 0 : _a.order) === null || _b === void 0 ? void 0 : _b.orderStatus) === factory.orderStatus.OrderCancelled;
150
+ if (!orderCancelled) {
151
+ // 取り消すべきアクションに絞る
152
+ authorizeActions = authorizeActions.filter((a) => a.actionStatus !== factory.actionStatusType.CompletedActionStatus);
153
+ if (transaction.typeOf === factory.transactionType.PlaceOrder) {
154
+ const paymentMethodIds = (_d = (_c = transaction.result) === null || _c === void 0 ? void 0 : _c.order) === null || _d === void 0 ? void 0 : _d.paymentMethods.map((p) => {
155
+ return p.paymentMethodId;
164
156
  });
157
+ if (!Array.isArray(paymentMethodIds)) {
158
+ throw new factory.errors.Argument('Transaction', `${transaction.id} must have result.order.paymentMethods`);
159
+ }
160
+ if (paymentMethodIds.length > 0) {
161
+ authorizeActions = authorizeActions.filter((a) => {
162
+ // paymentMethodIdが存在しない、あるいは、注文のpaymentMethodIdsに含まれなければ、アクション取消対象
163
+ const paymentMethodIdByAction = a.object.paymentMethodId;
164
+ const includedInOrder = typeof paymentMethodIdByAction === 'string'
165
+ && paymentMethodIds.includes(paymentMethodIdByAction);
166
+ return !includedInOrder;
167
+ });
168
+ }
165
169
  }
166
170
  }
167
171
  break;
@@ -339,7 +343,7 @@ function authorize(params) {
339
343
  if (error.name !== 'AbortError') {
340
344
  yield processVoidPayTransaction({
341
345
  project: action.project,
342
- agent: { id: action.project.id },
346
+ // agent: { id: action.project.id },
343
347
  id: action.id,
344
348
  purpose: action.purpose
345
349
  })(repos);
@@ -36,7 +36,6 @@ export type ISettings = factory.project.ISettings & {
36
36
  };
37
37
  export declare const DEFAULT_TASKS_EXPORT_AGENT_NAME: string;
38
38
  export declare const USE_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
39
- export declare const USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
40
39
  export declare const USE_NEW_EVENT_AVAILABILITY_KEY_FROM: moment.Moment;
41
40
  export declare const USE_ADVANCE_BOOKING_REQUIREMENT: boolean;
42
41
  export declare const USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT: boolean;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.settings = exports.MONGO_MAX_TIME_MS = exports.USE_ORDER_PAYMENT_DUE_ON_PLACED = exports.USE_CUSTOM_SENDER_EMAIL = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT = exports.USE_ADVANCE_BOOKING_REQUIREMENT = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
3
+ exports.settings = exports.MONGO_MAX_TIME_MS = exports.USE_ORDER_PAYMENT_DUE_ON_PLACED = exports.USE_CUSTOM_SENDER_EMAIL = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT = exports.USE_ADVANCE_BOOKING_REQUIREMENT = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
4
4
  const moment = require("moment");
5
5
  const factory = require("./factory");
6
6
  const transactionWebhookUrls = (typeof process.env.INFORM_TRANSACTION_URL === 'string')
@@ -60,7 +60,6 @@ exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = (typeof process.env.TRANSA
60
60
  exports.DEFAULT_SENDER_EMAIL = process.env.DEFAULT_SENDER_EMAIL;
61
61
  exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = `${process.env.GAE_APPLICATION}:${process.env.GAE_SERVICE}:jobs`;
62
62
  exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = process.env.USE_ASSET_TRANSACTION_SYNC_PROCESSING === '1';
63
- exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = process.env.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING === '1';
64
63
  exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = (typeof process.env.USE_NEW_EVENT_AVAILABILITY_KEY_FROM === 'string')
65
64
  ? moment(process.env.USE_NEW_EVENT_AVAILABILITY_KEY_FROM)
66
65
  : moment('2023-08-31T15:00:00Z');
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.327.0-alpha.8",
12
+ "@chevre/factory": "4.327.0-alpha.9",
13
13
  "@cinerino/sdk": "3.165.0",
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.0",
@@ -117,5 +117,5 @@
117
117
  "postversion": "git push origin --tags",
118
118
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
119
119
  },
120
- "version": "21.8.0-alpha.18"
120
+ "version": "21.8.0-alpha.19"
121
121
  }