@chevre/domain 25.2.0-alpha.3 → 25.2.0-alpha.31
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.
- package/lib/chevre/factory/customerTelephone2COATelNum.d.ts +3 -0
- package/lib/chevre/factory/customerTelephone2COATelNum.js +23 -0
- package/lib/chevre/repo/action/acceptPay.d.ts +15 -0
- package/lib/chevre/repo/action/acceptPay.js +47 -19
- package/lib/chevre/repo/action/actionProcess.js +57 -57
- package/lib/chevre/repo/action.d.ts +16 -9
- package/lib/chevre/repo/action.js +99 -180
- package/lib/chevre/repo/message.d.ts +1 -1
- package/lib/chevre/repo/message.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/action.js +67 -66
- package/lib/chevre/repo/mongoose/schemas/order.d.ts +4 -0
- package/lib/chevre/repo/mongoose/schemas/order.js +10 -0
- package/lib/chevre/repo/mongoose/schemas/setting.d.ts +4 -0
- package/lib/chevre/repo/mongoose/schemas/task.js +12 -12
- package/lib/chevre/repo/order.d.ts +735 -0
- package/lib/chevre/repo/order.js +13 -20
- package/lib/chevre/repo/orderInTransaction.d.ts +45 -0
- package/lib/chevre/repo/orderInTransaction.js +175 -0
- package/lib/chevre/repo/person.d.ts +0 -15
- package/lib/chevre/repo/person.js +122 -108
- package/lib/chevre/repo/transaction/placeOrder.d.ts +2 -45
- package/lib/chevre/repo/transaction/placeOrder.js +43 -83
- package/lib/chevre/service/assetTransaction/pay/publishPaymentUrl.js +1 -1
- package/lib/chevre/service/assetTransaction/pay/start/factory.js +3 -4
- package/lib/chevre/service/offer/event/authorize/factory.d.ts +5 -5
- package/lib/chevre/service/offer/event/authorize/factory.js +30 -20
- package/lib/chevre/service/offer/event/authorize.d.ts +2 -2
- package/lib/chevre/service/offer/event/authorize.js +3 -3
- package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.d.ts +6 -7
- package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.js +10 -10
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.d.ts +0 -5
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +17 -14
- package/lib/chevre/service/offer/eventServiceByCOA/authorizeByAcceptAction.d.ts +0 -5
- package/lib/chevre/service/offer/eventServiceByCOA/authorizeByAcceptAction.js +2 -2
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +1 -1
- package/lib/chevre/service/order/deleteOrder.d.ts +5 -1
- package/lib/chevre/service/order/deleteOrder.js +8 -1
- package/lib/chevre/service/order/onAssetTransactionStatusChanged/onPayTransactionConfirmed.d.ts +2 -0
- package/lib/chevre/service/order/onAssetTransactionStatusChanged/paymentDue2Processing.d.ts +2 -0
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +2 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.d.ts +5 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.js +95 -33
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.d.ts +2 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.js +2 -6
- package/lib/chevre/service/order/payOrder.d.ts +2 -0
- package/lib/chevre/service/order/placeOrder.d.ts +2 -0
- package/lib/chevre/service/payment/any/authorize/fixOrderAsNeeded.js +1 -2
- package/lib/chevre/service/payment/any/authorize/fixTransactionNumber.d.ts +3 -2
- package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.d.ts +4 -3
- package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.js +3 -31
- package/lib/chevre/service/payment/any/authorize.js +13 -37
- package/lib/chevre/service/payment/any/factory.d.ts +6 -6
- package/lib/chevre/service/payment/any/factory.js +19 -22
- package/lib/chevre/service/payment/any/findAcceptAction.d.ts +3 -1
- package/lib/chevre/service/payment/any/findAcceptAction.js +14 -6
- package/lib/chevre/service/payment/any/invalidatePaymentUrl.d.ts +2 -0
- package/lib/chevre/service/payment/any/invalidatePaymentUrl.js +4 -66
- package/lib/chevre/service/payment/any/publishPaymentUrl.d.ts +4 -0
- package/lib/chevre/service/payment/any/publishPaymentUrl.js +4 -18
- package/lib/chevre/service/payment/any/voidPayTransaction.d.ts +2 -0
- package/lib/chevre/service/payment/any/voidPayTransaction.js +1 -23
- package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard.d.ts +1 -1
- package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard.js +5 -9
- package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +17 -8
- package/lib/chevre/service/reserve/searchByOrder.js +2 -6
- package/lib/chevre/service/task/confirmReserveTransaction.js +2 -7
- package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +2 -2
- package/lib/chevre/service/task/onOrderPaymentCompleted.js +2 -0
- package/lib/chevre/service/task/placeOrder.js +2 -2
- package/lib/chevre/service/task/publishPaymentUrl.js +7 -3
- package/lib/chevre/service/task/voidPayTransaction.js +3 -7
- package/lib/chevre/service/transaction/deleteTransaction/deletePayTransactionsByPlaceOrder.d.ts +15 -0
- package/lib/chevre/service/transaction/deleteTransaction/deletePayTransactionsByPlaceOrder.js +51 -0
- package/lib/chevre/service/transaction/deleteTransaction/deleteReservationsByPlaceOrder.d.ts +23 -0
- package/lib/chevre/service/transaction/deleteTransaction/deleteReservationsByPlaceOrder.js +64 -0
- package/lib/chevre/service/transaction/deleteTransaction.js +15 -152
- package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions.js +0 -1
- package/lib/chevre/service/transaction/placeOrder/confirm/prepareUnitPriceOfferConditions.d.ts +7 -2
- package/lib/chevre/service/transaction/placeOrder/confirm/prepareUnitPriceOfferConditions.js +16 -12
- package/lib/chevre/service/transaction/placeOrder/confirm/validation/factory.d.ts +5 -1
- package/lib/chevre/service/transaction/placeOrder/confirm/validation.d.ts +11 -2
- package/lib/chevre/service/transaction/placeOrder/confirm/validation.js +112 -91
- package/lib/chevre/service/transaction/placeOrder/confirm.d.ts +4 -0
- package/lib/chevre/service/transaction/placeOrder/confirm.js +31 -74
- package/lib/chevre/service/transaction/placeOrder/publishConfirmationNumberIfNotExist.d.ts +4 -7
- package/lib/chevre/service/transaction/placeOrder/publishConfirmationNumberIfNotExist.js +33 -15
- package/lib/chevre/service/transaction/placeOrder/updateAgent.d.ts +2 -0
- package/lib/chevre/service/transaction/placeOrder/updateAgent.js +19 -9
- package/package.json +5 -4
package/lib/chevre/service/order/onAssetTransactionStatusChanged/onPayTransactionConfirmed.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AcceptedOfferRepo } from '../../../repo/acceptedOffer';
|
|
2
2
|
import type { AssetTransactionRepo } from '../../../repo/assetTransaction';
|
|
3
|
+
import type { MessageRepo } from '../../../repo/message';
|
|
3
4
|
import type { OrderRepo } from '../../../repo/order';
|
|
4
5
|
import type { SettingRepo } from '../../../repo/setting';
|
|
5
6
|
import type { TaskRepo } from '../../../repo/task';
|
|
@@ -9,6 +10,7 @@ import type { IntegrationSettingRepo as Settings } from '../../../repo/setting/i
|
|
|
9
10
|
interface IOnPayTransactionConfirmedRepos {
|
|
10
11
|
acceptedOffer: AcceptedOfferRepo;
|
|
11
12
|
assetTransaction: AssetTransactionRepo;
|
|
13
|
+
message: MessageRepo;
|
|
12
14
|
order: OrderRepo;
|
|
13
15
|
setting: SettingRepo;
|
|
14
16
|
task: TaskRepo;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AcceptedOfferRepo } from '../../../repo/acceptedOffer';
|
|
2
|
+
import type { MessageRepo } from '../../../repo/message';
|
|
2
3
|
import type { OrderRepo } from '../../../repo/order';
|
|
3
4
|
import type { SettingRepo } from '../../../repo/setting';
|
|
4
5
|
import type { TaskRepo } from '../../../repo/task';
|
|
@@ -6,6 +7,7 @@ import type { PlaceOrderRepo } from '../../../repo/transaction/placeOrder';
|
|
|
6
7
|
import type { IntegrationSettingRepo as Settings } from '../../../repo/setting/integration';
|
|
7
8
|
interface IPaymentDue2ProcessingRepos {
|
|
8
9
|
acceptedOffer: AcceptedOfferRepo;
|
|
10
|
+
message: MessageRepo;
|
|
9
11
|
order: OrderRepo;
|
|
10
12
|
setting: SettingRepo;
|
|
11
13
|
task: TaskRepo;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AcceptedOfferRepo } from '../../repo/acceptedOffer';
|
|
2
2
|
import type { AssetTransactionRepo } from '../../repo/assetTransaction';
|
|
3
|
+
import type { MessageRepo } from '../../repo/message';
|
|
3
4
|
import type { OrderRepo } from '../../repo/order';
|
|
4
5
|
import type { SettingRepo } from '../../repo/setting';
|
|
5
6
|
import type { TaskRepo } from '../../repo/task';
|
|
@@ -11,6 +12,7 @@ import type { IntegrationSettingRepo as Settings } from '../../repo/setting/inte
|
|
|
11
12
|
interface IOnAssetTransactionStatusChangedRepos {
|
|
12
13
|
acceptedOffer: AcceptedOfferRepo;
|
|
13
14
|
assetTransaction: AssetTransactionRepo;
|
|
15
|
+
message: MessageRepo;
|
|
14
16
|
order: OrderRepo;
|
|
15
17
|
setting: SettingRepo;
|
|
16
18
|
task: TaskRepo;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import type { MessageRepo } from '../../../../repo/message';
|
|
1
2
|
import type { TaskRepo } from '../../../../repo/task';
|
|
2
3
|
import { factory } from '../../../../factory';
|
|
3
4
|
declare function createSendEmailMessageTaskIfNotExist(params: {
|
|
4
|
-
sendEmailMessage?:
|
|
5
|
+
sendEmailMessage?: {
|
|
6
|
+
object: factory.action.transfer.send.message.email.IOptimizedObject;
|
|
7
|
+
}[];
|
|
5
8
|
order: Pick<factory.order.IOrder, 'customer' | 'orderDate' | 'orderNumber' | 'price' | 'priceCurrency' | 'project' | 'typeOf'>;
|
|
6
9
|
}): (repos: {
|
|
10
|
+
message: MessageRepo;
|
|
7
11
|
task: TaskRepo;
|
|
8
12
|
}) => Promise<void>;
|
|
9
13
|
export { createSendEmailMessageTaskIfNotExist };
|
|
@@ -1,45 +1,107 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.createSendEmailMessageTaskIfNotExist = createSendEmailMessageTaskIfNotExist;
|
|
7
|
+
const debug_1 = __importDefault(require("debug"));
|
|
4
8
|
const util_1 = require("util");
|
|
5
9
|
const factory_1 = require("../../../../factory");
|
|
10
|
+
const debug = (0, debug_1.default)('chevre-domain:service:order');
|
|
6
11
|
function createSendEmailMessageTaskIfNotExist(params) {
|
|
7
12
|
return async (repos) => {
|
|
8
13
|
const sendEmailMessageActions = params.sendEmailMessage;
|
|
9
14
|
const now = new Date();
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
15
|
+
// 取引のpotentialActions参照を廃止して、messageリポジトリを参照して存在すればタスクを作成(2026-07-16~)
|
|
16
|
+
const message4order = (await repos.message.findMessages({
|
|
17
|
+
limit: 1,
|
|
18
|
+
page: 1,
|
|
19
|
+
about: { identifier: { $eq: factory_1.factory.creativeWork.message.email.AboutIdentifier.OnOrderSent } },
|
|
20
|
+
mainEntity: { orderNumber: { $eq: params.order.orderNumber } }
|
|
21
|
+
}, ['identifier'])).shift();
|
|
22
|
+
debug('createSendEmailMessageTaskIfNotExist: message4order:', JSON.stringify(message4order));
|
|
23
|
+
if (typeof message4order?.identifier === 'string') {
|
|
24
|
+
// 取引のpotentialActionsが存在する間は、メッセージ識別子が想定通りか確認する
|
|
25
|
+
const messageIdentifierByTransaction = sendEmailMessageActions?.at(0)?.object.identifier;
|
|
26
|
+
if (typeof messageIdentifierByTransaction === 'string') {
|
|
27
|
+
debug('createSendEmailMessageTaskIfNotExist: identifier matched?', message4order.identifier, messageIdentifierByTransaction);
|
|
28
|
+
if (message4order.identifier !== messageIdentifierByTransaction) {
|
|
29
|
+
throw new factory_1.factory.errors.Internal(`message identifier not matched. ${message4order.identifier} ${messageIdentifierByTransaction}`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const taskIdentifier = (0, util_1.format)('%s:%s:%s:%s:%s:%s', params.order.project.id, factory_1.factory.taskName.SendEmailMessage, params.order.typeOf, params.order.orderNumber, factory_1.factory.orderStatus.OrderProcessing, 0 // 複数メッセージに対応していた時期の名残(2026-07-16~)
|
|
33
|
+
);
|
|
34
|
+
const simpleOrder = {
|
|
35
|
+
typeOf: params.order.typeOf,
|
|
36
|
+
orderNumber: params.order.orderNumber,
|
|
37
|
+
orderDate: params.order.orderDate
|
|
38
|
+
};
|
|
39
|
+
const actionAttributes = {
|
|
40
|
+
project: params.order.project,
|
|
41
|
+
typeOf: factory_1.factory.actionType.SendAction,
|
|
42
|
+
object: {
|
|
43
|
+
identifier: message4order.identifier,
|
|
44
|
+
typeOf: factory_1.factory.creativeWorkType.EmailMessage
|
|
45
|
+
},
|
|
46
|
+
agent: params.order.project,
|
|
47
|
+
recipient: { typeOf: params.order.customer.typeOf, id: params.order.customer.id },
|
|
48
|
+
purpose: simpleOrder
|
|
49
|
+
};
|
|
50
|
+
const sendEmailMessageTask = {
|
|
51
|
+
alternateName: taskIdentifier,
|
|
52
|
+
identifier: taskIdentifier,
|
|
53
|
+
project: params.order.project,
|
|
54
|
+
name: factory_1.factory.taskName.SendEmailMessage,
|
|
55
|
+
status: factory_1.factory.taskStatus.Ready,
|
|
56
|
+
runsAt: now, // なるはやで実行
|
|
57
|
+
remainingNumberOfTries: 10,
|
|
58
|
+
numberOfTried: 0,
|
|
59
|
+
executionResults: [],
|
|
60
|
+
data: { actionAttributes }
|
|
61
|
+
};
|
|
62
|
+
await repos.task.createIfNotExistByAlternateName(sendEmailMessageTask, { emitImmediately: true });
|
|
43
63
|
}
|
|
64
|
+
// if (Array.isArray(sendEmailMessageActions)) {
|
|
65
|
+
// await Promise.all(sendEmailMessageActions.map(async (sendEmailMessageAction, index) => {
|
|
66
|
+
// const taskIdentifier: string = format(
|
|
67
|
+
// '%s:%s:%s:%s:%s:%s',
|
|
68
|
+
// params.order.project.id,
|
|
69
|
+
// factory.taskName.SendEmailMessage,
|
|
70
|
+
// params.order.typeOf,
|
|
71
|
+
// params.order.orderNumber,
|
|
72
|
+
// factory.orderStatus.OrderProcessing,
|
|
73
|
+
// index
|
|
74
|
+
// );
|
|
75
|
+
// const simpleOrder: factory.order.ISimpleOrder = {
|
|
76
|
+
// typeOf: params.order.typeOf,
|
|
77
|
+
// orderNumber: params.order.orderNumber,
|
|
78
|
+
// orderDate: params.order.orderDate
|
|
79
|
+
// };
|
|
80
|
+
// const actionAttributes: factory.task.sendEmailMessage.IData['actionAttributes'] = {
|
|
81
|
+
// project: params.order.project,
|
|
82
|
+
// typeOf: factory.actionType.SendAction,
|
|
83
|
+
// object: sendEmailMessageAction.object,
|
|
84
|
+
// agent: params.order.project,
|
|
85
|
+
// recipient: { typeOf: params.order.customer.typeOf, id: params.order.customer.id },
|
|
86
|
+
// purpose: simpleOrder
|
|
87
|
+
// };
|
|
88
|
+
// const sendEmailMessageTask: factory.task.IAttributes<factory.taskName.SendEmailMessage> & {
|
|
89
|
+
// alternateName: string;
|
|
90
|
+
// identifier: string;
|
|
91
|
+
// } = {
|
|
92
|
+
// alternateName: taskIdentifier,
|
|
93
|
+
// identifier: taskIdentifier,
|
|
94
|
+
// project: params.order.project,
|
|
95
|
+
// name: factory.taskName.SendEmailMessage,
|
|
96
|
+
// status: factory.taskStatus.Ready,
|
|
97
|
+
// runsAt: now, // なるはやで実行
|
|
98
|
+
// remainingNumberOfTries: 10,
|
|
99
|
+
// numberOfTried: 0,
|
|
100
|
+
// executionResults: [],
|
|
101
|
+
// data: { actionAttributes }
|
|
102
|
+
// };
|
|
103
|
+
// await repos.task.createIfNotExistByAlternateName(sendEmailMessageTask, { emitImmediately: true });
|
|
104
|
+
// }));
|
|
105
|
+
// }
|
|
44
106
|
};
|
|
45
107
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { MessageRepo } from '../../../repo/message';
|
|
1
2
|
import type { SettingRepo } from '../../../repo/setting';
|
|
2
3
|
import type { TaskRepo } from '../../../repo/task';
|
|
3
4
|
import { factory } from '../../../factory';
|
|
@@ -13,6 +14,7 @@ declare function onOrderProcessing(params: {
|
|
|
13
14
|
};
|
|
14
15
|
placeOrderTransaction?: IPlaceOrderTransaction;
|
|
15
16
|
}): (repos: {
|
|
17
|
+
message: MessageRepo;
|
|
16
18
|
setting: SettingRepo;
|
|
17
19
|
task: TaskRepo;
|
|
18
20
|
}, settings: Settings) => Promise<void>;
|
|
@@ -8,7 +8,7 @@ exports.onOrderReturned = onOrderReturned;
|
|
|
8
8
|
* 注文返品時処理
|
|
9
9
|
*/
|
|
10
10
|
const debug_1 = __importDefault(require("debug"));
|
|
11
|
-
const
|
|
11
|
+
const customerTelephone2COATelNum_1 = require("../../../factory/customerTelephone2COATelNum");
|
|
12
12
|
const factory_1 = require("../../../factory");
|
|
13
13
|
// import { createMaskedCustomer } from '../../../factory/order';
|
|
14
14
|
const factory_2 = require("./onOrderReturned/factory");
|
|
@@ -104,11 +104,7 @@ function createReturnReserveTransactionTasks(order, simpleOrder) {
|
|
|
104
104
|
if (typeof superEventLocationBranchCode !== 'string') {
|
|
105
105
|
throw new factory_1.factory.errors.ArgumentNull('order.reservationForSuperEventLocationBranchCodes');
|
|
106
106
|
}
|
|
107
|
-
const
|
|
108
|
-
const phoneNumber = phoneUtil.parse(order.customer.telephone, 'JP');
|
|
109
|
-
let telNum = phoneUtil.format(phoneNumber, google_libphonenumber_1.PhoneNumberFormat.NATIONAL);
|
|
110
|
-
// COAでは数字のみ受け付けるので数字以外を除去
|
|
111
|
-
telNum = telNum.replace(/[^\d]/g, '');
|
|
107
|
+
const telNum = (0, customerTelephone2COATelNum_1.customerTelephone2COATelNum)({ telephone: String(order.customer.telephone) });
|
|
112
108
|
returnReserveTransactionAction = {
|
|
113
109
|
project: order.project,
|
|
114
110
|
typeOf: factory_1.factory.actionType.ReturnAction,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AcceptedOfferRepo } from '../../repo/acceptedOffer';
|
|
2
|
+
import type { MessageRepo } from '../../repo/message';
|
|
2
3
|
import type { OrderRepo } from '../../repo/order';
|
|
3
4
|
import type { SettingRepo } from '../../repo/setting';
|
|
4
5
|
import type { TaskRepo } from '../../repo/task';
|
|
@@ -10,6 +11,7 @@ import type { IntegrationSettingRepo as Settings } from '../../repo/setting/inte
|
|
|
10
11
|
*/
|
|
11
12
|
declare function payOrder(params: factory.task.IData<factory.taskName.OnOrderPaymentCompleted>): (repos: {
|
|
12
13
|
acceptedOffer: AcceptedOfferRepo;
|
|
14
|
+
message: MessageRepo;
|
|
13
15
|
order: OrderRepo;
|
|
14
16
|
setting: SettingRepo;
|
|
15
17
|
task: TaskRepo;
|
|
@@ -3,6 +3,7 @@ import type { AccountingReportRepo } from '../../repo/accountingReport';
|
|
|
3
3
|
import type { ActionRepo } from '../../repo/action';
|
|
4
4
|
import type { AuthorizeOfferActionRepo } from '../../repo/action/authorizeOffer';
|
|
5
5
|
import type { AuthorizePaymentMethodActionRepo } from '../../repo/action/authorizePaymentMethod';
|
|
6
|
+
import type { MessageRepo } from '../../repo/message';
|
|
6
7
|
import type { OrderRepo } from '../../repo/order';
|
|
7
8
|
import type { OrderInTransactionRepo } from '../../repo/orderInTransaction';
|
|
8
9
|
import type { SettingRepo } from '../../repo/setting';
|
|
@@ -17,6 +18,7 @@ interface IPlaceOrderRepos {
|
|
|
17
18
|
action: ActionRepo;
|
|
18
19
|
authorizeOfferAction: AuthorizeOfferActionRepo;
|
|
19
20
|
authorizePaymentMethodAction: AuthorizePaymentMethodActionRepo;
|
|
21
|
+
message: MessageRepo;
|
|
20
22
|
order: OrderRepo;
|
|
21
23
|
orderInTransaction: OrderInTransactionRepo;
|
|
22
24
|
setting: SettingRepo;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.fixOrderAsNeeded = fixOrderAsNeeded;
|
|
4
|
-
const factory_1 = require("../../../../factory");
|
|
5
4
|
const publishConfirmationNumberIfNotExist_1 = require("../../../transaction/placeOrder/publishConfirmationNumberIfNotExist");
|
|
6
5
|
function fixOrderAsNeeded(params) {
|
|
7
6
|
return async (repos) => {
|
|
@@ -12,7 +11,7 @@ function fixOrderAsNeeded(params) {
|
|
|
12
11
|
// if (params.paymentServiceType === factory.service.paymentService.PaymentServiceType.MovieTicket) {
|
|
13
12
|
const confirmationNumber = await (0, publishConfirmationNumberIfNotExist_1.publishConfirmationNumberIfNotExist)({
|
|
14
13
|
id: params.purpose.id,
|
|
15
|
-
status: { $in: [
|
|
14
|
+
// status: { $in: [factory.transactionStatusType.InProgress] },
|
|
16
15
|
object: { orderDate }
|
|
17
16
|
})(repos);
|
|
18
17
|
// }
|
|
@@ -3,7 +3,8 @@ import type { AcceptPayActionRepo } from '../../../../repo/action/acceptPay';
|
|
|
3
3
|
import type { AuthorizePaymentMethodActionRepo } from '../../../../repo/action/authorizePaymentMethod';
|
|
4
4
|
import type { AuthorizationRepo } from '../../../../repo/authorization';
|
|
5
5
|
import type { TicketRepo } from '../../../../repo/ticket';
|
|
6
|
-
import type {
|
|
6
|
+
import type { OrderInTransactionRepo } from '../../../../repo/orderInTransaction';
|
|
7
|
+
import type { ITransactionInProgress } from '../../../../repo/transaction/placeOrder';
|
|
7
8
|
import type { TransactionNumberRepo } from '../../../../repo/transactionNumber';
|
|
8
9
|
import * as PayTransactionService from '../../../assetTransaction/pay';
|
|
9
10
|
import { IInvoiceByTicketToken } from '../factory';
|
|
@@ -13,7 +14,7 @@ interface IFixTransactionNumberRepos {
|
|
|
13
14
|
authorizePaymentMethodAction: AuthorizePaymentMethodActionRepo;
|
|
14
15
|
authorization: AuthorizationRepo;
|
|
15
16
|
ticket: TicketRepo;
|
|
16
|
-
|
|
17
|
+
orderInTransaction: OrderInTransactionRepo;
|
|
17
18
|
transactionNumber: TransactionNumberRepo;
|
|
18
19
|
}
|
|
19
20
|
type IFixTransactionNumberOperation<T> = (repos: IFixTransactionNumberRepos) => Promise<T>;
|
package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.d.ts
CHANGED
|
@@ -3,7 +3,8 @@ import type { AcceptPayActionRepo } from '../../../../repo/action/acceptPay';
|
|
|
3
3
|
import type { AuthorizePaymentMethodActionRepo } from '../../../../repo/action/authorizePaymentMethod';
|
|
4
4
|
import type { AuthorizationRepo } from '../../../../repo/authorization';
|
|
5
5
|
import type { TicketRepo } from '../../../../repo/ticket';
|
|
6
|
-
import type {
|
|
6
|
+
import type { OrderInTransactionRepo } from '../../../../repo/orderInTransaction';
|
|
7
|
+
import type { ITransactionInProgress } from '../../../../repo/transaction/placeOrder';
|
|
7
8
|
import * as PayTransactionService from '../../../assetTransaction/pay';
|
|
8
9
|
import type { IInvoiceByTicketToken } from '../factory';
|
|
9
10
|
type IObjectWithoutDetail = factory.action.authorize.paymentMethod.any.IObjectWithoutDetail;
|
|
@@ -17,7 +18,7 @@ interface IHandlePrePublishedPaymentMethodIdOnAuthorizingRepos {
|
|
|
17
18
|
authorizePaymentMethodAction: AuthorizePaymentMethodActionRepo;
|
|
18
19
|
authorization: AuthorizationRepo;
|
|
19
20
|
ticket: TicketRepo;
|
|
20
|
-
|
|
21
|
+
orderInTransaction: OrderInTransactionRepo;
|
|
21
22
|
}
|
|
22
23
|
/**
|
|
23
24
|
* 決済承認前の決済採用アクションを参照する
|
|
@@ -29,9 +30,9 @@ declare function handlePrePublishedPaymentMethodIdOnAuthorizing(params: {
|
|
|
29
30
|
}): (repos: IHandlePrePublishedPaymentMethodIdOnAuthorizingRepos) => Promise<{
|
|
30
31
|
authorizeParams?: {
|
|
31
32
|
creditCard: factory.action.authorize.paymentMethod.any.ICreditCard;
|
|
32
|
-
paymentMethodByTransaction: factory.transaction.placeOrder.IPaymentMethodByPaymentUrl;
|
|
33
33
|
pendingPaymentAgencyTransaction: PayTransactionService.IPaymentAgencyTransaction;
|
|
34
34
|
acceptAction2ticketResult?: IAcceptAction2ticketResult;
|
|
35
|
+
paymentMethodByTransaction?: never;
|
|
35
36
|
};
|
|
36
37
|
existingCompletedAuthorizeAction?: never;
|
|
37
38
|
} | {
|
package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.js
CHANGED
|
@@ -98,25 +98,8 @@ function handlePrePublishedPaymentMethodIdOnAuthorizing(params) {
|
|
|
98
98
|
let existingCompletedAuthorizeAction;
|
|
99
99
|
let acceptPayAction;
|
|
100
100
|
// transaction.objectへのアクセス回避(2024-05-30~)
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (params.prePublishedPaymentMethodId === paymentMethodByTransaction?.paymentMethodId) {
|
|
104
|
-
// check existence of acceptAction when authorizing payment(2024-06-01~)
|
|
105
|
-
// acceptPayAction = (<Pick<IAcceptPayAction, 'object' | 'result' | 'id' | 'instrument'>[]>await repos.action.search<factory.actionType.AcceptAction>(
|
|
106
|
-
// {
|
|
107
|
-
// limit: 1,
|
|
108
|
-
// page: 1,
|
|
109
|
-
// project: { id: { $eq: params.transaction.project.id } },
|
|
110
|
-
// typeOf: { $eq: factory.actionType.AcceptAction },
|
|
111
|
-
// actionStatus: { $in: [factory.actionStatusType.CompletedActionStatus] },
|
|
112
|
-
// purpose: { id: { $in: [params.transaction.id] } },
|
|
113
|
-
// object: {
|
|
114
|
-
// transactionNumber: { $eq: params.prePublishedPaymentMethodId },
|
|
115
|
-
// typeOf: { $eq: factory.assetTransactionType.Pay }
|
|
116
|
-
// }
|
|
117
|
-
// },
|
|
118
|
-
// ['object', 'result', 'instrument']
|
|
119
|
-
// )).shift();
|
|
101
|
+
const paymentMethodIdByTransaction = await repos.orderInTransaction.findInProgressPaymentMethodId({ id: params.transaction.id });
|
|
102
|
+
if (params.prePublishedPaymentMethodId === paymentMethodIdByTransaction) {
|
|
120
103
|
acceptPayAction = (await repos.acceptPayAction.findCompletedAcceptActionsByTransactionNumber({
|
|
121
104
|
project: { id: params.transaction.project.id },
|
|
122
105
|
purpose: { id: params.transaction.id },
|
|
@@ -154,17 +137,6 @@ function handlePrePublishedPaymentMethodIdOnAuthorizing(params) {
|
|
|
154
137
|
throw new factory_1.factory.errors.Argument('paymentMethodId', 'pendingPaymentAgencyTransaction not found');
|
|
155
138
|
}
|
|
156
139
|
// 既に承認済であれば何もしない(2023-05-15~)
|
|
157
|
-
// const existingCompletedAuthorizeActions = <IAuthorizePaymentAction[]>
|
|
158
|
-
// await repos.action.searchByPurpose<factory.actionType.AuthorizeAction>({
|
|
159
|
-
// typeOf: factory.actionType.AuthorizeAction,
|
|
160
|
-
// purpose: { id: params.transaction.id, typeOf: params.transaction.typeOf },
|
|
161
|
-
// actionStatus: { $eq: factory.actionStatusType.CompletedActionStatus },
|
|
162
|
-
// object: {
|
|
163
|
-
// paymentMethodId: { $eq: params.prePublishedPaymentMethodId },
|
|
164
|
-
// typeOf: { $eq: factory.action.authorize.paymentMethod.any.ResultType.Payment }
|
|
165
|
-
// },
|
|
166
|
-
// sort: { startDate: factory.sortType.Ascending }
|
|
167
|
-
// });
|
|
168
140
|
const existingCompletedAuthorizeActions = await repos.authorizePaymentMethodAction.findAuthorizePaymentMethodActionsByPurpose({
|
|
169
141
|
purpose: { id: params.transaction.id, typeOf: params.transaction.typeOf },
|
|
170
142
|
actionStatus: { $eq: factory_1.factory.actionStatusType.CompletedActionStatus },
|
|
@@ -185,7 +157,7 @@ function handlePrePublishedPaymentMethodIdOnAuthorizing(params) {
|
|
|
185
157
|
acceptPayAction
|
|
186
158
|
})(repos);
|
|
187
159
|
return {
|
|
188
|
-
authorizeParams: { creditCard, pendingPaymentAgencyTransaction,
|
|
160
|
+
authorizeParams: { creditCard, pendingPaymentAgencyTransaction, acceptAction2ticketResult }
|
|
189
161
|
};
|
|
190
162
|
}
|
|
191
163
|
else {
|
|
@@ -78,13 +78,15 @@ function authorize(params) {
|
|
|
78
78
|
authorizePaymentMethodAction: repos.authorizePaymentMethodAction,
|
|
79
79
|
authorization: repos.authorization,
|
|
80
80
|
ticket: repos.ticket,
|
|
81
|
-
|
|
81
|
+
orderInTransaction: repos.orderInTransaction,
|
|
82
82
|
transactionNumber: repos.transactionNumber
|
|
83
83
|
});
|
|
84
84
|
if (typeof fixTransactionNumberResult.id === 'string') {
|
|
85
85
|
return { id: fixTransactionNumberResult.id };
|
|
86
86
|
}
|
|
87
|
-
const { transactionNumber, pendingPaymentAgencyTransaction, creditCard,
|
|
87
|
+
const { transactionNumber, pendingPaymentAgencyTransaction, creditCard,
|
|
88
|
+
// invoiceByTicketToken,
|
|
89
|
+
ticketToken } = fixTransactionNumberResult;
|
|
88
90
|
const movieTickets = (Array.isArray(params.object.movieTickets)) ? params.object.movieTickets.map(factory_2.createMovieTicket) : undefined;
|
|
89
91
|
const { accountId } = await fixAccountIdIfPossible({
|
|
90
92
|
object: params.object, project: { id: transaction.project.id }
|
|
@@ -196,10 +198,10 @@ function authorize(params) {
|
|
|
196
198
|
throw error;
|
|
197
199
|
}
|
|
198
200
|
}
|
|
199
|
-
const result = (0, factory_2.
|
|
201
|
+
const result = (0, factory_2.payTransaction2actionResult)({
|
|
200
202
|
payTransaction,
|
|
201
|
-
object: authorizeObjectIncludingPaymentMethodDetails,
|
|
202
|
-
invoiceByTicketToken
|
|
203
|
+
// object: authorizeObjectIncludingPaymentMethodDetails,
|
|
204
|
+
// invoiceByTicketToken
|
|
203
205
|
});
|
|
204
206
|
await repos.authorizePaymentMethodAction.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: result });
|
|
205
207
|
return { id: action.id };
|
|
@@ -209,40 +211,14 @@ function authorize(params) {
|
|
|
209
211
|
* 承認しようとしているobjectからaccountIdを決定する
|
|
210
212
|
*/
|
|
211
213
|
function fixAccountIdIfPossible(params) {
|
|
212
|
-
return async (
|
|
213
|
-
// repos: {
|
|
214
|
-
// action: ActionRepo;
|
|
215
|
-
// authorization: AuthorizationRepo;
|
|
216
|
-
// ticket: TicketRepo;
|
|
217
|
-
// }
|
|
218
|
-
// credentials: {
|
|
219
|
-
// jwt: JWTCredentials;
|
|
220
|
-
// }
|
|
221
|
-
) => {
|
|
214
|
+
return async () => {
|
|
222
215
|
let accountId = '';
|
|
223
|
-
const fromLocation = params.object?.fromLocation;
|
|
216
|
+
// const fromLocation = params.object?.fromLocation;
|
|
224
217
|
const movieTickets = params.object?.movieTickets;
|
|
225
|
-
// discontinue token as fromLocation(ticketTokenへ移行するべき)(2024-12-18~)
|
|
226
|
-
if (typeof fromLocation === 'string') {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
// const { authorizedObject } = await verifyToken({
|
|
230
|
-
// project: { id: params.project.id },
|
|
231
|
-
// agent: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
232
|
-
// token: fromLocation
|
|
233
|
-
// })(repos);
|
|
234
|
-
// const paymentCardOwnershipInfo = authorizedObject;
|
|
235
|
-
// if (Array.isArray(paymentCardOwnershipInfo)) {
|
|
236
|
-
// throw new factory.errors.NotImplemented('fromLocation as an array not implemented');
|
|
237
|
-
// }
|
|
238
|
-
// if (paymentCardOwnershipInfo.typeOf !== 'OwnershipInfo') {
|
|
239
|
-
// throw new factory.errors.Argument('fromLocation', 'must be OwnershipInfo');
|
|
240
|
-
// }
|
|
241
|
-
// if (paymentCardOwnershipInfo.typeOfGood.typeOf !== factory.permit.PermitType.Permit) {
|
|
242
|
-
// throw new factory.errors.Argument('fromLocation', 'must be Permit');
|
|
243
|
-
// }
|
|
244
|
-
// accountId = paymentCardOwnershipInfo.typeOfGood.identifier;
|
|
245
|
-
}
|
|
218
|
+
// // discontinue token as fromLocation(ticketTokenへ移行するべき)(2024-12-18~)
|
|
219
|
+
// if (typeof fromLocation === 'string') {
|
|
220
|
+
// throw new factory.errors.NotImplemented('object.fromLocation as string not implemented');
|
|
221
|
+
// }
|
|
246
222
|
// 購入番号管理番号をaccountIdにセット(2024-03-24~)
|
|
247
223
|
if (Array.isArray(movieTickets) && movieTickets.length > 0) {
|
|
248
224
|
accountId = movieTickets[0].identifier; // 決済カードidentifierは1つのみ許可の前提
|
|
@@ -49,13 +49,13 @@ export declare function creatPayTransactionStartParams(params: {
|
|
|
49
49
|
instrument: factory.action.trade.pay.IPlaceOrderRelatedInstrument[];
|
|
50
50
|
};
|
|
51
51
|
export declare function createMovieTicket(params: factory.action.trade.pay.IMovieTicket): factory.action.trade.pay.IMovieTicket;
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
/**
|
|
53
|
+
* 決済取引から決済承認アクション結果を生成する
|
|
54
|
+
*/
|
|
55
|
+
export declare function payTransaction2actionResult(params: {
|
|
54
56
|
payTransaction: Pick<factory.assetTransaction.pay.ITransaction, 'object'>;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
*/
|
|
58
|
-
invoiceByTicketToken?: IInvoiceByTicketToken;
|
|
57
|
+
object?: never;
|
|
58
|
+
invoiceByTicketToken?: never;
|
|
59
59
|
}): factory.action.authorize.paymentMethod.any.IResult;
|
|
60
60
|
/**
|
|
61
61
|
* 通知対象としてのアクションを最適化
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.creatPublishPaymentUrlParams = creatPublishPaymentUrlParams;
|
|
7
7
|
exports.creatPayTransactionStartParams = creatPayTransactionStartParams;
|
|
8
8
|
exports.createMovieTicket = createMovieTicket;
|
|
9
|
-
exports.
|
|
9
|
+
exports.payTransaction2actionResult = payTransaction2actionResult;
|
|
10
10
|
exports.optimizeAction4inform = optimizeAction4inform;
|
|
11
11
|
const moment_1 = __importDefault(require("moment"));
|
|
12
12
|
const util_1 = require("util");
|
|
@@ -140,7 +140,7 @@ function creatPayTransactionStartParams(params) {
|
|
|
140
140
|
...(typeof params.object.name === 'string') ? { name: params.object.name } : undefined,
|
|
141
141
|
...(typeof accountId === 'string') ? { accountId } : undefined,
|
|
142
142
|
...(typeof params.object.description === 'string') ? { description: params.object.description } : undefined,
|
|
143
|
-
...(typeof params.object.fromLocation === 'string') ? { fromLocation: params.object.fromLocation } : undefined,
|
|
143
|
+
// ...(typeof params.object.fromLocation === 'string') ? { fromLocation: params.object.fromLocation } : undefined, // discontinue(2026-07-08~)
|
|
144
144
|
...(params.object.creditCard !== undefined) ? { creditCard: params.object.creditCard } : undefined,
|
|
145
145
|
...(Array.isArray(movieTickets)) ? { movieTickets } : undefined
|
|
146
146
|
},
|
|
@@ -193,8 +193,14 @@ function createMovieTicket(params) {
|
|
|
193
193
|
serviceOutput
|
|
194
194
|
};
|
|
195
195
|
}
|
|
196
|
-
|
|
197
|
-
|
|
196
|
+
/**
|
|
197
|
+
* 決済取引から決済承認アクション結果を生成する
|
|
198
|
+
*/
|
|
199
|
+
function payTransaction2actionResult(params) {
|
|
200
|
+
const {
|
|
201
|
+
// object,
|
|
202
|
+
payTransaction } = params;
|
|
203
|
+
const payTransactionObject = payTransaction.object;
|
|
198
204
|
const totalPaymentDue = payTransactionObject.paymentMethod?.totalPaymentDue;
|
|
199
205
|
if (typeof totalPaymentDue?.typeOf !== 'string') {
|
|
200
206
|
throw new factory_1.factory.errors.Internal('payTransaction.object.paymentMethod.totalPaymentDue undefined');
|
|
@@ -208,7 +214,8 @@ function createAuthorizeResult(params) {
|
|
|
208
214
|
? payTransactionObject.paymentMethod?.amount?.currency
|
|
209
215
|
: undefined;
|
|
210
216
|
const paymentMethodAsObject = {
|
|
211
|
-
typeOf:
|
|
217
|
+
// typeOf: object.paymentMethod,
|
|
218
|
+
typeOf: payTransactionObject.paymentMethod.identifier,
|
|
212
219
|
// CreditCardIFのカード通貨区分を追加(2023-08-15~)
|
|
213
220
|
...(payTransactionObject.typeOf === factory_1.factory.service.paymentService.PaymentServiceType.CreditCard
|
|
214
221
|
&& typeof paymentMethodAmountCurrencyByPayTransaction === 'string')
|
|
@@ -223,9 +230,11 @@ function createAuthorizeResult(params) {
|
|
|
223
230
|
}
|
|
224
231
|
}
|
|
225
232
|
let invoiceOrderItems;
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
233
|
+
// const referencesOrderByObject = object.referencesOrder;
|
|
234
|
+
const referencesOrderByObject = payTransactionObject.serviceOutput?.referencesOrder;
|
|
235
|
+
if (referencesOrderByObject?.typeOf === factory_1.factory.order.OrderType.Order) {
|
|
236
|
+
if (Array.isArray(referencesOrderByObject.orderedItem)) {
|
|
237
|
+
invoiceOrderItems = referencesOrderByObject.orderedItem;
|
|
229
238
|
}
|
|
230
239
|
}
|
|
231
240
|
const referencesOrder = {
|
|
@@ -239,8 +248,6 @@ function createAuthorizeResult(params) {
|
|
|
239
248
|
? payTransactionObject.paymentMethod.accountId
|
|
240
249
|
: '',
|
|
241
250
|
issuedThrough,
|
|
242
|
-
// 完全廃止(paymentMethodAsObjectへ完全移行)(2023-08-16~)
|
|
243
|
-
// paymentMethod: params.object.paymentMethod,
|
|
244
251
|
paymentMethodAsObject,
|
|
245
252
|
paymentStatus,
|
|
246
253
|
paymentMethodId: (typeof payTransactionObject.paymentMethodId === 'string')
|
|
@@ -248,22 +255,12 @@ function createAuthorizeResult(params) {
|
|
|
248
255
|
: '',
|
|
249
256
|
name: (typeof payTransactionObject.paymentMethod?.name === 'string')
|
|
250
257
|
? payTransactionObject.paymentMethod.name
|
|
251
|
-
:
|
|
258
|
+
: payTransactionObject.paymentMethod.identifier,
|
|
252
259
|
totalPaymentDue: totalPaymentDue,
|
|
253
|
-
additionalProperty: (Array.isArray(
|
|
260
|
+
additionalProperty: (Array.isArray(payTransactionObject.paymentMethod.additionalProperty)) ? payTransactionObject.paymentMethod.additionalProperty : [],
|
|
254
261
|
typeOf: factory_1.factory.action.authorize.paymentMethod.any.ResultType.Payment,
|
|
255
262
|
referencesOrder // add(2025-11-23~)
|
|
256
263
|
};
|
|
257
|
-
// eslint-disable-next-line no-warning-comments
|
|
258
|
-
// TODO 保留 resultにメンバーシップを追加(2024-08-13~)
|
|
259
|
-
// let resultAsPermit: factory.action.authorize.paymentMethod.any.IResultAsPermit | undefined;
|
|
260
|
-
// if (typeof params.permit?.identifier === 'string') {
|
|
261
|
-
// resultAsPermit = {
|
|
262
|
-
// typeOf: factory.permit.PermitType.Permit,
|
|
263
|
-
// identifier: params.permit.identifier,
|
|
264
|
-
// issuedThrough: { serviceType: params.permit.issuedThrough?.serviceType }
|
|
265
|
-
// };
|
|
266
|
-
// }
|
|
267
264
|
// Arrayに統一(2023-09-04~)
|
|
268
265
|
// if (resultAsPermit !== undefined) {
|
|
269
266
|
// return [resultAsInvoice, resultAsPermit];
|
|
@@ -18,7 +18,9 @@ interface IFindAcceptActionResult {
|
|
|
18
18
|
name?: string;
|
|
19
19
|
message?: string;
|
|
20
20
|
};
|
|
21
|
-
result?: factory.action.accept.pay.IResult
|
|
21
|
+
result?: Pick<factory.action.accept.pay.IResult, 'paymentMethodId'> & {
|
|
22
|
+
paymentUrl: string;
|
|
23
|
+
};
|
|
22
24
|
}
|
|
23
25
|
declare function findAcceptAction(params: {
|
|
24
26
|
project: {
|