@chevre/domain 21.2.0-alpha.46 → 21.2.0-alpha.47
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.d.ts +12 -1
- package/lib/chevre/repo/action.js +9 -25
- package/lib/chevre/repo/assetTransaction.js +4 -4
- package/lib/chevre/service/notification.js +14 -1
- package/lib/chevre/service/payment/any.js +16 -0
- package/lib/chevre/settings.d.ts +2 -1
- package/lib/chevre/settings.js +7 -4
- package/package.json +1 -1
|
@@ -82,7 +82,18 @@ export declare class MongoRepository {
|
|
|
82
82
|
typeOf?: T;
|
|
83
83
|
purpose: {
|
|
84
84
|
typeOf: factory.transactionType;
|
|
85
|
-
id
|
|
85
|
+
id: string;
|
|
86
|
+
};
|
|
87
|
+
object?: {
|
|
88
|
+
typeOf?: {
|
|
89
|
+
$eq?: factory.action.authorize.offer.seatReservation.ObjectType.SeatReservation | factory.action.authorize.paymentMethod.any.ResultType.Payment;
|
|
90
|
+
};
|
|
91
|
+
paymentMethodId?: {
|
|
92
|
+
$eq?: string;
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
actionStatus?: {
|
|
96
|
+
$eq?: factory.actionStatusType;
|
|
86
97
|
};
|
|
87
98
|
sort?: factory.action.ISortOrder;
|
|
88
99
|
}): Promise<IAction<T>[]>;
|
|
@@ -528,32 +528,16 @@ class MongoRepository {
|
|
|
528
528
|
* 取引に対するアクション検索時などに使用
|
|
529
529
|
*/
|
|
530
530
|
searchByPurpose(params) {
|
|
531
|
-
var _a;
|
|
531
|
+
var _a, _b, _c, _d, _e, _f;
|
|
532
532
|
return __awaiter(this, void 0, void 0, function* () {
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
$
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
}
|
|
542
|
-
if (params.purpose.id !== undefined) {
|
|
543
|
-
conditions['purpose.id'] = {
|
|
544
|
-
$exists: true,
|
|
545
|
-
$eq: params.purpose.id
|
|
546
|
-
};
|
|
547
|
-
}
|
|
548
|
-
const query = this.actionModel.find(conditions)
|
|
549
|
-
.select({ __v: 0, createdAt: 0, updatedAt: 0 });
|
|
550
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
551
|
-
/* istanbul ignore else */
|
|
552
|
-
if (((_a = params.sort) === null || _a === void 0 ? void 0 : _a.startDate) !== undefined) {
|
|
553
|
-
query.sort({ startDate: params.sort.startDate });
|
|
554
|
-
}
|
|
555
|
-
return query.exec()
|
|
556
|
-
.then((docs) => docs.map((doc) => doc.toObject()));
|
|
533
|
+
return this.search(Object.assign(Object.assign(Object.assign({ purpose: {
|
|
534
|
+
id: { $in: [params.purpose.id] },
|
|
535
|
+
typeOf: { $in: [params.purpose.typeOf] }
|
|
536
|
+
}, object: Object.assign(Object.assign({}, (typeof ((_b = (_a = params.object) === null || _a === void 0 ? void 0 : _a.typeOf) === null || _b === void 0 ? void 0 : _b.$eq) === 'string')
|
|
537
|
+
? { typeOf: { $eq: params.object.typeOf.$eq } }
|
|
538
|
+
: undefined), (typeof ((_d = (_c = params.object) === null || _c === void 0 ? void 0 : _c.paymentMethodId) === null || _d === void 0 ? void 0 : _d.$eq) === 'string')
|
|
539
|
+
? { paymentMethodId: { $eq: params.object.paymentMethodId.$eq } }
|
|
540
|
+
: undefined) }, (typeof ((_e = params.actionStatus) === null || _e === void 0 ? void 0 : _e.$eq) === 'string') ? { actionStatus: { $in: [params.actionStatus.$eq] } } : undefined), (typeof params.typeOf === 'string') ? { typeOf: { $eq: params.typeOf } } : undefined), (typeof ((_f = params.sort) === null || _f === void 0 ? void 0 : _f.startDate) === 'number') ? { sort: params.sort } : undefined), [], []);
|
|
557
541
|
});
|
|
558
542
|
}
|
|
559
543
|
/**
|
|
@@ -330,10 +330,10 @@ class MongoRepository {
|
|
|
330
330
|
// すでに確定済の場合スルー
|
|
331
331
|
}
|
|
332
332
|
else if (transaction.status === factory.transactionStatusType.Expired) {
|
|
333
|
-
throw new factory.errors.Argument('Transaction id',
|
|
333
|
+
throw new factory.errors.Argument('Transaction id', `Transaction ${transaction.typeOf} ${transaction.transactionNumber} already expired`);
|
|
334
334
|
}
|
|
335
335
|
else if (transaction.status === factory.transactionStatusType.Canceled) {
|
|
336
|
-
throw new factory.errors.Argument('Transaction id',
|
|
336
|
+
throw new factory.errors.Argument('Transaction id', `Transaction ${transaction.typeOf} ${transaction.transactionNumber} already canceled`);
|
|
337
337
|
}
|
|
338
338
|
else {
|
|
339
339
|
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
|
@@ -558,10 +558,10 @@ class MongoRepository {
|
|
|
558
558
|
// すでに中止済の場合スルー
|
|
559
559
|
}
|
|
560
560
|
else if (transaction.status === factory.transactionStatusType.Expired) {
|
|
561
|
-
throw new factory.errors.Argument('Transaction id',
|
|
561
|
+
throw new factory.errors.Argument('Transaction id', `Transaction ${transaction.typeOf} ${transaction.transactionNumber} already expired`);
|
|
562
562
|
}
|
|
563
563
|
else if (transaction.status === factory.transactionStatusType.Confirmed) {
|
|
564
|
-
throw new factory.errors.Argument('Transaction id',
|
|
564
|
+
throw new factory.errors.Argument('Transaction id', `Confirmed transaction ${transaction.typeOf} ${transaction.transactionNumber} unable to cancel`);
|
|
565
565
|
}
|
|
566
566
|
else {
|
|
567
567
|
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
|
@@ -157,9 +157,13 @@ function triggerWebhook(params) {
|
|
|
157
157
|
while (numberOfTry >= 0) {
|
|
158
158
|
try {
|
|
159
159
|
numberOfTry += 1;
|
|
160
|
-
if (numberOfTry > settings_1.
|
|
160
|
+
if (numberOfTry > settings_1.TRIGGER_WEBHOOK_MAX_RETRY_COUNT) {
|
|
161
161
|
retry = false;
|
|
162
162
|
}
|
|
163
|
+
// retryInterval
|
|
164
|
+
if (numberOfTry > 1) {
|
|
165
|
+
yield sleep(settings_1.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS * (numberOfTry - 1));
|
|
166
|
+
}
|
|
163
167
|
yield processInformAction(params)(repos);
|
|
164
168
|
break;
|
|
165
169
|
}
|
|
@@ -175,6 +179,15 @@ function triggerWebhook(params) {
|
|
|
175
179
|
});
|
|
176
180
|
}
|
|
177
181
|
exports.triggerWebhook = triggerWebhook;
|
|
182
|
+
function sleep(waitTime) {
|
|
183
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
184
|
+
return new Promise((resolve) => {
|
|
185
|
+
setTimeout(() => {
|
|
186
|
+
resolve();
|
|
187
|
+
}, waitTime);
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
}
|
|
178
191
|
function processInformAction(params) {
|
|
179
192
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
180
193
|
var _a, _b;
|
|
@@ -240,6 +240,7 @@ exports.publishPaymentUrl = publishPaymentUrl;
|
|
|
240
240
|
* 決済承認
|
|
241
241
|
*/
|
|
242
242
|
function authorize(params) {
|
|
243
|
+
// tslint:disable-next-line:max-func-body-length
|
|
243
244
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
244
245
|
var _a, _b;
|
|
245
246
|
const transaction = yield repos.transaction.findInProgressById({ typeOf: params.purpose.typeOf, id: params.purpose.id });
|
|
@@ -251,6 +252,21 @@ function authorize(params) {
|
|
|
251
252
|
const paymentMethodIdByTransaction = (_a = transaction.object.paymentMethods) === null || _a === void 0 ? void 0 : _a.paymentMethodId;
|
|
252
253
|
if (params.object.paymentMethodId === paymentMethodIdByTransaction) {
|
|
253
254
|
transactionNumber = params.object.paymentMethodId;
|
|
255
|
+
// 既に承認済であれば何もしない(2023-05-15~)
|
|
256
|
+
const existingCompletedAuthorizeActions = yield repos.action.searchByPurpose({
|
|
257
|
+
typeOf: factory.actionType.AuthorizeAction,
|
|
258
|
+
purpose: { id: transaction.id, typeOf: transaction.typeOf },
|
|
259
|
+
actionStatus: { $eq: factory.actionStatusType.CompletedActionStatus },
|
|
260
|
+
object: {
|
|
261
|
+
paymentMethodId: { $eq: transactionNumber },
|
|
262
|
+
typeOf: { $eq: factory.action.authorize.paymentMethod.any.ResultType.Payment }
|
|
263
|
+
},
|
|
264
|
+
sort: { startDate: factory.sortType.Ascending }
|
|
265
|
+
});
|
|
266
|
+
const existingCompletedAuthorizeAction = existingCompletedAuthorizeActions.shift();
|
|
267
|
+
if (existingCompletedAuthorizeAction !== undefined) {
|
|
268
|
+
return existingCompletedAuthorizeAction;
|
|
269
|
+
}
|
|
254
270
|
}
|
|
255
271
|
else {
|
|
256
272
|
// 取引にないpaymentMethodIdの指定はクライアントエラー
|
package/lib/chevre/settings.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as moment from 'moment';
|
|
2
2
|
import * as factory from './factory';
|
|
3
|
+
export declare const TRIGGER_WEBHOOK_MAX_RETRY_COUNT: number;
|
|
4
|
+
export declare const TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS: number;
|
|
3
5
|
export declare const ABORTED_TASKS_WITHOUT_REPORT: string[];
|
|
4
6
|
/**
|
|
5
7
|
* 資産取引保管期間
|
|
@@ -32,7 +34,6 @@ export declare const USE_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
|
|
|
32
34
|
export declare const USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
|
|
33
35
|
export declare const USE_NEW_EVENT_AVAILABILITY_KEY_FROM: moment.Moment;
|
|
34
36
|
export declare const INFORM_RESERVATION_TASK_DELAY_IN_SECONDS: number;
|
|
35
|
-
export declare const MAX_RETRY_COUNT_TRIGGER_WEBHOOK: number;
|
|
36
37
|
/**
|
|
37
38
|
* グローバル設定
|
|
38
39
|
*/
|
package/lib/chevre/settings.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.settings = exports.
|
|
3
|
+
exports.settings = exports.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
|
|
4
4
|
const moment = require("moment");
|
|
5
5
|
const factory = require("./factory");
|
|
6
6
|
const transactionWebhookUrls = (typeof process.env.INFORM_TRANSACTION_URL === 'string')
|
|
@@ -14,6 +14,12 @@ const informReservationUrls = (typeof process.env.INFORM_RESERVATION_URL === 'st
|
|
|
14
14
|
: [];
|
|
15
15
|
// tslint:disable-next-line:no-magic-numbers
|
|
16
16
|
const triggerWebhookTimeout = (process.env.TRIGGER_WEBHOOK_TIMEOUT !== undefined) ? Number(process.env.TRIGGER_WEBHOOK_TIMEOUT) : 15000;
|
|
17
|
+
exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = (typeof process.env.TRIGGER_WEBHOOK_MAX_RETRY_COUNT === 'string')
|
|
18
|
+
? Number(process.env.TRIGGER_WEBHOOK_MAX_RETRY_COUNT)
|
|
19
|
+
: 0;
|
|
20
|
+
exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = (typeof process.env.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS === 'string')
|
|
21
|
+
? Number(process.env.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS)
|
|
22
|
+
: 0;
|
|
17
23
|
const MAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS = (typeof process.env.MAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS === 'string')
|
|
18
24
|
? Number(process.env.MAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS)
|
|
19
25
|
// tslint:disable-next-line:no-magic-numbers
|
|
@@ -53,9 +59,6 @@ exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = (typeof process.env.USE_NEW_EVENT_
|
|
|
53
59
|
exports.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = (typeof process.env.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS === 'string')
|
|
54
60
|
? Number(process.env.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS)
|
|
55
61
|
: 0;
|
|
56
|
-
exports.MAX_RETRY_COUNT_TRIGGER_WEBHOOK = (typeof process.env.MAX_RETRY_COUNT_TRIGGER_WEBHOOK === 'string')
|
|
57
|
-
? Number(process.env.MAX_RETRY_COUNT_TRIGGER_WEBHOOK)
|
|
58
|
-
: 0;
|
|
59
62
|
/**
|
|
60
63
|
* グローバル設定
|
|
61
64
|
*/
|
package/package.json
CHANGED