@chevre/domain 23.1.0-alpha.19 → 23.1.0-alpha.20

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.
@@ -14,7 +14,7 @@ interface IAcceptAction2ticketResult {
14
14
  * 決済承認前の決済採用アクションを参照する
15
15
  */
16
16
  declare function handlePrePublishedPaymentMethodIdOnAuthorizing(params: {
17
- object: Pick<IObjectWithoutDetail, 'amount' | 'issuedThrough' | 'paymentMethod'>;
17
+ object: Pick<IObjectWithoutDetail, 'amount' | 'issuedThrough' | 'paymentMethod' | 'referencesOrder'>;
18
18
  prePublishedPaymentMethodId: string;
19
19
  transaction: Pick<ITransactionInProgress<factory.transactionType.PlaceOrder>, 'agent' | 'expires' | 'id' | 'typeOf' | 'project' | 'seller'>;
20
20
  }): (repos: {
@@ -189,16 +189,13 @@ function handlePrePublishedPaymentMethodIdOnAuthorizing(params) {
189
189
  });
190
190
  }
191
191
  /**
192
- * 注文取引に保管された決済情報を承認しようとしている決済の整合性を検証する
192
+ * 決済採用と決済承認の整合性を検証する
193
193
  */
194
194
  function validatePaymentMethodByTransaction(params) {
195
- var _a, _b;
195
+ var _a, _b, _c, _d;
196
196
  const paymentServiceIdByObject = params.object.issuedThrough.id;
197
197
  const amountByObject = params.object.amount;
198
198
  const paymentMethodTypeByObject = params.object.paymentMethod;
199
- // const paymentServiceIdByTransaction = params.paymentMethodByTransaction.issuedThrough.id;
200
- // const amountByTransaction = params.paymentMethodByTransaction.paymentMethod?.amount;
201
- // const paymentMethodTypeByTransaction = params.paymentMethodByTransaction.paymentMethod?.identifier;
202
199
  const paymentServiceIdByTransaction = params.acceptObject.object.id;
203
200
  const amountByTransaction = (_a = params.acceptObject.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.amount;
204
201
  const paymentMethodTypeByTransaction = (_b = params.acceptObject.object.paymentMethod) === null || _b === void 0 ? void 0 : _b.identifier;
@@ -214,4 +211,22 @@ function validatePaymentMethodByTransaction(params) {
214
211
  if (paymentMethodTypeByObject !== paymentMethodTypeByTransaction) {
215
212
  throw new factory.errors.Argument('object.paymentMethod', 'paymentMethod must match the target of the paymentUrl');
216
213
  }
214
+ // 注文アイテム検証(2025-11-25)
215
+ let eventIdsMustBe = [];
216
+ let eventIdsByAuthorizeAction = [];
217
+ const orderedItemsByAcceptAction = (_c = params.acceptObject.object.serviceOutput) === null || _c === void 0 ? void 0 : _c.referencesOrder.orderedItem;
218
+ const orderedItemsByAuthorizeAction = (_d = params.object.referencesOrder) === null || _d === void 0 ? void 0 : _d.orderedItem;
219
+ if (Array.isArray(orderedItemsByAcceptAction)) {
220
+ eventIdsMustBe = orderedItemsByAcceptAction.map((orderedItem) => orderedItem.orderedItem.serviceOutput.reservationFor.id);
221
+ }
222
+ if (Array.isArray(orderedItemsByAuthorizeAction)) {
223
+ eventIdsByAuthorizeAction =
224
+ orderedItemsByAuthorizeAction.map((orderedItem) => orderedItem.orderedItem.serviceOutput.reservationFor.id);
225
+ }
226
+ debug('validatePaymentMethodByTransaction: eventIdsMustBe,eventIdsByAuthorizeAction:', JSON.stringify(eventIdsMustBe), JSON.stringify(eventIdsByAuthorizeAction));
227
+ const eventIdsMatched = eventIdsMustBe.length === eventIdsByAuthorizeAction.length
228
+ && eventIdsMustBe.every((eventIdMustExist) => eventIdsByAuthorizeAction.includes(eventIdMustExist));
229
+ if (!eventIdsMatched) {
230
+ throw new factory.errors.Argument('id', `referencesOrder.orderedItem between authorze and accept not matched.`);
231
+ }
217
232
  }
@@ -44,7 +44,7 @@ export declare function createAuthorizeResult(params: {
44
44
  object: factory.action.authorize.paymentMethod.any.IObjectIncludingPaymentMethodDetails;
45
45
  payTransaction: Pick<factory.assetTransaction.pay.ITransaction, 'object'>;
46
46
  /**
47
- * 決済方法チケットの承認対象が必要(請求の関連注文情報の含むため)
47
+ * 決済方法チケットの承認対象
48
48
  */
49
49
  invoiceByTicketToken?: IInvoiceByTicketToken;
50
50
  }): factory.action.authorize.paymentMethod.any.IResult;
@@ -140,8 +140,7 @@ function createMovieTicket(params) {
140
140
  };
141
141
  }
142
142
  function createAuthorizeResult(params) {
143
- var _a, _b, _c, _d, _e, _f, _g;
144
- const { invoiceByTicketToken } = params;
143
+ var _a, _b, _c, _d, _e, _f;
145
144
  const payTransactionObject = params.payTransaction.object;
146
145
  const totalPaymentDue = (_a = payTransactionObject.paymentMethod) === null || _a === void 0 ? void 0 : _a.totalPaymentDue;
147
146
  if (typeof (totalPaymentDue === null || totalPaymentDue === void 0 ? void 0 : totalPaymentDue.typeOf) !== 'string') {
@@ -167,15 +166,15 @@ function createAuthorizeResult(params) {
167
166
  }
168
167
  }
169
168
  let invoiceOrderItems;
170
- if (typeof (invoiceByTicketToken === null || invoiceByTicketToken === void 0 ? void 0 : invoiceByTicketToken.paymentMethodId) === 'string') {
171
- if (Array.isArray((_e = invoiceByTicketToken.referencesOrder) === null || _e === void 0 ? void 0 : _e.orderedItem)) {
172
- invoiceOrderItems = invoiceByTicketToken.referencesOrder.orderedItem;
169
+ if (params.object.referencesOrder.typeOf === factory.order.OrderType.Order) {
170
+ if (Array.isArray(params.object.referencesOrder.orderedItem)) {
171
+ invoiceOrderItems = params.object.referencesOrder.orderedItem;
173
172
  }
174
173
  }
175
174
  const referencesOrder = Object.assign({ typeOf: factory.order.OrderType.Order }, (Array.isArray(invoiceOrderItems) && invoiceOrderItems.length > 0) ? { orderedItem: invoiceOrderItems } : undefined);
176
175
  // Array対応(2023-09-02~)
177
176
  const resultAsInvoice = {
178
- accountId: (typeof ((_f = payTransactionObject.paymentMethod) === null || _f === void 0 ? void 0 : _f.accountId) === 'string')
177
+ accountId: (typeof ((_e = payTransactionObject.paymentMethod) === null || _e === void 0 ? void 0 : _e.accountId) === 'string')
179
178
  ? payTransactionObject.paymentMethod.accountId
180
179
  : '',
181
180
  issuedThrough,
@@ -186,7 +185,7 @@ function createAuthorizeResult(params) {
186
185
  paymentMethodId: (typeof payTransactionObject.paymentMethodId === 'string')
187
186
  ? payTransactionObject.paymentMethodId
188
187
  : '',
189
- name: (typeof ((_g = payTransactionObject.paymentMethod) === null || _g === void 0 ? void 0 : _g.name) === 'string')
188
+ name: (typeof ((_f = payTransactionObject.paymentMethod) === null || _f === void 0 ? void 0 : _f.name) === 'string')
190
189
  ? payTransactionObject.paymentMethod.name
191
190
  : params.object.paymentMethod,
192
191
  totalPaymentDue: totalPaymentDue,
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.3.0-alpha.3",
14
+ "@chevre/factory": "5.3.0-alpha.4",
15
15
  "@cinerino/sdk": "12.9.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.1.0-alpha.19"
118
+ "version": "23.1.0-alpha.20"
119
119
  }