@chevre/domain 21.35.0-alpha.32 → 21.35.0-alpha.33

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.
@@ -13,6 +13,7 @@ exports.validateMovieTicket = void 0;
13
13
  const createDebug = require("debug");
14
14
  const factory = require("../../../factory");
15
15
  const taskIdentifier_1 = require("../../../factory/taskIdentifier");
16
+ const settings_1 = require("../../../settings");
16
17
  const processPurchaseNumberAuth_1 = require("./processPurchaseNumberAuth");
17
18
  const debug = createDebug('chevre-domain:service:payment');
18
19
  function validateMovieTicket(params, paymentServiceId, useCheckByIdentifierIfNotYet, purpose) {
@@ -120,31 +121,27 @@ function checkByIdentifierIfNotYet(params) {
120
121
  // search from checkMovieTicketTask(2024-06-26~)
121
122
  const placeOrderId = params.purpose.id;
122
123
  if (typeof placeOrderId === 'string') {
123
- const taskIdentifier = (0, taskIdentifier_1.createCheckMovieTicketTaskIdentifier)({
124
- project: { id: params.screeningEvent.project.id },
125
- purpose: { id: placeOrderId },
126
- object: {
127
- id: params.paymentServiceId,
128
- movieTicket: {
129
- identifier: params.movieTicketIdentifier,
130
- serviceOutput: { reservationFor: { id: params.screeningEvent.id } }
124
+ if (settings_1.USE_EXPERIMENTAL_FEATURE) {
125
+ const taskIdentifier = (0, taskIdentifier_1.createCheckMovieTicketTaskIdentifier)({
126
+ project: { id: params.screeningEvent.project.id },
127
+ purpose: { id: placeOrderId },
128
+ object: {
129
+ id: params.paymentServiceId,
130
+ movieTicket: {
131
+ identifier: params.movieTicketIdentifier,
132
+ serviceOutput: { reservationFor: { id: params.screeningEvent.id } }
133
+ }
131
134
  }
132
- }
133
- });
134
- const existingCheckMovieTicketTask = yield repos.task.findByIdentifier({
135
- project: { id: params.screeningEvent.project.id },
136
- name: factory.taskName.CheckMovieTicket,
137
- identifier: taskIdentifier
138
- });
139
- debug('existingCheckMovieTicketTask:', JSON.stringify(existingCheckMovieTicketTask), 'placeOrderId:', placeOrderId);
135
+ });
136
+ const existingCheckMovieTicketTask = yield repos.task.findByIdentifier({
137
+ project: { id: params.screeningEvent.project.id },
138
+ name: factory.taskName.CheckMovieTicket,
139
+ identifier: taskIdentifier
140
+ });
141
+ debug('existingCheckMovieTicketTask:', JSON.stringify(existingCheckMovieTicketTask), 'placeOrderId:', placeOrderId);
142
+ }
140
143
  }
141
- alreadyCheckedAction = (yield repos.action.search({
142
- limit: 1,
143
- page: 1,
144
- sort: { startDate: factory.sortType.Descending },
145
- typeOf: { $eq: factory.actionType.CheckAction },
146
- actionStatus: { $in: [factory.actionStatusType.CompletedActionStatus] },
147
- object: {
144
+ alreadyCheckedAction = (yield repos.action.search(Object.assign({ limit: 1, page: 1, sort: { startDate: factory.sortType.Descending }, typeOf: { $eq: factory.actionType.CheckAction }, actionStatus: { $in: [factory.actionStatusType.CompletedActionStatus] }, object: {
148
145
  typeOf: { $eq: factory.service.paymentService.PaymentServiceType.MovieTicket },
149
146
  id: { $eq: params.paymentServiceId },
150
147
  movieTickets: {
@@ -153,8 +150,8 @@ function checkByIdentifierIfNotYet(params) {
153
150
  reservationFor: { id: { $eq: params.screeningEvent.id } } // 指定のイベントにおいて
154
151
  }
155
152
  }
156
- }
157
- }, ['_id'], [])).shift();
153
+ } }, (typeof placeOrderId === 'string') ? { purpose: { id: { $in: [placeOrderId] } } } : undefined), ['_id'], [])).shift();
154
+ debug('alreadyCheckedAction:', JSON.stringify(alreadyCheckedAction), 'placeOrderId:', placeOrderId);
158
155
  if (alreadyCheckedAction !== undefined) {
159
156
  const recipe = yield repos.action.findRecipeByAction({
160
157
  project: { id: params.screeningEvent.project.id },
@@ -91,11 +91,8 @@ function preStart(params) {
91
91
  validateAppliedReturnPolicy({ merchantReturnPolicy: appliedReturnPolicy });
92
92
  // アイテム検証
93
93
  yield validateItems({ orders, reason: params.object.reason })({ order: repos.order, reservation: repos.reservation });
94
- const transactionObject = {
95
- order: orders.map(({ confirmationNumber, orderNumber }) => ({ confirmationNumber, orderNumber })),
96
- returnPolicy: appliedReturnPolicy,
97
- reason: params.object.reason
98
- };
94
+ const transactionObject = Object.assign({ order: orders.map(({ confirmationNumber, orderNumber }) => ({ confirmationNumber, orderNumber })), returnPolicy: appliedReturnPolicy, reason: params.object.reason }, { usedReservationExists } // for debug(2024-06-26~)
95
+ );
99
96
  // fix expiresInSeconds(2022-11-30~)
100
97
  let expiresInSeconds;
101
98
  if (typeof params.expiresInSeconds === 'number') {
@@ -314,14 +311,14 @@ function getReturnPolicyByProject(params) {
314
311
  throw new Error('invalid return policy');
315
312
  }
316
313
  else {
317
- returnPolicy = {
318
- typeOf: 'MerchantReturnPolicy',
319
- restockingFee: {
314
+ returnPolicy = Object.assign({ typeOf: 'MerchantReturnPolicy', restockingFee: {
320
315
  currency: factory.priceCurrency.JPY,
321
316
  typeOf: 'MonetaryAmount',
322
317
  value: body.restockingFee.value
323
- }
324
- };
318
+ } }, {
319
+ // カスタム返品ポリシーを判定可能な属性を追加
320
+ sameAs: params.sameAs
321
+ });
325
322
  }
326
323
  break;
327
324
  case http_status_1.NOT_FOUND:
package/package.json CHANGED
@@ -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.35.0-alpha.32"
113
+ "version": "21.35.0-alpha.33"
114
114
  }