@chevre/domain 23.0.0-alpha.3 → 23.0.0-alpha.30
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/example/src/chevre/assetTransaction/processReserve.ts +102 -40
- package/example/src/chevre/categoryCode/checkUniqueness.ts +69 -0
- package/example/src/chevre/event/checkEventAdditionalPropertyUniqueness.ts +108 -0
- package/example/src/chevre/event/migrateEventAdditionalProperty2identifier.ts +121 -0
- package/example/src/chevre/event/updateSellerMakesOffersByIdentifier.ts +106 -0
- package/example/src/chevre/note/findNotes.ts +34 -0
- package/example/src/chevre/note/upsertNotesByIdentifier.ts +10 -5
- package/example/src/chevre/offerCatalog/updateManyOfferCatalogsByIds.ts +49 -0
- package/example/src/chevre/paymentServices/findPaymentServices.ts +37 -0
- package/example/src/chevre/product/findHasOfferCatalog.ts +31 -0
- package/example/src/chevre/reIndex.ts +2 -3
- package/example/src/chevre/roles/addAdminNotePermissionIfNotExists.ts +48 -0
- package/example/src/chevre/roles/{addAdminProductOfferPermissionIfNotExists.ts → addAdminPaymentServiceReadPermissionIfNotExists.ts} +20 -19
- package/example/src/chevre/roles/addAdminProductHasOfferCatalogReadPermissionIfNotExists.ts +33 -0
- package/example/src/chevre/roles/addAdminSellerEventIfNotExists.ts +48 -0
- package/example/src/chevre/roles/removeConsolePermissionIfExists.ts +1 -1
- package/example/src/chevre/roles/removePermissionIfExists.ts +1 -6
- package/example/src/chevre/unsetUnnecessaryFields.ts +5 -7
- package/example/src/objectId.ts +12 -0
- package/example/src/signPayload.ts +12 -7
- package/lib/chevre/errorHandler.d.ts +6 -2
- package/lib/chevre/errorHandler.js +18 -2
- package/lib/chevre/repo/categoryCode.d.ts +26 -14
- package/lib/chevre/repo/categoryCode.js +53 -42
- package/lib/chevre/repo/event.d.ts +25 -11
- package/lib/chevre/repo/event.js +60 -35
- package/lib/chevre/repo/eventSellerMakesOffer.d.ts +24 -39
- package/lib/chevre/repo/eventSellerMakesOffer.js +88 -43
- package/lib/chevre/repo/issuer.js +9 -5
- package/lib/chevre/repo/mongoose/schemas/categoryCode.js +48 -42
- package/lib/chevre/repo/mongoose/schemas/movieTicketTypes.d.ts +10 -0
- package/lib/chevre/repo/mongoose/schemas/movieTicketTypes.js +107 -0
- package/lib/chevre/repo/mongoose/schemas/note.js +9 -0
- package/lib/chevre/repo/mongoose/schemas/product.d.ts +4 -4
- package/lib/chevre/repo/mongoose/schemas/product.js +2 -2
- package/lib/chevre/repo/movieTicketType.d.ts +57 -0
- package/lib/chevre/repo/movieTicketType.js +253 -0
- package/lib/chevre/repo/note.d.ts +2 -9
- package/lib/chevre/repo/note.js +52 -18
- package/lib/chevre/repo/noteAboutOrder.d.ts +4 -0
- package/lib/chevre/repo/noteAboutOrder.js +17 -0
- package/lib/chevre/repo/offerCatalog.d.ts +17 -2
- package/lib/chevre/repo/offerCatalog.js +5 -2
- package/lib/chevre/repo/product.js +15 -14
- package/lib/chevre/repo/productHasOfferCatalog.d.ts +43 -0
- package/lib/chevre/repo/productHasOfferCatalog.js +71 -0
- package/lib/chevre/repository.d.ts +10 -0
- package/lib/chevre/repository.js +28 -2
- package/lib/chevre/service/assetTransaction/reserve/start.js +2 -2
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.d.ts +15 -0
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.js +159 -0
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.d.ts +16 -0
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.js +184 -0
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +4 -1
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +25 -138
- package/lib/chevre/service/event.js +1 -1
- package/lib/chevre/service/offer/event/importFromCOA.js +1 -1
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +3 -3
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +3 -3
- package/lib/chevre/service/offer/onEventChanged.js +26 -30
- package/lib/chevre/service/payment/any/authorize/fixTransactionNumber.d.ts +39 -0
- package/lib/chevre/service/payment/any/authorize/fixTransactionNumber.js +86 -0
- package/lib/chevre/service/payment/any/{handlePrePublishedPaymentMethodIdOnAuthorizing.d.ts → authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.d.ts} +4 -4
- package/lib/chevre/service/payment/any/{handlePrePublishedPaymentMethodIdOnAuthorizing.js → authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.js} +1 -1
- package/lib/chevre/service/payment/any/publishPaymentUrl/fixTransactionNumberOnPublishPaymentUrl.d.ts +25 -0
- package/lib/chevre/service/payment/any/publishPaymentUrl/fixTransactionNumberOnPublishPaymentUrl.js +51 -0
- package/lib/chevre/service/payment/any/verifyTicketTokenAsNeeded.d.ts +2 -2
- package/lib/chevre/service/payment/any.js +91 -70
- package/lib/chevre/service/project.d.ts +3 -0
- package/lib/chevre/service/project.js +2 -1
- package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.js +19 -105
- package/lib/chevre/service/task/onResourceUpdated/syncCategoryCode.js +1 -1
- package/lib/chevre/service/task/onResourceUpdated.js +1 -1
- package/package.json +4 -4
- package/example/src/chevre/aggregateEventSellerMakesOffer.ts +0 -32
- package/example/src/chevre/event/migrateEventIdentifier4ttts.ts +0 -96
- package/example/src/chevre/searchCategoryCodesByAggregate.ts +0 -31
- package/example/src/chevre/searchOfferCatalogItems.ts +0 -59
- package/example/src/chevre/searchPaymentServices.ts +0 -32
- package/example/src/chevre/unsetUnnecessaryFieldsInAction.ts +0 -50
- package/example/src/chevre/unsetUnnecessaryFieldsInTransaction.ts +0 -46
|
@@ -10,118 +10,37 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.validateStartRequest = validateStartRequest;
|
|
13
|
-
const jwt = require("jsonwebtoken");
|
|
14
13
|
const moment = require("moment");
|
|
15
14
|
const factory = require("../../../factory");
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
let result;
|
|
19
|
-
const { issuer, secret, token } = params;
|
|
20
|
-
try {
|
|
21
|
-
result = yield new Promise((resolve, reject) => {
|
|
22
|
-
jwt.verify(token, secret, {
|
|
23
|
-
issuer
|
|
24
|
-
// ...(Array.isArray(params.audience)) ? { audience: params.audience } : undefined
|
|
25
|
-
}, (err, decoded) => {
|
|
26
|
-
if (err instanceof Error) {
|
|
27
|
-
reject(err);
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
resolve(decoded);
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
catch (error) {
|
|
36
|
-
// JWTエラーをハンドリング
|
|
37
|
-
if (error instanceof jwt.TokenExpiredError) {
|
|
38
|
-
throw new factory.errors.Argument('memberOfToken', `invalid token. [${error.message} expiredAt:${error.expiredAt}]`);
|
|
39
|
-
}
|
|
40
|
-
else if (error instanceof jwt.JsonWebTokenError) {
|
|
41
|
-
throw new factory.errors.Argument('memberOfToken', `invalid token. [${error.message}]`);
|
|
42
|
-
}
|
|
43
|
-
throw error;
|
|
44
|
-
}
|
|
45
|
-
return result;
|
|
46
|
-
});
|
|
47
|
-
}
|
|
15
|
+
const validateIssuedOfferIfExists_1 = require("./validateStartRequest/validateIssuedOfferIfExists");
|
|
16
|
+
const validateMemberTierIfExists_1 = require("./validateStartRequest/validateMemberTierIfExists");
|
|
48
17
|
function validateStartRequest(params) {
|
|
49
18
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
50
|
-
var _a
|
|
19
|
+
var _a;
|
|
51
20
|
const now = params.now;
|
|
52
21
|
const event = params.event;
|
|
53
22
|
if (params.validateEventOfferPeriod === true) {
|
|
54
23
|
if (typeof ((_a = params.store) === null || _a === void 0 ? void 0 : _a.id) !== 'string') {
|
|
55
24
|
throw new factory.errors.NotFound('store.id');
|
|
56
25
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
now,
|
|
26
|
+
yield validateApplicationOffer({
|
|
27
|
+
event,
|
|
28
|
+
now,
|
|
29
|
+
availableAt: { id: params.store.id },
|
|
30
|
+
object: params.object
|
|
31
|
+
})(repos);
|
|
60
32
|
}
|
|
61
33
|
if (params.validateEvent === true) {
|
|
62
34
|
validateEvent({ event, object: params.object });
|
|
63
35
|
}
|
|
64
36
|
});
|
|
65
37
|
}
|
|
66
|
-
function validateMemberTier(params) {
|
|
67
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
var _a, _b, _c, _d, _e;
|
|
69
|
-
const { acceptedDate, event, verifiedValidForMemberTier, memberProgramIdentifierMustBe, aggregateOfferIdentifier } = params;
|
|
70
|
-
const tierIdentifier = (_b = (_a = verifiedValidForMemberTier.member) === null || _a === void 0 ? void 0 : _a.memberOf) === null || _b === void 0 ? void 0 : _b.identifier;
|
|
71
|
-
const memberProgramIdentifier = (_e = (_d = (_c = verifiedValidForMemberTier.member) === null || _c === void 0 ? void 0 : _c.memberOf) === null || _d === void 0 ? void 0 : _d.isTierOf) === null || _e === void 0 ? void 0 : _e.identifier;
|
|
72
|
-
if (typeof tierIdentifier !== 'string') {
|
|
73
|
-
throw new factory.errors.Argument('reservationFor.offers.validForMemberTier', 'tier identifier must be string');
|
|
74
|
-
}
|
|
75
|
-
if (typeof memberProgramIdentifier !== 'string') {
|
|
76
|
-
throw new factory.errors.Argument('reservationFor.offers.validForMemberTier', 'member program must be string');
|
|
77
|
-
}
|
|
78
|
-
if (memberProgramIdentifier !== memberProgramIdentifierMustBe) {
|
|
79
|
-
throw new factory.errors.Argument('reservationFor.offers.validForMemberTier', 'member program not matched');
|
|
80
|
-
}
|
|
81
|
-
const sellerId = event.offers.seller.id;
|
|
82
|
-
if (typeof sellerId !== 'string' || sellerId === '') {
|
|
83
|
-
throw new factory.errors.NotFound('event.offers.seller.id');
|
|
84
|
-
}
|
|
85
|
-
// 有効なプロダクトオファーを検証
|
|
86
|
-
const productOfferForMemberTier = (yield repos.productOffer.findProductOffers({
|
|
87
|
-
limit: 1,
|
|
88
|
-
page: 1,
|
|
89
|
-
project: { id: { $eq: event.project.id } },
|
|
90
|
-
// availableAtOrFrom: { id: { $eq: availableAt.id } },
|
|
91
|
-
itemOffered: { identifier: { $eq: aggregateOfferIdentifier } }, // オファーコレクションコード
|
|
92
|
-
validForMemberTier: { identifier: { $eq: tierIdentifier } },
|
|
93
|
-
validFrom: { $lte: acceptedDate.toDate() },
|
|
94
|
-
validThrough: { $gte: acceptedDate.toDate() },
|
|
95
|
-
offeredBy: { id: { $eq: sellerId } } // オファー提供者も検証する
|
|
96
|
-
}, ['identifier'])).shift();
|
|
97
|
-
if (productOfferForMemberTier === undefined) {
|
|
98
|
-
throw new factory.errors.NotFound(factory.offerType.Offer, 'valid product offers for member tier not found');
|
|
99
|
-
}
|
|
100
|
-
// let validThroughMoment: moment.Moment;
|
|
101
|
-
// let validFromMoment: moment.Moment;
|
|
102
|
-
// validThroughMoment = moment(productOfferForMemberTier.validThrough, ROLE_DATE_FORMAT, true);
|
|
103
|
-
// validFromMoment = moment(productOfferForMemberTier.validFrom, ROLE_DATE_FORMAT, true);
|
|
104
|
-
// if (acceptedDate.isBefore(validFromMoment)) {
|
|
105
|
-
// throw new factory.errors.Argument(
|
|
106
|
-
// 'reservationFor.offers.validForMemberTier',
|
|
107
|
-
// `the offer id valid from ${validFromMoment}`
|
|
108
|
-
// );
|
|
109
|
-
// }
|
|
110
|
-
// if (acceptedDate.isAfter(validThroughMoment)) {
|
|
111
|
-
// throw new factory.errors.Argument(
|
|
112
|
-
// 'reservationFor.offers.validForMemberTier',
|
|
113
|
-
// `the offer id valid through ${validThroughMoment}`
|
|
114
|
-
// );
|
|
115
|
-
// }
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
38
|
/**
|
|
119
|
-
*
|
|
39
|
+
* アプリケーションごとのオファーを検証する
|
|
120
40
|
*/
|
|
121
|
-
function
|
|
41
|
+
function validateApplicationOffer(params) {
|
|
122
42
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
123
|
-
|
|
124
|
-
const { event, availableAt, tokenizedMemberProgramTier } = params;
|
|
43
|
+
const { event, availableAt } = params;
|
|
125
44
|
const acceptedDate = moment(params.now);
|
|
126
45
|
const eventOffers = event.offers;
|
|
127
46
|
// アプリケーションごとの設定を参照する(2022-11-19~)
|
|
@@ -149,51 +68,19 @@ function validateEventOfferPeriod(params) {
|
|
|
149
68
|
}
|
|
150
69
|
}
|
|
151
70
|
// 有効メンバープログラムティアが存在する場合
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
// 有効メンバープログラムティアが存在する場合、オファーコレクションコードが必須
|
|
166
|
-
const aggregateOfferIdentifier = eventOffers.identifier;
|
|
167
|
-
if (typeof aggregateOfferIdentifier !== 'string' || aggregateOfferIdentifier === '') {
|
|
168
|
-
throw new factory.errors.NotFound('makesOfferOnApplication.identifier');
|
|
169
|
-
}
|
|
170
|
-
// トークン検証
|
|
171
|
-
const memberProgram = (yield repos.memberProgram.projectMemberPrograms({
|
|
172
|
-
limit: 1,
|
|
173
|
-
page: 1,
|
|
174
|
-
project: { id: { $eq: params.event.project.id } },
|
|
175
|
-
identifier: { $eq: memberProgramIdentifierMustBe }
|
|
176
|
-
})).shift();
|
|
177
|
-
if (memberProgram === undefined) {
|
|
178
|
-
throw new factory.errors.NotFound('MemberProgram', `MemberProgram '${memberProgramIdentifierMustBe}' not found`);
|
|
179
|
-
}
|
|
180
|
-
const issuer = yield repos.issuer.findByIdentifier({
|
|
181
|
-
project: { id: params.event.project.id },
|
|
182
|
-
identifier: memberProgram.hostingOrganization.identifier
|
|
183
|
-
});
|
|
184
|
-
if (typeof issuer.tokenSecret !== 'string' || issuer.tokenSecret === '') {
|
|
185
|
-
throw new factory.errors.NotFound('issuer.tokenSecret');
|
|
186
|
-
}
|
|
187
|
-
const verifiedValidForMemberTier = yield verifyOfferedByToken({
|
|
188
|
-
secret: issuer.tokenSecret,
|
|
189
|
-
issuer: issuer.url,
|
|
190
|
-
token: validForMemberTierToken
|
|
191
|
-
});
|
|
192
|
-
yield validateMemberTier({
|
|
193
|
-
event, acceptedDate, verifiedValidForMemberTier,
|
|
194
|
-
memberProgramIdentifierMustBe, aggregateOfferIdentifier
|
|
195
|
-
})(repos);
|
|
196
|
-
}
|
|
71
|
+
yield (0, validateMemberTierIfExists_1.validateMemberTierIfExists)({
|
|
72
|
+
event,
|
|
73
|
+
now: params.now,
|
|
74
|
+
object: params.object,
|
|
75
|
+
makesOfferOnApplication
|
|
76
|
+
})(repos);
|
|
77
|
+
// オファートークン検証(2025-10-21~)
|
|
78
|
+
yield (0, validateIssuedOfferIfExists_1.validateIssuedOfferIfExists)({
|
|
79
|
+
event,
|
|
80
|
+
now: params.now,
|
|
81
|
+
object: params.object,
|
|
82
|
+
makesOfferOnApplication
|
|
83
|
+
})(repos);
|
|
197
84
|
});
|
|
198
85
|
}
|
|
199
86
|
/**
|
|
@@ -239,7 +239,7 @@ function saveScreeningEventSeries(params) {
|
|
|
239
239
|
kubunClass: '043'
|
|
240
240
|
});
|
|
241
241
|
debug('kubunNames found.');
|
|
242
|
-
const availablePaymentMethodTypes = yield repos.categoryCode.
|
|
242
|
+
const availablePaymentMethodTypes = yield repos.categoryCode.projectCategoryCodeFields({
|
|
243
243
|
project: { id: { $eq: params.project.id } },
|
|
244
244
|
inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.PaymentMethodType } }
|
|
245
245
|
}, ['additionalProperty', 'codeValue']);
|
|
@@ -117,7 +117,7 @@ function importCategoryCodesFromCOA(params) {
|
|
|
117
117
|
upsert: true
|
|
118
118
|
});
|
|
119
119
|
});
|
|
120
|
-
yield repos.categoryCode.
|
|
120
|
+
yield repos.categoryCode.saveCategoryCodesByCodeValue(saveParams);
|
|
121
121
|
}
|
|
122
122
|
catch (error) {
|
|
123
123
|
let throwsError = true;
|
|
@@ -53,15 +53,15 @@ function authorize(params) {
|
|
|
53
53
|
'superEvent', 'typeOf', 'identifier', 'name'
|
|
54
54
|
] // optimize(2024-07-18~)
|
|
55
55
|
);
|
|
56
|
-
const availablePaymentMethodTypes = yield repos.categoryCode.
|
|
56
|
+
const availablePaymentMethodTypes = yield repos.categoryCode.projectCategoryCodeFields({
|
|
57
57
|
project: { id: { $eq: transaction.project.id } },
|
|
58
58
|
inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.PaymentMethodType } }
|
|
59
59
|
}, []);
|
|
60
|
-
const seatingTypes = yield repos.categoryCode.
|
|
60
|
+
const seatingTypes = yield repos.categoryCode.projectCategoryCodeFields({
|
|
61
61
|
project: { id: { $eq: transaction.project.id } },
|
|
62
62
|
inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.SeatingType } }
|
|
63
63
|
}, []);
|
|
64
|
-
const videoFormatTypes = yield repos.categoryCode.
|
|
64
|
+
const videoFormatTypes = yield repos.categoryCode.projectCategoryCodeFields({
|
|
65
65
|
project: { id: { $eq: transaction.project.id } },
|
|
66
66
|
inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.VideoFormatType } }
|
|
67
67
|
}, []);
|
|
@@ -79,15 +79,15 @@ function changeOffers(params) {
|
|
|
79
79
|
'superEvent', 'typeOf', 'identifier', 'name'
|
|
80
80
|
] // optimize(2024-07-18~)
|
|
81
81
|
);
|
|
82
|
-
const availablePaymentMethodTypes = yield repos.categoryCode.
|
|
82
|
+
const availablePaymentMethodTypes = yield repos.categoryCode.projectCategoryCodeFields({
|
|
83
83
|
project: { id: { $eq: transaction.project.id } },
|
|
84
84
|
inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.PaymentMethodType } }
|
|
85
85
|
}, []);
|
|
86
|
-
const seatingTypes = yield repos.categoryCode.
|
|
86
|
+
const seatingTypes = yield repos.categoryCode.projectCategoryCodeFields({
|
|
87
87
|
project: { id: { $eq: transaction.project.id } },
|
|
88
88
|
inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.SeatingType } }
|
|
89
89
|
}, []);
|
|
90
|
-
const videoFormatTypes = yield repos.categoryCode.
|
|
90
|
+
const videoFormatTypes = yield repos.categoryCode.projectCategoryCodeFields({
|
|
91
91
|
project: { id: { $eq: transaction.project.id } },
|
|
92
92
|
inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.VideoFormatType } }
|
|
93
93
|
}, []);
|
|
@@ -111,41 +111,37 @@ function createInformTasks(params, setting) {
|
|
|
111
111
|
typeOf: params.typeOf
|
|
112
112
|
}, [
|
|
113
113
|
'project', 'organizer', 'typeOf', 'name', 'doorTime', 'endDate',
|
|
114
|
-
'eventStatus', 'location', 'startDate', 'superEvent', 'offers', 'additionalProperty'
|
|
114
|
+
'eventStatus', 'location', 'startDate', 'superEvent', 'offers', 'additionalProperty', 'identifier'
|
|
115
115
|
] // inclusion(2024-07-30~)
|
|
116
116
|
);
|
|
117
117
|
// 最適化(2024-03-22~)
|
|
118
|
-
events4inform = screeningEvents4inform.map(({ project, organizer, typeOf, name, doorTime, endDate, eventStatus, location, startDate, superEvent, offers, id, additionalProperty }) => {
|
|
118
|
+
events4inform = screeningEvents4inform.map(({ project, organizer, typeOf, name, doorTime, endDate, eventStatus, location, startDate, superEvent, offers, id, additionalProperty, identifier }) => {
|
|
119
119
|
var _a;
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
120
|
+
const eventOfferAsNotification = (((_a = offers.offeredThrough) === null || _a === void 0 ? void 0 : _a.identifier) === factory.service.webAPI.Identifier.COA)
|
|
121
|
+
? {
|
|
122
|
+
typeOf: offers.typeOf,
|
|
123
|
+
itemOffered: offers.itemOffered
|
|
124
|
+
}
|
|
125
|
+
: {
|
|
126
|
+
typeOf: offers.typeOf,
|
|
127
|
+
itemOffered: offers.itemOffered,
|
|
128
|
+
seller: {
|
|
129
|
+
id: offers.seller.id,
|
|
130
|
+
typeOf: offers.seller.typeOf,
|
|
131
|
+
// makesOfferを追加(2024-03-26~)
|
|
132
|
+
makesOffer: (Array.isArray(offers.seller.makesOffer))
|
|
133
|
+
? offers.seller.makesOffer.map((eventSellerMakesOffer) => {
|
|
134
|
+
return Object.assign({ availabilityEnds: eventSellerMakesOffer.availabilityEnds, availabilityStarts: eventSellerMakesOffer.availabilityStarts, validFrom: eventSellerMakesOffer.validFrom, validThrough: eventSellerMakesOffer.validThrough, availableAtOrFrom: [eventSellerMakesOffer.availableAtOrFrom] }, (typeof eventSellerMakesOffer.identifier === 'string')
|
|
135
|
+
? { identifier: eventSellerMakesOffer.identifier }
|
|
136
|
+
: undefined // support notify identifier(2025-11-01~)
|
|
137
|
+
);
|
|
138
|
+
})
|
|
139
|
+
: []
|
|
127
140
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
id: offers.seller.id,
|
|
133
|
-
typeOf: offers.seller.typeOf,
|
|
134
|
-
// makesOfferを追加(2024-03-26~)
|
|
135
|
-
makesOffer: (Array.isArray(offers.seller.makesOffer))
|
|
136
|
-
? offers.seller.makesOffer.map(({ availabilityEnds, availabilityStarts, availableAtOrFrom, validFrom, validThrough }) => {
|
|
137
|
-
// support availableAtOrFrom as non-array(2024-10-13~)
|
|
138
|
-
const availableAtOrFrom4inform = (Array.isArray(availableAtOrFrom))
|
|
139
|
-
? availableAtOrFrom
|
|
140
|
-
: (typeof (availableAtOrFrom === null || availableAtOrFrom === void 0 ? void 0 : availableAtOrFrom.id) === 'string') ? [availableAtOrFrom] : undefined;
|
|
141
|
-
return Object.assign({ availabilityEnds, availabilityStarts, validFrom, validThrough }, (Array.isArray(availableAtOrFrom4inform))
|
|
142
|
-
? { availableAtOrFrom: availableAtOrFrom4inform }
|
|
143
|
-
: undefined);
|
|
144
|
-
})
|
|
145
|
-
: []
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
};
|
|
141
|
+
};
|
|
142
|
+
return Object.assign({ project, organizer, typeOf, name, doorTime, endDate,
|
|
143
|
+
eventStatus, location, startDate, superEvent, id, additionalProperty, offers: eventOfferAsNotification }, (typeof identifier === 'string') ? { identifier } : undefined // support notify identifier(2025-11-01~)
|
|
144
|
+
);
|
|
149
145
|
});
|
|
150
146
|
}
|
|
151
147
|
else {
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as factory from '../../../../factory';
|
|
2
|
+
import type { ActionRepo } from '../../../../repo/action';
|
|
3
|
+
import type { AuthorizationRepo } from '../../../../repo/authorization';
|
|
4
|
+
import type { TicketRepo } from '../../../../repo/ticket';
|
|
5
|
+
import type { ITransactionInProgress, TransactionRepo } from '../../../../repo/transaction';
|
|
6
|
+
import type { TransactionNumberRepo } from '../../../../repo/transactionNumber';
|
|
7
|
+
import * as PayTransactionService from '../../../assetTransaction/pay';
|
|
8
|
+
import { IPermitOrInvoice } from '../verifyTicketTokenAsNeeded';
|
|
9
|
+
interface IFixTransactionNumberRepos {
|
|
10
|
+
action: ActionRepo;
|
|
11
|
+
authorization: AuthorizationRepo;
|
|
12
|
+
ticket: TicketRepo;
|
|
13
|
+
transaction: TransactionRepo;
|
|
14
|
+
transactionNumber: TransactionNumberRepo;
|
|
15
|
+
}
|
|
16
|
+
type IFixTransactionNumberOperation<T> = (repos: IFixTransactionNumberRepos) => Promise<T>;
|
|
17
|
+
type IObjectWithoutDetail = factory.action.authorize.paymentMethod.any.IObjectWithoutDetail & {
|
|
18
|
+
ticketToken?: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* 決済承認時の取引番号を決定する
|
|
22
|
+
*/
|
|
23
|
+
declare function fixTransactionNumber(params: {
|
|
24
|
+
object: IObjectWithoutDetail;
|
|
25
|
+
transaction: Pick<ITransactionInProgress<factory.transactionType.PlaceOrder>, 'agent' | 'expires' | 'id' | 'typeOf' | 'project' | 'seller'>;
|
|
26
|
+
paymentServiceType: factory.service.paymentService.PaymentServiceType;
|
|
27
|
+
}): IFixTransactionNumberOperation<{
|
|
28
|
+
transactionNumber: string;
|
|
29
|
+
pendingPaymentAgencyTransaction?: PayTransactionService.IPaymentAgencyTransaction;
|
|
30
|
+
creditCard?: factory.action.authorize.paymentMethod.any.ICreditCard;
|
|
31
|
+
permitOrInvoice?: IPermitOrInvoice;
|
|
32
|
+
id?: never;
|
|
33
|
+
} | {
|
|
34
|
+
/**
|
|
35
|
+
* 完了済の決済承認アクションID
|
|
36
|
+
*/
|
|
37
|
+
id: string;
|
|
38
|
+
}>;
|
|
39
|
+
export { fixTransactionNumber };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.fixTransactionNumber = fixTransactionNumber;
|
|
13
|
+
const factory = require("../../../../factory");
|
|
14
|
+
const verifyTicketTokenAsNeeded_1 = require("../verifyTicketTokenAsNeeded");
|
|
15
|
+
const handlePrePublishedPaymentMethodIdOnAuthorizing_1 = require("./handlePrePublishedPaymentMethodIdOnAuthorizing");
|
|
16
|
+
/**
|
|
17
|
+
* 決済承認時の取引番号を決定する
|
|
18
|
+
*/
|
|
19
|
+
function fixTransactionNumber(params) {
|
|
20
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
const { paymentServiceType, transaction, object } = params;
|
|
22
|
+
// 取引番号生成
|
|
23
|
+
let transactionNumber;
|
|
24
|
+
let pendingPaymentAgencyTransaction;
|
|
25
|
+
let creditCard = object.creditCard;
|
|
26
|
+
// ticketTokenを解釈(2024-08-13~)
|
|
27
|
+
const { permitOrInvoice } = yield (0, verifyTicketTokenAsNeeded_1.verifyTicketTokenAsNeeded)({
|
|
28
|
+
project: { id: transaction.project.id },
|
|
29
|
+
object: object,
|
|
30
|
+
paymentServiceType,
|
|
31
|
+
purpose: { id: transaction.id }
|
|
32
|
+
})(repos);
|
|
33
|
+
/**
|
|
34
|
+
* ticketTokenによって指定された決済方法ID
|
|
35
|
+
*/
|
|
36
|
+
let paymentMethodIdByTicketToken;
|
|
37
|
+
if ((permitOrInvoice === null || permitOrInvoice === void 0 ? void 0 : permitOrInvoice.typeOf) === factory.permit.PermitType.Permit) {
|
|
38
|
+
paymentMethodIdByTicketToken = permitOrInvoice === null || permitOrInvoice === void 0 ? void 0 : permitOrInvoice.identifier;
|
|
39
|
+
if (typeof paymentMethodIdByTicketToken === 'string') {
|
|
40
|
+
transactionNumber = paymentMethodIdByTicketToken; // メンバーシップ指定の場合、取引番号に適用(2024-08-13~)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
else if ((permitOrInvoice === null || permitOrInvoice === void 0 ? void 0 : permitOrInvoice.typeOf) === 'Invoice') {
|
|
44
|
+
// support paymentServiceType.MovieTicket(2024-11-23~)
|
|
45
|
+
if (typeof (permitOrInvoice === null || permitOrInvoice === void 0 ? void 0 : permitOrInvoice.paymentMethodId) === 'string') {
|
|
46
|
+
paymentMethodIdByTicketToken = permitOrInvoice === null || permitOrInvoice === void 0 ? void 0 : permitOrInvoice.paymentMethodId;
|
|
47
|
+
if (typeof paymentMethodIdByTicketToken === 'string') {
|
|
48
|
+
transactionNumber = paymentMethodIdByTicketToken;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// リクエストでpaymentMethodIdを指定された場合、取引に保管されたpaymentMethodIdに一致すればそちらを適用(外部サイト決済対応)
|
|
53
|
+
if (typeof object.paymentMethodId === 'string' && object.paymentMethodId.length > 0) {
|
|
54
|
+
if (typeof paymentMethodIdByTicketToken === 'string') {
|
|
55
|
+
// 指定されたpaymentMethodIdとチケットから読み取った決済方法IDは一致しなければいけない
|
|
56
|
+
if (paymentMethodIdByTicketToken !== object.paymentMethodId) {
|
|
57
|
+
throw new factory.errors.Argument('ticketToken', 'not matched with paymentMethodId');
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const { authorizeParams, existingCompletedAuthorizeAction } = yield (0, handlePrePublishedPaymentMethodIdOnAuthorizing_1.handlePrePublishedPaymentMethodIdOnAuthorizing)({
|
|
61
|
+
object: object,
|
|
62
|
+
prePublishedPaymentMethodId: object.paymentMethodId,
|
|
63
|
+
transaction
|
|
64
|
+
})(repos);
|
|
65
|
+
if (existingCompletedAuthorizeAction !== undefined) {
|
|
66
|
+
return { id: existingCompletedAuthorizeAction.id };
|
|
67
|
+
}
|
|
68
|
+
else if (authorizeParams !== undefined) {
|
|
69
|
+
// creditCardを決済URL発行時の情報で上書き(2024-01-08~)
|
|
70
|
+
// creditCard = authorizeParams.paymentMethodByTransaction.paymentMethod?.creditCard;
|
|
71
|
+
creditCard = authorizeParams.creditCard;
|
|
72
|
+
transactionNumber = object.paymentMethodId;
|
|
73
|
+
pendingPaymentAgencyTransaction = authorizeParams.pendingPaymentAgencyTransaction;
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
throw new factory.errors.NotImplemented('pendingPaymentAgencyTransaction required on paymentMethodId specified');
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// 取引番号発行済でなければ発行
|
|
80
|
+
if (typeof transactionNumber !== 'string') {
|
|
81
|
+
const publishTransactionNumberResult = yield repos.transactionNumber.publishByTimestamp({ startDate: new Date() });
|
|
82
|
+
transactionNumber = publishTransactionNumberResult.transactionNumber;
|
|
83
|
+
}
|
|
84
|
+
return Object.assign(Object.assign(Object.assign({ transactionNumber }, (pendingPaymentAgencyTransaction !== undefined) ? { pendingPaymentAgencyTransaction } : undefined), (creditCard !== undefined) ? { creditCard } : undefined), (permitOrInvoice !== undefined) ? { permitOrInvoice } : undefined);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as factory from '
|
|
2
|
-
import type { ActionRepo } from '
|
|
3
|
-
import type { ITransactionInProgress, TransactionRepo } from '
|
|
4
|
-
import * as PayTransactionService from '
|
|
1
|
+
import * as factory from '../../../../factory';
|
|
2
|
+
import type { ActionRepo } from '../../../../repo/action';
|
|
3
|
+
import type { ITransactionInProgress, TransactionRepo } from '../../../../repo/transaction';
|
|
4
|
+
import * as PayTransactionService from '../../../assetTransaction/pay';
|
|
5
5
|
type IObjectWithoutDetail = factory.action.authorize.paymentMethod.any.IObjectWithoutDetail;
|
|
6
6
|
declare function handlePrePublishedPaymentMethodIdOnAuthorizing(params: {
|
|
7
7
|
object: Pick<IObjectWithoutDetail, 'amount' | 'issuedThrough' | 'paymentMethod'>;
|
|
@@ -11,7 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.handlePrePublishedPaymentMethodIdOnAuthorizing = handlePrePublishedPaymentMethodIdOnAuthorizing;
|
|
13
13
|
const createDebug = require("debug");
|
|
14
|
-
const factory = require("
|
|
14
|
+
const factory = require("../../../../factory");
|
|
15
15
|
const debug = createDebug('chevre-domain:service:payment');
|
|
16
16
|
function recipe2paymentAgencyTransaction(actionRecipe) {
|
|
17
17
|
var _a;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as factory from '../../../../factory';
|
|
2
|
+
import type { AuthorizationRepo } from '../../../../repo/authorization';
|
|
3
|
+
import type { TicketRepo } from '../../../../repo/ticket';
|
|
4
|
+
import type { ITransactionInProgress } from '../../../../repo/transaction';
|
|
5
|
+
import type { TransactionNumberRepo } from '../../../../repo/transactionNumber';
|
|
6
|
+
interface IFixTransactionNumberRepos {
|
|
7
|
+
authorization: AuthorizationRepo;
|
|
8
|
+
ticket: TicketRepo;
|
|
9
|
+
transactionNumber: TransactionNumberRepo;
|
|
10
|
+
}
|
|
11
|
+
type IFixTransactionNumberOperation<T> = (repos: IFixTransactionNumberRepos) => Promise<T>;
|
|
12
|
+
type IObjectWithoutDetail = factory.action.authorize.paymentMethod.any.IObjectWithoutDetail & {
|
|
13
|
+
ticketToken?: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* 外部決済ロケーション発行時の取引番号を決定する
|
|
17
|
+
*/
|
|
18
|
+
declare function fixTransactionNumberOnPublishPaymentUrl(params: {
|
|
19
|
+
object: IObjectWithoutDetail;
|
|
20
|
+
transaction: Pick<ITransactionInProgress<factory.transactionType.PlaceOrder>, 'id' | 'project'>;
|
|
21
|
+
paymentServiceType: factory.service.paymentService.PaymentServiceType;
|
|
22
|
+
}): IFixTransactionNumberOperation<{
|
|
23
|
+
transactionNumber: string;
|
|
24
|
+
}>;
|
|
25
|
+
export { fixTransactionNumberOnPublishPaymentUrl };
|
package/lib/chevre/service/payment/any/publishPaymentUrl/fixTransactionNumberOnPublishPaymentUrl.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.fixTransactionNumberOnPublishPaymentUrl = fixTransactionNumberOnPublishPaymentUrl;
|
|
13
|
+
const factory = require("../../../../factory");
|
|
14
|
+
const verifyTicketTokenAsNeeded_1 = require("../verifyTicketTokenAsNeeded");
|
|
15
|
+
/**
|
|
16
|
+
* 外部決済ロケーション発行時の取引番号を決定する
|
|
17
|
+
*/
|
|
18
|
+
function fixTransactionNumberOnPublishPaymentUrl(params) {
|
|
19
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
const { paymentServiceType, transaction, object } = params;
|
|
21
|
+
// 取引番号生成
|
|
22
|
+
let transactionNumber;
|
|
23
|
+
// support ticketToken(2024-08-21~)
|
|
24
|
+
const { permitOrInvoice } = yield (0, verifyTicketTokenAsNeeded_1.verifyTicketTokenAsNeeded)({
|
|
25
|
+
project: { id: transaction.project.id },
|
|
26
|
+
object,
|
|
27
|
+
paymentServiceType,
|
|
28
|
+
purpose: { id: transaction.id }
|
|
29
|
+
})(repos);
|
|
30
|
+
if ((permitOrInvoice === null || permitOrInvoice === void 0 ? void 0 : permitOrInvoice.typeOf) === factory.permit.PermitType.Permit) {
|
|
31
|
+
const paymentMethodIdByPermit = permitOrInvoice === null || permitOrInvoice === void 0 ? void 0 : permitOrInvoice.identifier;
|
|
32
|
+
if (typeof paymentMethodIdByPermit === 'string') {
|
|
33
|
+
transactionNumber = paymentMethodIdByPermit;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
else if ((permitOrInvoice === null || permitOrInvoice === void 0 ? void 0 : permitOrInvoice.typeOf) === 'Invoice') {
|
|
37
|
+
// support Invoice ticket(2025-11-09~)
|
|
38
|
+
if (typeof (permitOrInvoice === null || permitOrInvoice === void 0 ? void 0 : permitOrInvoice.paymentMethodId) === 'string') {
|
|
39
|
+
transactionNumber = permitOrInvoice.paymentMethodId;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (typeof transactionNumber !== 'string') {
|
|
43
|
+
const publishTransactionNumberResult = yield repos.transactionNumber.publishByTimestamp({ startDate: new Date() });
|
|
44
|
+
transactionNumber = publishTransactionNumberResult.transactionNumber;
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
transactionNumber
|
|
48
|
+
// ...(permitOrInvoice !== undefined) ? { permitOrInvoice } : undefined
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
}
|
|
@@ -8,11 +8,11 @@ declare function verifyTicketTokenAsNeeded(params: {
|
|
|
8
8
|
};
|
|
9
9
|
object: Pick<factory.action.authorize.paymentMethod.any.IObjectWithoutDetail, 'issuedThrough' | 'ticketToken'>;
|
|
10
10
|
paymentServiceType: factory.service.paymentService.PaymentServiceType;
|
|
11
|
-
purpose: factory.action.authorize.paymentMethod.any.IPurpose
|
|
11
|
+
purpose: Pick<factory.action.authorize.paymentMethod.any.IPurpose, 'id'>;
|
|
12
12
|
}): (repos: {
|
|
13
13
|
authorization: AuthorizationRepo;
|
|
14
14
|
ticket: TicketRepo;
|
|
15
15
|
}) => Promise<{
|
|
16
16
|
permitOrInvoice?: IPermitOrInvoice;
|
|
17
17
|
}>;
|
|
18
|
-
export { verifyTicketTokenAsNeeded };
|
|
18
|
+
export { IPermitOrInvoice, verifyTicketTokenAsNeeded };
|