@chevre/domain 24.0.0-alpha.0 → 24.0.0-alpha.2
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/acceptedPaymentMethod.js +1 -1
- package/lib/chevre/repo/additionalProperty.js +1 -1
- package/lib/chevre/repo/aggregateOffer.js +1 -1
- package/lib/chevre/repo/confirmationNumber.js +2 -4
- package/lib/chevre/repo/creativeWork.js +1 -1
- package/lib/chevre/repo/eventOffer.js +1 -1
- package/lib/chevre/repo/eventSeries.js +1 -1
- package/lib/chevre/repo/identity.js +1 -2
- package/lib/chevre/repo/issuer.js +2 -4
- package/lib/chevre/repo/message.js +1 -1
- package/lib/chevre/repo/note.js +1 -1
- package/lib/chevre/repo/noteAboutOrder.js +1 -1
- package/lib/chevre/repo/offer/unitPriceInCatalog.js +1 -1
- package/lib/chevre/repo/offerItemCondition.js +1 -1
- package/lib/chevre/repo/order.js +1 -1
- package/lib/chevre/repo/orderInTransaction.js +1 -2
- package/lib/chevre/repo/orderNumber.js +2 -4
- package/lib/chevre/repo/place/movieTheater.js +1 -1
- package/lib/chevre/repo/place/seat.js +1 -1
- package/lib/chevre/repo/product.js +1 -1
- package/lib/chevre/repo/productOffer.js +1 -1
- package/lib/chevre/repo/project.js +1 -1
- package/lib/chevre/repo/reservation.js +1 -1
- package/lib/chevre/repo/role.js +1 -2
- package/lib/chevre/repo/seller.js +1 -1
- package/lib/chevre/repo/serviceOutputIdentifier.js +2 -4
- package/lib/chevre/repo/transactionNumber.js +2 -4
- package/lib/chevre/repo/trip.js +1 -2
- package/lib/chevre/service/account.js +14 -21
- package/lib/chevre/service/accountTransaction/deposit.js +2 -8
- package/lib/chevre/service/accountTransaction/transfer.js +2 -8
- package/lib/chevre/service/accountTransaction/withdraw.js +2 -8
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +24 -32
- package/lib/chevre/service/assetTransaction/cancelReservationCOA.js +2 -4
- package/lib/chevre/service/assetTransaction/moneyTransfer.js +2 -23
- package/lib/chevre/service/assetTransaction/pay/check.js +6 -11
- package/lib/chevre/service/assetTransaction/pay/confirm.js +1 -2
- package/lib/chevre/service/assetTransaction/pay/searchGMOTrade.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/refund.js +13 -20
- package/lib/chevre/service/assetTransaction/registerService.js +1 -7
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.js +2 -4
- package/lib/chevre/service/assetTransaction/reserveCOA.js +2 -4
- package/lib/chevre/service/delivery/product/factory.js +1 -2
- package/lib/chevre/service/delivery/reservation/factory.js +1 -2
- package/lib/chevre/service/event/saveScreeningEvents.js +1 -0
- package/lib/chevre/service/event.js +0 -1
- package/lib/chevre/service/moneyTransfer.js +2 -2
- package/lib/chevre/service/notification/factory.js +1 -1
- package/lib/chevre/service/notification/notifyByEmail.js +50 -56
- package/lib/chevre/service/notification/sendEmailMessage.js +2 -3
- package/lib/chevre/service/notification/triggerWebhook.js +32 -37
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.js +1 -2
- package/lib/chevre/service/offer/event/authorize.js +1 -1
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer/authorize.js +1 -2
- package/lib/chevre/service/offer/moneyTransfer/authorize.js +47 -54
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +7 -13
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled.js +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.js +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.js +1 -1
- package/lib/chevre/service/order/onOrderUpdated.js +1 -2
- package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.js +1 -2
- package/lib/chevre/service/order/returnOrder.js +1 -1
- package/lib/chevre/service/payment/any/fixOrderAsNeeded.js +1 -2
- package/lib/chevre/service/payment/any.js +1 -2
- package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard.js +1 -2
- package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard3ds.d.ts +1 -1
- package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard3ds.js +1 -2
- package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard3dsResult2recipe.d.ts +1 -1
- package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCardResult2recipe.d.ts +1 -1
- package/lib/chevre/service/payment/creditCard/factory.d.ts +1 -1
- package/lib/chevre/service/payment/movieTicket/authorize.js +1 -1
- package/lib/chevre/service/payment/movieTicket/processPurchaseNumberAuth.js +2 -4
- package/lib/chevre/service/payment/movieTicket/refundMovieTicket.js +4 -6
- package/lib/chevre/service/payment/movieTicket/voidTransaction.js +1 -2
- package/lib/chevre/service/payment/paymentCard.js +2 -4
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +2 -6
- package/lib/chevre/service/task/confirmReserveTransaction.js +1 -2
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByProduct.js +3 -6
- package/lib/chevre/service/task/onResourceUpdated/onOfferCatalogUpdated.js +1 -1
- package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.js +1 -1
- package/lib/chevre/service/task/pay.js +1 -2
- package/lib/chevre/service/task/voidReserveTransaction.js +1 -1
- package/lib/chevre/service/transaction/deleteTransaction.js +1 -1
- package/lib/chevre/service/transaction/moneyTransfer.js +11 -19
- package/lib/chevre/service/transaction/placeOrder/confirm/publishCode.js +1 -1
- package/lib/chevre/service/transaction/placeOrder/confirm.js +2 -4
- package/lib/chevre/service/transaction/placeOrder/start/validateStartRequest.js +1 -2
- package/lib/chevre/service/transaction/returnOrder/potentialActions.js +1 -2
- package/lib/chevre/service/transaction/returnOrder/preStart/getReturnPolicyByProject.js +1 -1
- package/package.json +5 -14
|
@@ -47,13 +47,12 @@ function start(params) {
|
|
|
47
47
|
if (typeof paymentMethodId !== 'string') {
|
|
48
48
|
throw new factory.errors.ArgumentNull('object.paymentMethod.paymentMethodId');
|
|
49
49
|
}
|
|
50
|
-
let paymentServiceType = params.object?.typeOf;
|
|
51
50
|
// 必ず、決済取引からpaymentServiceTypeを取得する
|
|
52
51
|
const payTransaction = await repos.assetTransaction.findByTransactionNumber({
|
|
53
52
|
typeOf: factory.assetTransactionType.Pay,
|
|
54
53
|
transactionNumber: paymentMethodId
|
|
55
54
|
});
|
|
56
|
-
paymentServiceType = payTransaction.object.typeOf;
|
|
55
|
+
const paymentServiceType = payTransaction.object.typeOf;
|
|
57
56
|
// PayActionを確認する
|
|
58
57
|
const payAction = await repos.action.findPayAction({ project: { id: params.project.id }, paymentMethodId });
|
|
59
58
|
if (payAction === undefined) {
|
|
@@ -70,7 +69,6 @@ function start(params) {
|
|
|
70
69
|
project: { id: params.project.id }
|
|
71
70
|
})(repos);
|
|
72
71
|
// 取引開始
|
|
73
|
-
let transaction;
|
|
74
72
|
const startParams = (0, factory_1.createStartParams)({
|
|
75
73
|
...params,
|
|
76
74
|
transactionNumber,
|
|
@@ -79,23 +77,18 @@ function start(params) {
|
|
|
79
77
|
paymentServiceType,
|
|
80
78
|
informActions
|
|
81
79
|
});
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
throw new factory.errors.NotImplemented(`Payment service '${paymentServiceType}' not implemented`);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
catch (error) {
|
|
98
|
-
throw error;
|
|
80
|
+
const transaction = await repos.assetTransaction.start(startParams);
|
|
81
|
+
switch (paymentServiceType) {
|
|
82
|
+
case factory.service.paymentService.PaymentServiceType.FaceToFace:
|
|
83
|
+
break;
|
|
84
|
+
case factory.service.paymentService.PaymentServiceType.PaymentCard:
|
|
85
|
+
break;
|
|
86
|
+
case factory.service.paymentService.PaymentServiceType.CreditCard:
|
|
87
|
+
break;
|
|
88
|
+
case factory.service.paymentService.PaymentServiceType.MovieTicket:
|
|
89
|
+
break;
|
|
90
|
+
default:
|
|
91
|
+
throw new factory.errors.NotImplemented(`Payment service '${paymentServiceType}' not implemented`);
|
|
99
92
|
}
|
|
100
93
|
return transaction;
|
|
101
94
|
};
|
|
@@ -97,13 +97,7 @@ function start(params) {
|
|
|
97
97
|
transactionNumber: transactionNumber
|
|
98
98
|
};
|
|
99
99
|
// 取引作成
|
|
100
|
-
|
|
101
|
-
try {
|
|
102
|
-
transaction = await repos.assetTransaction.start(startParams);
|
|
103
|
-
}
|
|
104
|
-
catch (error) {
|
|
105
|
-
throw error;
|
|
106
|
-
}
|
|
100
|
+
const transaction = await repos.assetTransaction.start(startParams);
|
|
107
101
|
// 必要あれば在庫確認など
|
|
108
102
|
const serviceOutputs = transactionObject.map((o) => o.itemOffered?.serviceOutput);
|
|
109
103
|
// サービスアウトプット保管
|
|
@@ -91,10 +91,8 @@ function validateOfferToken(params) {
|
|
|
91
91
|
throw new factory.errors.Argument('ticketedOffer.token', 'identifier not matched');
|
|
92
92
|
}
|
|
93
93
|
// 有効期間検証
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
validThroughMoment = (0, moment_1.default)(verifiedOffer.validThrough, OFFER_TOKEN_DATE_FORMAT, true);
|
|
97
|
-
validFromMoment = (0, moment_1.default)(verifiedOffer.validFrom, OFFER_TOKEN_DATE_FORMAT, true);
|
|
94
|
+
const validThroughMoment = (0, moment_1.default)(verifiedOffer.validThrough, OFFER_TOKEN_DATE_FORMAT, true);
|
|
95
|
+
const validFromMoment = (0, moment_1.default)(verifiedOffer.validFrom, OFFER_TOKEN_DATE_FORMAT, true);
|
|
98
96
|
if (!validThroughMoment.isValid()) {
|
|
99
97
|
throw new factory.errors.Argument('ticketedOffer.token', 'invalid validThrough');
|
|
100
98
|
}
|
|
@@ -6,19 +6,17 @@ exports.confirm = confirm;
|
|
|
6
6
|
*/
|
|
7
7
|
function confirm(params) {
|
|
8
8
|
return async (repos) => {
|
|
9
|
-
let stateReserveArgs;
|
|
10
|
-
let stateReserveResult;
|
|
11
9
|
let updReserveArgs;
|
|
12
10
|
let updReserveResult;
|
|
13
11
|
// 未本予約であれば実行(COA本予約は一度成功すると成功できない)
|
|
14
12
|
// リトライ可能な前提でつくる必要があるので、要注意
|
|
15
13
|
// すでに本予約済みかどうか確認
|
|
16
|
-
stateReserveArgs = {
|
|
14
|
+
const stateReserveArgs = {
|
|
17
15
|
theaterCode: params.object.theaterCode,
|
|
18
16
|
reserveNum: params.object.tmpReserveNum,
|
|
19
17
|
telNum: params.object.telNum
|
|
20
18
|
};
|
|
21
|
-
stateReserveResult = await repos.reserveService.stateReserve(stateReserveArgs);
|
|
19
|
+
const stateReserveResult = await repos.reserveService.stateReserve(stateReserveArgs);
|
|
22
20
|
if (stateReserveResult === null) {
|
|
23
21
|
updReserveArgs = params.object;
|
|
24
22
|
updReserveResult = await repos.reserveService.updReserve(updReserveArgs);
|
|
@@ -31,7 +31,6 @@ const moment_1 = __importDefault(require("moment"));
|
|
|
31
31
|
const factory = __importStar(require("../../../factory"));
|
|
32
32
|
const MAX_OWNED_THROUGH = '3000-01-01T00:00:00Z';
|
|
33
33
|
function createProductOwnershipInfo(params) {
|
|
34
|
-
let ownershipInfo;
|
|
35
34
|
let ownedThrough;
|
|
36
35
|
// どういう期間でいくらのオファーなのか
|
|
37
36
|
const priceSpec = params.acceptedOffer.priceSpecification;
|
|
@@ -92,7 +91,7 @@ function createProductOwnershipInfo(params) {
|
|
|
92
91
|
...(itemOffered.validFor !== undefined) ? { validFor: itemOffered.validFor } : undefined,
|
|
93
92
|
...(itemOffered.name !== undefined) ? { name: itemOffered.name } : undefined
|
|
94
93
|
};
|
|
95
|
-
ownershipInfo = {
|
|
94
|
+
const ownershipInfo = {
|
|
96
95
|
project: params.project,
|
|
97
96
|
typeOf: 'OwnershipInfo',
|
|
98
97
|
id: '',
|
|
@@ -31,7 +31,6 @@ const moment_timezone_1 = __importDefault(require("moment-timezone"));
|
|
|
31
31
|
const factory = __importStar(require("../../../factory"));
|
|
32
32
|
function createReservationOwnershipInfo(params) {
|
|
33
33
|
const itemOffered = params.acceptedOffer.itemOffered;
|
|
34
|
-
let ownershipInfo;
|
|
35
34
|
// イベント予約に対する所有権の有効期限はイベント終了日時までで十分だろう
|
|
36
35
|
// 現時点では所有権対象がイベント予約のみなので、これで問題ないが、
|
|
37
36
|
// 対象が他に広がれば、有効期間のコントロールは別でしっかり行う必要があるだろう
|
|
@@ -77,7 +76,7 @@ function createReservationOwnershipInfo(params) {
|
|
|
77
76
|
else {
|
|
78
77
|
throw new factory.errors.NotImplemented(`itemOffered.typeOf '${itemOffered.typeOf}' not implemented`);
|
|
79
78
|
}
|
|
80
|
-
ownershipInfo = {
|
|
79
|
+
const ownershipInfo = {
|
|
81
80
|
project: params.project,
|
|
82
81
|
typeOf: 'OwnershipInfo',
|
|
83
82
|
id: '',
|
|
@@ -29,6 +29,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
exports.createScreeningEventIdFromCOA = createScreeningEventIdFromCOA;
|
|
30
30
|
exports.saveScreeningEvents = saveScreeningEvents;
|
|
31
31
|
const debug_1 = __importDefault(require("debug"));
|
|
32
|
+
// import difference from 'lodash.difference';
|
|
32
33
|
// import { google } from 'googleapis';
|
|
33
34
|
const moment_timezone_1 = __importDefault(require("moment-timezone"));
|
|
34
35
|
const factory = __importStar(require("../../factory"));
|
|
@@ -29,7 +29,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
exports.saveScreeningEvents = exports.saveScreeningEventSeries = void 0;
|
|
30
30
|
exports.importFromCOA = importFromCOA;
|
|
31
31
|
const debug_1 = __importDefault(require("debug"));
|
|
32
|
-
// @ts-ignore
|
|
33
32
|
const lodash_difference_1 = __importDefault(require("lodash.difference"));
|
|
34
33
|
// import { google } from 'googleapis';
|
|
35
34
|
const moment_timezone_1 = __importDefault(require("moment-timezone"));
|
|
@@ -65,8 +65,8 @@ function authorize(params) {
|
|
|
65
65
|
}
|
|
66
66
|
catch (error) {
|
|
67
67
|
// PecorinoAPIのエラーをハンドリング
|
|
68
|
-
|
|
69
|
-
throw
|
|
68
|
+
const handledError = (0, errorHandler_1.handlePecorinoError)(error);
|
|
69
|
+
throw handledError;
|
|
70
70
|
}
|
|
71
71
|
// return pendingTransaction;
|
|
72
72
|
};
|
|
@@ -58,7 +58,7 @@ lastMessage:${lastMessage}`;
|
|
|
58
58
|
const MAX_LAST_MESSAGE_LENGTH = 60;
|
|
59
59
|
function tasks2lineNotify(params) {
|
|
60
60
|
const subject = `${params.tasks.length} ${exports.ABORT_REPORT_SUBJECT}`;
|
|
61
|
-
let content
|
|
61
|
+
let content;
|
|
62
62
|
// あまりに通知タスク数が多いケースに対応
|
|
63
63
|
if (params.tasks.length > 10) {
|
|
64
64
|
content = params.tasks.map((task) => {
|
|
@@ -41,64 +41,58 @@ function notifyByEmail(params) {
|
|
|
41
41
|
const message = util.format('\n%s\n%s\n%s\n%s\n%s\n\n%s', `[${logLevel}] ${shortSubject}`, `now:${(new Date()).toISOString()}`, `pid:${process.pid}`, `GAE_APPLICATION:${process.env.GAE_APPLICATION}`,
|
|
42
42
|
// `GAE_INSTANCE:${process.env.GAE_INSTANCE}`,
|
|
43
43
|
`GAE_SERVICE:${process.env.GAE_SERVICE}`, params.content);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (typeof apiKey !== 'string') {
|
|
48
|
-
throw new factory.errors.Internal('API Key not found');
|
|
49
|
-
}
|
|
50
|
-
const senderName = credentials.sendGrid.alert?.sender?.name;
|
|
51
|
-
const senderEmail = credentials.sendGrid.alert?.sender?.email;
|
|
52
|
-
const toRecipientEmail = (Array.isArray(credentials.sendGrid.alert?.toRecipient))
|
|
53
|
-
? credentials.sendGrid.alert?.toRecipient.at(0)?.email
|
|
54
|
-
: undefined;
|
|
55
|
-
if (typeof senderName !== 'string') {
|
|
56
|
-
throw new factory.errors.Internal('senderName not found');
|
|
57
|
-
}
|
|
58
|
-
if (typeof senderEmail !== 'string') {
|
|
59
|
-
throw new factory.errors.Internal('senderEmail not found');
|
|
60
|
-
}
|
|
61
|
-
if (typeof toRecipientEmail !== 'string') {
|
|
62
|
-
throw new factory.errors.Internal('toRecipientEmail not found');
|
|
63
|
-
}
|
|
64
|
-
const emailMessageFrom = {
|
|
65
|
-
name: senderName,
|
|
66
|
-
email: senderEmail
|
|
67
|
-
};
|
|
68
|
-
const subject = `[${logLevel}] ${shortSubject}`;
|
|
69
|
-
const emailDatas = [{
|
|
70
|
-
name: 'developers',
|
|
71
|
-
email: toRecipientEmail
|
|
72
|
-
}];
|
|
73
|
-
const sgClient = new client_1.Client();
|
|
74
|
-
sgClient.setApiKey(apiKey);
|
|
75
|
-
// const response = await sgMail.sendMultiple(msg);
|
|
76
|
-
const response = await sgClient.request({
|
|
77
|
-
body: {
|
|
78
|
-
content: [{ type: 'text/plain', value: message }],
|
|
79
|
-
from: emailMessageFrom,
|
|
80
|
-
personalizations: [{ to: emailDatas }],
|
|
81
|
-
subject,
|
|
82
|
-
custom_args: {
|
|
83
|
-
emailMessage: subject
|
|
84
|
-
// actionId: action.id,
|
|
85
|
-
// projectId: project.id
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
method: 'POST',
|
|
89
|
-
url: '/v3/mail/send'
|
|
90
|
-
});
|
|
91
|
-
// check the response.
|
|
92
|
-
if (response[0].statusCode !== http_status_1.ACCEPTED) {
|
|
93
|
-
throw new factory.errors.Internal(`sendgrid request not accepted. response is ${util.inspect(response)}`);
|
|
94
|
-
}
|
|
95
|
-
const { statusCode } = response[0];
|
|
96
|
-
// const statusMessage = response[1];
|
|
97
|
-
result = { statusCode };
|
|
44
|
+
const apiKey = credentials.sendGrid.apiKey;
|
|
45
|
+
if (typeof apiKey !== 'string') {
|
|
46
|
+
throw new factory.errors.Internal('API Key not found');
|
|
98
47
|
}
|
|
99
|
-
|
|
100
|
-
|
|
48
|
+
const senderName = credentials.sendGrid.alert?.sender?.name;
|
|
49
|
+
const senderEmail = credentials.sendGrid.alert?.sender?.email;
|
|
50
|
+
const toRecipientEmail = (Array.isArray(credentials.sendGrid.alert?.toRecipient))
|
|
51
|
+
? credentials.sendGrid.alert?.toRecipient.at(0)?.email
|
|
52
|
+
: undefined;
|
|
53
|
+
if (typeof senderName !== 'string') {
|
|
54
|
+
throw new factory.errors.Internal('senderName not found');
|
|
101
55
|
}
|
|
56
|
+
if (typeof senderEmail !== 'string') {
|
|
57
|
+
throw new factory.errors.Internal('senderEmail not found');
|
|
58
|
+
}
|
|
59
|
+
if (typeof toRecipientEmail !== 'string') {
|
|
60
|
+
throw new factory.errors.Internal('toRecipientEmail not found');
|
|
61
|
+
}
|
|
62
|
+
const emailMessageFrom = {
|
|
63
|
+
name: senderName,
|
|
64
|
+
email: senderEmail
|
|
65
|
+
};
|
|
66
|
+
const subject = `[${logLevel}] ${shortSubject}`;
|
|
67
|
+
const emailDatas = [{
|
|
68
|
+
name: 'developers',
|
|
69
|
+
email: toRecipientEmail
|
|
70
|
+
}];
|
|
71
|
+
const sgClient = new client_1.Client();
|
|
72
|
+
sgClient.setApiKey(apiKey);
|
|
73
|
+
// const response = await sgMail.sendMultiple(msg);
|
|
74
|
+
const response = await sgClient.request({
|
|
75
|
+
body: {
|
|
76
|
+
content: [{ type: 'text/plain', value: message }],
|
|
77
|
+
from: emailMessageFrom,
|
|
78
|
+
personalizations: [{ to: emailDatas }],
|
|
79
|
+
subject,
|
|
80
|
+
custom_args: {
|
|
81
|
+
emailMessage: subject
|
|
82
|
+
// actionId: action.id,
|
|
83
|
+
// projectId: project.id
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
method: 'POST',
|
|
87
|
+
url: '/v3/mail/send'
|
|
88
|
+
});
|
|
89
|
+
// check the response.
|
|
90
|
+
if (response[0].statusCode !== http_status_1.ACCEPTED) {
|
|
91
|
+
throw new factory.errors.Internal(`sendgrid request not accepted. response is ${util.inspect(response)}`);
|
|
92
|
+
}
|
|
93
|
+
const { statusCode } = response[0];
|
|
94
|
+
// const statusMessage = response[1];
|
|
95
|
+
const result = { statusCode };
|
|
102
96
|
return { result };
|
|
103
97
|
};
|
|
104
98
|
}
|
|
@@ -43,7 +43,6 @@ function createMailData(params) {
|
|
|
43
43
|
id: params.project.id,
|
|
44
44
|
inclusion: ['settings']
|
|
45
45
|
});
|
|
46
|
-
let mailData;
|
|
47
46
|
let apiKey = credentials.sendGrid.apiKey;
|
|
48
47
|
// プロジェクト固有のSendGrid設定があれば、そちらを使用
|
|
49
48
|
if (typeof project.settings?.sendgridApiKey === 'string' && project.settings.sendgridApiKey.length > 0) {
|
|
@@ -82,7 +81,7 @@ function createMailData(params) {
|
|
|
82
81
|
};
|
|
83
82
|
})
|
|
84
83
|
: [];
|
|
85
|
-
mailData = {
|
|
84
|
+
const mailData = {
|
|
86
85
|
to: emailDatas,
|
|
87
86
|
from: emailMessageFrom,
|
|
88
87
|
subject,
|
|
@@ -104,7 +103,7 @@ function sendEmailMessage(params) {
|
|
|
104
103
|
});
|
|
105
104
|
const startingAction = createSendEmailMessageActionAttributes(params);
|
|
106
105
|
const action = await repos.action.start(startingAction, { recipe });
|
|
107
|
-
let result
|
|
106
|
+
let result;
|
|
108
107
|
try {
|
|
109
108
|
mailData.customArgs = {
|
|
110
109
|
emailMessage: emailMessage.identifier,
|
|
@@ -171,45 +171,40 @@ function processInformAction(params, options) {
|
|
|
171
171
|
signature = signRequest({ requestBody, timestamp, secretKey });
|
|
172
172
|
}
|
|
173
173
|
if (useFetchAPI) {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
headers.append(`X-${headerIdentifier}-Webhook-Signature`, signature);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
const res = await fetch(urlTemplate, {
|
|
183
|
-
method: 'POST',
|
|
184
|
-
headers,
|
|
185
|
-
body: requestBody, // body data type must match "Content-Type" header
|
|
186
|
-
...(typeof timeout === 'number')
|
|
187
|
-
? { signal: AbortSignal.timeout(timeout) }
|
|
188
|
-
: undefined
|
|
189
|
-
});
|
|
190
|
-
let body;
|
|
191
|
-
try {
|
|
192
|
-
body = await res.text();
|
|
193
|
-
}
|
|
194
|
-
catch (error) {
|
|
195
|
-
// no op
|
|
196
|
-
}
|
|
197
|
-
switch (res.status) {
|
|
198
|
-
case http_status_1.OK:
|
|
199
|
-
case http_status_1.CREATED:
|
|
200
|
-
case http_status_1.ACCEPTED:
|
|
201
|
-
case http_status_1.NO_CONTENT:
|
|
202
|
-
result = {
|
|
203
|
-
statusCode: res.status,
|
|
204
|
-
useFetchAPI
|
|
205
|
-
};
|
|
206
|
-
break;
|
|
207
|
-
default:
|
|
208
|
-
throw new factory.errors.Internal(`statusCode: ${res.status} body: ${body}`);
|
|
174
|
+
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
175
|
+
if (typeof headerIdentifier === 'string' && headerIdentifier !== '') {
|
|
176
|
+
headers.append(`X-${headerIdentifier}-Webhook-Timestamp`, String(timestamp));
|
|
177
|
+
if (typeof signature === 'string') {
|
|
178
|
+
headers.append(`X-${headerIdentifier}-Webhook-Signature`, signature);
|
|
209
179
|
}
|
|
210
180
|
}
|
|
211
|
-
|
|
212
|
-
|
|
181
|
+
const res = await fetch(urlTemplate, {
|
|
182
|
+
method: 'POST',
|
|
183
|
+
headers,
|
|
184
|
+
body: requestBody, // body data type must match "Content-Type" header
|
|
185
|
+
...(typeof timeout === 'number')
|
|
186
|
+
? { signal: AbortSignal.timeout(timeout) }
|
|
187
|
+
: undefined
|
|
188
|
+
});
|
|
189
|
+
let body;
|
|
190
|
+
try {
|
|
191
|
+
body = await res.text();
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
// no op
|
|
195
|
+
}
|
|
196
|
+
switch (res.status) {
|
|
197
|
+
case http_status_1.OK:
|
|
198
|
+
case http_status_1.CREATED:
|
|
199
|
+
case http_status_1.ACCEPTED:
|
|
200
|
+
case http_status_1.NO_CONTENT:
|
|
201
|
+
result = {
|
|
202
|
+
statusCode: res.status,
|
|
203
|
+
useFetchAPI
|
|
204
|
+
};
|
|
205
|
+
break;
|
|
206
|
+
default:
|
|
207
|
+
throw new factory.errors.Internal(`statusCode: ${res.status} body: ${body}`);
|
|
213
208
|
}
|
|
214
209
|
}
|
|
215
210
|
else {
|
|
@@ -35,7 +35,6 @@ function processStartReserve4chevre(params, options) {
|
|
|
35
35
|
// }
|
|
36
36
|
) => {
|
|
37
37
|
const { event, transaction, transactionNumber } = params;
|
|
38
|
-
let acceptedOffers4result = [];
|
|
39
38
|
// 予約取引開始
|
|
40
39
|
const startParams = (0, factory_1.createReserveTransactionStartParams)({
|
|
41
40
|
project: transaction.project,
|
|
@@ -69,7 +68,7 @@ function processStartReserve4chevre(params, options) {
|
|
|
69
68
|
// stockHoldUntilDaysAfterEventEnd: params.stockHoldUntilDaysAfterEventEnd
|
|
70
69
|
}, options)(repos, settings);
|
|
71
70
|
// 予約取引結果から注文オファーを生成する
|
|
72
|
-
acceptedOffers4result = (0, factory_1.responseBody2acceptedOffers4result)({
|
|
71
|
+
const acceptedOffers4result = (0, factory_1.responseBody2acceptedOffers4result)({
|
|
73
72
|
issuedThrough: startReserveTransactionResult.issuedThrough,
|
|
74
73
|
reservationFor: startReserveTransactionResult.reservationFor,
|
|
75
74
|
objectSubReservations: startReserveTransactionResult.objectSubReservations,
|
|
@@ -50,7 +50,7 @@ function authorize(params, options) {
|
|
|
50
50
|
store: params.store,
|
|
51
51
|
noOfferSpecified
|
|
52
52
|
})(repos);
|
|
53
|
-
let acceptedOffers4result
|
|
53
|
+
let acceptedOffers4result;
|
|
54
54
|
const now = new Date();
|
|
55
55
|
const orderNumber = await (0, publishOrderNumberIfNotExist_1.publishOrderNumberIfNotExist)({
|
|
56
56
|
project: { id: params.project.id },
|
|
@@ -191,7 +191,6 @@ function offer2availableSalesTicket(params) {
|
|
|
191
191
|
};
|
|
192
192
|
}
|
|
193
193
|
function availableSalesTicket2offerWithDetails(params) {
|
|
194
|
-
let offerWithDetails;
|
|
195
194
|
const availableSalesTicket = params.availableSalesTicket;
|
|
196
195
|
const offer = params.offer;
|
|
197
196
|
const includeGlasses = (offer.ticketInfo.addGlasses > 0);
|
|
@@ -248,7 +247,7 @@ function availableSalesTicket2offerWithDetails(params) {
|
|
|
248
247
|
? availableSalesTicket.limitCount
|
|
249
248
|
: 1
|
|
250
249
|
};
|
|
251
|
-
offerWithDetails = {
|
|
250
|
+
const offerWithDetails = {
|
|
252
251
|
// ticketCodeで照合するためidは不要(2023-03-22~)
|
|
253
252
|
// id: params.offerId,
|
|
254
253
|
// identifierはchevre/apiで自動補完(2023-03-10~)
|
|
@@ -51,7 +51,7 @@ function authorize(params) {
|
|
|
51
51
|
const { transactionNumber } = await repos.transactionNumber.publishByTimestamp({ startDate: now });
|
|
52
52
|
let requestBody;
|
|
53
53
|
let responseBody;
|
|
54
|
-
let acceptedOffers4result
|
|
54
|
+
let acceptedOffers4result;
|
|
55
55
|
// 承認アクションを開始
|
|
56
56
|
const actionAttributes = createAuthorizeMoneyTransferOfferActionattributes({
|
|
57
57
|
transaction,
|
|
@@ -189,66 +189,59 @@ function createAuthorizeMoneyTransferOfferActionattributes(params) {
|
|
|
189
189
|
}
|
|
190
190
|
function processStartDepositTransaction(params) {
|
|
191
191
|
return async (repos) => {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
project:
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
typeOf: 'MonetaryAmount',
|
|
221
|
-
value: Number(params.object.itemOffered.amount.value),
|
|
222
|
-
currency: ''
|
|
223
|
-
},
|
|
224
|
-
fromLocation: {
|
|
225
|
-
typeOf: params.transaction.agent.typeOf,
|
|
226
|
-
id: params.transaction.agent.id,
|
|
227
|
-
name: (typeof params.transaction.agent.name === 'string')
|
|
228
|
-
? params.transaction.agent.name
|
|
229
|
-
: `${params.transaction.typeOf} Transaction ${params.transaction.id}`
|
|
230
|
-
},
|
|
231
|
-
toLocation,
|
|
232
|
-
description: description,
|
|
233
|
-
pendingTransaction: {
|
|
234
|
-
typeOf: factory.account.transactionType.Deposit,
|
|
235
|
-
transactionNumber: params.transactionNumber
|
|
236
|
-
}
|
|
192
|
+
const description = `for ${params.transaction.typeOf} Transaction ${params.transaction.id}`;
|
|
193
|
+
// 最大1ヵ月のオーソリ
|
|
194
|
+
const expires = (0, moment_1.default)()
|
|
195
|
+
.add(1, 'month')
|
|
196
|
+
.toDate();
|
|
197
|
+
const toLocation = {
|
|
198
|
+
typeOf: factory.permit.PermitType.Permit,
|
|
199
|
+
identifier: params.object.itemOffered.toLocation.identifier,
|
|
200
|
+
issuedThrough: { id: params.object.itemOffered.toLocation.issuedThrough?.id }
|
|
201
|
+
};
|
|
202
|
+
// 販売者が取引人に入金
|
|
203
|
+
const requestBody = {
|
|
204
|
+
typeOf: factory.assetTransactionType.MoneyTransfer,
|
|
205
|
+
project: { typeOf: factory.organizationType.Project, id: params.project.id },
|
|
206
|
+
transactionNumber: params.transactionNumber,
|
|
207
|
+
agent: {
|
|
208
|
+
// project: params.transaction.project,
|
|
209
|
+
typeOf: params.transaction.seller.typeOf,
|
|
210
|
+
id: String(params.transaction.seller.id),
|
|
211
|
+
name: (typeof params.transaction.seller.name === 'string')
|
|
212
|
+
? params.transaction.seller.name
|
|
213
|
+
: String(params.transaction.seller.name?.ja)
|
|
214
|
+
},
|
|
215
|
+
object: {
|
|
216
|
+
amount: {
|
|
217
|
+
typeOf: 'MonetaryAmount',
|
|
218
|
+
value: Number(params.object.itemOffered.amount.value),
|
|
219
|
+
currency: ''
|
|
237
220
|
},
|
|
238
|
-
|
|
221
|
+
fromLocation: {
|
|
239
222
|
typeOf: params.transaction.agent.typeOf,
|
|
240
223
|
id: params.transaction.agent.id,
|
|
241
224
|
name: (typeof params.transaction.agent.name === 'string')
|
|
242
225
|
? params.transaction.agent.name
|
|
243
226
|
: `${params.transaction.typeOf} Transaction ${params.transaction.id}`
|
|
244
227
|
},
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
228
|
+
toLocation,
|
|
229
|
+
description: description,
|
|
230
|
+
pendingTransaction: {
|
|
231
|
+
typeOf: factory.account.transactionType.Deposit,
|
|
232
|
+
transactionNumber: params.transactionNumber
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
recipient: {
|
|
236
|
+
typeOf: params.transaction.agent.typeOf,
|
|
237
|
+
id: params.transaction.agent.id,
|
|
238
|
+
name: (typeof params.transaction.agent.name === 'string')
|
|
239
|
+
? params.transaction.agent.name
|
|
240
|
+
: `${params.transaction.typeOf} Transaction ${params.transaction.id}`
|
|
241
|
+
},
|
|
242
|
+
expires: expires
|
|
243
|
+
};
|
|
244
|
+
const responseBody = await MoneyTransferAssetTransactionService.start(requestBody)(repos);
|
|
252
245
|
return { requestBody, responseBody };
|
|
253
246
|
};
|
|
254
247
|
}
|
|
@@ -193,7 +193,7 @@ function isProcessable(params) {
|
|
|
193
193
|
inclusion: ['paymentMethods']
|
|
194
194
|
});
|
|
195
195
|
// PayTransactionのステータス検証
|
|
196
|
-
let allPayTransactionConfirmed
|
|
196
|
+
let allPayTransactionConfirmed;
|
|
197
197
|
const paymentMethodIds = order.paymentMethods.filter((invoice) => typeof invoice.paymentMethodId === 'string' && invoice.paymentMethodId.length > 0)
|
|
198
198
|
.map((invoice) => invoice.paymentMethodId);
|
|
199
199
|
if (paymentMethodIds.length > 0) {
|
|
@@ -306,18 +306,12 @@ function cancelOrderIfExist(params) {
|
|
|
306
306
|
confirmationNumber: orderByPaymentMethodId.confirmationNumber,
|
|
307
307
|
orderNumber: orderByPaymentMethodId.orderNumber
|
|
308
308
|
})({ transaction: repos.transaction });
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
previousOrderStatus: factory.orderStatus.OrderPaymentDue
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
catch (error) {
|
|
319
|
-
throw error;
|
|
320
|
-
}
|
|
309
|
+
const order = await repos.order.changeStatus({
|
|
310
|
+
project: { id: params.project.id },
|
|
311
|
+
orderNumber: orderByPaymentMethodId.orderNumber,
|
|
312
|
+
orderStatus: factory.orderStatus.OrderCancelled,
|
|
313
|
+
previousOrderStatus: factory.orderStatus.OrderPaymentDue
|
|
314
|
+
});
|
|
321
315
|
if (params.useOnOrderStatusChanged) {
|
|
322
316
|
await (0, onOrderStatusChanged_1.onOrderCancelled)({
|
|
323
317
|
order: {
|
|
@@ -37,7 +37,7 @@ const debug = (0, debug_1.default)('chevre-domain:service:order');
|
|
|
37
37
|
function onOrderCancelled(params) {
|
|
38
38
|
return async (repos) => {
|
|
39
39
|
debug('onOrderStatusChanged called.', params.order.orderNumber, params.order.orderStatus, params.order.orderDate);
|
|
40
|
-
let tasks
|
|
40
|
+
let tasks;
|
|
41
41
|
switch (params.order.orderStatus) {
|
|
42
42
|
// OrderCancelled追加(2023-08-30~)
|
|
43
43
|
case factory.orderStatus.OrderCancelled:
|
|
@@ -41,7 +41,7 @@ function onOrderDelivered(params) {
|
|
|
41
41
|
) => {
|
|
42
42
|
const setting = await repos.setting.findOne({ project: { id: { $eq: '*' } } }, ['onOrderStatusChanged']);
|
|
43
43
|
debug('onOrderStatusChanged called.', params.order.orderNumber, params.order.orderStatus, params.order.orderDate);
|
|
44
|
-
let tasks
|
|
44
|
+
let tasks;
|
|
45
45
|
// const sendOrderPotentialActions =
|
|
46
46
|
// params.placeOrderTransaction?.potentialActions?.order?.potentialActions?.sendOrder?.potentialActions;
|
|
47
47
|
switch (params.order.orderStatus) {
|
|
@@ -41,7 +41,7 @@ function onOrderDeliveredPartially(params) {
|
|
|
41
41
|
) => {
|
|
42
42
|
const setting = await repos.setting.findOne({ project: { id: { $eq: '*' } } }, ['onOrderStatusChanged']);
|
|
43
43
|
debug('onOrderStatusChanged called.', params.order.orderNumber, params.order.orderStatus, params.order.orderDate);
|
|
44
|
-
let tasks
|
|
44
|
+
let tasks;
|
|
45
45
|
switch (params.order.orderStatus) {
|
|
46
46
|
case factory.orderStatus.OrderInTransit:
|
|
47
47
|
tasks = [
|