@chevre/domain 21.8.0-alpha.9 → 21.8.0

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.
Files changed (131) hide show
  1. package/example/src/chevre/countOffers.ts +32 -0
  2. package/example/src/chevre/findItemListElementByCatalogId.ts +30 -0
  3. package/example/src/chevre/importOffersFromCOA.ts +7 -1
  4. package/example/src/chevre/migrateOrderPaymentMethodIdentifier.ts +81 -0
  5. package/example/src/chevre/migratePayTransactionPaymentMethodId.ts +72 -0
  6. package/example/src/chevre/migratePayTransactionPaymentMethodIdentifier.ts +78 -0
  7. package/example/src/chevre/optimizeCatalogs.ts +54 -0
  8. package/example/src/chevre/processPay.ts +3 -4
  9. package/example/src/chevre/publishPermitOwnershipInfoToken.ts +56 -0
  10. package/example/src/chevre/pullAddOnsFromOffer.ts +26 -0
  11. package/example/src/chevre/pushIncludedInDataCatalog.ts +47 -0
  12. package/example/src/chevre/searchAggregateOffers.ts +48 -0
  13. package/example/src/chevre/searchEventTicketOffers.ts +5 -1
  14. package/example/src/chevre/searchEvents.ts +9 -7
  15. package/example/src/chevre/searchOfferCatalogs.ts +7 -3
  16. package/example/src/chevre/searchOffers.ts +5 -2
  17. package/example/src/chevre/searchOffersByCatalog.ts +15 -9
  18. package/example/src/chevre/searchOffersFromAggregateOffer.ts +168 -0
  19. package/example/src/chevre/searchOrders.ts +9 -7
  20. package/example/src/chevre/syncCatalogs2aggregateOffers.ts +85 -0
  21. package/lib/chevre/emailMessageBuilder.js +6 -5
  22. package/lib/chevre/repo/aggregateOffer.d.ts +62 -0
  23. package/lib/chevre/repo/aggregateOffer.js +562 -0
  24. package/lib/chevre/repo/assetTransaction.d.ts +16 -1
  25. package/lib/chevre/repo/assetTransaction.js +54 -2
  26. package/lib/chevre/repo/mongoose/schemas/aggregateOffer.d.ts +74 -0
  27. package/lib/chevre/repo/mongoose/schemas/aggregateOffer.js +189 -0
  28. package/lib/chevre/repo/mongoose/schemas/authorization.d.ts +3 -3
  29. package/lib/chevre/repo/mongoose/schemas/creativeWork.d.ts +3 -3
  30. package/lib/chevre/repo/mongoose/schemas/event.d.ts +3 -3
  31. package/lib/chevre/repo/mongoose/schemas/offerCatalog.d.ts +3 -0
  32. package/lib/chevre/repo/mongoose/schemas/offerCatalog.js +10 -1
  33. package/lib/chevre/repo/mongoose/schemas/order.d.ts +3 -0
  34. package/lib/chevre/repo/mongoose/schemas/order.js +7 -0
  35. package/lib/chevre/repo/mongoose/schemas/priceSpecification.d.ts +9 -9
  36. package/lib/chevre/repo/mongoose/schemas/product.d.ts +3 -3
  37. package/lib/chevre/repo/mongoose/schemas/project.d.ts +3 -3
  38. package/lib/chevre/repo/mongoose/schemas/task.d.ts +3 -0
  39. package/lib/chevre/repo/mongoose/schemas/task.js +8 -0
  40. package/lib/chevre/repo/offer.d.ts +87 -51
  41. package/lib/chevre/repo/offer.js +513 -283
  42. package/lib/chevre/repo/offerCatalog.d.ts +32 -3
  43. package/lib/chevre/repo/offerCatalog.js +97 -10
  44. package/lib/chevre/repo/order.d.ts +15 -0
  45. package/lib/chevre/repo/order.js +58 -26
  46. package/lib/chevre/repo/task.d.ts +6 -2
  47. package/lib/chevre/repo/task.js +58 -4
  48. package/lib/chevre/repository.d.ts +3 -0
  49. package/lib/chevre/repository.js +5 -1
  50. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +3 -41
  51. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.d.ts +2 -0
  52. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +2 -40
  53. package/lib/chevre/service/aggregation/event/findEventOffers.d.ts +16 -0
  54. package/lib/chevre/service/aggregation/event/findEventOffers.js +58 -0
  55. package/lib/chevre/service/assetTransaction/pay/account/validation.js +2 -2
  56. package/lib/chevre/service/assetTransaction/pay/factory.js +26 -18
  57. package/lib/chevre/service/assetTransaction/pay/potentialActions.js +3 -3
  58. package/lib/chevre/service/assetTransaction/pay.js +65 -46
  59. package/lib/chevre/service/assetTransaction/refund/factory.js +8 -2
  60. package/lib/chevre/service/assetTransaction/registerService.js +2 -1
  61. package/lib/chevre/service/assetTransaction/reserve.js +111 -35
  62. package/lib/chevre/service/offer/event/authorize.js +39 -35
  63. package/lib/chevre/service/offer/event/factory.d.ts +1 -1
  64. package/lib/chevre/service/offer/event/factory.js +8 -8
  65. package/lib/chevre/service/offer/event/importFromCOA.d.ts +2 -0
  66. package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +3 -0
  67. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +48 -17
  68. package/lib/chevre/service/offer/event/voidTransaction.js +57 -36
  69. package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +2 -1
  70. package/lib/chevre/service/offer/eventServiceByCOA/factory.js +7 -11
  71. package/lib/chevre/service/offer/eventServiceByCOA.js +55 -27
  72. package/lib/chevre/service/offer/factory.d.ts +12 -4
  73. package/lib/chevre/service/offer/factory.js +9 -11
  74. package/lib/chevre/service/offer/product/searchProductOffers.d.ts +10 -1
  75. package/lib/chevre/service/offer/product/searchProductOffers.js +51 -12
  76. package/lib/chevre/service/offer/product.d.ts +2 -0
  77. package/lib/chevre/service/offer/product.js +3 -2
  78. package/lib/chevre/service/offer.d.ts +1 -0
  79. package/lib/chevre/service/offer.js +7 -1
  80. package/lib/chevre/service/order/confirmPayTransaction.d.ts +0 -2
  81. package/lib/chevre/service/order/confirmPayTransaction.js +20 -46
  82. package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +27 -0
  83. package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +226 -0
  84. package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +8 -6
  85. package/lib/chevre/service/order/onOrderStatusChanged/factory.js +80 -57
  86. package/lib/chevre/service/order/onOrderStatusChanged.js +49 -9
  87. package/lib/chevre/service/order/payOrder.js +4 -45
  88. package/lib/chevre/service/order/placeOrder.js +11 -24
  89. package/lib/chevre/service/order.d.ts +3 -1
  90. package/lib/chevre/service/order.js +6 -2
  91. package/lib/chevre/service/payment/any/factory.js +33 -8
  92. package/lib/chevre/service/payment/any.js +30 -21
  93. package/lib/chevre/service/payment/creditCard.js +12 -12
  94. package/lib/chevre/service/payment/movieTicket/validation.js +2 -2
  95. package/lib/chevre/service/payment/movieTicket.js +10 -11
  96. package/lib/chevre/service/payment/paymentCard.js +9 -12
  97. package/lib/chevre/service/project.js +1 -1
  98. package/lib/chevre/service/reserve/checkInReservation.d.ts +8 -0
  99. package/lib/chevre/service/reserve/checkInReservation.js +3 -2
  100. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.d.ts +3 -0
  101. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +4 -5
  102. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.d.ts +8 -0
  103. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +16 -11
  104. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +2 -1
  105. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.d.ts +3 -0
  106. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +3 -5
  107. package/lib/chevre/service/task/aggregateUseActionsOnEvent.js +2 -0
  108. package/lib/chevre/service/task/confirmPayTransaction.js +1 -3
  109. package/lib/chevre/service/task/importOffersFromCOA.js +3 -0
  110. package/lib/chevre/service/task/onAssetTransactionStatusChanged.d.ts +6 -0
  111. package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +37 -0
  112. package/lib/chevre/service/task/onAuthorizationCreated.js +5 -1
  113. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +2 -0
  114. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +7 -0
  115. package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.d.ts +17 -0
  116. package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.js +78 -0
  117. package/lib/chevre/service/task/onResourceUpdated.js +12 -0
  118. package/lib/chevre/service/task/returnPayTransaction.js +8 -3
  119. package/lib/chevre/service/transaction/placeOrderInProgress/result.js +32 -16
  120. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js +13 -11
  121. package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +53 -17
  122. package/lib/chevre/service/transaction/placeOrderInProgress.js +4 -1
  123. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +7 -6
  124. package/lib/chevre/service/transaction/returnOrder.js +5 -1
  125. package/lib/chevre/settings.d.ts +3 -3
  126. package/lib/chevre/settings.js +4 -12
  127. package/package.json +3 -3
  128. package/example/src/chevre/migrateAuthorizePaymentActionResult.ts +0 -83
  129. package/example/src/chevre/migrateEventOrganizer.ts +0 -154
  130. package/lib/chevre/repo/mongoose/schemas/offer.d.ts +0 -149
  131. package/lib/chevre/repo/mongoose/schemas/offer.js +0 -210
@@ -18,6 +18,7 @@ const moment = require("moment-timezone");
18
18
  const event_1 = require("../../../repo/event");
19
19
  const factory = require("../../../factory");
20
20
  const settings_1 = require("../../../settings");
21
+ const findEventOffers_1 = require("./findEventOffers");
21
22
  const debug = createDebug('chevre-domain:service');
22
23
  /**
23
24
  * イベントデータをID指定で集計する
@@ -31,7 +32,7 @@ function aggregateScreeningEvent(params) {
31
32
  let aggregatingEvents = [event];
32
33
  // プロジェクト限定(2023-02-22~)
33
34
  if (settings_1.settings.useOfferRateLimitProjects.includes(event.project.id)) {
34
- const availableOffers = yield findOffers({ event })(repos);
35
+ const availableOffers = yield (0, findEventOffers_1.findEventOffers)({ event })(repos);
35
36
  const offerRateLimitExists = availableOffers.some((o) => { var _a; return typeof ((_a = o.validRateLimit) === null || _a === void 0 ? void 0 : _a.scope) === 'string'; });
36
37
  if (offerRateLimitExists) {
37
38
  // 同location、かつ同時間帯、のイベントに関しても集計する(ttts暫定対応)
@@ -133,7 +134,7 @@ function aggregateOfferByEvent(params) {
133
134
  var _a, _b, _c;
134
135
  // プロジェクト限定(2023-02-22~)
135
136
  if (settings_1.settings.useAggregateOfferProjects.includes(params.event.project.id)) {
136
- const availableOffers = yield findOffers(params)(repos);
137
+ const availableOffers = yield (0, findEventOffers_1.findEventOffers)(params)(repos);
137
138
  // オファーごとの予約集計
138
139
  const offersWithAggregateReservation = [];
139
140
  for (const o of availableOffers) {
@@ -163,45 +164,6 @@ function aggregateOfferByEvent(params) {
163
164
  }
164
165
  });
165
166
  }
166
- /**
167
- * イベントオファー検索
168
- * NotFoundエラーをハンドリングする
169
- */
170
- function findOffers(params) {
171
- return (repos) => __awaiter(this, void 0, void 0, function* () {
172
- var _a, _b;
173
- let availableOffers = [];
174
- try {
175
- // 興行設定があれば興行のカタログを参照する(2022-08-31~)
176
- const eventOffers = params.event.offers;
177
- if (typeof ((_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
178
- const eventService = yield repos.product.findById({ id: eventOffers.itemOffered.id }, ['hasOfferCatalog'], []);
179
- if (typeof ((_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
180
- const findOffersByOfferCatalogIdResult = yield repos.offer.findOffersByOfferCatalogId({
181
- offerCatalog: { id: eventService.hasOfferCatalog.id },
182
- excludeAppliesToMovieTicket: false,
183
- sort: false // ソート不要(2023-01-27~)
184
- });
185
- availableOffers = findOffersByOfferCatalogIdResult.offers;
186
- }
187
- }
188
- else {
189
- throw new factory.errors.NotFound('event.offers.itemOffered.id');
190
- }
191
- }
192
- catch (error) {
193
- let throwsError = true;
194
- // 万が一カタログが見つからない場合に対応
195
- if (error instanceof factory.errors.NotFound) {
196
- throwsError = false;
197
- }
198
- if (throwsError) {
199
- throw error;
200
- }
201
- }
202
- return availableOffers;
203
- });
204
- }
205
167
  function calculateOfferCount(params) {
206
168
  return (repos) => __awaiter(this, void 0, void 0, function* () {
207
169
  var _a, _b, _c;
@@ -1,12 +1,14 @@
1
1
  import { MongoRepository as ActionRepo } from '../../../repo/action';
2
2
  import { MongoRepository as EventRepo } from '../../../repo/event';
3
3
  import { MongoRepository as OfferRepo } from '../../../repo/offer';
4
+ import { MongoRepository as OfferCatalogRepo } from '../../../repo/offerCatalog';
4
5
  import { MongoRepository as PlaceRepo } from '../../../repo/place';
5
6
  import { MongoRepository as ProductRepo } from '../../../repo/product';
6
7
  export type IAggregateOperation<T> = (repos: {
7
8
  action: ActionRepo;
8
9
  event: EventRepo;
9
10
  offer: OfferRepo;
11
+ offerCatalog: OfferCatalogRepo;
10
12
  place: PlaceRepo;
11
13
  product: ProductRepo;
12
14
  }) => Promise<T>;
@@ -15,6 +15,7 @@ exports.aggregateUseActionsOnEvent = void 0;
15
15
  */
16
16
  const createDebug = require("debug");
17
17
  const factory = require("../../../factory");
18
+ const findEventOffers_1 = require("./findEventOffers");
18
19
  const debug = createDebug('chevre-domain:service');
19
20
  function aggregateUseActionsOnEvent(params) {
20
21
  return (repos) => __awaiter(this, void 0, void 0, function* () {
@@ -88,45 +89,6 @@ function findEntranceGates(params) {
88
89
  return movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.hasEntranceGate;
89
90
  });
90
91
  }
91
- /**
92
- * イベントオファー検索
93
- * NotFoundエラーをハンドリングする
94
- */
95
- function findOffers(params) {
96
- return (repos) => __awaiter(this, void 0, void 0, function* () {
97
- var _a, _b;
98
- let availableOffers = [];
99
- try {
100
- // 興行設定があれば興行のカタログを参照する(2022-08-31~)
101
- const eventOffers = params.event.offers;
102
- if (typeof ((_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
103
- const eventService = yield repos.product.findById({ id: eventOffers.itemOffered.id }, ['hasOfferCatalog'], []);
104
- if (typeof ((_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
105
- const findOffersByOfferCatalogIdResult = yield repos.offer.findOffersByOfferCatalogId({
106
- offerCatalog: { id: eventService.hasOfferCatalog.id },
107
- excludeAppliesToMovieTicket: false,
108
- sort: false // ソート不要(2023-01-27~)
109
- });
110
- availableOffers = findOffersByOfferCatalogIdResult.offers;
111
- }
112
- }
113
- else {
114
- throw new factory.errors.NotFound('event.offers.itemOffered.id');
115
- }
116
- }
117
- catch (error) {
118
- let throwsError = true;
119
- // 万が一カタログが見つからない場合に対応
120
- if (error instanceof factory.errors.NotFound) {
121
- throwsError = false;
122
- }
123
- if (throwsError) {
124
- throw error;
125
- }
126
- }
127
- return availableOffers;
128
- });
129
- }
130
92
  /**
131
93
  * 入場ゲートごとに集計する
132
94
  */
@@ -135,7 +97,7 @@ function aggregateEntranceGateByEvent(params) {
135
97
  // 入場ゲートの予約使用アクション集計
136
98
  const places = [];
137
99
  if (Array.isArray(params.entranceGates) && params.entranceGates.length > 0) {
138
- const availableOffers = yield findOffers(params)(repos);
100
+ const availableOffers = yield (0, findEventOffers_1.findEventOffers)(params)(repos);
139
101
  // 念のため、identifierの存在する入場ゲートに絞る
140
102
  const entranceGates = params.entranceGates.filter((e) => {
141
103
  return typeof e.identifier === 'string' && e.identifier.length > 0;
@@ -0,0 +1,16 @@
1
+ import { IMinimizedIndividualEvent } from '../../../repo/event';
2
+ import { MongoRepository as OfferRepo } from '../../../repo/offer';
3
+ import { MongoRepository as OfferCatalogRepo } from '../../../repo/offerCatalog';
4
+ import { MongoRepository as ProductRepo } from '../../../repo/product';
5
+ import * as factory from '../../../factory';
6
+ /**
7
+ * イベントオファー検索
8
+ * NotFoundエラーをハンドリングする
9
+ */
10
+ export declare function findEventOffers(params: {
11
+ event: IMinimizedIndividualEvent<factory.eventType.ScreeningEvent> | IMinimizedIndividualEvent<factory.eventType.Event>;
12
+ }): (repos: {
13
+ offer: OfferRepo;
14
+ offerCatalog: OfferCatalogRepo;
15
+ product: ProductRepo;
16
+ }) => Promise<factory.unitPriceOffer.IUnitPriceOffer[]>;
@@ -0,0 +1,58 @@
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.findEventOffers = void 0;
13
+ const factory = require("../../../factory");
14
+ /**
15
+ * イベントオファー検索
16
+ * NotFoundエラーをハンドリングする
17
+ */
18
+ function findEventOffers(params) {
19
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
20
+ var _a, _b;
21
+ let availableOffers = [];
22
+ try {
23
+ // 興行設定があれば興行のカタログを参照する
24
+ const eventOffers = params.event.offers;
25
+ if (typeof ((_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
26
+ const eventService = yield repos.product.findById({ id: eventOffers.itemOffered.id }, ['hasOfferCatalog'], []);
27
+ const offerCatalogId = (_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id;
28
+ if (typeof offerCatalogId === 'string') {
29
+ // サブカタログIDを決定
30
+ let subOfferCatalogId = offerCatalogId;
31
+ const offerCatalogFirstElement = yield repos.offerCatalog.findFirstItemListElementById({ id: offerCatalogId });
32
+ if (offerCatalogFirstElement.typeOf === 'OfferCatalog') {
33
+ subOfferCatalogId = offerCatalogFirstElement.id;
34
+ }
35
+ const { offers } = yield repos.offer.searchAllByOfferCatalogId({
36
+ subOfferCatalog: { id: subOfferCatalogId }
37
+ });
38
+ availableOffers = offers;
39
+ }
40
+ }
41
+ else {
42
+ throw new factory.errors.NotFound('event.offers.itemOffered.id');
43
+ }
44
+ }
45
+ catch (error) {
46
+ let throwsError = true;
47
+ // 万が一カタログが見つからない場合に対応
48
+ if (error instanceof factory.errors.NotFound) {
49
+ throwsError = false;
50
+ }
51
+ if (throwsError) {
52
+ throw error;
53
+ }
54
+ }
55
+ return availableOffers;
56
+ });
57
+ }
58
+ exports.findEventOffers = findEventOffers;
@@ -15,9 +15,9 @@ function validateAccount(params) {
15
15
  return (repos) => __awaiter(this, void 0, void 0, function* () {
16
16
  var _a, _b, _c, _d;
17
17
  // 引き出し口座の存在を確認する
18
- const paymentMethodType = (_a = params.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.typeOf;
18
+ const paymentMethodType = (_a = params.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.identifier;
19
19
  if (typeof paymentMethodType !== 'string') {
20
- throw new factory.errors.ArgumentNull('object.paymentMethod.typeOf');
20
+ throw new factory.errors.ArgumentNull('object.paymentMethod.identifier');
21
21
  }
22
22
  const accountNumber = (_b = params.object.paymentMethod) === null || _b === void 0 ? void 0 : _b.accountId;
23
23
  if (typeof accountNumber !== 'string') {
@@ -8,16 +8,16 @@ const factory = require("../../../factory");
8
8
  const settings_1 = require("../../../settings");
9
9
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
10
10
  function createStartParams(params) {
11
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
11
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
12
12
  const paymentServiceId = (params.paymentService !== undefined)
13
13
  ? String(params.paymentService.id)
14
14
  : '';
15
15
  const paymentMethodType = (params.paymentService !== undefined)
16
16
  // FaceToFace以外は、プロダクトから決済方法タイプを自動取得
17
17
  ? (_a = params.paymentService.serviceType) === null || _a === void 0 ? void 0 : _a.codeValue
18
- : (_b = params.object.paymentMethod) === null || _b === void 0 ? void 0 : _b.typeOf;
18
+ : (_b = params.object.paymentMethod) === null || _b === void 0 ? void 0 : _b.identifier;
19
19
  if (typeof paymentMethodType !== 'string') {
20
- throw new factory.errors.ArgumentNull('object.paymentMethod.typeOf');
20
+ throw new factory.errors.ArgumentNull('object.paymentMethod.identifier');
21
21
  }
22
22
  let totalPaymentDue;
23
23
  switch (params.paymentServiceType) {
@@ -68,10 +68,16 @@ function createStartParams(params) {
68
68
  }
69
69
  }
70
70
  else if (params.paymentServiceType === factory.service.paymentService.PaymentServiceType.CreditCard) {
71
+ const creditCardPaymentServiceOutput = (_l = params.paymentService) === null || _l === void 0 ? void 0 : _l.serviceOutput;
72
+ const invoiceAsServiceOutput = (Array.isArray(creditCardPaymentServiceOutput))
73
+ ? creditCardPaymentServiceOutput.find((output) => output.typeOf === 'Invoice')
74
+ : creditCardPaymentServiceOutput;
71
75
  // カード通貨区分が存在すれば適用
72
- const creditCardAsPaymentServiceOutputCurrency = (_p = (_o = (_m = (_l = params.paymentService) === null || _l === void 0 ? void 0 : _l.serviceOutput) === null || _m === void 0 ? void 0 : _m.paymentMethod) === null || _o === void 0 ? void 0 : _o.amount) === null || _p === void 0 ? void 0 : _p.currency;
73
- if (typeof creditCardAsPaymentServiceOutputCurrency === 'string') {
74
- paymentMethodCurrency = creditCardAsPaymentServiceOutputCurrency;
76
+ if ((invoiceAsServiceOutput === null || invoiceAsServiceOutput === void 0 ? void 0 : invoiceAsServiceOutput.typeOf) === 'Invoice') {
77
+ const creditCardAsPaymentServiceOutputCurrency = (_o = (_m = invoiceAsServiceOutput.paymentMethod) === null || _m === void 0 ? void 0 : _m.amount) === null || _o === void 0 ? void 0 : _o.currency;
78
+ if (typeof creditCardAsPaymentServiceOutputCurrency === 'string') {
79
+ paymentMethodCurrency = creditCardAsPaymentServiceOutputCurrency;
80
+ }
75
81
  }
76
82
  }
77
83
  const paymentMethodAmount = {
@@ -79,22 +85,24 @@ function createStartParams(params) {
79
85
  currency: paymentMethodCurrency,
80
86
  value: params.amount
81
87
  };
82
- const paymentMethod = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ additionalProperty: (Array.isArray((_q = params.object.paymentMethod) === null || _q === void 0 ? void 0 : _q.additionalProperty))
83
- ? (_r = params.object.paymentMethod) === null || _r === void 0 ? void 0 : _r.additionalProperty
84
- : [], name: (typeof ((_s = params.object.paymentMethod) === null || _s === void 0 ? void 0 : _s.name) === 'string')
88
+ const paymentMethod = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ additionalProperty: (Array.isArray((_p = params.object.paymentMethod) === null || _p === void 0 ? void 0 : _p.additionalProperty))
89
+ ? (_q = params.object.paymentMethod) === null || _q === void 0 ? void 0 : _q.additionalProperty
90
+ : [], name: (typeof ((_r = params.object.paymentMethod) === null || _r === void 0 ? void 0 : _r.name) === 'string')
85
91
  ? params.object.paymentMethod.name
86
92
  : paymentMethodType,
87
93
  // MonetaryAmount対応(2023-08-14~)
88
- amount: (settings_1.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT) ? paymentMethodAmount : params.amount, paymentMethodId: params.transactionNumber, typeOf: paymentMethodType }, (typeof ((_t = params.object.paymentMethod) === null || _t === void 0 ? void 0 : _t.description) === 'string')
89
- ? { description: (_u = params.object.paymentMethod) === null || _u === void 0 ? void 0 : _u.description }
94
+ amount: (settings_1.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT) ? paymentMethodAmount : params.amount,
95
+ // paymentMethodId: params.transactionNumber, // object.paymentMethodIdへ完全移行(2023-08-30~)
96
+ identifier: paymentMethodType }, (typeof ((_s = params.object.paymentMethod) === null || _s === void 0 ? void 0 : _s.description) === 'string')
97
+ ? { description: (_t = params.object.paymentMethod) === null || _t === void 0 ? void 0 : _t.description }
90
98
  : undefined), (totalPaymentDue !== undefined)
91
99
  ? { totalPaymentDue: totalPaymentDue }
92
- : undefined), (typeof accountId === 'string') ? { accountId: accountId } : undefined), (typeof ((_v = params.object.paymentMethod) === null || _v === void 0 ? void 0 : _v.method) === 'string')
93
- ? { method: (_w = params.object.paymentMethod) === null || _w === void 0 ? void 0 : _w.method }
94
- : undefined), (((_x = params.object.paymentMethod) === null || _x === void 0 ? void 0 : _x.creditCard) !== undefined)
95
- ? { creditCard: (_y = params.object.paymentMethod) === null || _y === void 0 ? void 0 : _y.creditCard }
96
- : undefined), (Array.isArray((_z = params.object.paymentMethod) === null || _z === void 0 ? void 0 : _z.movieTickets))
97
- ? { movieTickets: (_0 = params.object.paymentMethod) === null || _0 === void 0 ? void 0 : _0.movieTickets }
100
+ : undefined), (typeof accountId === 'string') ? { accountId: accountId } : undefined), (typeof ((_u = params.object.paymentMethod) === null || _u === void 0 ? void 0 : _u.method) === 'string')
101
+ ? { method: (_v = params.object.paymentMethod) === null || _v === void 0 ? void 0 : _v.method }
102
+ : undefined), (((_w = params.object.paymentMethod) === null || _w === void 0 ? void 0 : _w.creditCard) !== undefined)
103
+ ? { creditCard: (_x = params.object.paymentMethod) === null || _x === void 0 ? void 0 : _x.creditCard }
104
+ : undefined), (Array.isArray((_y = params.object.paymentMethod) === null || _y === void 0 ? void 0 : _y.movieTickets))
105
+ ? { movieTickets: (_z = params.object.paymentMethod) === null || _z === void 0 ? void 0 : _z.movieTickets }
98
106
  : undefined);
99
107
  const object = {
100
108
  // パラメータから必要なもののみ取り込む
@@ -105,7 +113,7 @@ function createStartParams(params) {
105
113
  onPaymentStatusChanged: { informPayment: informPaymentParams },
106
114
  paymentMethod
107
115
  };
108
- return Object.assign({ project: { typeOf: factory.organizationType.Project, id: params.project.id }, transactionNumber: params.transactionNumber, typeOf: factory.assetTransactionType.Pay, agent: params.agent, recipient: params.recipient, object, expires: params.expires }, (typeof ((_1 = params.location) === null || _1 === void 0 ? void 0 : _1.typeOf) === 'string')
116
+ return Object.assign({ project: { typeOf: factory.organizationType.Project, id: params.project.id }, transactionNumber: params.transactionNumber, typeOf: factory.assetTransactionType.Pay, agent: params.agent, recipient: params.recipient, object, expires: params.expires }, (typeof ((_0 = params.location) === null || _0 === void 0 ? void 0 : _0.typeOf) === 'string')
109
117
  ? { location: params.location }
110
118
  : undefined);
111
119
  }
@@ -33,9 +33,9 @@ function createPayObject(params) {
33
33
  var _a;
34
34
  const transaction = params.transaction;
35
35
  const paymentMethod = transaction.object.paymentMethod;
36
- const paymentMethodType = String(paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.typeOf);
36
+ const paymentMethodType = String(paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.identifier);
37
37
  const additionalProperty = paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.additionalProperty;
38
- const paymentMethodId = (typeof (paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.paymentMethodId) === 'string') ? paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.paymentMethodId : transaction.id;
38
+ const paymentMethodId = transaction.object.paymentMethodId;
39
39
  const paymentMethodName = (typeof (paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.name) === 'string') ? paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.name : paymentMethodType;
40
40
  // MonetaryAmount対応(2023-08-13~)
41
41
  const paymentMethodAmountValue = (typeof (paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.amount) === 'number')
@@ -139,7 +139,7 @@ function createPayObjectServiceOutput(params) {
139
139
  // }
140
140
  break;
141
141
  case factory.service.paymentService.PaymentServiceType.MovieTicket:
142
- const paymentMethodType = paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.typeOf;
142
+ const paymentMethodType = paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.identifier;
143
143
  const movieTickets = paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.movieTickets;
144
144
  if (Array.isArray(movieTickets)) {
145
145
  paymentServiceOutput = movieTickets.map((movieTicket) => {
@@ -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");
@@ -205,7 +203,7 @@ function fixPaymentService(params) {
205
203
  }
206
204
  function validateSeller(params) {
207
205
  return (repos) => __awaiter(this, void 0, void 0, function* () {
208
- var _a, _b, _c;
206
+ var _a, _b, _c, _d;
209
207
  const sellerId = (_a = params.recipient) === null || _a === void 0 ? void 0 : _a.id;
210
208
  if (typeof sellerId !== 'string') {
211
209
  throw new factory.errors.ArgumentNull('recipient.id');
@@ -219,14 +217,26 @@ function validateSeller(params) {
219
217
  if (seller === undefined) {
220
218
  throw new factory.errors.NotFound(factory.organizationType.Corporation);
221
219
  }
222
- const paymentMethodType = (_b = params.object.paymentMethod) === null || _b === void 0 ? void 0 : _b.typeOf;
220
+ const paymentMethodType = (_b = params.object.paymentMethod) === null || _b === void 0 ? void 0 : _b.identifier;
223
221
  if (typeof paymentMethodType !== 'string') {
224
- throw new factory.errors.ArgumentNull('object.paymentMethod.typeOf');
222
+ throw new factory.errors.ArgumentNull('object.paymentMethod.identifier');
225
223
  }
226
- // 販売者の対応決済方法かどうか確認
227
- const paymentAccepted = (_c = seller.paymentAccepted) === null || _c === void 0 ? void 0 : _c.some((a) => a.paymentMethodType === paymentMethodType);
228
- if (paymentAccepted !== true) {
229
- throw new factory.errors.Argument('object.paymentMethod.typeOf', `payment not accepted`);
224
+ // FaceToFaceの場合、決済方法区分未指定に対応(2023-08-29~)
225
+ if (params.object.typeOf === factory.service.paymentService.PaymentServiceType.FaceToFace) {
226
+ if (paymentMethodType.length > 0) {
227
+ // 販売者の対応決済方法かどうか確認
228
+ const paymentAccepted = (_c = seller.paymentAccepted) === null || _c === void 0 ? void 0 : _c.some((a) => a.paymentMethodType === paymentMethodType);
229
+ if (paymentAccepted !== true) {
230
+ throw new factory.errors.Argument('object.paymentMethod.identifier', `payment not accepted`);
231
+ }
232
+ }
233
+ }
234
+ else {
235
+ // 販売者の対応決済方法かどうか確認
236
+ const paymentAccepted = (_d = seller.paymentAccepted) === null || _d === void 0 ? void 0 : _d.some((a) => a.paymentMethodType === paymentMethodType);
237
+ if (paymentAccepted !== true) {
238
+ throw new factory.errors.Argument('object.paymentMethod.identifier', `payment not accepted`);
239
+ }
230
240
  }
231
241
  });
232
242
  }
@@ -301,6 +311,7 @@ function saveAuthorizeResult(params) {
301
311
  */
302
312
  function confirm(params) {
303
313
  return (repos) => __awaiter(this, void 0, void 0, function* () {
314
+ var _a, _b;
304
315
  let transaction;
305
316
  // 取引存在確認
306
317
  if (typeof params.id === 'string') {
@@ -318,29 +329,24 @@ function confirm(params) {
318
329
  else {
319
330
  throw new factory.errors.ArgumentNull('Transaction ID or Transaction Number');
320
331
  }
332
+ let overwritingPaymentMethodIdentifier;
333
+ if (transaction.object.typeOf === factory.service.paymentService.PaymentServiceType.FaceToFace) {
334
+ const specifiedPaymentMethodIdentifire = (_b = (_a = params.object) === null || _a === void 0 ? void 0 : _a.paymentMethod) === null || _b === void 0 ? void 0 : _b.identifier;
335
+ if (typeof specifiedPaymentMethodIdentifire === 'string' && specifiedPaymentMethodIdentifire.length > 0) {
336
+ overwritingPaymentMethodIdentifier = specifiedPaymentMethodIdentifire;
337
+ transaction.object.paymentMethod.identifier = overwritingPaymentMethodIdentifier;
338
+ // transaction.object.paymentMethod.typeOf = overwritingPaymentMethodIdentifier;
339
+ }
340
+ }
321
341
  const order = yield fixOrderAsPurpose(params, transaction)(repos);
322
342
  const potentialActions = (0, potentialActions_1.createPotentialActions)({
323
343
  transaction: transaction,
324
344
  potentialActions: params.potentialActions,
325
345
  order
326
346
  });
327
- yield repos.assetTransaction.confirm({
328
- typeOf: factory.assetTransactionType.Pay,
329
- id: transaction.id,
330
- result: {},
331
- // sync対応(2023-01-14~)
332
- potentialActions: (settings_1.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING)
333
- ? { pay: [] }
334
- : potentialActions
335
- });
336
- // sync対応(2023-01-14~)
337
- if (settings_1.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING) {
338
- if (Array.isArray(potentialActions.pay)) {
339
- for (const payAction of potentialActions.pay) {
340
- yield (0, payment_1.pay)(payAction)(repos);
341
- }
342
- }
343
- }
347
+ yield repos.assetTransaction.confirm(Object.assign({ typeOf: factory.assetTransactionType.Pay, id: transaction.id, result: {}, potentialActions: potentialActions }, (typeof overwritingPaymentMethodIdentifier === 'string')
348
+ ? { object: { paymentMethod: { identifier: overwritingPaymentMethodIdentifier } } }
349
+ : undefined));
344
350
  });
345
351
  }
346
352
  exports.confirm = confirm;
@@ -373,23 +379,11 @@ function fixOrderAsPurpose(params, transaction) {
373
379
  */
374
380
  function cancel(params) {
375
381
  return (repos) => __awaiter(this, void 0, void 0, function* () {
376
- const transaction = yield repos.assetTransaction.cancel({
382
+ yield repos.assetTransaction.cancel({
377
383
  typeOf: factory.assetTransactionType.Pay,
378
384
  id: params.id,
379
385
  transactionNumber: params.transactionNumber
380
386
  });
381
- // sync対応(2023-01-14~)
382
- if (settings_1.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING) {
383
- const payTransactionAsObject = {
384
- project: transaction.project,
385
- typeOf: transaction.typeOf,
386
- id: transaction.id,
387
- transactionNumber: transaction.transactionNumber,
388
- object: transaction.object,
389
- recipient: transaction.recipient
390
- };
391
- yield (0, payment_1.voidPayment)({ object: payTransactionAsObject })(repos);
392
- }
393
387
  });
394
388
  }
395
389
  exports.cancel = cancel;
@@ -404,6 +398,9 @@ function exportTasksById(params) {
404
398
  id: params.id
405
399
  });
406
400
  const potentialActions = transaction.potentialActions;
401
+ if (transaction.status === factory.transactionStatusType.InProgress) {
402
+ throw new factory.errors.NotImplemented(`Transaction status "${transaction.status}" not implemented.`);
403
+ }
407
404
  const taskAttributes = [];
408
405
  // タスク実行日時バッファの指定があれば調整
409
406
  let taskRunsAt = new Date();
@@ -430,6 +427,31 @@ function exportTasksById(params) {
430
427
  executionResults: [],
431
428
  data: { object: payTransactionAsObject }
432
429
  };
430
+ // OnAssetTransactionStatusChangedを追加(2023-08-30~)
431
+ const onAssetTransactionStatusChangedTaskData = {
432
+ project: transaction.project,
433
+ object: {
434
+ typeOf: factory.assetTransactionType.Pay,
435
+ transactionNumber: transaction.transactionNumber,
436
+ status: transaction.status
437
+ },
438
+ purpose: {
439
+ confirmationNumber: '',
440
+ orderNumber: '',
441
+ typeOf: 'Order'
442
+ },
443
+ useOnOrderStatusChanged: true
444
+ };
445
+ const onAssetTransactionStatusChangedTask = {
446
+ project: transaction.project,
447
+ name: factory.taskName.OnAssetTransactionStatusChanged,
448
+ status: factory.taskStatus.Ready,
449
+ runsAt: taskRunsAt,
450
+ remainingNumberOfTries: 10,
451
+ numberOfTried: 0,
452
+ executionResults: [],
453
+ data: onAssetTransactionStatusChangedTaskData
454
+ };
433
455
  switch (transaction.status) {
434
456
  case factory.transactionStatusType.Confirmed:
435
457
  const payActions = potentialActions === null || potentialActions === void 0 ? void 0 : potentialActions.pay;
@@ -450,13 +472,10 @@ function exportTasksById(params) {
450
472
  }
451
473
  break;
452
474
  case factory.transactionStatusType.Canceled:
453
- // sync対応(2023-01-14~)
454
- if (!settings_1.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING) {
455
- taskAttributes.push(voidPaymentTasks);
456
- }
475
+ taskAttributes.push(voidPaymentTasks, onAssetTransactionStatusChangedTask);
457
476
  break;
458
477
  case factory.transactionStatusType.Expired:
459
- taskAttributes.push(voidPaymentTasks);
478
+ taskAttributes.push(voidPaymentTasks, onAssetTransactionStatusChangedTask);
460
479
  break;
461
480
  default:
462
481
  throw new factory.errors.NotImplemented(`Transaction status "${transaction.status}" not implemented.`);
@@ -482,9 +501,9 @@ function searchGMOTrade(params) {
482
501
  // throw new factory.errors.Argument('transactionNumber', 'must be confirmed');
483
502
  // }
484
503
  // CreditCard系統の決済方法タイプは動的
485
- const paymentMethodType = (_a = assetTransaction.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.typeOf;
504
+ const paymentMethodType = (_a = assetTransaction.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.identifier;
486
505
  if (typeof paymentMethodType !== 'string') {
487
- throw new factory.errors.ArgumentNull('object.paymentMethod.typeOf');
506
+ throw new factory.errors.ArgumentNull('object.paymentMethod.identifier');
488
507
  }
489
508
  const paymentServiceId = String(assetTransaction.object.id);
490
509
  const availableChannel = yield repos.product.findAvailableChannel({
@@ -6,7 +6,7 @@ exports.createStartParams = void 0;
6
6
  */
7
7
  const factory = require("../../../factory");
8
8
  function createStartParams(params) {
9
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
9
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
10
10
  const paymentMethodType = (_a = params.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.typeOf;
11
11
  if (typeof paymentMethodType !== 'string') {
12
12
  throw new factory.errors.ArgumentNull('object.paymentMethod.typeOf');
@@ -23,7 +23,13 @@ function createStartParams(params) {
23
23
  let refundFee;
24
24
  if (((_g = params.paymentService) === null || _g === void 0 ? void 0 : _g.typeOf) === factory.service.paymentService.PaymentServiceType.CreditCard) {
25
25
  // カード通貨区分の存在する決済サービスを考慮(2023-08-09~)
26
- const paymentServiceOutputAmountCurrency = (_k = (_j = (_h = params.paymentService.serviceOutput) === null || _h === void 0 ? void 0 : _h.paymentMethod) === null || _j === void 0 ? void 0 : _j.amount) === null || _k === void 0 ? void 0 : _k.currency;
26
+ const invoiceAsServiceOutput = (Array.isArray(params.paymentService.serviceOutput))
27
+ ? params.paymentService.serviceOutput.find((output) => output.typeOf === 'Invoice')
28
+ : params.paymentService.serviceOutput;
29
+ let paymentServiceOutputAmountCurrency;
30
+ if ((invoiceAsServiceOutput === null || invoiceAsServiceOutput === void 0 ? void 0 : invoiceAsServiceOutput.typeOf) === 'Invoice') {
31
+ paymentServiceOutputAmountCurrency = (_j = (_h = invoiceAsServiceOutput === null || invoiceAsServiceOutput === void 0 ? void 0 : invoiceAsServiceOutput.paymentMethod) === null || _h === void 0 ? void 0 : _h.amount) === null || _j === void 0 ? void 0 : _j.currency;
32
+ }
27
33
  if (typeof paymentServiceOutputAmountCurrency !== 'string') {
28
34
  if (typeof params.object.refundFee === 'number') {
29
35
  refundFee = params.object.refundFee;
@@ -94,7 +94,8 @@ function createTransactionObject(params) {
94
94
  ids: params.acceptedOffers.map((o) => o.id),
95
95
  itemOffered: { id: String(params.product.id) },
96
96
  onlyValid: true,
97
- addSortIndex: false
97
+ addSortIndex: false,
98
+ useIncludeInDataCatalog: false
98
99
  })(repos);
99
100
  const transactionObject = [];
100
101
  for (const acceptedOffer of params.acceptedOffers) {