@chevre/domain 21.27.0-alpha.8 → 21.27.0
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/{aggregateEventReservation.ts → aggregation/aggregateEventReservation.ts} +2 -3
- package/example/src/chevre/aggregation/aggregateOffersOnEvent.ts +82 -0
- package/example/src/chevre/{aggregateAllEvents.ts → aggregation/createAggregateEventTasks.ts} +26 -13
- package/example/src/chevre/aggregation/searchAggregateReservations.ts +33 -0
- package/example/src/chevre/searchEvents.ts +4 -4
- package/example/src/chevre/transaction/processPlaceOrder.ts +1 -2
- package/example/src/chevre/unsetUnnecessaryFields.ts +4 -4
- package/lib/chevre/credentials.d.ts +7 -0
- package/lib/chevre/credentials.js +10 -6
- package/lib/chevre/repo/action.d.ts +9 -1
- package/lib/chevre/repo/action.js +80 -47
- package/lib/chevre/repo/aggregateReservation.d.ts +68 -0
- package/lib/chevre/repo/aggregateReservation.js +135 -0
- package/lib/chevre/repo/event.d.ts +16 -14
- package/lib/chevre/repo/event.js +62 -20
- package/lib/chevre/repo/mongoose/schemas/action.js +18 -0
- package/lib/chevre/repo/mongoose/schemas/aggregateReservation.d.ts +5 -0
- package/lib/chevre/repo/mongoose/schemas/aggregateReservation.js +84 -0
- package/lib/chevre/repo/mongoose/schemas/event.js +1 -1
- package/lib/chevre/repo/offer.d.ts +5 -0
- package/lib/chevre/repository.d.ts +5 -0
- package/lib/chevre/repository.js +15 -2
- package/lib/chevre/service/aggregation/event/aggregateOffers.d.ts +31 -0
- package/lib/chevre/service/aggregation/event/aggregateOffers.js +290 -0
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.d.ts +3 -4
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +33 -238
- package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.d.ts +2 -0
- package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +19 -15
- package/lib/chevre/service/aggregation/event/findEventOffers.d.ts +2 -2
- package/lib/chevre/service/aggregation/event/findEventOffers.js +0 -2
- package/lib/chevre/service/aggregation/event.d.ts +2 -1
- package/lib/chevre/service/aggregation/event.js +3 -1
- package/lib/chevre/service/assetTransaction/pay.d.ts +4 -1
- package/lib/chevre/service/assetTransaction/pay.js +53 -27
- package/lib/chevre/service/assetTransaction/reserve.js +2 -1
- package/lib/chevre/service/event.js +16 -23
- package/lib/chevre/service/notification.js +0 -102
- package/lib/chevre/service/offer/onEventChanged.d.ts +25 -0
- package/lib/chevre/service/offer/onEventChanged.js +232 -0
- package/lib/chevre/service/offer.d.ts +0 -40
- package/lib/chevre/service/offer.js +1 -184
- package/lib/chevre/service/payment/any/onPaymentStatusChanged.js +2 -9
- package/lib/chevre/service/payment/any/onRefund.d.ts +1 -3
- package/lib/chevre/service/payment/any/onRefund.js +64 -60
- package/lib/chevre/service/payment/any.d.ts +4 -2
- package/lib/chevre/service/payment/any.js +76 -48
- package/lib/chevre/service/payment/creditCard.js +14 -7
- package/lib/chevre/service/payment/movieTicket/checkByIdentifier.js +1 -9
- package/lib/chevre/service/payment/movieTicket.d.ts +1 -1
- package/lib/chevre/service/payment/movieTicket.js +13 -4
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +2 -2
- package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +2 -2
- package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +2 -2
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +2 -2
- package/lib/chevre/service/task/aggregateOffers.d.ts +7 -0
- package/lib/chevre/service/task/aggregateOffers.js +47 -0
- package/lib/chevre/service/task/aggregateScreeningEvent.js +0 -2
- package/lib/chevre/service/task/aggregateUseActionsOnEvent.js +2 -0
- package/lib/chevre/service/task/onEventChanged.js +2 -2
- package/lib/chevre/service/transaction/returnOrder/preStart.js +0 -18
- package/lib/chevre/settings.d.ts +1 -0
- package/lib/chevre/settings.js +2 -1
- package/package.json +3 -3
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.searchEventSeatOffersWithPaging = exports.addOffers2Seat = exports.product = exports.moneyTransfer = exports.eventServiceByCOA = exports.event = void 0;
|
|
13
13
|
const moment = require("moment");
|
|
14
14
|
const factory = require("../factory");
|
|
15
15
|
const EventOfferService = require("./offer/event");
|
|
@@ -20,8 +20,6 @@ const MoneyTransferOfferService = require("./offer/moneyTransfer");
|
|
|
20
20
|
exports.moneyTransfer = MoneyTransferOfferService;
|
|
21
21
|
const ProductOfferService = require("./offer/product");
|
|
22
22
|
exports.product = ProductOfferService;
|
|
23
|
-
const settings_1 = require("../settings");
|
|
24
|
-
const informEvents = settings_1.settings.onEventChanged.informEvent;
|
|
25
23
|
/**
|
|
26
24
|
* 座席にオファー情報を付加する
|
|
27
25
|
*/
|
|
@@ -127,184 +125,3 @@ function searchEventSeatOffersWithPaging(params) {
|
|
|
127
125
|
});
|
|
128
126
|
}
|
|
129
127
|
exports.searchEventSeatOffersWithPaging = searchEventSeatOffersWithPaging;
|
|
130
|
-
/**
|
|
131
|
-
* イベント変更時処理
|
|
132
|
-
*/
|
|
133
|
-
function onEventChanged(params) {
|
|
134
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
135
|
-
if (params.id.length > 0) {
|
|
136
|
-
// ScreeningEventであれば集計タスク
|
|
137
|
-
if (params.typeOf === factory.eventType.ScreeningEvent) {
|
|
138
|
-
yield createAggregateScreeningEventIfNotExist({
|
|
139
|
-
project: { id: params.project.id },
|
|
140
|
-
reservationFor: params.id.map((id) => {
|
|
141
|
-
return { id };
|
|
142
|
-
}),
|
|
143
|
-
// 新規作成の場合は強制的に集計
|
|
144
|
-
force: params.isNew,
|
|
145
|
-
identifier: `onEventChanged`
|
|
146
|
-
})(repos);
|
|
147
|
-
}
|
|
148
|
-
// 通知タスク作成(2023-06-08~)
|
|
149
|
-
if (params.useInform === true) {
|
|
150
|
-
yield createInformTasks({
|
|
151
|
-
project: { id: params.project.id },
|
|
152
|
-
ids: params.id,
|
|
153
|
-
typeOf: params.typeOf
|
|
154
|
-
})(repos);
|
|
155
|
-
}
|
|
156
|
-
if (params.useSync === true) {
|
|
157
|
-
switch (params.typeOf) {
|
|
158
|
-
case factory.eventType.ScreeningEventSeries:
|
|
159
|
-
// 施設コンテンツを興行イベントへ同期(2023-07-28~)
|
|
160
|
-
yield syncEventSeries2screeningEvents({
|
|
161
|
-
project: { id: params.project.id },
|
|
162
|
-
ids: params.id
|
|
163
|
-
})(repos);
|
|
164
|
-
break;
|
|
165
|
-
default:
|
|
166
|
-
// no op
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
exports.onEventChanged = onEventChanged;
|
|
173
|
-
function syncEventSeries2screeningEvents(params) {
|
|
174
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
175
|
-
const now = new Date();
|
|
176
|
-
for (const eventSeriesId of params.ids) {
|
|
177
|
-
yield repos.event.syncScreeningEventSeries2screeningEvents({
|
|
178
|
-
project: { id: params.project.id },
|
|
179
|
-
superEvent: { id: eventSeriesId },
|
|
180
|
-
startDate: { $gte: now }
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
exports.syncEventSeries2screeningEvents = syncEventSeries2screeningEvents;
|
|
186
|
-
function createAggregateScreeningEventIfNotExist(params) {
|
|
187
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
188
|
-
let aggregateTasks = [];
|
|
189
|
-
const runsAt = new Date();
|
|
190
|
-
const remainingNumberOfTries = 2;
|
|
191
|
-
const project = {
|
|
192
|
-
id: params.project.id, typeOf: factory.organizationType.Project
|
|
193
|
-
};
|
|
194
|
-
const nowInMilliseconds = Date.now();
|
|
195
|
-
if (params.force) {
|
|
196
|
-
aggregateTasks = params.reservationFor.map((reservationFor) => {
|
|
197
|
-
const taskIdentifier = `${params.project.id}:${factory.taskName.AggregateScreeningEvent}:${reservationFor.id}:${params.identifier}:${nowInMilliseconds}`;
|
|
198
|
-
return {
|
|
199
|
-
identifier: taskIdentifier,
|
|
200
|
-
project,
|
|
201
|
-
name: factory.taskName.AggregateScreeningEvent,
|
|
202
|
-
status: factory.taskStatus.Ready,
|
|
203
|
-
runsAt,
|
|
204
|
-
remainingNumberOfTries,
|
|
205
|
-
numberOfTried: 0,
|
|
206
|
-
executionResults: [],
|
|
207
|
-
data: { typeOf: factory.eventType.ScreeningEvent, id: reservationFor.id }
|
|
208
|
-
};
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
for (const reservationFor of params.reservationFor) {
|
|
213
|
-
// 冗長な作成を避ける
|
|
214
|
-
const readyAggregateScreeningEventTaskDoc = yield repos.task.taskModel.findOne({
|
|
215
|
-
'project.id': { $eq: project.id },
|
|
216
|
-
name: { $eq: factory.taskName.AggregateScreeningEvent },
|
|
217
|
-
status: { $eq: factory.taskStatus.Ready },
|
|
218
|
-
'data.id': { $exists: true, $eq: reservationFor.id }
|
|
219
|
-
}, { _id: 1 })
|
|
220
|
-
.exec();
|
|
221
|
-
if (readyAggregateScreeningEventTaskDoc === null) {
|
|
222
|
-
const taskIdentifier = `${params.project.id}:${factory.taskName.AggregateScreeningEvent}:${reservationFor.id}:${params.identifier}:${nowInMilliseconds}`;
|
|
223
|
-
aggregateTasks.push({
|
|
224
|
-
identifier: taskIdentifier,
|
|
225
|
-
project,
|
|
226
|
-
name: factory.taskName.AggregateScreeningEvent,
|
|
227
|
-
status: factory.taskStatus.Ready,
|
|
228
|
-
runsAt,
|
|
229
|
-
remainingNumberOfTries,
|
|
230
|
-
numberOfTried: 0,
|
|
231
|
-
executionResults: [],
|
|
232
|
-
data: { typeOf: factory.eventType.ScreeningEvent, id: reservationFor.id }
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
if (aggregateTasks.length > 0) {
|
|
238
|
-
yield repos.task.saveMany(aggregateTasks, { emitImmediately: true });
|
|
239
|
-
}
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
exports.createAggregateScreeningEventIfNotExist = createAggregateScreeningEventIfNotExist;
|
|
243
|
-
function createInformTasks(params) {
|
|
244
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
245
|
-
let events4inform;
|
|
246
|
-
if (params.typeOf === factory.eventType.Event) {
|
|
247
|
-
events4inform = yield repos.event.search({
|
|
248
|
-
id: { $in: params.ids },
|
|
249
|
-
typeOf: params.typeOf
|
|
250
|
-
}, [], [
|
|
251
|
-
'aggregateEntranceGate', 'aggregateOffer', 'aggregateReservation',
|
|
252
|
-
'remainingAttendeeCapacity', 'checkInCount', 'attendeeCount'
|
|
253
|
-
]);
|
|
254
|
-
}
|
|
255
|
-
else if (params.typeOf === factory.eventType.ScreeningEvent) {
|
|
256
|
-
events4inform = yield repos.event.search({
|
|
257
|
-
id: { $in: params.ids },
|
|
258
|
-
typeOf: params.typeOf
|
|
259
|
-
}, [], [
|
|
260
|
-
'aggregateEntranceGate', 'aggregateOffer', 'aggregateReservation',
|
|
261
|
-
'remainingAttendeeCapacity', 'checkInCount', 'attendeeCount'
|
|
262
|
-
]);
|
|
263
|
-
}
|
|
264
|
-
else {
|
|
265
|
-
events4inform = yield repos.event.search({
|
|
266
|
-
id: { $in: params.ids },
|
|
267
|
-
typeOf: params.typeOf
|
|
268
|
-
}, [], []);
|
|
269
|
-
}
|
|
270
|
-
if (events4inform.length > 0) {
|
|
271
|
-
const taskRunsAt = new Date();
|
|
272
|
-
const informTasks = [];
|
|
273
|
-
informEvents === null || informEvents === void 0 ? void 0 : informEvents.forEach((informEvent) => {
|
|
274
|
-
var _a;
|
|
275
|
-
const informUrl = String((_a = informEvent.recipient) === null || _a === void 0 ? void 0 : _a.url);
|
|
276
|
-
events4inform.forEach((event4inform) => {
|
|
277
|
-
var _a;
|
|
278
|
-
// _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
|
|
279
|
-
delete event4inform._id;
|
|
280
|
-
const informActionAttributes = {
|
|
281
|
-
agent: event4inform.project,
|
|
282
|
-
object: event4inform,
|
|
283
|
-
project: event4inform.project,
|
|
284
|
-
recipient: {
|
|
285
|
-
id: '',
|
|
286
|
-
name: String((_a = informEvent.recipient) === null || _a === void 0 ? void 0 : _a.name),
|
|
287
|
-
typeOf: factory.creativeWorkType.WebApplication,
|
|
288
|
-
url: informUrl
|
|
289
|
-
},
|
|
290
|
-
typeOf: factory.actionType.InformAction
|
|
291
|
-
};
|
|
292
|
-
informTasks.push({
|
|
293
|
-
project: event4inform.project,
|
|
294
|
-
name: factory.taskName.TriggerWebhook,
|
|
295
|
-
status: factory.taskStatus.Ready,
|
|
296
|
-
runsAt: taskRunsAt,
|
|
297
|
-
remainingNumberOfTries: 10,
|
|
298
|
-
numberOfTried: 0,
|
|
299
|
-
executionResults: [],
|
|
300
|
-
data: informActionAttributes
|
|
301
|
-
});
|
|
302
|
-
});
|
|
303
|
-
});
|
|
304
|
-
if (informTasks.length > 0) {
|
|
305
|
-
yield repos.task.saveMany(informTasks, { emitImmediately: true });
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
});
|
|
309
|
-
}
|
|
310
|
-
exports.createInformTasks = createInformTasks;
|
|
@@ -72,17 +72,10 @@ function optimizeAction4report(action) {
|
|
|
72
72
|
typeOf: o.typeOf
|
|
73
73
|
};
|
|
74
74
|
});
|
|
75
|
-
const optimizedRefundAction = {
|
|
76
|
-
actionStatus: action.actionStatus,
|
|
77
|
-
endDate: action.endDate,
|
|
78
|
-
id: action.id,
|
|
79
|
-
object: optimizedRefundActionObject,
|
|
75
|
+
const optimizedRefundAction = Object.assign({ actionStatus: action.actionStatus, endDate: action.endDate, id: action.id, object: optimizedRefundActionObject,
|
|
80
76
|
// 最適化(2023-06-30~)
|
|
81
77
|
// project: action.project,
|
|
82
|
-
purpose: action.purpose,
|
|
83
|
-
startDate: action.startDate,
|
|
84
|
-
typeOf: action.typeOf
|
|
85
|
-
};
|
|
78
|
+
purpose: action.purpose, startDate: action.startDate, typeOf: action.typeOf }, (action.error !== undefined) ? { error: action.error } : undefined);
|
|
86
79
|
optimizedAction = optimizedRefundAction;
|
|
87
80
|
break;
|
|
88
81
|
default:
|
|
@@ -20,6 +20,7 @@ const onPaymentStatusChanged_1 = require("./onPaymentStatusChanged");
|
|
|
20
20
|
* 返金後のアクション
|
|
21
21
|
*/
|
|
22
22
|
function onRefund(refundAction) {
|
|
23
|
+
// tslint:disable-next-line:max-func-body-length
|
|
23
24
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
24
25
|
var _a, _b;
|
|
25
26
|
const aciton4inform = (0, factory_1.optimizeAction4inform)(refundAction);
|
|
@@ -31,75 +32,78 @@ function onRefund(refundAction) {
|
|
|
31
32
|
// 同期的に経理レポート連携する(2022-08-27~)
|
|
32
33
|
yield (0, onPaymentStatusChanged_1.onPaymentStatusChanged)(aciton4inform)(repos);
|
|
33
34
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
if (
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
35
|
+
// FailedActionStatusに対応(経理レポート連携はするが、通知はしない)(2024-03-21~)
|
|
36
|
+
if (refundAction.actionStatus === factory.actionStatusType.CompletedActionStatus) {
|
|
37
|
+
const informPayment = potentialActions === null || potentialActions === void 0 ? void 0 : potentialActions.informPayment;
|
|
38
|
+
// 手数料決済があれば処理
|
|
39
|
+
// CreditCardIFのみ(2023-06-29~)
|
|
40
|
+
const paymentServiceType = (_a = refundAction.object[0]) === null || _a === void 0 ? void 0 : _a.typeOf;
|
|
41
|
+
if (paymentServiceType === factory.service.paymentService.PaymentServiceType.CreditCard) {
|
|
42
|
+
const refundFee = (_b = refundAction.object[0]) === null || _b === void 0 ? void 0 : _b.refundFee;
|
|
43
|
+
if (typeof refundFee === 'number' && refundFee > 0) {
|
|
44
|
+
// purpose.typeOf:PlaceOrderは外部決済URL無効化における返金アクションのみなので、手数料決済から除外してよい(2024-03-19~)
|
|
45
|
+
if (refundAction.purpose.typeOf !== factory.transactionType.PlaceOrder) {
|
|
46
|
+
const payObject = refundAction.object.map((o) => {
|
|
47
|
+
return {
|
|
48
|
+
typeOf: o.typeOf,
|
|
49
|
+
id: o.id,
|
|
50
|
+
paymentMethod: {
|
|
51
|
+
accountId: o.paymentMethod.accountId,
|
|
52
|
+
additionalProperty: o.paymentMethod.additionalProperty,
|
|
53
|
+
name: o.paymentMethod.name,
|
|
54
|
+
paymentMethodId: o.paymentMethod.paymentMethodId,
|
|
55
|
+
totalPaymentDue: {
|
|
56
|
+
typeOf: 'MonetaryAmount',
|
|
57
|
+
currency: factory.priceCurrency.JPY,
|
|
58
|
+
value: refundFee
|
|
59
|
+
},
|
|
60
|
+
typeOf: o.paymentMethod.typeOf
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
const payAction = {
|
|
65
|
+
project: refundAction.project,
|
|
66
|
+
typeOf: factory.actionType.PayAction,
|
|
67
|
+
object: payObject,
|
|
68
|
+
agent: refundAction.project,
|
|
69
|
+
recipient: refundAction.agent,
|
|
70
|
+
purpose: refundAction.purpose,
|
|
71
|
+
potentialActions: {
|
|
72
|
+
add2report: true,
|
|
73
|
+
informPayment: (Array.isArray(informPayment)) ? informPayment : []
|
|
58
74
|
}
|
|
59
75
|
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
+
const payTask = {
|
|
77
|
+
project: refundAction.project,
|
|
78
|
+
name: factory.taskName.Pay,
|
|
79
|
+
status: factory.taskStatus.Ready,
|
|
80
|
+
runsAt: now,
|
|
81
|
+
remainingNumberOfTries: 10,
|
|
82
|
+
numberOfTried: 0,
|
|
83
|
+
executionResults: [],
|
|
84
|
+
data: payAction
|
|
85
|
+
};
|
|
86
|
+
taskAttributes.push(payTask);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (Array.isArray(informPayment)) {
|
|
91
|
+
taskAttributes.push(...informPayment.map((a) => {
|
|
92
|
+
return {
|
|
93
|
+
project: a.project,
|
|
94
|
+
name: factory.taskName.TriggerWebhook,
|
|
76
95
|
status: factory.taskStatus.Ready,
|
|
77
96
|
runsAt: now,
|
|
78
|
-
remainingNumberOfTries:
|
|
97
|
+
remainingNumberOfTries: 30,
|
|
79
98
|
numberOfTried: 0,
|
|
80
99
|
executionResults: [],
|
|
81
|
-
data:
|
|
100
|
+
data: Object.assign(Object.assign({}, a), { object: aciton4inform })
|
|
82
101
|
};
|
|
83
|
-
|
|
84
|
-
}
|
|
102
|
+
}));
|
|
85
103
|
}
|
|
104
|
+
// タスク保管
|
|
105
|
+
yield repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
86
106
|
}
|
|
87
|
-
if (Array.isArray(informPayment)) {
|
|
88
|
-
taskAttributes.push(...informPayment.map((a) => {
|
|
89
|
-
return {
|
|
90
|
-
project: a.project,
|
|
91
|
-
name: factory.taskName.TriggerWebhook,
|
|
92
|
-
status: factory.taskStatus.Ready,
|
|
93
|
-
runsAt: now,
|
|
94
|
-
remainingNumberOfTries: 30,
|
|
95
|
-
numberOfTried: 0,
|
|
96
|
-
executionResults: [],
|
|
97
|
-
data: Object.assign(Object.assign({}, a), { object: aciton4inform })
|
|
98
|
-
};
|
|
99
|
-
}));
|
|
100
|
-
}
|
|
101
|
-
// タスク保管
|
|
102
|
-
return repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
103
107
|
});
|
|
104
108
|
}
|
|
105
109
|
exports.onRefund = onRefund;
|
|
@@ -66,6 +66,7 @@ interface IAuthorizeRepos {
|
|
|
66
66
|
}
|
|
67
67
|
type IAuthorizeOperation<T> = (repos: IAuthorizeRepos) => Promise<T>;
|
|
68
68
|
interface IPublishPaymentUrlRepos {
|
|
69
|
+
action: ActionRepo;
|
|
69
70
|
assetTransaction: AssetTransactionRepo;
|
|
70
71
|
paymentAccepted: PaymentAcceptedRepo;
|
|
71
72
|
paymentService: PaymentServiceRepo;
|
|
@@ -84,11 +85,12 @@ declare function publishPaymentUrl(params: {
|
|
|
84
85
|
agent: {
|
|
85
86
|
id: string;
|
|
86
87
|
};
|
|
87
|
-
object:
|
|
88
|
+
object: Pick<IObjectWithoutDetail, 'amount' | 'creditCard' | 'issuedThrough' | 'method' | 'paymentMethod'>;
|
|
88
89
|
purpose: factory.action.authorize.paymentMethod.any.IPurpose;
|
|
89
90
|
paymentServiceType: factory.service.paymentService.PaymentServiceType;
|
|
90
91
|
location: factory.action.trade.pay.ILocation;
|
|
91
92
|
}): IPublishPaymentUrlOperation<Pick<PayTransactionService.IPublishPaymentUrlResult, 'paymentMethodId' | 'paymentUrl'>>;
|
|
93
|
+
type IObjectWithoutDetail = factory.action.authorize.paymentMethod.any.IObjectWithoutDetail;
|
|
92
94
|
/**
|
|
93
95
|
* 決済承認
|
|
94
96
|
*/
|
|
@@ -99,7 +101,7 @@ declare function authorize(params: {
|
|
|
99
101
|
agent: {
|
|
100
102
|
id: string;
|
|
101
103
|
};
|
|
102
|
-
object:
|
|
104
|
+
object: IObjectWithoutDetail;
|
|
103
105
|
purpose: factory.action.authorize.paymentMethod.any.IPurpose;
|
|
104
106
|
paymentServiceType: factory.service.paymentService.PaymentServiceType;
|
|
105
107
|
location?: factory.action.trade.pay.ILocation;
|
|
@@ -222,44 +222,55 @@ exports.processVoidPayTransaction = processVoidPayTransaction;
|
|
|
222
222
|
*/
|
|
223
223
|
function publishPaymentUrl(params) {
|
|
224
224
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
225
|
+
try {
|
|
226
|
+
const transaction = yield repos.transaction.findInProgressById({ typeOf: params.purpose.typeOf, id: params.purpose.id });
|
|
227
|
+
const paymentServiceType = params.paymentServiceType;
|
|
228
|
+
// 取引番号生成
|
|
229
|
+
const { transactionNumber } = yield repos.transactionNumber.publishByTimestamp({
|
|
230
|
+
startDate: new Date()
|
|
231
|
+
});
|
|
232
|
+
let result;
|
|
233
|
+
// URL発行
|
|
234
|
+
const authorizeObject = Object.assign(Object.assign({}, params.object), { accountId: '', paymentMethodId: transactionNumber, typeOf: factory.action.authorize.paymentMethod.any.ResultType.Payment });
|
|
235
|
+
const startParams = (0, factory_1.creatPayTransactionStartParams)({
|
|
236
|
+
object: authorizeObject,
|
|
237
|
+
paymentServiceType,
|
|
238
|
+
transaction: transaction,
|
|
239
|
+
transactionNumber: transactionNumber,
|
|
240
|
+
location: params.location
|
|
241
|
+
});
|
|
242
|
+
result = yield PayTransactionService.publishPaymentUrl(startParams, { id: transaction.id })(repos);
|
|
243
|
+
// 取引に保管
|
|
244
|
+
const paymentMethodByPaymentUrl = {
|
|
245
|
+
typeOf: params.object.paymentMethod,
|
|
246
|
+
paymentMethodId: result.paymentMethodId,
|
|
247
|
+
paymentUrl: result.paymentUrl,
|
|
248
|
+
issuedThrough: { id: (typeof startParams.object.id === 'string') ? startParams.object.id : '' },
|
|
249
|
+
// GMO IFを保管(2024-01-01~)
|
|
250
|
+
entryTranArgs: result.entryTranArgs,
|
|
251
|
+
entryTranResult: result.entryTranResult,
|
|
252
|
+
execTranArgs: result.execTranArgs,
|
|
253
|
+
execTranResult: result.execTranResult,
|
|
254
|
+
paymentMethod: startParams.object.paymentMethod // 拡張(2024-01-04~)
|
|
255
|
+
};
|
|
256
|
+
yield repos.transaction.findByIdAndUpdateInProgress({
|
|
257
|
+
id: transaction.id,
|
|
258
|
+
update: { $set: { 'object.paymentMethods': paymentMethodByPaymentUrl } }
|
|
259
|
+
});
|
|
260
|
+
return {
|
|
261
|
+
paymentMethodId: result.paymentMethodId,
|
|
262
|
+
paymentUrl: result.paymentUrl
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
catch (error) {
|
|
266
|
+
// 複数対応(2024-03-27~)
|
|
267
|
+
if (Array.isArray(error)) {
|
|
268
|
+
throw error[0];
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
throw error;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
263
274
|
});
|
|
264
275
|
}
|
|
265
276
|
exports.publishPaymentUrl = publishPaymentUrl;
|
|
@@ -318,7 +329,11 @@ function authorize(params) {
|
|
|
318
329
|
const publishTransactionNumberResult = yield repos.transactionNumber.publishByTimestamp({ startDate: new Date() });
|
|
319
330
|
transactionNumber = publishTransactionNumberResult.transactionNumber;
|
|
320
331
|
}
|
|
321
|
-
const
|
|
332
|
+
const { accountId } = yield fixAccountIdIfPossible({
|
|
333
|
+
object: params.object,
|
|
334
|
+
project: { id: transaction.project.id }
|
|
335
|
+
})({ action: repos.action });
|
|
336
|
+
const authorizeObject = Object.assign(Object.assign(Object.assign({}, params.object), { accountId, paymentMethodId: transactionNumber, typeOf: factory.action.authorize.paymentMethod.any.ResultType.Payment }), (creditCard !== undefined) ? { creditCard } : undefined);
|
|
322
337
|
// 承認アクションを開始する
|
|
323
338
|
const actionAttributes = {
|
|
324
339
|
project: transaction.project,
|
|
@@ -346,10 +361,6 @@ function authorize(params) {
|
|
|
346
361
|
const action = yield repos.action.start(actionAttributes);
|
|
347
362
|
let payTransaction;
|
|
348
363
|
try {
|
|
349
|
-
const { accountId } = yield validateFromLocation({
|
|
350
|
-
object: authorizeObject,
|
|
351
|
-
project: { id: transaction.project.id }
|
|
352
|
-
})({ action: repos.action });
|
|
353
364
|
const startParams = (0, factory_1.creatPayTransactionStartParams)({
|
|
354
365
|
accountId,
|
|
355
366
|
object: authorizeObject,
|
|
@@ -384,15 +395,23 @@ function authorize(params) {
|
|
|
384
395
|
})(repos);
|
|
385
396
|
}
|
|
386
397
|
}
|
|
387
|
-
|
|
398
|
+
// 複数対応(2024-03-27~)
|
|
399
|
+
if (Array.isArray(error)) {
|
|
400
|
+
throw error[0];
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
throw error;
|
|
404
|
+
}
|
|
388
405
|
}
|
|
389
|
-
// アクションを完了
|
|
390
406
|
const result = (0, factory_1.createAuthorizeResult)({ payTransaction, object: authorizeObject });
|
|
391
407
|
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: result });
|
|
392
408
|
return { id: action.id };
|
|
393
409
|
});
|
|
394
410
|
}
|
|
395
411
|
exports.authorize = authorize;
|
|
412
|
+
/**
|
|
413
|
+
* 注文取引に保管された決済情報を承認しようとしている決済の整合性をを検証する
|
|
414
|
+
*/
|
|
396
415
|
function validatePaymentMethodByTransaction(params) {
|
|
397
416
|
var _a, _b;
|
|
398
417
|
const paymentServiceIdByObject = params.object.issuedThrough.id;
|
|
@@ -414,11 +433,16 @@ function validatePaymentMethodByTransaction(params) {
|
|
|
414
433
|
throw new factory.errors.Argument('object.paymentMethod', 'paymentMethod must match the target of the paymentUrl');
|
|
415
434
|
}
|
|
416
435
|
}
|
|
417
|
-
|
|
436
|
+
/**
|
|
437
|
+
* 承認しようとしているobjectからaccountIdを決定する
|
|
438
|
+
*/
|
|
439
|
+
function fixAccountIdIfPossible(params) {
|
|
418
440
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
419
441
|
var _a, _b;
|
|
420
|
-
let accountId =
|
|
421
|
-
|
|
442
|
+
// let accountId = params.object?.accountId;
|
|
443
|
+
let accountId = '';
|
|
444
|
+
const fromLocation = (_a = params.object) === null || _a === void 0 ? void 0 : _a.fromLocation;
|
|
445
|
+
const movieTickets = (_b = params.object) === null || _b === void 0 ? void 0 : _b.movieTickets;
|
|
422
446
|
// トークン化されたペイメントカード情報でリクエストされた場合、実ペイメントカード情報へ変換する
|
|
423
447
|
if (typeof fromLocation === 'string') {
|
|
424
448
|
const paymentCardOwnershipInfo = yield (0, code_1.verifyToken)({
|
|
@@ -434,6 +458,10 @@ function validateFromLocation(params) {
|
|
|
434
458
|
}
|
|
435
459
|
accountId = paymentCardOwnershipInfo.typeOfGood.identifier;
|
|
436
460
|
}
|
|
461
|
+
// 購入番号管理番号をaccountIdにセット(2024-03-24~)
|
|
462
|
+
if (Array.isArray(movieTickets) && movieTickets.length > 0) {
|
|
463
|
+
accountId = movieTickets[0].identifier; // 決済カードidentifierは1つのみ許可の前提
|
|
464
|
+
}
|
|
437
465
|
return { accountId };
|
|
438
466
|
});
|
|
439
467
|
}
|
|
@@ -47,9 +47,7 @@ function authorize(params, paymentServiceId, options) {
|
|
|
47
47
|
if (typeof orderId !== 'string') {
|
|
48
48
|
throw new factory.errors.ArgumentNull('transactionNumber');
|
|
49
49
|
}
|
|
50
|
-
// GMOオーソリ取得
|
|
51
50
|
let authorizeResult;
|
|
52
|
-
// let searchTradeResult: GMO.factory.credit.ISearchTradeResult | undefined;
|
|
53
51
|
try {
|
|
54
52
|
const pendingPaymentAgencyTransaction = options.pendingPaymentAgencyTransaction;
|
|
55
53
|
const redirectUrl = (_c = pendingPaymentAgencyTransaction === null || pendingPaymentAgencyTransaction === void 0 ? void 0 : pendingPaymentAgencyTransaction.execTranResult) === null || _c === void 0 ? void 0 : _c.redirectUrl;
|
|
@@ -62,7 +60,6 @@ function authorize(params, paymentServiceId, options) {
|
|
|
62
60
|
}
|
|
63
61
|
else {
|
|
64
62
|
authorizeResult = yield processAuthorizeCreditCard({
|
|
65
|
-
// projectSettings: project.settings,
|
|
66
63
|
shopId: shopId,
|
|
67
64
|
shopPass: shopPass,
|
|
68
65
|
returnUrls3ds,
|
|
@@ -75,15 +72,15 @@ function authorize(params, paymentServiceId, options) {
|
|
|
75
72
|
}
|
|
76
73
|
}
|
|
77
74
|
catch (error) {
|
|
78
|
-
throw
|
|
75
|
+
// アクション保管用のエラーと両方throw(2024-03-27~)
|
|
76
|
+
throw [handleAuthorizeError(error), error];
|
|
77
|
+
// throw handleAuthorizeError(error);
|
|
79
78
|
}
|
|
80
79
|
// クレジットカード詳細情報取得廃止(2024-03-19~)
|
|
81
80
|
// const searchTrade4accountId = options?.searchTrade4accountId === true;
|
|
82
81
|
// if (searchTrade4accountId) {
|
|
83
82
|
// }
|
|
84
|
-
return Object.assign({
|
|
85
|
-
// accountId: (searchTradeResult !== undefined) ? searchTradeResult.cardNo : '',
|
|
86
|
-
accountId: '', paymentMethodId: orderId, entryTranArgs: authorizeResult.entryTranArgs, entryTranResult: authorizeResult.entryTranResult, execTranArgs: authorizeResult.execTranArgs, execTranResult: authorizeResult.execTranResult }, (authorizeResult.secureTran2Result !== undefined) ? { secureTran2Result: authorizeResult.secureTran2Result } : undefined);
|
|
83
|
+
return Object.assign({ accountId: '', paymentMethodId: orderId, entryTranArgs: authorizeResult.entryTranArgs, entryTranResult: authorizeResult.entryTranResult, execTranArgs: authorizeResult.execTranArgs, execTranResult: authorizeResult.execTranResult }, (authorizeResult.secureTran2Result !== undefined) ? { secureTran2Result: authorizeResult.secureTran2Result } : undefined);
|
|
87
84
|
});
|
|
88
85
|
}
|
|
89
86
|
exports.authorize = authorize;
|
|
@@ -202,6 +199,16 @@ function handleAuthorizeError(error) {
|
|
|
202
199
|
// const uri: string | undefined = error.requestOptions?.uri;
|
|
203
200
|
handledError = new factory.errors.GatewayTimeout(`Gateway Timeout. name:${error.name} type:${error.type} message:${error.message}`);
|
|
204
201
|
}
|
|
202
|
+
else if (error.name === 'AbortError') {
|
|
203
|
+
// タイムアウト設定によって中止されたリクエストの場合
|
|
204
|
+
// AbortErrorハンドリング(2024-03-27~)
|
|
205
|
+
// {
|
|
206
|
+
// "type": "aborted",
|
|
207
|
+
// "message": "The user aborted a request.",
|
|
208
|
+
// "name": "AbortError"
|
|
209
|
+
// }
|
|
210
|
+
handledError = new factory.errors.GatewayTimeout(`Gateway Timeout. name:${error.name} type:${error.type} message:${error.message}`);
|
|
211
|
+
}
|
|
205
212
|
// 決済代行側が4xxを返却した場合
|
|
206
213
|
if (typeof error.code === 'number' && error.code < http_status_1.INTERNAL_SERVER_ERROR) {
|
|
207
214
|
handledError = new factory.errors.Argument('payment', `bad request code:${error.code} message:${error.message}`);
|