@chevre/domain 24.0.0-alpha.1 → 24.0.0-alpha.11

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 (184) hide show
  1. package/lib/chevre/repo/acceptedPaymentMethod.js +1 -1
  2. package/lib/chevre/repo/additionalProperty.js +1 -1
  3. package/lib/chevre/repo/aggregateOffer.js +1 -1
  4. package/lib/chevre/repo/confirmationNumber.js +2 -4
  5. package/lib/chevre/repo/creativeWork.js +1 -1
  6. package/lib/chevre/repo/eventOffer.js +1 -1
  7. package/lib/chevre/repo/eventSeries.js +1 -1
  8. package/lib/chevre/repo/identity.js +1 -2
  9. package/lib/chevre/repo/issuer.js +2 -4
  10. package/lib/chevre/repo/message.js +1 -1
  11. package/lib/chevre/repo/mongoose/schemas/transaction.js +31 -0
  12. package/lib/chevre/repo/note.js +1 -1
  13. package/lib/chevre/repo/noteAboutOrder.js +1 -1
  14. package/lib/chevre/repo/offer/unitPriceInCatalog.js +1 -1
  15. package/lib/chevre/repo/offerItemCondition.js +1 -1
  16. package/lib/chevre/repo/order.js +1 -1
  17. package/lib/chevre/repo/orderInTransaction.d.ts +8 -0
  18. package/lib/chevre/repo/orderInTransaction.js +17 -4
  19. package/lib/chevre/repo/orderNumber.d.ts +3 -2
  20. package/lib/chevre/repo/orderNumber.js +25 -32
  21. package/lib/chevre/repo/place/movieTheater.js +1 -1
  22. package/lib/chevre/repo/place/seat.js +1 -1
  23. package/lib/chevre/repo/product.js +1 -1
  24. package/lib/chevre/repo/productOffer.js +1 -1
  25. package/lib/chevre/repo/project.js +1 -1
  26. package/lib/chevre/repo/reservation.js +1 -1
  27. package/lib/chevre/repo/role.js +1 -2
  28. package/lib/chevre/repo/seller.js +1 -1
  29. package/lib/chevre/repo/serviceOutputIdentifier.js +2 -4
  30. package/lib/chevre/repo/transaction/placeOrder.d.ts +140 -0
  31. package/lib/chevre/repo/transaction/placeOrder.js +528 -0
  32. package/lib/chevre/repo/transaction/returnOrder.d.ts +23 -0
  33. package/lib/chevre/repo/transaction/returnOrder.js +213 -0
  34. package/lib/chevre/repo/transaction.d.ts +11 -84
  35. package/lib/chevre/repo/transaction.js +331 -270
  36. package/lib/chevre/repo/transactionNumber.js +2 -4
  37. package/lib/chevre/repo/trip.js +1 -2
  38. package/lib/chevre/repository.d.ts +12 -0
  39. package/lib/chevre/repository.js +26 -1
  40. package/lib/chevre/service/account.js +14 -21
  41. package/lib/chevre/service/accountTransaction/deposit.js +2 -8
  42. package/lib/chevre/service/accountTransaction/transfer.js +2 -8
  43. package/lib/chevre/service/accountTransaction/withdraw.js +2 -8
  44. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +24 -32
  45. package/lib/chevre/service/assetTransaction/cancelReservationCOA.js +2 -4
  46. package/lib/chevre/service/assetTransaction/moneyTransfer.js +2 -23
  47. package/lib/chevre/service/assetTransaction/pay/check.js +6 -11
  48. package/lib/chevre/service/assetTransaction/pay/confirm.js +1 -2
  49. package/lib/chevre/service/assetTransaction/pay/searchGMOTrade.d.ts +1 -1
  50. package/lib/chevre/service/assetTransaction/pay/start/factory.d.ts +51 -3
  51. package/lib/chevre/service/assetTransaction/pay/start/factory.js +58 -21
  52. package/lib/chevre/service/assetTransaction/pay/start/preStart/fixPaymentService.d.ts +10 -0
  53. package/lib/chevre/service/assetTransaction/pay/start/preStart/fixPaymentService.js +88 -0
  54. package/lib/chevre/service/assetTransaction/pay/start/processAuthorize.d.ts +53 -0
  55. package/lib/chevre/service/assetTransaction/pay/start/processAuthorize.js +56 -0
  56. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeMovieTicket.d.ts +1 -1
  57. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeMovieTicket.js +1 -11
  58. package/lib/chevre/service/assetTransaction/pay/start.js +8 -132
  59. package/lib/chevre/service/assetTransaction/refund.js +13 -20
  60. package/lib/chevre/service/assetTransaction/registerService.js +1 -7
  61. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.js +2 -4
  62. package/lib/chevre/service/assetTransaction/reserveCOA.js +2 -4
  63. package/lib/chevre/service/delivery/product/factory.js +1 -2
  64. package/lib/chevre/service/delivery/reservation/factory.js +1 -2
  65. package/lib/chevre/service/event/saveScreeningEvents.js +1 -0
  66. package/lib/chevre/service/event.js +0 -1
  67. package/lib/chevre/service/moneyTransfer.js +2 -2
  68. package/lib/chevre/service/notification/factory.js +1 -1
  69. package/lib/chevre/service/notification/notifyByEmail.js +50 -56
  70. package/lib/chevre/service/notification/sendEmailMessage.js +2 -3
  71. package/lib/chevre/service/notification/triggerWebhook.js +32 -37
  72. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.js +1 -2
  73. package/lib/chevre/service/offer/event/authorize.d.ts +2 -2
  74. package/lib/chevre/service/offer/event/authorize.js +4 -4
  75. package/lib/chevre/service/offer/event/issueEventOfferTicket.d.ts +2 -2
  76. package/lib/chevre/service/offer/event/issueEventOfferTicket.js +1 -1
  77. package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4chevre.d.ts +0 -2
  78. package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4chevre.js +1 -0
  79. package/lib/chevre/service/offer/event/voidTransaction.d.ts +2 -2
  80. package/lib/chevre/service/offer/event/voidTransaction.js +2 -2
  81. package/lib/chevre/service/offer/event/voidTransactionByActionId.d.ts +2 -2
  82. package/lib/chevre/service/offer/event/voidTransactionByActionId.js +2 -2
  83. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer/authorize.js +1 -2
  84. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.d.ts +2 -2
  85. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.js +6 -6
  86. package/lib/chevre/service/offer/eventServiceByCOA/authorize.d.ts +2 -2
  87. package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +3 -10
  88. package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +2 -2
  89. package/lib/chevre/service/offer/moneyTransfer/authorize.d.ts +2 -2
  90. package/lib/chevre/service/offer/moneyTransfer/authorize.js +53 -57
  91. package/lib/chevre/service/offer/moneyTransfer/voidTransaction.d.ts +2 -2
  92. package/lib/chevre/service/offer/moneyTransfer/voidTransaction.js +4 -1
  93. package/lib/chevre/service/offer/product.d.ts +3 -3
  94. package/lib/chevre/service/offer/product.js +4 -4
  95. package/lib/chevre/service/order/confirmPayTransaction.d.ts +0 -2
  96. package/lib/chevre/service/order/confirmPayTransaction.js +1 -0
  97. package/lib/chevre/service/order/findPlaceOrderTransaction.d.ts +2 -2
  98. package/lib/chevre/service/order/findPlaceOrderTransaction.js +1 -1
  99. package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +4 -4
  100. package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +10 -19
  101. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled.js +1 -1
  102. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +1 -1
  103. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.js +1 -1
  104. package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.d.ts +2 -2
  105. package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +1 -1
  106. package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +1 -1
  107. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +1 -1
  108. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.js +1 -1
  109. package/lib/chevre/service/order/onOrderUpdated.js +1 -2
  110. package/lib/chevre/service/order/payOrder.d.ts +2 -2
  111. package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.d.ts +2 -2
  112. package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.js +2 -3
  113. package/lib/chevre/service/order/placeOrder.d.ts +2 -2
  114. package/lib/chevre/service/order/returnOrder.d.ts +2 -2
  115. package/lib/chevre/service/order/returnOrder.js +2 -2
  116. package/lib/chevre/service/order/sendOrder.d.ts +2 -2
  117. package/lib/chevre/service/order/sendOrder.js +1 -1
  118. package/lib/chevre/service/payment/any/authorize/fixTransactionNumber.d.ts +3 -3
  119. package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.d.ts +3 -3
  120. package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.js +1 -1
  121. package/lib/chevre/service/payment/any/fixOrderAsNeeded.d.ts +2 -2
  122. package/lib/chevre/service/payment/any/fixOrderAsNeeded.js +4 -8
  123. package/lib/chevre/service/payment/any/publishPaymentUrl/fixTransactionNumberOnPublishPaymentUrl.d.ts +2 -2
  124. package/lib/chevre/service/payment/any.d.ts +6 -6
  125. package/lib/chevre/service/payment/any.js +10 -11
  126. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard.js +1 -2
  127. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard3ds.d.ts +1 -1
  128. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard3ds.js +1 -2
  129. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard3dsResult2recipe.d.ts +1 -1
  130. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCardResult2recipe.d.ts +1 -1
  131. package/lib/chevre/service/payment/creditCard/factory.d.ts +1 -1
  132. package/lib/chevre/service/payment/movieTicket/authorize.js +1 -1
  133. package/lib/chevre/service/payment/movieTicket/processPurchaseNumberAuth.js +2 -4
  134. package/lib/chevre/service/payment/movieTicket/refundMovieTicket.js +4 -6
  135. package/lib/chevre/service/payment/movieTicket/voidTransaction.js +1 -2
  136. package/lib/chevre/service/payment/paymentCard.js +2 -4
  137. package/lib/chevre/service/report/telemetry.d.ts +4 -0
  138. package/lib/chevre/service/report/telemetry.js +7 -12
  139. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +2 -6
  140. package/lib/chevre/service/task/acceptCOAOffer.js +6 -4
  141. package/lib/chevre/service/task/authorizePayment.js +4 -2
  142. package/lib/chevre/service/task/confirmPayTransaction.js +2 -2
  143. package/lib/chevre/service/task/confirmReserveTransaction.js +1 -2
  144. package/lib/chevre/service/task/deleteTransaction.js +5 -1
  145. package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +4 -2
  146. package/lib/chevre/service/task/onOrderPaymentCompleted.js +2 -2
  147. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByProduct.js +3 -6
  148. package/lib/chevre/service/task/onResourceUpdated/onOfferCatalogUpdated.js +1 -1
  149. package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.js +1 -1
  150. package/lib/chevre/service/task/pay.js +1 -2
  151. package/lib/chevre/service/task/placeOrder.js +6 -4
  152. package/lib/chevre/service/task/publishPaymentUrl.js +4 -2
  153. package/lib/chevre/service/task/returnOrder.js +4 -4
  154. package/lib/chevre/service/task/returnPayTransaction.js +4 -3
  155. package/lib/chevre/service/task/sendOrder.js +2 -2
  156. package/lib/chevre/service/task/voidMoneyTransferTransaction.js +6 -3
  157. package/lib/chevre/service/task/voidPayTransaction.js +4 -2
  158. package/lib/chevre/service/task/voidRegisterServiceTransaction.js +3 -3
  159. package/lib/chevre/service/task/voidReserveTransaction.js +5 -4
  160. package/lib/chevre/service/transaction/deleteTransaction.d.ts +4 -0
  161. package/lib/chevre/service/transaction/deleteTransaction.js +57 -15
  162. package/lib/chevre/service/transaction/moneyTransfer.js +15 -23
  163. package/lib/chevre/service/transaction/placeOrder/confirm/publishCode.js +1 -1
  164. package/lib/chevre/service/transaction/placeOrder/confirm.d.ts +2 -2
  165. package/lib/chevre/service/transaction/placeOrder/confirm.js +12 -13
  166. package/lib/chevre/service/transaction/placeOrder/exportTasksById.d.ts +2 -2
  167. package/lib/chevre/service/transaction/placeOrder/exportTasksById.js +1 -1
  168. package/lib/chevre/service/transaction/placeOrder/{publishOrderNumberIfNotExist.d.ts → issueOrderNumberIfNotExist.d.ts} +4 -4
  169. package/lib/chevre/service/transaction/placeOrder/{publishOrderNumberIfNotExist.js → issueOrderNumberIfNotExist.js} +21 -13
  170. package/lib/chevre/service/transaction/placeOrder/publishConfirmationNumberIfNotExist.d.ts +2 -2
  171. package/lib/chevre/service/transaction/placeOrder/publishConfirmationNumberIfNotExist.js +3 -3
  172. package/lib/chevre/service/transaction/placeOrder/start/validateStartRequest.js +1 -2
  173. package/lib/chevre/service/transaction/placeOrder/start.d.ts +3 -3
  174. package/lib/chevre/service/transaction/placeOrder/start.js +2 -2
  175. package/lib/chevre/service/transaction/placeOrder/updateAgent.d.ts +23 -0
  176. package/lib/chevre/service/transaction/placeOrder/updateAgent.js +126 -0
  177. package/lib/chevre/service/transaction/placeOrder.d.ts +2 -1
  178. package/lib/chevre/service/transaction/placeOrder.js +3 -1
  179. package/lib/chevre/service/transaction/returnOrder/potentialActions.js +1 -2
  180. package/lib/chevre/service/transaction/returnOrder/preStart/getReturnPolicyByProject.js +1 -1
  181. package/lib/chevre/service/transaction/returnOrder.js +4 -4
  182. package/lib/chevre/service/transaction.d.ts +5 -21
  183. package/lib/chevre/service/transaction.js +5 -111
  184. package/package.json +6 -18
@@ -51,13 +51,11 @@ class TransactionNumberRepo {
51
51
  const timestamp = (0, moment_timezone_1.default)(params.startDate)
52
52
  .valueOf()
53
53
  .toString();
54
- let dataFeedExpires;
55
54
  const dataFeedIdentifier = timestamp;
56
- let incrReply;
57
- dataFeedExpires = (0, moment_timezone_1.default)(params.startDate)
55
+ const dataFeedExpires = (0, moment_timezone_1.default)(params.startDate)
58
56
  .add(1, 'minute') // ミリ秒でカウントしていくので、予約日時後1分で十分
59
57
  .toDate();
60
- incrReply = await this.counterRepo.incrementByMongo({
58
+ const incrReply = await this.counterRepo.incrementByMongo({
61
59
  identifier: dataFeedIdentifier,
62
60
  includedInDataCatalog: { identifier: transactionNumber_2.DataCatalogIdentifier.transactionNumber },
63
61
  expires: dataFeedExpires
@@ -88,9 +88,8 @@ class TripRepo {
88
88
  return docs.map((doc) => doc.toObject());
89
89
  }
90
90
  async updatePartiallyById(params) {
91
- let doc;
92
91
  const { typeOf, ...updateFields } = params.attributes;
93
- doc = await this.tripModel.findOneAndUpdate({
92
+ const doc = await this.tripModel.findOneAndUpdate({
94
93
  _id: params.id,
95
94
  typeOf: params.attributes.typeOf
96
95
  }, {
@@ -84,6 +84,8 @@ import type { TaskRepo } from './repo/task';
84
84
  import type { TelemetryRepo } from './repo/telemetry';
85
85
  import type { TicketRepo } from './repo/ticket';
86
86
  import type { TransactionRepo } from './repo/transaction';
87
+ import type { PlaceOrderRepo } from './repo/transaction/placeOrder';
88
+ import type { ReturnOrderRepo } from './repo/transaction/returnOrder';
87
89
  import type { TransactionNumberRepo } from './repo/transactionNumber';
88
90
  import type { TransactionProcessRepo } from './repo/transactionProcess';
89
91
  import type { TripRepo } from './repo/trip';
@@ -466,6 +468,16 @@ export type Transaction = TransactionRepo;
466
468
  export declare namespace Transaction {
467
469
  function createInstance(...params: ConstructorParameters<typeof TransactionRepo>): Promise<TransactionRepo>;
468
470
  }
471
+ export declare namespace transaction {
472
+ type PlaceOrder = PlaceOrderRepo;
473
+ namespace PlaceOrder {
474
+ function createInstance(...params: ConstructorParameters<typeof PlaceOrderRepo>): Promise<PlaceOrderRepo>;
475
+ }
476
+ type ReturnOrder = ReturnOrderRepo;
477
+ namespace ReturnOrder {
478
+ function createInstance(...params: ConstructorParameters<typeof ReturnOrderRepo>): Promise<ReturnOrderRepo>;
479
+ }
480
+ }
469
481
  export type TransactionNumber = TransactionNumberRepo;
470
482
  export declare namespace TransactionNumber {
471
483
  function createInstance(...params: ConstructorParameters<typeof TransactionNumberRepo>): Promise<TransactionNumberRepo>;
@@ -24,7 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.PendingReservation = exports.PaymentServiceProvider = exports.PaymentServiceChannel = exports.PaymentService = exports.Passport = exports.OwnershipInfo = exports.OrderNumber = exports.OrderInTransaction = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.NoteAboutOrder = exports.Note = exports.MovieTicketType = exports.Message = exports.MerchantReturnPolicy = exports.MemberProgram = exports.Member = exports.Issuer = exports.IdentityProvider = exports.Identity = exports.EventSeries = exports.EventSellerMakesOffer = exports.EventOffer = exports.Event = exports.EmailMessage = exports.CustomerType = exports.Customer = exports.Credentials = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Authorization = exports.CategoryCode = exports.AssetTransaction = exports.Aggregation = exports.AggregateReservation = exports.AggregateOrder = exports.AggregateOffer = exports.AdvanceBookingRequirement = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = exports.AcceptedPaymentMethod = exports.AcceptedOffer = void 0;
27
- exports.WebSite = exports.rateLimit = exports.Trip = exports.TransactionProcess = exports.TransactionNumber = exports.Transaction = exports.Ticket = exports.Telemetry = exports.Task = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.ServiceAvailableHour = exports.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.SellerMakesOffer = exports.Seller = exports.Schedule = exports.Role = exports.ReserveInterface = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductOffer = exports.ProductModel = exports.ProductHasOfferCatalog = exports.Product = exports.PriceSpecification = exports.PotentialAction = exports.place = exports.Permit = exports.Person = exports.paymentMethod = void 0;
27
+ exports.WebSite = exports.rateLimit = exports.Trip = exports.TransactionProcess = exports.TransactionNumber = exports.transaction = exports.Transaction = exports.Ticket = exports.Telemetry = exports.Task = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.ServiceAvailableHour = exports.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.SellerMakesOffer = exports.Seller = exports.Schedule = exports.Role = exports.ReserveInterface = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductOffer = exports.ProductModel = exports.ProductHasOfferCatalog = exports.Product = exports.PriceSpecification = exports.PotentialAction = exports.place = exports.Permit = exports.Person = exports.paymentMethod = void 0;
28
28
  var AcceptedOffer;
29
29
  (function (AcceptedOffer) {
30
30
  let repo;
@@ -1001,6 +1001,31 @@ var Transaction;
1001
1001
  }
1002
1002
  Transaction.createInstance = createInstance;
1003
1003
  })(Transaction || (exports.Transaction = Transaction = {}));
1004
+ var transaction;
1005
+ (function (transaction) {
1006
+ let PlaceOrder;
1007
+ (function (PlaceOrder) {
1008
+ let repo;
1009
+ async function createInstance(...params) {
1010
+ if (repo === undefined) {
1011
+ repo = (await Promise.resolve().then(() => __importStar(require('./repo/transaction/placeOrder')))).PlaceOrderRepo;
1012
+ }
1013
+ return new repo(...params);
1014
+ }
1015
+ PlaceOrder.createInstance = createInstance;
1016
+ })(PlaceOrder = transaction.PlaceOrder || (transaction.PlaceOrder = {}));
1017
+ let ReturnOrder;
1018
+ (function (ReturnOrder) {
1019
+ let repo;
1020
+ async function createInstance(...params) {
1021
+ if (repo === undefined) {
1022
+ repo = (await Promise.resolve().then(() => __importStar(require('./repo/transaction/returnOrder')))).ReturnOrderRepo;
1023
+ }
1024
+ return new repo(...params);
1025
+ }
1026
+ ReturnOrder.createInstance = createInstance;
1027
+ })(ReturnOrder = transaction.ReturnOrder || (transaction.ReturnOrder = {}));
1028
+ })(transaction || (exports.transaction = transaction = {}));
1004
1029
  var TransactionNumber;
1005
1030
  (function (TransactionNumber) {
1006
1031
  let repo;
@@ -75,27 +75,20 @@ function open(params) {
75
75
  function transferMoney(actionAttributes) {
76
76
  return async (repos) => {
77
77
  const action = actionAttributes;
78
- let fromAccountNumber;
79
- let toAccountNumber;
80
- try {
81
- fromAccountNumber = (typeof action.fromLocation.accountNumber === 'string')
82
- ? action.fromLocation.accountNumber
83
- /* istanbul ignore next */
84
- : undefined;
85
- toAccountNumber = (typeof action.toLocation.accountNumber === 'string')
86
- ? action.toLocation.accountNumber
87
- /* istanbul ignore next */
88
- : undefined;
89
- await repos.account.settleTransaction({
90
- fromAccountNumber: fromAccountNumber,
91
- toAccountNumber: toAccountNumber,
92
- amount: (typeof action.amount === 'number') ? action.amount : Number(action.amount.value),
93
- transactionId: action.purpose.id
94
- });
95
- }
96
- catch (error) {
97
- throw error;
98
- }
78
+ const fromAccountNumber = (typeof action.fromLocation.accountNumber === 'string')
79
+ ? action.fromLocation.accountNumber
80
+ /* istanbul ignore next */
81
+ : undefined;
82
+ const toAccountNumber = (typeof action.toLocation.accountNumber === 'string')
83
+ ? action.toLocation.accountNumber
84
+ /* istanbul ignore next */
85
+ : undefined;
86
+ await repos.account.settleTransaction({
87
+ fromAccountNumber: fromAccountNumber,
88
+ toAccountNumber: toAccountNumber,
89
+ amount: (typeof action.amount === 'number') ? action.amount : Number(action.amount.value),
90
+ transactionId: action.purpose.id
91
+ });
99
92
  };
100
93
  }
101
94
  /**
@@ -60,14 +60,8 @@ function start(params) {
60
60
  ...(typeof params.identifier === 'string' && params.identifier.length > 0) ? { identifier: params.identifier } : undefined
61
61
  };
62
62
  // 取引作成
63
- let transaction;
64
- try {
65
- // 取引識別子が指定されていれば、進行中取引のユニークネスを保証する
66
- transaction = await repos.accountTransaction.startByIdentifier(startParams);
67
- }
68
- catch (error) {
69
- throw error;
70
- }
63
+ // 取引識別子が指定されていれば、進行中取引のユニークネスを保証する
64
+ const transaction = await repos.accountTransaction.startByIdentifier(startParams);
71
65
  const pendingTransaction = {
72
66
  typeOf: transaction.typeOf,
73
67
  id: transaction.id,
@@ -82,14 +82,8 @@ function start(params) {
82
82
  ...(typeof params.identifier === 'string' && params.identifier.length > 0) ? { identifier: params.identifier } : undefined
83
83
  };
84
84
  // 取引作成
85
- let transaction;
86
- try {
87
- // 取引識別子が指定されていれば、進行中取引のユニークネスを保証する
88
- transaction = await repos.accountTransaction.startByIdentifier(startParams);
89
- }
90
- catch (error) {
91
- throw error;
92
- }
85
+ // 取引識別子が指定されていれば、進行中取引のユニークネスを保証する
86
+ const transaction = await repos.accountTransaction.startByIdentifier(startParams);
93
87
  const pendingTransaction = {
94
88
  typeOf: transaction.typeOf,
95
89
  id: transaction.id,
@@ -67,14 +67,8 @@ function start(params) {
67
67
  ...(typeof params.identifier === 'string' && params.identifier.length > 0) ? { identifier: params.identifier } : undefined
68
68
  };
69
69
  // 取引作成
70
- let transaction;
71
- try {
72
- // 取引識別子が指定されていれば、進行中取引のユニークネスを保証する
73
- transaction = await repos.accountTransaction.startByIdentifier(startParams);
74
- }
75
- catch (error) {
76
- throw error;
77
- }
70
+ // 取引識別子が指定されていれば、進行中取引のユニークネスを保証する
71
+ const transaction = await repos.accountTransaction.startByIdentifier(startParams);
78
72
  const pendingTransaction = {
79
73
  typeOf: transaction.typeOf,
80
74
  id: transaction.id,
@@ -192,37 +192,32 @@ function aggregateOfferByEvent(params) {
192
192
  function calculateOfferCount(params) {
193
193
  return async (repos) => {
194
194
  let offerCount = 0;
195
- try {
196
- const eventOffers = params.event.offers;
197
- if (typeof eventOffers?.itemOffered?.id === 'string') {
198
- const eventService = (await repos.product.projectFields({
195
+ const eventOffers = params.event.offers;
196
+ if (typeof eventOffers?.itemOffered?.id === 'string') {
197
+ const eventService = (await repos.product.projectFields({
198
+ limit: 1,
199
+ page: 1,
200
+ id: { $eq: eventOffers.itemOffered.id }
201
+ }, ['hasOfferCatalog']
202
+ // []
203
+ )).shift();
204
+ if (eventService === undefined) {
205
+ throw new factory.errors.NotFound(factory.product.ProductType.EventService);
206
+ }
207
+ // const firstCatalogIdOfProduct = eventService.hasOfferCatalog?.id; // migrate to itemListElement(2024-09-30~)
208
+ const firstCatalogIdOfProduct = eventService.hasOfferCatalog?.itemListElement.at(0)?.id;
209
+ if (typeof firstCatalogIdOfProduct === 'string') {
210
+ const catalogs = await repos.offerCatalog.projectFields({
199
211
  limit: 1,
200
212
  page: 1,
201
- id: { $eq: eventOffers.itemOffered.id }
202
- }, ['hasOfferCatalog']
203
- // []
204
- )).shift();
205
- if (eventService === undefined) {
206
- throw new factory.errors.NotFound(factory.product.ProductType.EventService);
207
- }
208
- // const firstCatalogIdOfProduct = eventService.hasOfferCatalog?.id; // migrate to itemListElement(2024-09-30~)
209
- const firstCatalogIdOfProduct = eventService.hasOfferCatalog?.itemListElement.at(0)?.id;
210
- if (typeof firstCatalogIdOfProduct === 'string') {
211
- const catalogs = await repos.offerCatalog.projectFields({
212
- limit: 1,
213
- page: 1,
214
- id: { $in: [firstCatalogIdOfProduct] }
215
- }, ['numberOfItems']);
216
- const numberOfItems = catalogs.shift()?.numberOfItems;
217
- if (typeof numberOfItems === 'number') {
218
- offerCount = numberOfItems;
219
- }
213
+ id: { $in: [firstCatalogIdOfProduct] }
214
+ }, ['numberOfItems']);
215
+ const numberOfItems = catalogs.shift()?.numberOfItems;
216
+ if (typeof numberOfItems === 'number') {
217
+ offerCount = numberOfItems;
220
218
  }
221
219
  }
222
220
  }
223
- catch (error) {
224
- throw error;
225
- }
226
221
  return { offerCount };
227
222
  };
228
223
  }
@@ -231,11 +226,8 @@ function aggregateReservationByEvent(params) {
231
226
  // 収容人数を集計
232
227
  let maximumAttendeeCapacity;
233
228
  let remainingAttendeeCapacity;
234
- let attendeeCount;
235
- let checkInCount;
236
- let reservationCount;
237
229
  const reservationType = factory.reservationType.EventReservation;
238
- reservationCount = await repos.reservation.count({
230
+ const reservationCount = await repos.reservation.count({
239
231
  typeOf: reservationType,
240
232
  reservationFor: { id: { $eq: params.event.id } },
241
233
  reservationStatuses: [factory.reservationStatusType.ReservationConfirmed]
@@ -275,12 +267,12 @@ function aggregateReservationByEvent(params) {
275
267
  remainingAttendeeCapacity = 0;
276
268
  }
277
269
  }
278
- attendeeCount = await repos.reservation.count({
270
+ const attendeeCount = await repos.reservation.count({
279
271
  typeOf: reservationType,
280
272
  reservationFor: { id: { $eq: params.event.id } },
281
273
  attended: true
282
274
  });
283
- checkInCount = await repos.reservation.count({
275
+ const checkInCount = await repos.reservation.count({
284
276
  typeOf: reservationType,
285
277
  reservationFor: { id: { $eq: params.event.id } },
286
278
  checkedIn: true
@@ -3,11 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.confirm = confirm;
4
4
  function confirm(params) {
5
5
  return async (repos) => {
6
- let stateReserveArgs;
7
- let stateReserveResult;
8
6
  let delReserveArgs;
9
- stateReserveArgs = params.object;
10
- stateReserveResult = await repos.reserveService.stateReserve(stateReserveArgs);
7
+ const stateReserveArgs = params.object;
8
+ const stateReserveResult = await repos.reserveService.stateReserve(stateReserveArgs);
11
9
  if (stateReserveResult !== null) {
12
10
  delReserveArgs = {
13
11
  theaterCode: stateReserveArgs.theaterCode,
@@ -95,29 +95,8 @@ function start(params) {
95
95
  expires: params.expires
96
96
  };
97
97
  // 取引開始
98
- let transaction;
99
- try {
100
- transaction = await repos.assetTransaction.start(startParams);
101
- // const pendingTransaction = await authorizeAccount({ transaction })(repos);
102
- await authorizeAccount({ transaction })(repos);
103
- // 更新不要(2023-02-20~)
104
- // await repos.assetTransaction.findByIdAndUpdate<factory.assetTransactionType.MoneyTransfer>({
105
- // id: transaction.id,
106
- // update: {
107
- // 'object.pendingTransaction': {
108
- // typeOf: pendingTransaction.typeOf,
109
- // id: pendingTransaction.id,
110
- // transactionNumber: pendingTransaction.transactionNumber,
111
- // ...(typeof pendingTransaction.identifier === 'string')
112
- // ? { identifier: pendingTransaction.identifier }
113
- // : undefined
114
- // }
115
- // }
116
- // });
117
- }
118
- catch (error) {
119
- throw error;
120
- }
98
+ const transaction = await repos.assetTransaction.start(startParams);
99
+ await authorizeAccount({ transaction })(repos);
121
100
  return transaction;
122
101
  };
123
102
  }
@@ -33,17 +33,12 @@ function check(params) {
33
33
  return async (repos, settings) => {
34
34
  let action;
35
35
  const paymentServiceType = params.object[0]?.typeOf;
36
- try {
37
- switch (paymentServiceType) {
38
- case factory.service.paymentService.PaymentServiceType.MovieTicket:
39
- action = await MovieTicketPayment.checkMovieTicket(params)(repos, settings);
40
- break;
41
- default:
42
- throw new factory.errors.NotImplemented(`Payment service '${paymentServiceType}' not implemented`);
43
- }
44
- }
45
- catch (error) {
46
- throw error;
36
+ switch (paymentServiceType) {
37
+ case factory.service.paymentService.PaymentServiceType.MovieTicket:
38
+ action = await MovieTicketPayment.checkMovieTicket(params)(repos, settings);
39
+ break;
40
+ default:
41
+ throw new factory.errors.NotImplemented(`Payment service '${paymentServiceType}' not implemented`);
47
42
  }
48
43
  return action;
49
44
  };
@@ -61,7 +61,6 @@ function confirm(params) {
61
61
  || typeof orderNumber !== 'string' || orderNumber.length === 0) {
62
62
  throw new factory.errors.ArgumentNull('potentialActions.pay.purpose');
63
63
  }
64
- let potentialActions;
65
64
  // 注文検証
66
65
  const existingOrders = await repos.order.projectFields({
67
66
  limit: 1,
@@ -77,7 +76,7 @@ function confirm(params) {
77
76
  object: { paymentMethod: { paymentMethodId: transaction.transactionNumber } },
78
77
  purpose: { confirmationNumber, orderNumber, typeOf: factory.order.OrderType.Order }
79
78
  };
80
- potentialActions = { pay: [payActionData4order] };
79
+ const potentialActions = { pay: [payActionData4order] };
81
80
  await repos.assetTransaction.confirm({
82
81
  typeOf: factory.assetTransactionType.Pay,
83
82
  id: transaction.id,
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * 決済取引サービス
3
3
  */
4
- import * as GMO from '@motionpicture/gmo-service';
4
+ import type * as GMO from '@motionpicture/gmo-service';
5
5
  import { Settings } from '../../../settings';
6
6
  import type { AssetTransactionRepo } from '../../../repo/assetTransaction';
7
7
  import type { PaymentServiceRepo } from '../../../repo/paymentService';
@@ -2,11 +2,17 @@
2
2
  * 決済取引ファクトリー
3
3
  */
4
4
  import * as factory from '../../../../factory';
5
+ import type { IPaymentAgencyTransaction } from '../../../payment/creditCard';
6
+ /**
7
+ * 決済取引開始パラメータ生成
8
+ */
5
9
  export declare function createStartParams(params: factory.assetTransaction.pay.IStartParamsWithoutDetail & {
6
- transactionNumber: string;
7
10
  paymentServiceType: factory.service.paymentService.PaymentServiceType;
8
- amount: number;
9
- paymentService?: Pick<factory.service.paymentService.IService, 'availableChannel' | 'id' | 'serviceOutput' | 'serviceType'> | Pick<factory.product.IProduct, 'availableChannel' | 'id' | 'serviceOutput' | 'serviceType'>;
11
+ paymentService?: Pick<factory.service.paymentService.IService, 'availableChannel' | 'id' | 'serviceOutput' | 'serviceType'> | Pick<factory.product.IProduct, 'availableChannel' | 'id' | 'serviceOutput' | 'serviceType'> | {
12
+ typeOf: factory.service.paymentService.PaymentServiceType.FaceToFace;
13
+ id?: never;
14
+ serviceType?: never;
15
+ };
10
16
  location?: factory.action.trade.pay.ILocation;
11
17
  informActions: {
12
18
  /**
@@ -20,3 +26,45 @@ export declare function createStartParams(params: factory.assetTransaction.pay.I
20
26
  id: string;
21
27
  };
22
28
  }): factory.assetTransaction.IStartParams<factory.assetTransactionType.Pay>;
29
+ /**
30
+ * クレジットカード決済用の追加オプションを生成する
31
+ */
32
+ export declare function createAuthorizeCreditCardOptions(options: {
33
+ executor?: {
34
+ id?: string;
35
+ };
36
+ pendingPaymentAgencyTransaction?: IPaymentAgencyTransaction;
37
+ }): {
38
+ pendingPaymentAgencyTransaction?: IPaymentAgencyTransaction | undefined;
39
+ executor: {
40
+ id: string;
41
+ } | {
42
+ id?: undefined;
43
+ };
44
+ };
45
+ /**
46
+ * ムビチケ決済用の追加オプションを生成する
47
+ */
48
+ export declare function createAuthorizeMovieTicketOptions(options: {
49
+ executor?: {
50
+ id?: string;
51
+ };
52
+ purpose: {
53
+ id?: string;
54
+ };
55
+ checkedAction: {
56
+ id: string;
57
+ };
58
+ }): {
59
+ executor: {
60
+ id: string;
61
+ } | {
62
+ id?: undefined;
63
+ };
64
+ purpose: {
65
+ id?: string;
66
+ };
67
+ checkedAction: {
68
+ id: string;
69
+ };
70
+ };
@@ -24,11 +24,35 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.createStartParams = createStartParams;
27
+ exports.createAuthorizeCreditCardOptions = createAuthorizeCreditCardOptions;
28
+ exports.createAuthorizeMovieTicketOptions = createAuthorizeMovieTicketOptions;
27
29
  /**
28
30
  * 決済取引ファクトリー
29
31
  */
30
32
  const factory = __importStar(require("../../../../factory"));
33
+ function createServiceOutputAsPayTransactionObject(params) {
34
+ return {
35
+ serviceOutput: (params.object.serviceOutput?.typeOf === 'Invoice')
36
+ ? params.object.serviceOutput
37
+ : {
38
+ typeOf: 'Invoice',
39
+ referencesOrder: { typeOf: factory.order.OrderType.Order }
40
+ }
41
+ };
42
+ }
43
+ /**
44
+ * 決済取引開始パラメータ生成
45
+ */
31
46
  function createStartParams(params, options) {
47
+ // 金額をfix
48
+ const amount = params.object.paymentMethod?.amount;
49
+ if (typeof amount !== 'number') {
50
+ throw new factory.errors.ArgumentNull('object.paymentMethod.amount');
51
+ }
52
+ const transactionNumber = params.transactionNumber;
53
+ if (typeof transactionNumber !== 'string' || transactionNumber.length === 0) {
54
+ throw new factory.errors.ArgumentNull('transactionNumber');
55
+ }
32
56
  const { instrument } = params;
33
57
  const paymentServiceId = (params.paymentService !== undefined)
34
58
  ? String(params.paymentService.id)
@@ -48,14 +72,14 @@ function createStartParams(params, options) {
48
72
  totalPaymentDue = {
49
73
  typeOf: 'MonetaryAmount',
50
74
  currency: factory.priceCurrency.JPY,
51
- value: params.amount
75
+ value: amount
52
76
  };
53
77
  break;
54
78
  case factory.service.paymentService.PaymentServiceType.CreditCard:
55
79
  totalPaymentDue = {
56
80
  typeOf: 'MonetaryAmount',
57
81
  currency: factory.priceCurrency.JPY,
58
- value: params.amount
82
+ value: amount
59
83
  };
60
84
  accountId = ''; // 強制的に空文字化(2024-06-14~)
61
85
  break;
@@ -109,7 +133,7 @@ function createStartParams(params, options) {
109
133
  const paymentMethodAmount = {
110
134
  typeOf: 'MonetaryAmount',
111
135
  currency: paymentMethodCurrency,
112
- value: params.amount
136
+ value: amount
113
137
  };
114
138
  const paymentMethod = {
115
139
  additionalProperty: (Array.isArray(params.object.paymentMethod?.additionalProperty))
@@ -140,19 +164,14 @@ function createStartParams(params, options) {
140
164
  ? { paymentMethodId: params.transactionNumber } // 必要ないはずだが互換性維持対応(2024-06-14~)
141
165
  : undefined
142
166
  };
167
+ const { serviceOutput } = createServiceOutputAsPayTransactionObject(params);
143
168
  const object = {
144
169
  accountId: (typeof accountId === 'string') ? accountId : '',
145
170
  paymentMethodId: params.transactionNumber,
146
171
  typeOf: params.paymentServiceType,
147
172
  id: paymentServiceId,
148
- // onPaymentStatusChanged: { informPayment: params.informActions }, // discontinue(2025-02-09~)
149
173
  paymentMethod,
150
- serviceOutput: (params.object.serviceOutput?.typeOf === 'Invoice') // support serviceOutput(2025-11-24~)
151
- ? params.object.serviceOutput
152
- : {
153
- typeOf: 'Invoice',
154
- referencesOrder: { typeOf: factory.order.OrderType.Order }
155
- },
174
+ serviceOutput, // support serviceOutput(2025-11-24~)
156
175
  ...(params.paymentServiceType === factory.service.paymentService.PaymentServiceType.MovieTicket)
157
176
  ? { checkedAction: { id: options.checkedAction.id } } // add checkedAction(2024-12-13~)
158
177
  : undefined
@@ -178,14 +197,32 @@ function createStartParams(params, options) {
178
197
  ...(potentialAction.length > 0) ? { potentialAction } : undefined // add potentialAction(2025-02-05~)
179
198
  };
180
199
  }
181
- // function createInformPaymentParams(params: {
182
- // paymentService?: Pick<factory.service.paymentService.IService, 'availableChannel' | 'potentialAction'>;
183
- // }): factory.product.IInformPayment[] {
184
- // const informPaymentParams: factory.product.IInformPayment[] = [];
185
- // // プロダクト設定を適用
186
- // const informPaymentParamsByProduct = params.paymentService?.availableChannel?.onPaymentStatusChanged?.informPayment;
187
- // if (Array.isArray(informPaymentParamsByProduct)) {
188
- // informPaymentParams.push(...informPaymentParamsByProduct);
189
- // }
190
- // return informPaymentParams;
191
- // }
200
+ /**
201
+ * 決済プロセッサに渡す実行者情報を生成する
202
+ */
203
+ function createExecutor(options) {
204
+ return (typeof options.executor?.id === 'string')
205
+ ? { id: options.executor.id }
206
+ : {}; // タスク関連付け(2024-05-18~)
207
+ }
208
+ /**
209
+ * クレジットカード決済用の追加オプションを生成する
210
+ */
211
+ function createAuthorizeCreditCardOptions(options) {
212
+ return {
213
+ executor: createExecutor(options),
214
+ ...(options.pendingPaymentAgencyTransaction !== undefined
215
+ ? { pendingPaymentAgencyTransaction: options.pendingPaymentAgencyTransaction }
216
+ : {})
217
+ };
218
+ }
219
+ /**
220
+ * ムビチケ決済用の追加オプションを生成する
221
+ */
222
+ function createAuthorizeMovieTicketOptions(options) {
223
+ return {
224
+ executor: createExecutor(options),
225
+ purpose: options.purpose,
226
+ checkedAction: options.checkedAction
227
+ };
228
+ }
@@ -0,0 +1,10 @@
1
+ import * as factory from '../../../../../factory';
2
+ import type { PaymentServiceRepo } from '../../../../../repo/paymentService';
3
+ import type { ProductRepo } from '../../../../../repo/product';
4
+ export declare function fixPaymentService(params: factory.assetTransaction.pay.IStartParamsWithoutDetail): (repos: {
5
+ paymentService: PaymentServiceRepo;
6
+ product: ProductRepo;
7
+ }) => Promise<{
8
+ paymentServiceType: factory.service.paymentService.PaymentServiceType;
9
+ paymentService?: Pick<factory.product.IProduct, "availableChannel" | "id" | "serviceOutput" | "serviceType" | "potentialAction"> | Pick<factory.service.paymentService.IService, "availableChannel" | "id" | "serviceOutput" | "serviceType" | "potentialAction"> | undefined;
10
+ }>;