@chevre/domain 21.8.0-alpha.21 → 21.8.0-alpha.23

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.
@@ -52,6 +52,7 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
52
52
  };
53
53
  }, {
54
54
  additionalProperty: any[];
55
+ offers: any[];
55
56
  addOn: any[];
56
57
  availability: string;
57
58
  availableAtOrFrom: any[];
@@ -83,6 +84,7 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
83
84
  validRateLimit?: any;
84
85
  }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
85
86
  additionalProperty: any[];
87
+ offers: any[];
86
88
  addOn: any[];
87
89
  availability: string;
88
90
  availableAtOrFrom: any[];
@@ -114,6 +116,7 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
114
116
  validRateLimit?: any;
115
117
  }>> & Omit<import("mongoose").FlatRecord<{
116
118
  additionalProperty: any[];
119
+ offers: any[];
117
120
  addOn: any[];
118
121
  availability: string;
119
122
  availableAtOrFrom: any[];
@@ -29,6 +29,7 @@ const schema = new mongoose_1.Schema({
29
29
  availableAtOrFrom: [mongoose_1.SchemaTypes.Mixed],
30
30
  hasMerchantReturnPolicy: mongoose_1.SchemaTypes.Mixed,
31
31
  itemOffered: mongoose_1.SchemaTypes.Mixed,
32
+ offers: [mongoose_1.SchemaTypes.Mixed],
32
33
  priceCurrency: String,
33
34
  priceSpecification: mongoose_1.SchemaTypes.Mixed,
34
35
  eligibleCustomerType: mongoose_1.SchemaTypes.Mixed,
@@ -8,7 +8,7 @@ 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
  : '';
@@ -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,24 +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
94
  amount: (settings_1.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT) ? paymentMethodAmount : params.amount,
89
95
  // paymentMethodId: params.transactionNumber, // object.paymentMethodIdへ完全移行(2023-08-30~)
90
- identifier: paymentMethodType }, (typeof ((_t = params.object.paymentMethod) === null || _t === void 0 ? void 0 : _t.description) === 'string')
91
- ? { description: (_u = params.object.paymentMethod) === null || _u === void 0 ? void 0 : _u.description }
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 }
92
98
  : undefined), (totalPaymentDue !== undefined)
93
99
  ? { totalPaymentDue: totalPaymentDue }
94
- : undefined), (typeof accountId === 'string') ? { accountId: accountId } : undefined), (typeof ((_v = params.object.paymentMethod) === null || _v === void 0 ? void 0 : _v.method) === 'string')
95
- ? { method: (_w = params.object.paymentMethod) === null || _w === void 0 ? void 0 : _w.method }
96
- : undefined), (((_x = params.object.paymentMethod) === null || _x === void 0 ? void 0 : _x.creditCard) !== undefined)
97
- ? { creditCard: (_y = params.object.paymentMethod) === null || _y === void 0 ? void 0 : _y.creditCard }
98
- : undefined), (Array.isArray((_z = params.object.paymentMethod) === null || _z === void 0 ? void 0 : _z.movieTickets))
99
- ? { 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 }
100
106
  : undefined);
101
107
  const object = {
102
108
  // パラメータから必要なもののみ取り込む
@@ -107,7 +113,7 @@ function createStartParams(params) {
107
113
  onPaymentStatusChanged: { informPayment: informPaymentParams },
108
114
  paymentMethod
109
115
  };
110
- 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')
111
117
  ? { location: params.location }
112
118
  : undefined);
113
119
  }
@@ -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;
@@ -571,31 +571,64 @@ function validateProgramMembershipUsed(params) {
571
571
  if (typeof issuedThroughId !== 'string' || issuedThroughId.length === 0) {
572
572
  throw new factory.errors.ArgumentNull('acceptedOffer.itemOffered.serviceOutput.programMembershipUsed.issuedThrough.id');
573
573
  }
574
- // requestedProgramMembershipUsedの発行サービスIDから外部連携設定を取得する
575
- const permitService = yield createPermitService({ issuedThrough: { id: issuedThroughId } })(repos);
576
- // メンバーシップの存在確認
577
- const serviceOutput = yield permitService.findByIdentifier({
578
- project: { id: params.project.id },
579
- identifier: programMembershipUsedIdentifier,
580
- issuedThrough: { typeOf: factory.product.ProductType.MembershipService }
581
- });
582
- // 有効期間のチェック
583
- if (serviceOutput.validFrom === undefined || serviceOutput.validFrom === null
584
- || serviceOutput.validUntil === undefined || serviceOutput.validUntil === null) {
585
- throw new factory.errors.Argument('acceptedOffer.itemOffered.serviceOutput.programMembershipUsed', 'not valid programMembership');
586
- }
587
- if (moment(serviceOutput.validFrom)
588
- .isAfter(moment(now))
589
- || moment(serviceOutput.validUntil)
590
- .isBefore(moment(now))) {
591
- throw new factory.errors.Argument('acceptedOffer.itemOffered.serviceOutput.programMembershipUsed', 'unavailable programMembership');
574
+ const permitIssuedThrough = yield repos.product.findById({ id: issuedThroughId }, ['_id', 'typeOf', 'project', 'serviceType', 'serviceOutput'], []);
575
+ switch (permitIssuedThrough.typeOf) {
576
+ // 発行サービスがCreditCardのケースに対応(2023-09-01~)
577
+ case factory.service.paymentService.PaymentServiceType.CreditCard:
578
+ // 決済サービスのserviceOutputにPermitが存在すれば、設定されたメンバーシップ区分のPermitをprogramMembershipUsedとして適用する
579
+ let issuedThroughServiceType;
580
+ if (Array.isArray(permitIssuedThrough.serviceOutput)) {
581
+ const serviceOutputAsPermit = permitIssuedThrough.serviceOutput.find((output) => output.typeOf === factory.permit.PermitType.Permit);
582
+ if ((serviceOutputAsPermit === null || serviceOutputAsPermit === void 0 ? void 0 : serviceOutputAsPermit.typeOf) === factory.permit.PermitType.Permit) {
583
+ issuedThroughServiceType = serviceOutputAsPermit.issuedThrough.serviceType;
584
+ }
585
+ }
586
+ if ((issuedThroughServiceType === null || issuedThroughServiceType === void 0 ? void 0 : issuedThroughServiceType.typeOf) === 'CategoryCode') {
587
+ programMembershipUsed = {
588
+ project: permitIssuedThrough.project,
589
+ typeOf: factory.permit.PermitType.Permit,
590
+ identifier: programMembershipUsedIdentifier,
591
+ issuedThrough: {
592
+ id: permitIssuedThrough.id,
593
+ serviceType: issuedThroughServiceType,
594
+ typeOf: permitIssuedThrough.typeOf
595
+ }
596
+ };
597
+ }
598
+ else {
599
+ throw new factory.errors.Argument('acceptedOffer.itemOffered.serviceOutput.programMembershipUsed', 'issuedThrough has no serviceOutput as Permit');
600
+ }
601
+ break;
602
+ case factory.product.ProductType.MembershipService:
603
+ // requestedProgramMembershipUsedの発行サービスIDから外部連携設定を取得する
604
+ const permitService = yield createPermitService({ issuedThrough: { id: issuedThroughId } })(repos);
605
+ // メンバーシップの存在確認
606
+ const serviceOutput = yield permitService.findByIdentifier({
607
+ project: { id: params.project.id },
608
+ identifier: programMembershipUsedIdentifier,
609
+ issuedThrough: { typeOf: factory.product.ProductType.MembershipService }
610
+ });
611
+ // 有効期間のチェック
612
+ if (serviceOutput.validFrom === undefined || serviceOutput.validFrom === null
613
+ || serviceOutput.validUntil === undefined || serviceOutput.validUntil === null) {
614
+ throw new factory.errors.Argument('acceptedOffer.itemOffered.serviceOutput.programMembershipUsed', 'not valid programMembership');
615
+ }
616
+ if (moment(serviceOutput.validFrom)
617
+ .isAfter(moment(now))
618
+ || moment(serviceOutput.validUntil)
619
+ .isBefore(moment(now))) {
620
+ throw new factory.errors.Argument('acceptedOffer.itemOffered.serviceOutput.programMembershipUsed', 'unavailable programMembership');
621
+ }
622
+ programMembershipUsed = {
623
+ project: serviceOutput.project,
624
+ typeOf: serviceOutput.typeOf,
625
+ identifier: serviceOutput.identifier,
626
+ issuedThrough: serviceOutput.issuedThrough
627
+ };
628
+ break;
629
+ default:
630
+ throw new factory.errors.Argument('acceptedOffer.itemOffered.serviceOutput.programMembershipUsed', `${permitIssuedThrough.typeOf} not implemented`);
592
631
  }
593
- programMembershipUsed = {
594
- project: serviceOutput.project,
595
- typeOf: serviceOutput.typeOf,
596
- identifier: serviceOutput.identifier,
597
- issuedThrough: serviceOutput.issuedThrough
598
- };
599
632
  }
600
633
  return programMembershipUsed;
601
634
  });
@@ -299,6 +299,7 @@ function createReservation(params) {
299
299
  }
300
300
  return reservationItem;
301
301
  }
302
+ // tslint:disable-next-line:max-func-body-length
302
303
  function coaTicket2offer(params) {
303
304
  var _a, _b;
304
305
  // 適用通貨区分
@@ -322,7 +323,6 @@ function coaTicket2offer(params) {
322
323
  }]
323
324
  : undefined;
324
325
  const unitPriceSpec = {
325
- // project: { typeOf: factory.organizationType.Project, id: params.project.id },
326
326
  typeOf: factory.priceSpecificationType.UnitPriceSpecification,
327
327
  price: 0,
328
328
  priceCurrency: factory.priceCurrency.JPY,
@@ -332,15 +332,25 @@ function coaTicket2offer(params) {
332
332
  unitCode: factory.unitCode.C62,
333
333
  value: 1
334
334
  }
335
- // appliesToMovieTicket?: {};
336
335
  };
337
336
  const identifier = (0, util_1.format)('%s-%s-%s', factory.service.webAPI.Identifier.COA, params.theaterCode, params.ticketResult.ticketCode);
338
- return Object.assign(Object.assign(Object.assign({ project: { typeOf: factory.organizationType.Project, id: params.project.id }, typeOf: factory.offerType.Offer, priceCurrency: factory.priceCurrency.JPY, id: '', identifier: identifier, name: {
339
- ja: params.ticketResult.ticketName,
340
- en: (typeof params.ticketResult.ticketNameEng === 'string')
341
- ? params.ticketResult.ticketNameEng
342
- : ''
343
- }, description: {
337
+ const offerName = {
338
+ ja: params.ticketResult.ticketName,
339
+ en: (typeof params.ticketResult.ticketNameEng === 'string')
340
+ ? params.ticketResult.ticketNameEng
341
+ : ''
342
+ };
343
+ const subOfferPriceSpec = {
344
+ price: unitPriceSpec.price,
345
+ typeOf: unitPriceSpec.typeOf
346
+ };
347
+ const subOffers = [{
348
+ typeOf: factory.offerType.Offer,
349
+ identifier: identifier,
350
+ name: offerName,
351
+ priceSpecification: subOfferPriceSpec
352
+ }];
353
+ return Object.assign(Object.assign(Object.assign({ project: { typeOf: factory.organizationType.Project, id: params.project.id }, typeOf: factory.offerType.Offer, priceCurrency: factory.priceCurrency.JPY, id: '', identifier: identifier, name: offerName, description: {
344
354
  ja: '',
345
355
  en: ''
346
356
  }, alternateName: {
@@ -350,7 +360,7 @@ function coaTicket2offer(params) {
350
360
  : ''
351
361
  }, availability: factory.itemAvailability.InStock, itemOffered: {
352
362
  typeOf: factory.product.ProductType.EventService
353
- }, priceSpecification: unitPriceSpec }, (Array.isArray(eligibleMembershipType)) ? { eligibleMembershipType } : undefined), (Array.isArray(eligibleMonetaryAmount)) ? { eligibleMonetaryAmount } : undefined), { additionalProperty: [
363
+ }, offers: subOffers, priceSpecification: unitPriceSpec }, (Array.isArray(eligibleMembershipType)) ? { eligibleMembershipType } : undefined), (Array.isArray(eligibleMonetaryAmount)) ? { eligibleMonetaryAmount } : undefined), { additionalProperty: [
354
364
  { name: 'theaterCode', value: params.theaterCode },
355
365
  ...Object.keys(params.ticketResult)
356
366
  .map((key) => {
@@ -186,9 +186,14 @@ function processVoidPayTransaction(params) {
186
186
  project: { id: { $eq: action.project.id } },
187
187
  typeOf: factory.assetTransactionType.Pay,
188
188
  transactionNumber: { $eq: transactionNumber }
189
- });
190
- if (payTransactions.length > 0) {
191
- yield PayTransactionService.cancel({ transactionNumber })(repos);
189
+ }, ['_id', 'status']);
190
+ const payTransaction = payTransactions.shift();
191
+ if (payTransaction !== undefined) {
192
+ // ステータス検証(Expiredから実行される可能性がある)
193
+ if (payTransaction.status !== factory.transactionStatusType.Canceled
194
+ && payTransaction.status !== factory.transactionStatusType.Expired) {
195
+ yield PayTransactionService.cancel({ transactionNumber })(repos);
196
+ }
192
197
  }
193
198
  }
194
199
  yield repos.action.cancel({ typeOf: action.typeOf, id: action.id });
@@ -149,10 +149,10 @@ function authorizeSeatReservationActions2requiredMovieTickets(params) {
149
149
  appliesToMovieTickets4paymentMethod = appliesToMovieTickets4reservation.filter((a) => {
150
150
  return a.serviceOutput.typeOf === paymentMethodType;
151
151
  });
152
- }
153
- else if (typeof (appliesToMovieTickets4reservation === null || appliesToMovieTickets4reservation === void 0 ? void 0 : appliesToMovieTickets4reservation.identifier) === 'string') {
154
- // Arrayでない場合を廃止(2022-08-01~)
155
- throw new factory.errors.NotImplemented('appliesToMovieTickets.typeOf as string not implemented');
152
+ // Array以外への考慮自体を廃止(2023-09-01~)
153
+ // } else if (typeof appliesToMovieTickets4reservation?.identifier === 'string') {
154
+ // // Arrayでない場合を廃止(2022-08-01~)
155
+ // throw new factory.errors.NotImplemented('appliesToMovieTickets.typeOf as string not implemented');
156
156
  }
157
157
  if (Array.isArray(appliesToMovieTickets4paymentMethod) && appliesToMovieTickets4paymentMethod.length > 0) {
158
158
  appliesToMovieTickets4paymentMethod.forEach((appliesToMovieTicket) => {
package/package.json CHANGED
@@ -9,8 +9,8 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.328.0",
13
- "@cinerino/sdk": "3.165.0",
12
+ "@chevre/factory": "4.329.0-alpha.1",
13
+ "@cinerino/sdk": "3.166.0-alpha.4",
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.0",
16
16
  "@sendgrid/mail": "6.4.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.21"
120
+ "version": "21.8.0-alpha.23"
121
121
  }