@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
|
@@ -42,12 +42,20 @@ function findAcceptAction(params) {
|
|
|
42
42
|
if (acceptAction.purpose?.id !== params.purpose.id) {
|
|
43
43
|
throw new factory_1.factory.errors.NotFound('Action');
|
|
44
44
|
}
|
|
45
|
-
|
|
45
|
+
// result.paymentUrl廃止につき、paymentUrlはrecipeを参照する(2026-07-14~)
|
|
46
|
+
// const acceptActionWithResult = await repos.acceptPayAction.findById(
|
|
47
|
+
// { id: acceptAction.id, typeOf: factory.actionType.AcceptAction },
|
|
48
|
+
// ['result', 'object'],
|
|
49
|
+
// []
|
|
50
|
+
// ) as Pick<factory.action.accept.pay.IAction, 'result' | 'object'>;
|
|
51
|
+
const acceptPayResult = await repos.acceptPayAction.findPaymentUrlById({
|
|
52
|
+
project: { id: params.project.id },
|
|
53
|
+
id: acceptAction.id
|
|
54
|
+
});
|
|
46
55
|
action = {
|
|
47
56
|
id: acceptAction.id,
|
|
48
57
|
actionStatus: acceptAction.actionStatus,
|
|
49
|
-
// add object.transactionNumber(2025-08-26~)
|
|
50
|
-
object: { transactionNumber: acceptActionWithResult.object.transactionNumber },
|
|
58
|
+
object: { transactionNumber: acceptPayResult.paymentMethodId }, // add object.transactionNumber(2025-08-26~)
|
|
51
59
|
...(acceptAction.error !== undefined)
|
|
52
60
|
? {
|
|
53
61
|
error: (Array.isArray(acceptAction.error))
|
|
@@ -55,11 +63,11 @@ function findAcceptAction(params) {
|
|
|
55
63
|
: acceptAction.error
|
|
56
64
|
}
|
|
57
65
|
: undefined,
|
|
58
|
-
...(
|
|
66
|
+
...(typeof acceptPayResult.paymentUrl === 'string')
|
|
59
67
|
? {
|
|
60
68
|
result: {
|
|
61
|
-
paymentMethodId:
|
|
62
|
-
paymentUrl:
|
|
69
|
+
paymentMethodId: acceptPayResult.paymentMethodId,
|
|
70
|
+
paymentUrl: acceptPayResult.paymentUrl
|
|
63
71
|
}
|
|
64
72
|
}
|
|
65
73
|
: undefined
|
|
@@ -6,6 +6,7 @@ import type { PaymentServiceRepo } from '../../../repo/paymentService';
|
|
|
6
6
|
import type { PaymentServiceProviderRepo } from '../../../repo/paymentServiceProvider';
|
|
7
7
|
import type { SellerPaymentAcceptedRepo } from '../../../repo/sellerPaymentAccepted';
|
|
8
8
|
import type { TaskRepo } from '../../../repo/task';
|
|
9
|
+
import type { OrderInTransactionRepo } from '../../../repo/orderInTransaction';
|
|
9
10
|
import type { PlaceOrderRepo } from '../../../repo/transaction/placeOrder';
|
|
10
11
|
interface IInvalidatePaymentUrlRepos {
|
|
11
12
|
accountingReport: AccountingReportRepo;
|
|
@@ -16,6 +17,7 @@ interface IInvalidatePaymentUrlRepos {
|
|
|
16
17
|
paymentService: PaymentServiceRepo;
|
|
17
18
|
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
18
19
|
task: TaskRepo;
|
|
20
|
+
orderInTransaction: OrderInTransactionRepo;
|
|
19
21
|
placeOrder: PlaceOrderRepo;
|
|
20
22
|
}
|
|
21
23
|
/**
|
|
@@ -25,14 +25,6 @@ function invalidatePaymentUrl(params) {
|
|
|
25
25
|
// }
|
|
26
26
|
// support multiple accept actions(2025-02-25~)
|
|
27
27
|
let acceptPayActions = await repos.acceptPayAction.findAcceptActionsByPurpose({
|
|
28
|
-
// project: { id: { $eq: transaction.project.id } },
|
|
29
|
-
// typeOf: { $eq: factory.actionType.AcceptAction },
|
|
30
|
-
// // actionStatus: { $in: [factory.actionStatusType.CompletedActionStatus] }, // all statuses(2025-02-26~)
|
|
31
|
-
// purpose: { id: { $in: [transaction.id] } },
|
|
32
|
-
// object: {
|
|
33
|
-
// // transactionNumber: { $eq: paymentMethodIdByPaymentUrl },
|
|
34
|
-
// typeOf: { $eq: factory.assetTransactionType.Pay }
|
|
35
|
-
// }
|
|
36
28
|
project: { id: transaction.project.id },
|
|
37
29
|
purpose: { id: transaction.id },
|
|
38
30
|
}, ['object']);
|
|
@@ -43,9 +35,10 @@ function invalidatePaymentUrl(params) {
|
|
|
43
35
|
// support OrderCanceled(2025-02-25~)
|
|
44
36
|
const orderCancelled = params.purpose.result?.order?.orderStatus === factory_1.factory.orderStatus.OrderCancelled;
|
|
45
37
|
if (!orderCancelled) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
38
|
+
// 確定取引の場合、注文に紐づいた決済方法IDは除外しなければいけない
|
|
39
|
+
const paymentMethodIdByTransaction = await repos.orderInTransaction.findPaymentMethodId({ id: transaction.id });
|
|
40
|
+
if (typeof paymentMethodIdByTransaction === 'string') {
|
|
41
|
+
acceptPayActions = acceptPayActions.filter(({ object }) => object.transactionNumber !== paymentMethodIdByTransaction);
|
|
49
42
|
}
|
|
50
43
|
}
|
|
51
44
|
break;
|
|
@@ -106,60 +99,5 @@ function invalidatePaymentUrl(params) {
|
|
|
106
99
|
if (invalidatePaymentUrlTasks.length > 0) {
|
|
107
100
|
await repos.task.saveMany(invalidatePaymentUrlTasks, { emitImmediately: true });
|
|
108
101
|
}
|
|
109
|
-
// const paymentMethodIdByPaymentUrl = transaction.object.paymentMethods?.paymentMethodId;
|
|
110
|
-
// if (typeof paymentMethodIdByPaymentUrl === 'string' && paymentMethodIdByPaymentUrl.length > 0) {
|
|
111
|
-
// const acceptPayAction = (<Pick<IAcceptPayAction, 'object'>[]>await repos.action.search(
|
|
112
|
-
// {
|
|
113
|
-
// limit: 1,
|
|
114
|
-
// page: 1,
|
|
115
|
-
// project: { id: { $eq: transaction.project.id } },
|
|
116
|
-
// typeOf: { $eq: factory.actionType.AcceptAction },
|
|
117
|
-
// actionStatus: { $in: [factory.actionStatusType.CompletedActionStatus] },
|
|
118
|
-
// purpose: { id: { $in: [transaction.id] } },
|
|
119
|
-
// object: {
|
|
120
|
-
// transactionNumber: { $eq: paymentMethodIdByPaymentUrl },
|
|
121
|
-
// typeOf: { $eq: factory.assetTransactionType.Pay }
|
|
122
|
-
// }
|
|
123
|
-
// },
|
|
124
|
-
// ['object']
|
|
125
|
-
// )).shift();
|
|
126
|
-
// if (acceptPayAction !== undefined) {
|
|
127
|
-
// // const paymentMethodType = transaction.object.paymentMethods?.typeOf;
|
|
128
|
-
// const paymentMethodType = acceptPayAction.object.object.paymentMethod.identifier;
|
|
129
|
-
// if (typeof paymentMethodType === 'string' && paymentMethodType.length > 0) {
|
|
130
|
-
// // chevreで決済URL無効化
|
|
131
|
-
// await PayTransactionService.invalidatePaymentUrl({
|
|
132
|
-
// project: transaction.project,
|
|
133
|
-
// typeOf: factory.actionType.RefundAction,
|
|
134
|
-
// agent: {
|
|
135
|
-
// typeOf: transaction.seller.typeOf,
|
|
136
|
-
// name: (typeof transaction.seller.name === 'string')
|
|
137
|
-
// ? transaction.seller.name
|
|
138
|
-
// : String(transaction.seller.name?.ja),
|
|
139
|
-
// id: transaction.seller.id
|
|
140
|
-
// },
|
|
141
|
-
// recipient: {
|
|
142
|
-
// typeOf: transaction.agent.typeOf,
|
|
143
|
-
// id: transaction.agent.id,
|
|
144
|
-
// name: transaction.agent.name
|
|
145
|
-
// },
|
|
146
|
-
// object: [{
|
|
147
|
-
// typeOf: factory.service.paymentService.PaymentServiceType.CreditCard,
|
|
148
|
-
// id: acceptPayAction.object.object.id,
|
|
149
|
-
// paymentMethod: {
|
|
150
|
-
// additionalProperty: [],
|
|
151
|
-
// name: paymentMethodType,
|
|
152
|
-
// typeOf: paymentMethodType,
|
|
153
|
-
// paymentMethodId: paymentMethodIdByPaymentUrl
|
|
154
|
-
// },
|
|
155
|
-
// refundFee: 0
|
|
156
|
-
// }],
|
|
157
|
-
// purpose: { typeOf: transaction.typeOf, id: transaction.id },
|
|
158
|
-
// instrument: [],
|
|
159
|
-
// ...(typeof params.sameAs?.id === 'string') ? { sameAs: params.sameAs } : undefined
|
|
160
|
-
// })(repos, settings);
|
|
161
|
-
// }
|
|
162
|
-
// }
|
|
163
|
-
// }
|
|
164
102
|
};
|
|
165
103
|
}
|
|
@@ -7,6 +7,7 @@ import type { AuthorizationRepo } from '../../../repo/authorization';
|
|
|
7
7
|
import type { EventRepo } from '../../../repo/event';
|
|
8
8
|
import type { EventSeriesRepo } from '../../../repo/eventSeries';
|
|
9
9
|
import type { IssuerRepo } from '../../../repo/issuer';
|
|
10
|
+
import type { OrderInTransactionRepo } from '../../../repo/orderInTransaction';
|
|
10
11
|
import type { PaymentServiceRepo } from '../../../repo/paymentService';
|
|
11
12
|
import type { PaymentServiceProviderRepo } from '../../../repo/paymentServiceProvider';
|
|
12
13
|
import type { SellerPaymentAcceptedRepo } from '../../../repo/sellerPaymentAccepted';
|
|
@@ -22,6 +23,7 @@ interface IPublishPaymentUrlRepos {
|
|
|
22
23
|
event: EventRepo;
|
|
23
24
|
eventSeries: EventSeriesRepo;
|
|
24
25
|
issuer: IssuerRepo;
|
|
26
|
+
orderInTransaction: OrderInTransactionRepo;
|
|
25
27
|
paymentAccepted: SellerPaymentAcceptedRepo;
|
|
26
28
|
paymentService: PaymentServiceRepo;
|
|
27
29
|
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
@@ -58,5 +60,7 @@ declare function publishPaymentUrl(params: {
|
|
|
58
60
|
*/
|
|
59
61
|
identifier?: string;
|
|
60
62
|
instrument: factory.action.trade.pay.IAcceptedPaymentMethodOfferAsInstrument[];
|
|
63
|
+
}, options: {
|
|
64
|
+
savePaymentMethodIdInTransaction: boolean;
|
|
61
65
|
}): IPublishPaymentUrlOperation<Pick<PayTransactionService.IPublishPaymentUrlResult, 'paymentMethodId' | 'paymentUrl'>>;
|
|
62
66
|
export { IPublishPaymentUrlRepos, publishPaymentUrl };
|
|
@@ -41,7 +41,7 @@ const factory_2 = require("./factory");
|
|
|
41
41
|
/**
|
|
42
42
|
* 外部決済ロケーションを発行する
|
|
43
43
|
*/
|
|
44
|
-
function publishPaymentUrl(params) {
|
|
44
|
+
function publishPaymentUrl(params, options) {
|
|
45
45
|
return async (repos, settings) => {
|
|
46
46
|
const { paymentServiceType, purpose, project } = params;
|
|
47
47
|
if (purpose.typeOf !== factory_1.factory.transactionType.PlaceOrder) {
|
|
@@ -104,24 +104,10 @@ function publishPaymentUrl(params) {
|
|
|
104
104
|
executor: (typeof taskId === 'string') ? { id: taskId } : {} // タスク関連付け(2024-05-22~)
|
|
105
105
|
})(repos, settings);
|
|
106
106
|
// 取引に保管
|
|
107
|
-
|
|
108
|
-
// typeOf: params.object.paymentMethod, // discontinue(2024-06-05~)
|
|
109
|
-
paymentMethodId: result.paymentMethodId
|
|
110
|
-
// paymentUrl: result.paymentUrl, // migrate to recipe(2024-06-05~)
|
|
111
|
-
// issuedThrough: {
|
|
112
|
-
// id: (typeof startParams.object.id === 'string') ? startParams.object.id : ''
|
|
113
|
-
// } // migrate to acceptAction(2024-06-05~)
|
|
114
|
-
// GMO IFを保管(2024-01-01~)
|
|
115
|
-
// entryTranArgs: result.entryTranArgs, // migrate to recipe(2024-06-05~)
|
|
116
|
-
// entryTranResult: result.entryTranResult, // migrate to recipe(2024-06-05~)
|
|
117
|
-
// execTranArgs: result.execTranArgs, // migrate to recipe(2024-06-05~)
|
|
118
|
-
// execTranResult: result.execTranResult, // migrate to recipe(2024-06-05~)
|
|
119
|
-
// paymentMethod: startParams.object.paymentMethod // 拡張(2024-01-04~) // migrate to acceptAction(2024-06-05~)
|
|
120
|
-
};
|
|
121
|
-
await repos.placeOrder.findByIdAndUpdateInProgress({
|
|
107
|
+
await repos.orderInTransaction.savePaymentMethodId({
|
|
122
108
|
id: transaction.id,
|
|
123
|
-
|
|
124
|
-
});
|
|
109
|
+
paymentMethod: { paymentMethodId: result.paymentMethodId }
|
|
110
|
+
}, options);
|
|
125
111
|
return {
|
|
126
112
|
paymentMethodId: result.paymentMethodId,
|
|
127
113
|
paymentUrl: result.paymentUrl
|
|
@@ -7,6 +7,7 @@ import type { PaymentServiceRepo } from '../../../repo/paymentService';
|
|
|
7
7
|
import type { PaymentServiceProviderRepo } from '../../../repo/paymentServiceProvider';
|
|
8
8
|
import type { SellerPaymentAcceptedRepo } from '../../../repo/sellerPaymentAccepted';
|
|
9
9
|
import type { TaskRepo } from '../../../repo/task';
|
|
10
|
+
import type { OrderInTransactionRepo } from '../../../repo/orderInTransaction';
|
|
10
11
|
import type { PlaceOrderRepo } from '../../../repo/transaction/placeOrder';
|
|
11
12
|
/**
|
|
12
13
|
* 決済承認中止
|
|
@@ -29,6 +30,7 @@ declare function voidPayTransaction(params: factory.task.IData<factory.taskName.
|
|
|
29
30
|
paymentService: PaymentServiceRepo;
|
|
30
31
|
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
31
32
|
task: TaskRepo;
|
|
33
|
+
orderInTransaction: OrderInTransactionRepo;
|
|
32
34
|
placeOrder: PlaceOrderRepo;
|
|
33
35
|
}) => Promise<void>;
|
|
34
36
|
export { voidPayTransaction, };
|
|
@@ -8,29 +8,7 @@ const processVoidPayTransaction_1 = require("./processVoidPayTransaction");
|
|
|
8
8
|
* タスクから決済承認を取り消す
|
|
9
9
|
*/
|
|
10
10
|
function voidPayTransaction(params) {
|
|
11
|
-
return async (repos
|
|
12
|
-
// settings: Settings
|
|
13
|
-
) => {
|
|
14
|
-
// 決済承認アクション確認不要(2024-03-12~)
|
|
15
|
-
// 決済承認アクションを検索
|
|
16
|
-
// let authorizeActions = <factory.action.authorize.paymentMethod.any.IAction[]>
|
|
17
|
-
// await repos.action.searchByPurpose({
|
|
18
|
-
// typeOf: factory.actionType.AuthorizeAction,
|
|
19
|
-
// purpose: {
|
|
20
|
-
// typeOf: params.purpose.typeOf,
|
|
21
|
-
// id: params.purpose.id
|
|
22
|
-
// }
|
|
23
|
-
// });
|
|
24
|
-
// authorizeActions = authorizeActions.filter(
|
|
25
|
-
// (a) => a.object.typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment
|
|
26
|
-
// );
|
|
27
|
-
// // Chevreを使用した承認を取り消し
|
|
28
|
-
// const authorizeActionsWithChevre = authorizeActions.filter((a) => {
|
|
29
|
-
// return a.instrument?.identifier === factory.action.authorize.paymentMethod.any.ServiceIdentifier.Chevre;
|
|
30
|
-
// });
|
|
31
|
-
// if (authorizeActionsWithChevre.length > 0) {
|
|
32
|
-
// await processVoidPayTransaction(params)(repos);
|
|
33
|
-
// }
|
|
11
|
+
return async (repos) => {
|
|
34
12
|
await (0, processVoidPayTransaction_1.processVoidPayTransaction)(params)(repos);
|
|
35
13
|
// 決済URL無効化もここで処理
|
|
36
14
|
await (0, invalidatePaymentUrl_1.invalidatePaymentUrl)(params)(repos);
|
|
@@ -26,7 +26,7 @@ declare function processAuthorizeCreditCard(params: {
|
|
|
26
26
|
callbackType3ds?: factory.service.paymentService.ICallbackType3ds;
|
|
27
27
|
orderId: string;
|
|
28
28
|
availableChannel: Pick<factory.serviceChannel.IServiceChannelCreditCard, 'credentials' | 'serviceUrl'>;
|
|
29
|
-
object: factory.assetTransaction.pay.
|
|
29
|
+
object: factory.assetTransaction.pay.IPaymentMethodWithoutDetail;
|
|
30
30
|
/**
|
|
31
31
|
* 決済URL発行処理かどうか
|
|
32
32
|
*/
|
|
@@ -15,6 +15,9 @@ function processAuthorizeCreditCard(params) {
|
|
|
15
15
|
// const { cardSeq, memberId } = creditCard as IUnauthorizedCardOfMember; // 会員カード廃止(2026-04-07~)
|
|
16
16
|
const { cardNo, cardPass, expire } = creditCard;
|
|
17
17
|
const { token } = creditCard;
|
|
18
|
+
if (typeof params.object.amount !== 'number') {
|
|
19
|
+
throw new factory_1.factory.errors.Argument('object.amount', 'must be number');
|
|
20
|
+
}
|
|
18
21
|
const retUrl = creditCard?.retUrl;
|
|
19
22
|
// 3DS拡張(2024-01-02~)
|
|
20
23
|
if (params.processPublishPaymentUrl === true && typeof retUrl === 'string' && retUrl.length > 0) {
|
|
@@ -32,13 +35,8 @@ function processAuthorizeCreditCard(params) {
|
|
|
32
35
|
entryTranArgs = {
|
|
33
36
|
shopId, shopPass, orderId,
|
|
34
37
|
jobCd: gmo_service_1.GMO.factory.util.JobCd.Auth,
|
|
35
|
-
amount:
|
|
36
|
-
? params.object.amount
|
|
37
|
-
: params.object.amount.value,
|
|
38
|
-
// siteId: params.availableChannel.credentials?.siteId,
|
|
39
|
-
// sitePass: params.availableChannel.credentials?.sitePass,
|
|
38
|
+
amount: params.object.amount,
|
|
40
39
|
tdFlag: gmo_service_1.GMO.factory.util.TdFlag.Version2,
|
|
41
|
-
// tdTenantName: '',
|
|
42
40
|
tds2Type: gmo_service_1.GMO.factory.util.Tds2Type.Error
|
|
43
41
|
};
|
|
44
42
|
entryTranResult = await repos.creditCardService.entryTran(entryTranArgs);
|
|
@@ -65,9 +63,7 @@ function processAuthorizeCreditCard(params) {
|
|
|
65
63
|
entryTranArgs = {
|
|
66
64
|
shopId, shopPass, orderId,
|
|
67
65
|
jobCd: gmo_service_1.GMO.factory.util.JobCd.Auth,
|
|
68
|
-
amount:
|
|
69
|
-
? params.object.amount
|
|
70
|
-
: params.object.amount.value,
|
|
66
|
+
amount: params.object.amount,
|
|
71
67
|
siteId: params.availableChannel.credentials?.siteId,
|
|
72
68
|
sitePass: params.availableChannel.credentials?.sitePass
|
|
73
69
|
};
|
|
@@ -46,6 +46,7 @@ function onReservationConfirmed(confirmedReservations, reserveAction) {
|
|
|
46
46
|
const setting = await repos.setting.findOne({ project: { id: { $eq: '*' } } }, ['onReservationStatusChanged']);
|
|
47
47
|
// const informReservations = settings.onReservationStatusChanged.informReservation;
|
|
48
48
|
const informReservations = setting?.onReservationStatusChanged?.informReservation;
|
|
49
|
+
const minimizeReservation = setting?.onReservationStatusChanged?.minimizeReservation === true;
|
|
49
50
|
let orderAsAbout;
|
|
50
51
|
if (Array.isArray(reserveAction.instrument)) {
|
|
51
52
|
for (const eachInstrument of reserveAction.instrument) {
|
|
@@ -98,16 +99,24 @@ function onReservationConfirmed(confirmedReservations, reserveAction) {
|
|
|
98
99
|
}
|
|
99
100
|
const subReservations4inform = confirmedReservations.map((r) => {
|
|
100
101
|
const { additionalProperty, additionalTicketText, id, modifiedTime, price, programMembershipUsed, reservedTicket, subReservation, typeOf } = r;
|
|
102
|
+
let reservedTicket4inform;
|
|
103
|
+
if (minimizeReservation) {
|
|
104
|
+
const { ticketType: _ticketType, ...reservedTicketWithNoTicketType } = reservedTicket;
|
|
105
|
+
reservedTicket4inform = reservedTicketWithNoTicketType;
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
reservedTicket4inform = reservedTicket; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
109
|
+
}
|
|
101
110
|
return {
|
|
102
111
|
id,
|
|
103
112
|
typeOf,
|
|
104
|
-
reservedTicket,
|
|
105
|
-
...(Array.isArray(additionalProperty)) ? { additionalProperty } : undefined,
|
|
113
|
+
reservedTicket: reservedTicket4inform,
|
|
106
114
|
...(typeof additionalTicketText === 'string') ? { additionalTicketText } : undefined,
|
|
107
115
|
...(modifiedTime instanceof Date) ? { modifiedTime } : undefined,
|
|
108
|
-
...(
|
|
109
|
-
...(
|
|
110
|
-
...(
|
|
116
|
+
...(Array.isArray(subReservation)) ? { subReservation } : undefined,
|
|
117
|
+
...(!minimizeReservation && Array.isArray(additionalProperty)) ? { additionalProperty } : undefined, // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
118
|
+
...(!minimizeReservation && price !== undefined) ? { price } : undefined, // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
119
|
+
...(!minimizeReservation && programMembershipUsed !== undefined) ? { programMembershipUsed } : undefined, // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
111
120
|
};
|
|
112
121
|
});
|
|
113
122
|
if (typeof issuedThrough.id !== 'string') {
|
|
@@ -116,7 +125,6 @@ function onReservationConfirmed(confirmedReservations, reserveAction) {
|
|
|
116
125
|
}
|
|
117
126
|
const informObject = {
|
|
118
127
|
bookingTime,
|
|
119
|
-
issuedThrough, // subReservationから移行(2024-03-20~)
|
|
120
128
|
project,
|
|
121
129
|
provider, // subReservationから移行(2024-03-20~)
|
|
122
130
|
reservationFor,
|
|
@@ -124,8 +132,9 @@ function onReservationConfirmed(confirmedReservations, reserveAction) {
|
|
|
124
132
|
reservationStatus: factory_1.factory.reservationStatusType.ReservationConfirmed,
|
|
125
133
|
subReservation: subReservations4inform,
|
|
126
134
|
typeOf: factory_1.factory.reservationType.ReservationPackage,
|
|
127
|
-
...(
|
|
128
|
-
|
|
135
|
+
...(!minimizeReservation) ? { issuedThrough } : undefined, // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
136
|
+
...(!minimizeReservation && typeof underName?.typeOf === 'string')
|
|
137
|
+
? { underName: (0, factory_2.optimizeUnderName4inform)({ underName }) } // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
129
138
|
: undefined
|
|
130
139
|
};
|
|
131
140
|
const informIdentifier = `${factory_1.factory.reservationType.ReservationPackage}:${informObject.reservationNumber}:${informObject.reservationStatus}`;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.searchByOrder = searchByOrder;
|
|
4
|
-
const
|
|
4
|
+
const customerTelephone2COATelNum_1 = require("../../factory/customerTelephone2COATelNum");
|
|
5
5
|
const factory_1 = require("../../factory");
|
|
6
6
|
function searchByOrder(params) {
|
|
7
7
|
return async (repos) => {
|
|
@@ -42,11 +42,7 @@ function searchByOrder(params) {
|
|
|
42
42
|
if (order === undefined) {
|
|
43
43
|
throw new factory_1.factory.errors.NotFound(factory_1.factory.order.OrderType.Order);
|
|
44
44
|
}
|
|
45
|
-
const
|
|
46
|
-
const phoneNumber = phoneUtil.parse(order.customer.telephone, 'JP');
|
|
47
|
-
let telNum = phoneUtil.format(phoneNumber, google_libphonenumber_1.PhoneNumberFormat.NATIONAL);
|
|
48
|
-
// COAでは数字のみ受け付けるので数字以外を除去
|
|
49
|
-
telNum = telNum.replace(/[^\d]/g, '');
|
|
45
|
+
const telNum = (0, customerTelephone2COATelNum_1.customerTelephone2COATelNum)({ telephone: String(order.customer.telephone) });
|
|
50
46
|
const reservationNumber = (await repos.acceptedOffer.distinctValues({
|
|
51
47
|
orderNumber: { $in: [params.orderNumber] }
|
|
52
48
|
}, 'acceptedOffers.itemOffered.reservationNumber')).shift();
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.call = call;
|
|
4
4
|
exports.confirmReserveTransaction = confirmReserveTransaction;
|
|
5
5
|
const coa_service_1 = require("@motionpicture/coa-service");
|
|
6
|
-
const google_libphonenumber_1 = require("google-libphonenumber");
|
|
7
6
|
const util_1 = require("util");
|
|
7
|
+
const customerTelephone2COATelNum_1 = require("../../factory/customerTelephone2COATelNum");
|
|
8
8
|
const factory_1 = require("../../factory");
|
|
9
9
|
const confirm_1 = require("../assetTransaction/reserve/confirm");
|
|
10
10
|
const reserveCOA_1 = require("../assetTransaction/reserveCOA");
|
|
@@ -71,12 +71,7 @@ function createConfirmObject4COAByOrder(params) {
|
|
|
71
71
|
&& o.offeredThrough?.identifier === factory_1.factory.service.webAPI.Identifier.COA;
|
|
72
72
|
});
|
|
73
73
|
const customer = params.order.customer;
|
|
74
|
-
|
|
75
|
-
const phoneUtil = google_libphonenumber_1.PhoneNumberUtil.getInstance();
|
|
76
|
-
const phoneNumber = phoneUtil.parse(customer.telephone, 'JP');
|
|
77
|
-
let telNum = phoneUtil.format(phoneNumber, google_libphonenumber_1.PhoneNumberFormat.NATIONAL);
|
|
78
|
-
// COAでは数字のみ受け付けるので数字以外を除去
|
|
79
|
-
telNum = telNum.replace(/[^\d]/g, '');
|
|
74
|
+
const telNum = (0, customerTelephone2COATelNum_1.customerTelephone2COATelNum)({ telephone: String(customer.telephone) });
|
|
80
75
|
const mailAddr = customer.email;
|
|
81
76
|
if (mailAddr === undefined) {
|
|
82
77
|
throw new factory_1.factory.errors.Argument('order', 'order.customer.email undefined');
|
|
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.call = call;
|
|
4
4
|
const acceptedOffer_1 = require("../../repo/acceptedOffer");
|
|
5
5
|
const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
6
|
+
const message_1 = require("../../repo/message");
|
|
6
7
|
const order_1 = require("../../repo/order");
|
|
7
8
|
const setting_1 = require("../../repo/setting");
|
|
8
9
|
const integration_1 = require("../../repo/setting/integration");
|
|
9
10
|
const task_1 = require("../../repo/task");
|
|
10
|
-
// import { TransactionRepo } from '../../repo/transaction';
|
|
11
11
|
const placeOrder_1 = require("../../repo/transaction/placeOrder");
|
|
12
12
|
const onAssetTransactionStatusChanged_1 = require("../order/onAssetTransactionStatusChanged");
|
|
13
13
|
/**
|
|
@@ -19,10 +19,10 @@ function call(data) {
|
|
|
19
19
|
await (0, onAssetTransactionStatusChanged_1.onAssetTransactionStatusChanged)(data)({
|
|
20
20
|
acceptedOffer: new acceptedOffer_1.AcceptedOfferRepo(connection),
|
|
21
21
|
assetTransaction: new assetTransaction_1.AssetTransactionRepo(connection),
|
|
22
|
+
message: new message_1.MessageRepo(connection),
|
|
22
23
|
order: new order_1.OrderRepo(connection),
|
|
23
24
|
setting: new setting_1.SettingRepo(connection),
|
|
24
25
|
task: new task_1.TaskRepo(connection),
|
|
25
|
-
// transaction: new TransactionRepo(connection),
|
|
26
26
|
placeOrder: new placeOrder_1.PlaceOrderRepo(connection)
|
|
27
27
|
}, settings);
|
|
28
28
|
};
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.call = call;
|
|
4
4
|
const acceptedOffer_1 = require("../../repo/acceptedOffer");
|
|
5
|
+
const message_1 = require("../../repo/message");
|
|
5
6
|
const order_1 = require("../../repo/order");
|
|
6
7
|
const setting_1 = require("../../repo/setting");
|
|
7
8
|
const integration_1 = require("../../repo/setting/integration");
|
|
@@ -16,6 +17,7 @@ function call(data) {
|
|
|
16
17
|
const settings = new integration_1.IntegrationSettingRepo({ connection });
|
|
17
18
|
await (0, payOrder_1.payOrder)(data)({
|
|
18
19
|
acceptedOffer: new acceptedOffer_1.AcceptedOfferRepo(connection),
|
|
20
|
+
message: new message_1.MessageRepo(connection),
|
|
19
21
|
order: new order_1.OrderRepo(connection),
|
|
20
22
|
setting: new setting_1.SettingRepo(connection),
|
|
21
23
|
task: new task_1.TaskRepo(connection),
|
|
@@ -6,12 +6,12 @@ const accountingReport_1 = require("../../repo/accountingReport");
|
|
|
6
6
|
const action_1 = require("../../repo/action");
|
|
7
7
|
const authorizeOffer_1 = require("../../repo/action/authorizeOffer");
|
|
8
8
|
const authorizePaymentMethod_1 = require("../../repo/action/authorizePaymentMethod");
|
|
9
|
+
const message_1 = require("../../repo/message");
|
|
9
10
|
const order_1 = require("../../repo/order");
|
|
10
11
|
const orderInTransaction_1 = require("../../repo/orderInTransaction");
|
|
11
12
|
const setting_1 = require("../../repo/setting");
|
|
12
13
|
const integration_1 = require("../../repo/setting/integration");
|
|
13
14
|
const task_1 = require("../../repo/task");
|
|
14
|
-
// import { TransactionRepo } from '../../repo/transaction';
|
|
15
15
|
const placeOrder_1 = require("../../repo/transaction/placeOrder");
|
|
16
16
|
const placeOrder_2 = require("../order/placeOrder");
|
|
17
17
|
/**
|
|
@@ -29,11 +29,11 @@ function call(data) {
|
|
|
29
29
|
action: new action_1.ActionRepo(connection),
|
|
30
30
|
authorizeOfferAction: new authorizeOffer_1.AuthorizeOfferActionRepo(connection),
|
|
31
31
|
authorizePaymentMethodAction: new authorizePaymentMethod_1.AuthorizePaymentMethodActionRepo(connection),
|
|
32
|
+
message: new message_1.MessageRepo(connection),
|
|
32
33
|
order: new order_1.OrderRepo(connection),
|
|
33
34
|
orderInTransaction: new orderInTransaction_1.OrderInTransactionRepo(connection),
|
|
34
35
|
setting: new setting_1.SettingRepo(connection),
|
|
35
36
|
task: new task_1.TaskRepo(connection),
|
|
36
|
-
// transaction: new TransactionRepo(connection),
|
|
37
37
|
placeOrder: new placeOrder_1.PlaceOrderRepo(connection)
|
|
38
38
|
}, settings);
|
|
39
39
|
};
|
|
@@ -9,7 +9,7 @@ const authorization_1 = require("../../repo/authorization");
|
|
|
9
9
|
const event_1 = require("../../repo/event");
|
|
10
10
|
const eventSeries_1 = require("../../repo/eventSeries");
|
|
11
11
|
const issuer_1 = require("../../repo/issuer");
|
|
12
|
-
|
|
12
|
+
const orderInTransaction_1 = require("../../repo/orderInTransaction");
|
|
13
13
|
// import { OrderNumberRepo } from '../../repo/orderNumber';
|
|
14
14
|
const paymentService_1 = require("../../repo/paymentService");
|
|
15
15
|
const paymentServiceProvider_1 = require("../../repo/paymentServiceProvider");
|
|
@@ -36,10 +36,14 @@ function call(params) {
|
|
|
36
36
|
const actionRepo = new acceptPay_1.AcceptPayActionRepo(connection);
|
|
37
37
|
// const transactionProcessRepo = new TransactionProcessRepo(redisClient, { lockExpiresInSeconds: 120 });
|
|
38
38
|
try {
|
|
39
|
+
const { savePaymentMethodIdInTransaction, project: _project, ...publishPaymentUrlParams } = params.data;
|
|
39
40
|
await (0, any_1.publishPaymentUrl)({
|
|
40
|
-
...
|
|
41
|
+
...publishPaymentUrlParams,
|
|
42
|
+
project: { id: params.project.id },
|
|
41
43
|
instrument: (Array.isArray(params.data.instrument)) ? params.data.instrument : [],
|
|
42
44
|
sameAs: { id: params.id }
|
|
45
|
+
}, {
|
|
46
|
+
savePaymentMethodIdInTransaction: savePaymentMethodIdInTransaction === true
|
|
43
47
|
})({
|
|
44
48
|
acceptPayAction: actionRepo,
|
|
45
49
|
authorizeInvoiceAction: new authorizeInvoice_1.AuthorizeInvoiceActionRepo(connection),
|
|
@@ -48,7 +52,7 @@ function call(params) {
|
|
|
48
52
|
event: new event_1.EventRepo(connection),
|
|
49
53
|
eventSeries: new eventSeries_1.EventSeriesRepo(connection),
|
|
50
54
|
issuer: new issuer_1.IssuerRepo(connection),
|
|
51
|
-
|
|
55
|
+
orderInTransaction: new orderInTransaction_1.OrderInTransactionRepo(connection),
|
|
52
56
|
// orderNumber: new OrderNumberRepo({ connection }),
|
|
53
57
|
paymentAccepted: new sellerPaymentAccepted_1.SellerPaymentAcceptedRepo(connection),
|
|
54
58
|
paymentService: new paymentService_1.PaymentServiceRepo(connection),
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.call = call;
|
|
4
4
|
const accountingReport_1 = require("../../repo/accountingReport");
|
|
5
|
-
// import { ActionRepo } from '../../repo/action';
|
|
6
5
|
const acceptPay_1 = require("../../repo/action/acceptPay");
|
|
7
6
|
const authorizePaymentMethod_1 = require("../../repo/action/authorizePaymentMethod");
|
|
8
7
|
const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
@@ -10,8 +9,8 @@ const paymentService_1 = require("../../repo/paymentService");
|
|
|
10
9
|
const paymentServiceProvider_1 = require("../../repo/paymentServiceProvider");
|
|
11
10
|
const sellerPaymentAccepted_1 = require("../../repo/sellerPaymentAccepted");
|
|
12
11
|
const task_1 = require("../../repo/task");
|
|
12
|
+
const orderInTransaction_1 = require("../../repo/orderInTransaction");
|
|
13
13
|
const placeOrder_1 = require("../../repo/transaction/placeOrder");
|
|
14
|
-
// import { TransactionRepo } from '../../repo/transaction';
|
|
15
14
|
const any_1 = require("../payment/any");
|
|
16
15
|
/**
|
|
17
16
|
* タスク実行関数
|
|
@@ -24,7 +23,6 @@ function call(params) {
|
|
|
24
23
|
sameAs: { id: params.id }
|
|
25
24
|
})({
|
|
26
25
|
accountingReport: new accountingReport_1.AccountingReportRepo(connection),
|
|
27
|
-
// action: new ActionRepo(connection),
|
|
28
26
|
acceptPayAction: new acceptPay_1.AcceptPayActionRepo(connection),
|
|
29
27
|
authorizePaymentMethodAction: new authorizePaymentMethod_1.AuthorizePaymentMethodActionRepo(connection),
|
|
30
28
|
assetTransaction: new assetTransaction_1.AssetTransactionRepo(connection),
|
|
@@ -32,10 +30,8 @@ function call(params) {
|
|
|
32
30
|
paymentService: new paymentService_1.PaymentServiceRepo(connection),
|
|
33
31
|
paymentServiceProvider: new paymentServiceProvider_1.PaymentServiceProviderRepo(connection),
|
|
34
32
|
task: new task_1.TaskRepo(connection),
|
|
33
|
+
orderInTransaction: new orderInTransaction_1.OrderInTransactionRepo(connection),
|
|
35
34
|
placeOrder: new placeOrder_1.PlaceOrderRepo(connection)
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
// settings
|
|
39
|
-
);
|
|
35
|
+
});
|
|
40
36
|
};
|
|
41
37
|
}
|
package/lib/chevre/service/transaction/deleteTransaction/deletePayTransactionsByPlaceOrder.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { factory } from '../../../factory';
|
|
2
|
+
import type { AssetTransactionRepo } from '../../../repo/assetTransaction';
|
|
3
|
+
type IAuthorizeOfferAction = factory.action.authorize.offer.eventService.IAction;
|
|
4
|
+
type IAuthorizePaymentAction = factory.action.authorize.paymentMethod.any.IAction;
|
|
5
|
+
export declare function deletePayTransactionsByPlaceOrder(params: {
|
|
6
|
+
authorizeActions: (IAuthorizeOfferAction | IAuthorizePaymentAction)[];
|
|
7
|
+
transaction: Pick<factory.transaction.placeOrder.ITransaction, 'project'>;
|
|
8
|
+
}): (repos: {
|
|
9
|
+
assetTransaction: AssetTransactionRepo;
|
|
10
|
+
}) => Promise<{
|
|
11
|
+
deletePayTransactionResult: any;
|
|
12
|
+
deleteRefundResult: any;
|
|
13
|
+
payTransactionNumbers: string[];
|
|
14
|
+
}>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deletePayTransactionsByPlaceOrder = deletePayTransactionsByPlaceOrder;
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
5
|
+
const factory_1 = require("../../../factory");
|
|
6
|
+
function deletePayTransactionsByPlaceOrder(params) {
|
|
7
|
+
return async (repos) => {
|
|
8
|
+
let deletePayTransactionResult;
|
|
9
|
+
let deleteRefundResult;
|
|
10
|
+
const authorizeActions = params.authorizeActions;
|
|
11
|
+
// 決済取引番号を抽出
|
|
12
|
+
const authorizePaymentActions = authorizeActions
|
|
13
|
+
.filter((a) => {
|
|
14
|
+
return a.object.typeOf === factory_1.factory.action.authorize.paymentMethod.any.ResultType.Payment
|
|
15
|
+
&& typeof a.object?.paymentMethodId === 'string'
|
|
16
|
+
&& a.object.paymentMethodId.length > 0;
|
|
17
|
+
});
|
|
18
|
+
const payTransactionNumbers = authorizePaymentActions.map((a) => String(a.object.paymentMethodId));
|
|
19
|
+
if (payTransactionNumbers.length > 0) {
|
|
20
|
+
// 決済取引を削除(プロジェクトでも絞ること)(2022-06-07~)
|
|
21
|
+
const deleteAssetTransactionsResult = await repos.assetTransaction.deleteByTransactionNumber({
|
|
22
|
+
project: { id: params.transaction.project.id },
|
|
23
|
+
transactionNumbers: payTransactionNumbers,
|
|
24
|
+
typeOf: factory_1.factory.assetTransactionType.Pay
|
|
25
|
+
});
|
|
26
|
+
deletePayTransactionResult = {
|
|
27
|
+
n: deleteAssetTransactionsResult?.n,
|
|
28
|
+
ok: deleteAssetTransactionsResult?.ok,
|
|
29
|
+
deletedCount: deleteAssetTransactionsResult?.deletedCount
|
|
30
|
+
};
|
|
31
|
+
// 返金取引も削除(2023-05-19~)
|
|
32
|
+
const refundTransactions = await repos.assetTransaction.search({
|
|
33
|
+
typeOf: factory_1.factory.assetTransactionType.Refund,
|
|
34
|
+
object: { paymentMethodId: { $in: payTransactionNumbers } }
|
|
35
|
+
}, ['transactionNumber'], []);
|
|
36
|
+
if (refundTransactions.length > 0) {
|
|
37
|
+
const deleteRefundAssetTransactionsResult = await repos.assetTransaction.deleteByTransactionNumber({
|
|
38
|
+
project: { id: params.transaction.project.id },
|
|
39
|
+
transactionNumbers: refundTransactions.map(({ transactionNumber }) => transactionNumber),
|
|
40
|
+
typeOf: factory_1.factory.assetTransactionType.Refund
|
|
41
|
+
});
|
|
42
|
+
deleteRefundResult = {
|
|
43
|
+
n: deleteRefundAssetTransactionsResult?.n,
|
|
44
|
+
ok: deleteRefundAssetTransactionsResult?.ok,
|
|
45
|
+
deletedCount: deleteRefundAssetTransactionsResult?.deletedCount
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return { deletePayTransactionResult, deleteRefundResult, payTransactionNumbers };
|
|
50
|
+
};
|
|
51
|
+
}
|