@chevre/domain 24.0.0-alpha.2 → 24.0.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.
Files changed (176) hide show
  1. package/lib/chevre/repo/action/acceptCOAOffer.d.ts +23 -0
  2. package/lib/chevre/repo/action/acceptCOAOffer.js +64 -0
  3. package/lib/chevre/repo/action/acceptPay.d.ts +8 -0
  4. package/lib/chevre/repo/action/acceptPay.js +13 -0
  5. package/lib/chevre/repo/action/actionProcess.d.ts +115 -0
  6. package/lib/chevre/repo/action/actionProcess.js +293 -0
  7. package/lib/chevre/repo/action/authorizeOffer.d.ts +21 -0
  8. package/lib/chevre/repo/action/authorizeOffer.js +85 -0
  9. package/lib/chevre/repo/action/checkMovieTicket.d.ts +93 -0
  10. package/lib/chevre/repo/action/checkMovieTicket.js +200 -0
  11. package/lib/chevre/repo/action/checkThing.d.ts +8 -0
  12. package/lib/chevre/repo/action/checkThing.js +13 -0
  13. package/lib/chevre/repo/action.d.ts +9 -249
  14. package/lib/chevre/repo/action.js +308 -708
  15. package/lib/chevre/repo/aggregateAction.d.ts +102 -0
  16. package/lib/chevre/repo/aggregateAction.js +379 -0
  17. package/lib/chevre/repo/mongoose/schemas/transaction.js +31 -0
  18. package/lib/chevre/repo/orderInTransaction.d.ts +8 -0
  19. package/lib/chevre/repo/orderInTransaction.js +16 -2
  20. package/lib/chevre/repo/orderNumber.d.ts +3 -2
  21. package/lib/chevre/repo/orderNumber.js +23 -28
  22. package/lib/chevre/repo/transaction/moneyTransfer.d.ts +61 -0
  23. package/lib/chevre/repo/transaction/moneyTransfer.js +379 -0
  24. package/lib/chevre/repo/transaction/placeOrder.d.ts +140 -0
  25. package/lib/chevre/repo/transaction/placeOrder.js +528 -0
  26. package/lib/chevre/repo/transaction/returnOrder.d.ts +45 -0
  27. package/lib/chevre/repo/transaction/returnOrder.js +341 -0
  28. package/lib/chevre/repo/transaction.d.ts +1 -125
  29. package/lib/chevre/repo/transaction.js +726 -632
  30. package/lib/chevre/repository.d.ts +49 -0
  31. package/lib/chevre/repository.js +107 -2
  32. package/lib/chevre/service/aggregation/system.d.ts +10 -10
  33. package/lib/chevre/service/aggregation/system.js +9 -9
  34. package/lib/chevre/service/assetTransaction/pay/check.d.ts +5 -4
  35. package/lib/chevre/service/assetTransaction/pay/publishPaymentUrl.d.ts +5 -2
  36. package/lib/chevre/service/assetTransaction/pay/publishPaymentUrl.js +3 -3
  37. package/lib/chevre/service/assetTransaction/pay/start/factory.d.ts +51 -3
  38. package/lib/chevre/service/assetTransaction/pay/start/factory.js +58 -21
  39. package/lib/chevre/service/assetTransaction/pay/start/preStart/fixPaymentService.d.ts +10 -0
  40. package/lib/chevre/service/assetTransaction/pay/start/preStart/fixPaymentService.js +88 -0
  41. package/lib/chevre/service/assetTransaction/pay/start/processAuthorize.d.ts +55 -0
  42. package/lib/chevre/service/assetTransaction/pay/start/processAuthorize.js +56 -0
  43. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeMovieTicket.d.ts +3 -1
  44. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeMovieTicket.js +1 -11
  45. package/lib/chevre/service/assetTransaction/pay/start.d.ts +2 -0
  46. package/lib/chevre/service/assetTransaction/pay/start.js +8 -132
  47. package/lib/chevre/service/notification/triggerWebhook.d.ts +7 -6
  48. package/lib/chevre/service/offer/event/authorize.d.ts +2 -2
  49. package/lib/chevre/service/offer/event/authorize.js +3 -3
  50. package/lib/chevre/service/offer/event/issueEventOfferTicket.d.ts +2 -2
  51. package/lib/chevre/service/offer/event/issueEventOfferTicket.js +1 -1
  52. package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4chevre.d.ts +0 -2
  53. package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4chevre.js +1 -0
  54. package/lib/chevre/service/offer/event/voidTransaction.d.ts +2 -2
  55. package/lib/chevre/service/offer/event/voidTransaction.js +2 -2
  56. package/lib/chevre/service/offer/event/voidTransactionByActionId.d.ts +3 -3
  57. package/lib/chevre/service/offer/event/voidTransactionByActionId.js +2 -2
  58. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.d.ts +16 -5
  59. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.js +7 -7
  60. package/lib/chevre/service/offer/eventServiceByCOA/authorize.d.ts +6 -4
  61. package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +3 -10
  62. package/lib/chevre/service/offer/eventServiceByCOA/authorizeByAcceptAction.js +21 -13
  63. package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +19 -10
  64. package/lib/chevre/service/offer/eventServiceByCOA/findAcceptAction.d.ts +2 -2
  65. package/lib/chevre/service/offer/moneyTransfer/authorize.d.ts +2 -2
  66. package/lib/chevre/service/offer/moneyTransfer/authorize.js +6 -3
  67. package/lib/chevre/service/offer/moneyTransfer/voidTransaction.d.ts +2 -2
  68. package/lib/chevre/service/offer/moneyTransfer/voidTransaction.js +4 -1
  69. package/lib/chevre/service/offer/product.d.ts +3 -3
  70. package/lib/chevre/service/offer/product.js +4 -4
  71. package/lib/chevre/service/order/confirmPayTransaction.d.ts +0 -2
  72. package/lib/chevre/service/order/confirmPayTransaction.js +1 -0
  73. package/lib/chevre/service/order/findPlaceOrderTransaction.d.ts +2 -2
  74. package/lib/chevre/service/order/findPlaceOrderTransaction.js +1 -1
  75. package/lib/chevre/service/order/onAssetTransactionStatusChanged/isDeliverable.d.ts +16 -0
  76. package/lib/chevre/service/order/onAssetTransactionStatusChanged/isDeliverable.js +97 -0
  77. package/lib/chevre/service/order/onAssetTransactionStatusChanged/onPayTransactionCanceled.d.ts +21 -0
  78. package/lib/chevre/service/order/onAssetTransactionStatusChanged/onPayTransactionCanceled.js +86 -0
  79. package/lib/chevre/service/order/onAssetTransactionStatusChanged/onPayTransactionConfirmed.d.ts +22 -0
  80. package/lib/chevre/service/order/onAssetTransactionStatusChanged/onPayTransactionConfirmed.js +112 -0
  81. package/lib/chevre/service/order/onAssetTransactionStatusChanged/onReserveTransactionConfirmed.d.ts +22 -0
  82. package/lib/chevre/service/order/onAssetTransactionStatusChanged/onReserveTransactionConfirmed.js +74 -0
  83. package/lib/chevre/service/order/onAssetTransactionStatusChanged/paymentDue2Processing.d.ts +25 -0
  84. package/lib/chevre/service/order/onAssetTransactionStatusChanged/paymentDue2Processing.js +111 -0
  85. package/lib/chevre/service/order/onAssetTransactionStatusChanged/processing2inTransit.d.ts +16 -0
  86. package/lib/chevre/service/order/onAssetTransactionStatusChanged/processing2inTransit.js +74 -0
  87. package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +8 -30
  88. package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +37 -348
  89. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.d.ts +6 -7
  90. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.d.ts +6 -5
  91. package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.d.ts +7 -6
  92. package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +1 -1
  93. package/lib/chevre/service/order/payOrder.d.ts +2 -2
  94. package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.d.ts +2 -2
  95. package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.js +1 -1
  96. package/lib/chevre/service/order/placeOrder.d.ts +13 -12
  97. package/lib/chevre/service/order/returnOrder.d.ts +2 -2
  98. package/lib/chevre/service/order/returnOrder.js +1 -1
  99. package/lib/chevre/service/order/sendOrder.d.ts +6 -6
  100. package/lib/chevre/service/order/sendOrder.js +10 -8
  101. package/lib/chevre/service/order.d.ts +3 -6
  102. package/lib/chevre/service/order.js +3 -9
  103. package/lib/chevre/service/payment/any/{fixOrderAsNeeded.d.ts → authorize/fixOrderAsNeeded.d.ts} +6 -6
  104. package/lib/chevre/service/payment/any/{fixOrderAsNeeded.js → authorize/fixOrderAsNeeded.js} +5 -8
  105. package/lib/chevre/service/payment/any/authorize/fixTransactionNumber.d.ts +3 -3
  106. package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.d.ts +3 -3
  107. package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.js +1 -1
  108. package/lib/chevre/service/payment/any/authorize.d.ts +92 -0
  109. package/lib/chevre/service/payment/any/authorize.js +225 -0
  110. package/lib/chevre/service/payment/any/findAcceptAction.d.ts +43 -0
  111. package/lib/chevre/service/payment/any/findAcceptAction.js +94 -0
  112. package/lib/chevre/service/payment/any/findAuthorizeAction.d.ts +41 -0
  113. package/lib/chevre/service/payment/any/findAuthorizeAction.js +83 -0
  114. package/lib/chevre/service/payment/any/findCheckAction.d.ts +45 -0
  115. package/lib/chevre/service/payment/any/findCheckAction.js +89 -0
  116. package/lib/chevre/service/payment/any/invalidatePaymentUrl.d.ts +28 -0
  117. package/lib/chevre/service/payment/any/invalidatePaymentUrl.js +185 -0
  118. package/lib/chevre/service/payment/any/onPayActionCompleted.d.ts +7 -3
  119. package/lib/chevre/service/payment/any/onPayActionCompleted.js +3 -0
  120. package/lib/chevre/service/payment/any/processVoidPayTransaction.d.ts +29 -0
  121. package/lib/chevre/service/payment/any/processVoidPayTransaction.js +125 -0
  122. package/lib/chevre/service/payment/any/publishPaymentUrl/fixTransactionNumberOnPublishPaymentUrl.d.ts +2 -2
  123. package/lib/chevre/service/payment/any/publishPaymentUrl.d.ts +66 -0
  124. package/lib/chevre/service/payment/any/publishPaymentUrl.js +133 -0
  125. package/lib/chevre/service/payment/any/voidPayTransaction.d.ts +31 -0
  126. package/lib/chevre/service/payment/any/voidPayTransaction.js +38 -0
  127. package/lib/chevre/service/payment/any.d.ts +8 -305
  128. package/lib/chevre/service/payment/any.js +17 -857
  129. package/lib/chevre/service/payment/movieTicket/authorize.d.ts +2 -0
  130. package/lib/chevre/service/payment/movieTicket/checkMovieTicket.d.ts +3 -3
  131. package/lib/chevre/service/payment/movieTicket/checkMovieTicket.js +3 -3
  132. package/lib/chevre/service/payment/movieTicket/validation.d.ts +11 -10
  133. package/lib/chevre/service/payment/movieTicket/validation.js +18 -15
  134. package/lib/chevre/service/report/telemetry.d.ts +4 -0
  135. package/lib/chevre/service/report/telemetry.js +7 -12
  136. package/lib/chevre/service/task/acceptCOAOffer.js +11 -6
  137. package/lib/chevre/service/task/authorizePayment.js +6 -2
  138. package/lib/chevre/service/task/checkMovieTicket.js +3 -3
  139. package/lib/chevre/service/task/checkResource.js +2 -2
  140. package/lib/chevre/service/task/confirmPayTransaction.js +2 -2
  141. package/lib/chevre/service/task/deleteTransaction.js +7 -1
  142. package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +4 -2
  143. package/lib/chevre/service/task/onOrderPaymentCompleted.js +2 -2
  144. package/lib/chevre/service/task/placeOrder.js +6 -4
  145. package/lib/chevre/service/task/publishPaymentUrl.js +8 -4
  146. package/lib/chevre/service/task/returnOrder.js +4 -4
  147. package/lib/chevre/service/task/returnPayTransaction.js +4 -3
  148. package/lib/chevre/service/task/sendOrder.js +4 -4
  149. package/lib/chevre/service/task/voidMoneyTransferTransaction.js +6 -3
  150. package/lib/chevre/service/task/voidPayTransaction.js +4 -2
  151. package/lib/chevre/service/task/voidRegisterServiceTransaction.js +3 -3
  152. package/lib/chevre/service/task/voidReserveTransaction.js +4 -3
  153. package/lib/chevre/service/transaction/deleteTransaction.d.ts +6 -0
  154. package/lib/chevre/service/transaction/deleteTransaction.js +56 -14
  155. package/lib/chevre/service/transaction/moneyTransfer.d.ts +5 -5
  156. package/lib/chevre/service/transaction/moneyTransfer.js +5 -5
  157. package/lib/chevre/service/transaction/placeOrder/confirm.d.ts +2 -2
  158. package/lib/chevre/service/transaction/placeOrder/confirm.js +10 -9
  159. package/lib/chevre/service/transaction/placeOrder/exportTasksById.d.ts +7 -6
  160. package/lib/chevre/service/transaction/placeOrder/exportTasksById.js +1 -1
  161. package/lib/chevre/service/transaction/placeOrder/{publishOrderNumberIfNotExist.d.ts → issueOrderNumberIfNotExist.d.ts} +4 -4
  162. package/lib/chevre/service/transaction/placeOrder/{publishOrderNumberIfNotExist.js → issueOrderNumberIfNotExist.js} +21 -13
  163. package/lib/chevre/service/transaction/placeOrder/publishConfirmationNumberIfNotExist.d.ts +2 -2
  164. package/lib/chevre/service/transaction/placeOrder/publishConfirmationNumberIfNotExist.js +3 -3
  165. package/lib/chevre/service/transaction/placeOrder/start.d.ts +3 -3
  166. package/lib/chevre/service/transaction/placeOrder/start.js +2 -2
  167. package/lib/chevre/service/transaction/placeOrder/updateAgent.d.ts +23 -0
  168. package/lib/chevre/service/transaction/placeOrder/updateAgent.js +126 -0
  169. package/lib/chevre/service/transaction/placeOrder.d.ts +2 -1
  170. package/lib/chevre/service/transaction/placeOrder.js +3 -1
  171. package/lib/chevre/service/transaction/returnOrder/preStart.d.ts +1 -1
  172. package/lib/chevre/service/transaction/returnOrder.d.ts +16 -14
  173. package/lib/chevre/service/transaction/returnOrder.js +4 -4
  174. package/lib/chevre/service/transaction.d.ts +9 -21
  175. package/lib/chevre/service/transaction.js +5 -111
  176. package/package.json +4 -8
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.findAcceptAction = findAcceptAction;
27
+ const factory = __importStar(require("../../../factory"));
28
+ function findAcceptAction(params) {
29
+ return async (repos) => {
30
+ // タスク検索
31
+ const task = (await repos.task.projectFields({
32
+ limit: 1,
33
+ page: 1,
34
+ id: { $eq: params.sameAs.id },
35
+ project: { id: { $eq: params.project.id } },
36
+ name: factory.taskName.PublishPaymentUrl
37
+ }, ['status', 'executionResults'])).shift();
38
+ if (task === undefined) {
39
+ throw new factory.errors.NotFound(factory.taskName.PublishPaymentUrl);
40
+ }
41
+ const errorByTask = task.executionResults.shift()?.error;
42
+ let defaultActionError;
43
+ if (typeof errorByTask === 'string') {
44
+ defaultActionError = { message: errorByTask };
45
+ }
46
+ else if (typeof errorByTask?.message === 'string') {
47
+ defaultActionError = { message: errorByTask.message, name: errorByTask.name };
48
+ }
49
+ let action = {
50
+ actionStatus: factory.actionStatusType.PotentialActionStatus,
51
+ ...(defaultActionError !== undefined) ? { error: defaultActionError } : undefined
52
+ };
53
+ switch (task.status) {
54
+ case factory.taskStatus.Ready:
55
+ break;
56
+ default:
57
+ // タスクがReadyでなければアクション検索
58
+ const acceptAction = (await repos.acceptPayAction.searchBySameAs({
59
+ sameAs: { id: { $eq: task.id } },
60
+ typeOf: { $eq: factory.actionType.AcceptAction }
61
+ // purpose: { id: { $eq: String(params.purpose.id) } }
62
+ })).shift();
63
+ if (acceptAction !== undefined) {
64
+ // purpose検証
65
+ if (acceptAction.purpose?.id !== params.purpose.id) {
66
+ throw new factory.errors.NotFound('Action');
67
+ }
68
+ const acceptActionWithResult = await repos.acceptPayAction.findById({ id: acceptAction.id, typeOf: factory.actionType.AcceptAction }, ['result', 'object'], []);
69
+ action = {
70
+ id: acceptAction.id,
71
+ actionStatus: acceptAction.actionStatus,
72
+ // add object.transactionNumber(2025-08-26~)
73
+ object: { transactionNumber: acceptActionWithResult.object.transactionNumber },
74
+ ...(acceptAction.error !== undefined)
75
+ ? {
76
+ error: (Array.isArray(acceptAction.error))
77
+ ? acceptAction.error[0]
78
+ : acceptAction.error
79
+ }
80
+ : undefined,
81
+ ...(acceptActionWithResult?.result !== undefined)
82
+ ? {
83
+ result: {
84
+ paymentMethodId: acceptActionWithResult.result.paymentMethodId,
85
+ paymentUrl: acceptActionWithResult.result.paymentUrl
86
+ }
87
+ }
88
+ : undefined
89
+ };
90
+ }
91
+ }
92
+ return action;
93
+ };
94
+ }
@@ -0,0 +1,41 @@
1
+ import * as factory from '../../../factory';
2
+ import type { ActionRepo } from '../../../repo/action';
3
+ import type { TaskRepo } from '../../../repo/task';
4
+ interface IFindAuthorizeActionResult {
5
+ /**
6
+ * アクションID
7
+ */
8
+ id?: string;
9
+ /**
10
+ * アクションスタータス
11
+ */
12
+ actionStatus: factory.actionStatusType;
13
+ /**
14
+ * エラー
15
+ */
16
+ error?: {
17
+ name?: string;
18
+ message?: string;
19
+ };
20
+ }
21
+ declare function findAuthorizeAction(params: {
22
+ project: {
23
+ id: string;
24
+ };
25
+ sameAs: {
26
+ /**
27
+ * task ID
28
+ */
29
+ id: string;
30
+ };
31
+ purpose: {
32
+ /**
33
+ * transaction ID
34
+ */
35
+ id: string;
36
+ };
37
+ }): (repos: {
38
+ action: ActionRepo;
39
+ task: TaskRepo;
40
+ }) => Promise<IFindAuthorizeActionResult>;
41
+ export { findAuthorizeAction, };
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.findAuthorizeAction = findAuthorizeAction;
27
+ const factory = __importStar(require("../../../factory"));
28
+ function findAuthorizeAction(params) {
29
+ return async (repos) => {
30
+ // タスク検索
31
+ const task = (await repos.task.projectFields({
32
+ limit: 1,
33
+ page: 1,
34
+ id: { $eq: params.sameAs.id },
35
+ project: { id: { $eq: params.project.id } },
36
+ name: factory.taskName.AuthorizePayment
37
+ }, ['status', 'executionResults'])).shift();
38
+ if (task === undefined) {
39
+ throw new factory.errors.NotFound(factory.taskName.AuthorizePayment);
40
+ }
41
+ const errorByTask = task.executionResults.shift()?.error;
42
+ let defaultActionError;
43
+ if (typeof errorByTask === 'string') {
44
+ defaultActionError = { message: errorByTask };
45
+ }
46
+ else if (typeof errorByTask?.message === 'string') {
47
+ defaultActionError = { message: errorByTask.message, name: errorByTask.name };
48
+ }
49
+ let action = {
50
+ actionStatus: factory.actionStatusType.PotentialActionStatus,
51
+ ...(defaultActionError !== undefined) ? { error: defaultActionError } : undefined
52
+ };
53
+ switch (task.status) {
54
+ case factory.taskStatus.Ready:
55
+ break;
56
+ default:
57
+ // タスクがReadyでなければアクション検索
58
+ const authorizeAction = (await repos.action.searchBySameAs({
59
+ sameAs: { id: { $eq: task.id } },
60
+ typeOf: { $eq: factory.actionType.AuthorizeAction }
61
+ // purpose: { id: { $eq: String(params.purpose.id) } }
62
+ })).shift();
63
+ if (authorizeAction !== undefined) {
64
+ // purpose検証
65
+ if (authorizeAction.purpose?.id !== params.purpose.id) {
66
+ throw new factory.errors.NotFound('Action');
67
+ }
68
+ action = {
69
+ id: authorizeAction.id,
70
+ actionStatus: authorizeAction.actionStatus,
71
+ ...(authorizeAction.error !== undefined)
72
+ ? {
73
+ error: (Array.isArray(authorizeAction.error))
74
+ ? authorizeAction.error[0]
75
+ : authorizeAction.error
76
+ }
77
+ : undefined
78
+ };
79
+ }
80
+ }
81
+ return action;
82
+ };
83
+ }
@@ -0,0 +1,45 @@
1
+ import * as factory from '../../../factory';
2
+ import type { CheckMovieTicketActionRepo, IMinimizedPurchaseNumberAuthResult } from '../../../repo/action/checkMovieTicket';
3
+ import type { TaskRepo } from '../../../repo/task';
4
+ interface IFindCheckActionRepos {
5
+ checkMovieTicketAction: CheckMovieTicketActionRepo;
6
+ task: TaskRepo;
7
+ }
8
+ interface IFindCheckActionResult {
9
+ /**
10
+ * アクションID
11
+ */
12
+ id?: string;
13
+ /**
14
+ * アクションスタータス
15
+ */
16
+ actionStatus: factory.actionStatusType;
17
+ /**
18
+ * エラー
19
+ */
20
+ error?: {
21
+ name?: string;
22
+ message?: string;
23
+ };
24
+ result?: {
25
+ purchaseNumberAuthResult: IMinimizedPurchaseNumberAuthResult;
26
+ };
27
+ }
28
+ declare function findCheckAction(params: {
29
+ project: {
30
+ id: string;
31
+ };
32
+ sameAs: {
33
+ /**
34
+ * task ID
35
+ */
36
+ id: string;
37
+ };
38
+ purpose: {
39
+ /**
40
+ * transaction ID
41
+ */
42
+ id: string;
43
+ };
44
+ }): (repos: IFindCheckActionRepos) => Promise<IFindCheckActionResult>;
45
+ export { IFindCheckActionRepos, findCheckAction, };
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.findCheckAction = findCheckAction;
27
+ const factory = __importStar(require("../../../factory"));
28
+ function findCheckAction(params) {
29
+ return async (repos) => {
30
+ // タスク検索
31
+ const task = (await repos.task.projectFields({
32
+ limit: 1,
33
+ page: 1,
34
+ id: { $eq: params.sameAs.id },
35
+ project: { id: { $eq: params.project.id } },
36
+ name: factory.taskName.CheckMovieTicket
37
+ }, ['status', 'executionResults'])).shift();
38
+ if (task === undefined) {
39
+ throw new factory.errors.NotFound(factory.taskName.CheckMovieTicket);
40
+ }
41
+ const errorByTask = task.executionResults.shift()?.error;
42
+ let defaultActionError;
43
+ if (typeof errorByTask === 'string') {
44
+ defaultActionError = { message: errorByTask };
45
+ }
46
+ else if (typeof errorByTask?.message === 'string') {
47
+ defaultActionError = { message: errorByTask.message, name: errorByTask.name };
48
+ }
49
+ let action = {
50
+ actionStatus: factory.actionStatusType.PotentialActionStatus,
51
+ ...(defaultActionError !== undefined) ? { error: defaultActionError } : undefined
52
+ };
53
+ switch (task.status) {
54
+ case factory.taskStatus.Ready:
55
+ break;
56
+ default:
57
+ // タスクがReadyでなければアクション検索
58
+ const authorizeAction = (await repos.checkMovieTicketAction.searchBySameAs({
59
+ sameAs: { id: { $eq: task.id } },
60
+ typeOf: { $eq: factory.actionType.CheckAction }
61
+ // purpose: { id: { $eq: String(params.purpose.id) } }
62
+ })).shift();
63
+ if (authorizeAction !== undefined) {
64
+ // purpose検証
65
+ if (authorizeAction.purpose?.id !== params.purpose.id) {
66
+ throw new factory.errors.NotFound('Action');
67
+ }
68
+ // result from recipe(2024-06-10~)
69
+ const purchaseNumberAuthResult = await repos.checkMovieTicketAction.findIMinimizedPurchaseNumberAuthResultByCheckMovieTicketRecipe({
70
+ project: { id: params.project.id },
71
+ recipeFor: { id: authorizeAction.id }
72
+ });
73
+ action = {
74
+ id: authorizeAction.id,
75
+ actionStatus: authorizeAction.actionStatus,
76
+ ...(authorizeAction.error !== undefined)
77
+ ? {
78
+ error: (Array.isArray(authorizeAction.error))
79
+ ? authorizeAction.error[0]
80
+ : authorizeAction.error
81
+ }
82
+ : undefined,
83
+ ...(purchaseNumberAuthResult !== undefined) ? { result: { purchaseNumberAuthResult } } : undefined
84
+ };
85
+ }
86
+ }
87
+ return action;
88
+ };
89
+ }
@@ -0,0 +1,28 @@
1
+ import * as factory from '../../../factory';
2
+ import type { AccountingReportRepo } from '../../../repo/accountingReport';
3
+ import type { ActionRepo } from '../../../repo/action';
4
+ import type { AssetTransactionRepo } from '../../../repo/assetTransaction';
5
+ import type { PaymentServiceRepo } from '../../../repo/paymentService';
6
+ import type { PaymentServiceProviderRepo } from '../../../repo/paymentServiceProvider';
7
+ import type { SellerPaymentAcceptedRepo } from '../../../repo/sellerPaymentAccepted';
8
+ import type { TaskRepo } from '../../../repo/task';
9
+ import type { PlaceOrderRepo } from '../../../repo/transaction/placeOrder';
10
+ interface IInvalidatePaymentUrlRepos {
11
+ accountingReport: AccountingReportRepo;
12
+ action: ActionRepo;
13
+ assetTransaction: AssetTransactionRepo;
14
+ paymentAccepted: SellerPaymentAcceptedRepo;
15
+ paymentService: PaymentServiceRepo;
16
+ paymentServiceProvider: PaymentServiceProviderRepo;
17
+ task: TaskRepo;
18
+ placeOrder: PlaceOrderRepo;
19
+ }
20
+ /**
21
+ * 決済承認中止タスクから決済URLを無効化する
22
+ */
23
+ declare function invalidatePaymentUrl(params: factory.task.IData<factory.taskName.VoidPayTransaction> & {
24
+ sameAs?: {
25
+ id: string;
26
+ };
27
+ }): (repos: IInvalidatePaymentUrlRepos) => Promise<void>;
28
+ export { IInvalidatePaymentUrlRepos, invalidatePaymentUrl, };
@@ -0,0 +1,185 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.invalidatePaymentUrl = invalidatePaymentUrl;
27
+ const factory = __importStar(require("../../../factory"));
28
+ /**
29
+ * 決済承認中止タスクから決済URLを無効化する
30
+ */
31
+ function invalidatePaymentUrl(params) {
32
+ return async (repos
33
+ // settings: Settings
34
+ ) => {
35
+ if (params.purpose.typeOf !== factory.transactionType.PlaceOrder) {
36
+ throw new factory.errors.Argument('purpose.typeOf', `must be ${factory.transactionType.PlaceOrder}`);
37
+ }
38
+ const transaction = await repos.placeOrder.findPlaceOrderById({
39
+ typeOf: params.purpose.typeOf,
40
+ id: params.purpose.id
41
+ }, ['typeOf', 'status', 'object', 'project', 'seller', 'agent']);
42
+ // const orderCancelled: boolean = params.purpose.result?.order?.orderStatus === factory.orderStatus.OrderCancelled;
43
+ // if (transaction.status === factory.transactionStatusType.Confirmed) {
44
+ // if (!orderCancelled) {
45
+ // // no op
46
+ // return;
47
+ // }
48
+ // }
49
+ // support multiple accept actions(2025-02-25~)
50
+ let acceptPayActions = await repos.action.search({
51
+ project: { id: { $eq: transaction.project.id } },
52
+ typeOf: { $eq: factory.actionType.AcceptAction },
53
+ // actionStatus: { $in: [factory.actionStatusType.CompletedActionStatus] }, // all statuses(2025-02-26~)
54
+ purpose: { id: { $in: [transaction.id] } },
55
+ object: {
56
+ // transactionNumber: { $eq: paymentMethodIdByPaymentUrl },
57
+ typeOf: { $eq: factory.assetTransactionType.Pay }
58
+ }
59
+ }, ['object']);
60
+ switch (transaction.status) {
61
+ case factory.transactionStatusType.InProgress:
62
+ throw new factory.errors.NotImplemented(`${transaction.status} not implemented`);
63
+ case factory.transactionStatusType.Confirmed:
64
+ // support OrderCanceled(2025-02-25~)
65
+ const orderCancelled = params.purpose.result?.order?.orderStatus === factory.orderStatus.OrderCancelled;
66
+ if (!orderCancelled) {
67
+ const paymentMethodIdByPaymentUrl = transaction.object.paymentMethods?.paymentMethodId;
68
+ if (typeof paymentMethodIdByPaymentUrl === 'string') {
69
+ acceptPayActions = acceptPayActions.filter(({ object }) => object.transactionNumber !== paymentMethodIdByPaymentUrl);
70
+ }
71
+ }
72
+ break;
73
+ default:
74
+ // no op
75
+ }
76
+ const invalidatePaymentUrlTasks = [];
77
+ const runsAt = new Date();
78
+ for (const acceptPayAction of acceptPayActions) {
79
+ const paymentMethodIdByPaymentUrl = acceptPayAction.object.transactionNumber;
80
+ const paymentMethodType = acceptPayAction.object.object.paymentMethod.identifier;
81
+ if (typeof paymentMethodType === 'string' && paymentMethodType.length > 0) {
82
+ // create task(2025-02-26~)
83
+ // await PayTransactionService.invalidatePaymentUrl({})(repos, settings);
84
+ const invalidatePaymentUrlData = {
85
+ project: transaction.project,
86
+ typeOf: factory.actionType.RefundAction,
87
+ agent: {
88
+ typeOf: transaction.seller.typeOf,
89
+ name: (typeof transaction.seller.name === 'string')
90
+ ? transaction.seller.name
91
+ : String(transaction.seller.name?.ja),
92
+ id: transaction.seller.id
93
+ },
94
+ recipient: {
95
+ typeOf: transaction.agent.typeOf,
96
+ id: transaction.agent.id,
97
+ name: transaction.agent.name
98
+ },
99
+ object: [{
100
+ typeOf: factory.service.paymentService.PaymentServiceType.CreditCard,
101
+ id: acceptPayAction.object.object.id,
102
+ paymentMethod: {
103
+ additionalProperty: [],
104
+ name: paymentMethodType,
105
+ typeOf: paymentMethodType,
106
+ paymentMethodId: paymentMethodIdByPaymentUrl
107
+ },
108
+ refundFee: 0
109
+ }],
110
+ purpose: { typeOf: transaction.typeOf, id: transaction.id },
111
+ instrument: []
112
+ // ...(typeof params.sameAs?.id === 'string') ? { sameAs: params.sameAs } : undefined
113
+ };
114
+ invalidatePaymentUrlTasks.push({
115
+ project: transaction.project,
116
+ name: factory.taskName.InvalidatePaymentUrl,
117
+ status: factory.taskStatus.Ready,
118
+ runsAt,
119
+ remainingNumberOfTries: 10,
120
+ numberOfTried: 0,
121
+ executionResults: [],
122
+ data: invalidatePaymentUrlData
123
+ });
124
+ }
125
+ }
126
+ if (invalidatePaymentUrlTasks.length > 0) {
127
+ await repos.task.saveMany(invalidatePaymentUrlTasks, { emitImmediately: true });
128
+ }
129
+ // const paymentMethodIdByPaymentUrl = transaction.object.paymentMethods?.paymentMethodId;
130
+ // if (typeof paymentMethodIdByPaymentUrl === 'string' && paymentMethodIdByPaymentUrl.length > 0) {
131
+ // const acceptPayAction = (<Pick<IAcceptPayAction, 'object'>[]>await repos.action.search(
132
+ // {
133
+ // limit: 1,
134
+ // page: 1,
135
+ // project: { id: { $eq: transaction.project.id } },
136
+ // typeOf: { $eq: factory.actionType.AcceptAction },
137
+ // actionStatus: { $in: [factory.actionStatusType.CompletedActionStatus] },
138
+ // purpose: { id: { $in: [transaction.id] } },
139
+ // object: {
140
+ // transactionNumber: { $eq: paymentMethodIdByPaymentUrl },
141
+ // typeOf: { $eq: factory.assetTransactionType.Pay }
142
+ // }
143
+ // },
144
+ // ['object']
145
+ // )).shift();
146
+ // if (acceptPayAction !== undefined) {
147
+ // // const paymentMethodType = transaction.object.paymentMethods?.typeOf;
148
+ // const paymentMethodType = acceptPayAction.object.object.paymentMethod.identifier;
149
+ // if (typeof paymentMethodType === 'string' && paymentMethodType.length > 0) {
150
+ // // chevreで決済URL無効化
151
+ // await PayTransactionService.invalidatePaymentUrl({
152
+ // project: transaction.project,
153
+ // typeOf: factory.actionType.RefundAction,
154
+ // agent: {
155
+ // typeOf: transaction.seller.typeOf,
156
+ // name: (typeof transaction.seller.name === 'string')
157
+ // ? transaction.seller.name
158
+ // : String(transaction.seller.name?.ja),
159
+ // id: transaction.seller.id
160
+ // },
161
+ // recipient: {
162
+ // typeOf: transaction.agent.typeOf,
163
+ // id: transaction.agent.id,
164
+ // name: transaction.agent.name
165
+ // },
166
+ // object: [{
167
+ // typeOf: factory.service.paymentService.PaymentServiceType.CreditCard,
168
+ // id: acceptPayAction.object.object.id,
169
+ // paymentMethod: {
170
+ // additionalProperty: [],
171
+ // name: paymentMethodType,
172
+ // typeOf: paymentMethodType,
173
+ // paymentMethodId: paymentMethodIdByPaymentUrl
174
+ // },
175
+ // refundFee: 0
176
+ // }],
177
+ // purpose: { typeOf: transaction.typeOf, id: transaction.id },
178
+ // instrument: [],
179
+ // ...(typeof params.sameAs?.id === 'string') ? { sameAs: params.sameAs } : undefined
180
+ // })(repos, settings);
181
+ // }
182
+ // }
183
+ // }
184
+ };
185
+ }
@@ -5,9 +5,13 @@ import * as factory from '../../../factory';
5
5
  import type { AccountingReportRepo } from '../../../repo/accountingReport';
6
6
  import type { ActionRepo } from '../../../repo/action';
7
7
  import type { TaskRepo } from '../../../repo/task';
8
- declare function onPayActionCompleted(payAction: Pick<factory.action.trade.pay.IAction, 'id' | 'object' | 'potentialActions' | 'project' | 'purpose' | 'typeOf'>): (repos: {
8
+ interface IOnPayActionCompletedRepos {
9
9
  action: ActionRepo;
10
10
  accountingReport: AccountingReportRepo;
11
11
  task: TaskRepo;
12
- }) => Promise<void>;
13
- export { onPayActionCompleted };
12
+ }
13
+ /**
14
+ * 決済アクション完了時処理
15
+ */
16
+ declare function onPayActionCompleted(payAction: Pick<factory.action.trade.pay.IAction, 'id' | 'object' | 'potentialActions' | 'project' | 'purpose' | 'typeOf'>): (repos: IOnPayActionCompletedRepos) => Promise<void>;
17
+ export { IOnPayActionCompletedRepos, onPayActionCompleted };
@@ -30,6 +30,9 @@ exports.onPayActionCompleted = onPayActionCompleted;
30
30
  const factory = __importStar(require("../../../factory"));
31
31
  const factory_1 = require("./factory");
32
32
  const onPaymentStatusChanged_1 = require("./onPaymentStatusChanged");
33
+ /**
34
+ * 決済アクション完了時処理
35
+ */
33
36
  function onPayActionCompleted(payAction) {
34
37
  return async (repos) => {
35
38
  const aciton4inform = (0, factory_1.optimizeAction4inform)(payAction);
@@ -0,0 +1,29 @@
1
+ import * as factory from '../../../factory';
2
+ import type { AccountingReportRepo } from '../../../repo/accountingReport';
3
+ import type { ActionRepo } from '../../../repo/action';
4
+ import type { AssetTransactionRepo } from '../../../repo/assetTransaction';
5
+ import type { TaskRepo } from '../../../repo/task';
6
+ import type { PlaceOrderRepo } from '../../../repo/transaction/placeOrder';
7
+ interface IProcessVoidPayTransactionRepos {
8
+ action: ActionRepo;
9
+ accountingReport: AccountingReportRepo;
10
+ assetTransaction: AssetTransactionRepo;
11
+ task: TaskRepo;
12
+ placeOrder: PlaceOrderRepo;
13
+ }
14
+ /**
15
+ * 決済承認中止
16
+ * apiもしくはタスクから決済承認を取り消す
17
+ */
18
+ declare function processVoidPayTransaction(params: factory.task.IData<factory.taskName.VoidPayTransaction> & {
19
+ project: {
20
+ id: string;
21
+ };
22
+ sameAs?: {
23
+ /**
24
+ * 実行元タスクID
25
+ */
26
+ id: string;
27
+ };
28
+ }): (repos: IProcessVoidPayTransactionRepos) => Promise<void>;
29
+ export { IProcessVoidPayTransactionRepos, processVoidPayTransaction, };