@chevre/domain 25.2.0-alpha.24 → 25.2.0-alpha.26
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/repo/action/acceptPay.d.ts +15 -0
- package/lib/chevre/repo/action/acceptPay.js +47 -19
- package/lib/chevre/repo/mongoose/schemas/setting.d.ts +4 -0
- package/lib/chevre/service/assetTransaction/pay/publishPaymentUrl.js +1 -1
- 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/reserve/potentialActions/onReservationConfirmed.js +17 -8
- package/lib/chevre/service/transaction/deleteTransaction/deleteReservationsByPlaceOrder.js +0 -1
- package/lib/chevre/service/transaction/placeOrder/confirm/validation.js +2 -2
- package/package.json +2 -2
|
@@ -37,4 +37,19 @@ export declare class AcceptPayActionRepo extends ActionProcessRepo<IAcceptPayAct
|
|
|
37
37
|
transactionNumber: string;
|
|
38
38
|
};
|
|
39
39
|
}, inclusion: IKeyOfProjection[]): Promise<IAcceptPayAction[]>;
|
|
40
|
+
/**
|
|
41
|
+
* アクションIDからレシピのafterMediaを参照する
|
|
42
|
+
*/
|
|
43
|
+
findPaymentUrlById(params: {
|
|
44
|
+
project: {
|
|
45
|
+
id: string;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* アクションID
|
|
49
|
+
*/
|
|
50
|
+
id: string;
|
|
51
|
+
}): Promise<{
|
|
52
|
+
paymentMethodId: string;
|
|
53
|
+
paymentUrl?: string;
|
|
54
|
+
}>;
|
|
40
55
|
}
|
|
@@ -29,25 +29,6 @@ class AcceptPayActionRepo extends actionProcess_1.ActionProcessRepo {
|
|
|
29
29
|
...(typeof limit === 'number') ? { limit } : undefined,
|
|
30
30
|
...(typeof page === 'number') ? { page } : undefined,
|
|
31
31
|
}, inclusion);
|
|
32
|
-
// const andConditions: FilterQuery<IAcceptPayAction>[] = [
|
|
33
|
-
// { typeOf: { $eq: factory.actionType.AcceptAction } },
|
|
34
|
-
// { 'project.id': { $eq: params.project.id } },
|
|
35
|
-
// { 'object.typeOf': { $exists: true, $eq: factory.assetTransactionType.Pay } },
|
|
36
|
-
// { 'purpose.id': { $exists: true, $eq: params.purpose.id } }
|
|
37
|
-
// ];
|
|
38
|
-
// let positiveProjectionFields: IKeyOfProjection[] = AVAILABLE_PROJECT_FIELDS;
|
|
39
|
-
// if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
40
|
-
// positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
|
|
41
|
-
// }
|
|
42
|
-
// const projection: ProjectionType<IAcceptPayAction> = {
|
|
43
|
-
// _id: 0,
|
|
44
|
-
// id: { $toString: '$_id' },
|
|
45
|
-
// ...Object.fromEntries<1>(positiveProjectionFields.map((key) => ([key, 1])))
|
|
46
|
-
// };
|
|
47
|
-
// const query = this.actionModel.find({ $and: andConditions }, projection);
|
|
48
|
-
// return query.setOptions({ maxTimeMS: MONGO_MAX_TIME_MS })
|
|
49
|
-
// .lean<IAcceptPayAction[]>()
|
|
50
|
-
// .exec();
|
|
51
32
|
}
|
|
52
33
|
/**
|
|
53
34
|
* 決済取引番号から完了済の決済採用アクションを参照する
|
|
@@ -66,5 +47,52 @@ class AcceptPayActionRepo extends actionProcess_1.ActionProcessRepo {
|
|
|
66
47
|
}
|
|
67
48
|
}, inclusion);
|
|
68
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* アクションIDからレシピのafterMediaを参照する
|
|
52
|
+
*/
|
|
53
|
+
async findPaymentUrlById(params) {
|
|
54
|
+
const acceptActionWithResult = await this.actionModel.findOne({
|
|
55
|
+
typeOf: { $eq: factory_1.factory.actionType.AcceptAction }, // 採用アクション
|
|
56
|
+
_id: { $eq: params.id }
|
|
57
|
+
}, {
|
|
58
|
+
_id: 0,
|
|
59
|
+
result: 1,
|
|
60
|
+
object: 1
|
|
61
|
+
})
|
|
62
|
+
.lean() // 2024-08-26~
|
|
63
|
+
.exec();
|
|
64
|
+
if (acceptActionWithResult === null) {
|
|
65
|
+
throw new factory_1.factory.errors.NotFound(this.actionModel.modelName);
|
|
66
|
+
}
|
|
67
|
+
const paymentMethodId = acceptActionWithResult.object.transactionNumber;
|
|
68
|
+
// アクション未完了であればpaymentMethodIdだけ返す
|
|
69
|
+
if (acceptActionWithResult.result === undefined) {
|
|
70
|
+
return { paymentMethodId };
|
|
71
|
+
}
|
|
72
|
+
const recipe = await this.actionRecipeModel.findOne({
|
|
73
|
+
'project.id': { $eq: params.project.id },
|
|
74
|
+
'recipeFor.id': { $eq: params.id }
|
|
75
|
+
}, {
|
|
76
|
+
_id: 0,
|
|
77
|
+
step: 1
|
|
78
|
+
})
|
|
79
|
+
.lean()
|
|
80
|
+
.exec();
|
|
81
|
+
const afterMedia = recipe?.step[0]?.itemListElement[1]?.itemListElement[0]?.afterMedia;
|
|
82
|
+
let paymentUrl;
|
|
83
|
+
// 3DS拡張(2024-01-02~)
|
|
84
|
+
const retUrl = acceptActionWithResult.object.object.paymentMethod.creditCard?.retUrl;
|
|
85
|
+
if (typeof retUrl === 'string' && retUrl.length > 0) {
|
|
86
|
+
paymentUrl = afterMedia?.redirectUrl;
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
paymentUrl = afterMedia?.acsUrl;
|
|
90
|
+
}
|
|
91
|
+
// アクション完了済であれば、レシピからpaymentUrlを必ず参照できるはず
|
|
92
|
+
if (typeof paymentUrl !== 'string' || paymentUrl === '') {
|
|
93
|
+
throw new factory_1.factory.errors.Internal(`Payment URL unable to publish. [retUrl: ${retUrl}]`);
|
|
94
|
+
}
|
|
95
|
+
return { paymentMethodId, paymentUrl };
|
|
96
|
+
}
|
|
69
97
|
}
|
|
70
98
|
exports.AcceptPayActionRepo = AcceptPayActionRepo;
|
|
@@ -167,7 +167,7 @@ function publishPaymentUrl(params, options) {
|
|
|
167
167
|
}
|
|
168
168
|
const actionResult = {
|
|
169
169
|
paymentMethodId: result.paymentMethodId,
|
|
170
|
-
paymentUrl: result.paymentUrl
|
|
170
|
+
// paymentUrl: result.paymentUrl // result.paymentUrlは廃止(2026-07-14~)
|
|
171
171
|
};
|
|
172
172
|
await repos.acceptPayAction.completeWithVoid({ typeOf: actionAttributes.typeOf, id: action.id, result: actionResult, recipe });
|
|
173
173
|
return result;
|
|
@@ -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: {
|
|
@@ -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
|
|
@@ -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,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.deleteReservationsByPlaceOrder = deleteReservationsByPlaceOrder;
|
|
4
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
5
4
|
const factory_1 = require("../../../factory");
|
|
6
5
|
function deleteReservationsByPlaceOrder(params) {
|
|
7
6
|
return async (repos) => {
|
|
@@ -115,8 +115,8 @@ function validatePaymentUrl(params) {
|
|
|
115
115
|
// check existing accept action(2025-02-26~)
|
|
116
116
|
const acceptActionExists = acceptPayActions.some(({ object, result }) => {
|
|
117
117
|
return object.transactionNumber === paymentMethodId
|
|
118
|
-
&& result?.paymentMethodId === paymentMethodId
|
|
119
|
-
|
|
118
|
+
&& result?.paymentMethodId === paymentMethodId;
|
|
119
|
+
// && typeof result?.paymentUrl === 'string'; // result.paymentUrlは廃止(2026-07-14~)
|
|
120
120
|
});
|
|
121
121
|
debug('validatePaymentUrl: acceptActionExists:', acceptActionExists);
|
|
122
122
|
if (!acceptActionExists) {
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/client-cognito-identity-provider": "3.600.0",
|
|
13
13
|
"@aws-sdk/credential-providers": "3.600.0",
|
|
14
|
-
"@chevre/factory": "9.5.0-alpha.
|
|
14
|
+
"@chevre/factory": "9.5.0-alpha.9",
|
|
15
15
|
"@motionpicture/coa-service": "10.0.0",
|
|
16
16
|
"@motionpicture/gmo-service": "6.1.0-alpha.0",
|
|
17
17
|
"@sendgrid/client": "8.1.4",
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
"postversion": "git push origin --tags",
|
|
92
92
|
"prepublishOnly": "npm run clean && npm run build"
|
|
93
93
|
},
|
|
94
|
-
"version": "25.2.0-alpha.
|
|
94
|
+
"version": "25.2.0-alpha.26"
|
|
95
95
|
}
|