@chevre/domain 21.17.0-alpha.10 → 21.17.0-alpha.12
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/service/offer/event/voidTransaction.js +7 -5
- package/lib/chevre/service/payment/any.js +3 -6
- package/lib/chevre/service/transaction/moneyTransfer/potentialActions.js +0 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.js +0 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.js +0 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +1 -4
- package/lib/chevre/service/transaction/placeOrderInProgress/result.js +1 -2
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js +2 -4
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +9 -18
- package/lib/chevre/service/transaction/placeOrderInProgress.js +3 -3
- package/package.json +1 -1
|
@@ -32,16 +32,18 @@ function voidTransaction(params) {
|
|
|
32
32
|
id: params.purpose.id,
|
|
33
33
|
inclusion: ['_id', 'typeOf', 'status']
|
|
34
34
|
});
|
|
35
|
-
//
|
|
35
|
+
// 興行オファー承認アクション検索
|
|
36
36
|
let authorizeActions = yield repos.action.searchByPurpose({
|
|
37
37
|
typeOf: factory.actionType.AuthorizeAction,
|
|
38
38
|
purpose: {
|
|
39
39
|
typeOf: params.purpose.typeOf,
|
|
40
40
|
id: params.purpose.id
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
},
|
|
42
|
+
object: { typeOf: { $eq: factory.action.authorize.offer.eventService.ObjectType.SeatReservation } }
|
|
43
|
+
});
|
|
44
|
+
// .then((actions) => actions
|
|
45
|
+
// .filter((a) => a.object.typeOf === factory.action.authorize.offer.eventService.ObjectType.SeatReservation)
|
|
46
|
+
// );
|
|
45
47
|
switch (transaction.status) {
|
|
46
48
|
case factory.transactionStatusType.InProgress:
|
|
47
49
|
throw new factory.errors.NotImplemented(`${transaction.status} not implemented`);
|
|
@@ -133,13 +133,10 @@ function processVoidPayTransaction(params) {
|
|
|
133
133
|
purpose: {
|
|
134
134
|
typeOf: transaction.typeOf,
|
|
135
135
|
id: transaction.id
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
authorizeActions = authorizeActionsOnTransaction.filter((a) => {
|
|
139
|
-
var _a, _b;
|
|
140
|
-
return ((_a = a.object) === null || _a === void 0 ? void 0 : _a.typeOf) === factory.action.authorize.paymentMethod.any.ResultType.Payment
|
|
141
|
-
&& ((_b = a.instrument) === null || _b === void 0 ? void 0 : _b.identifier) === factory.action.authorize.paymentMethod.any.ServiceIdentifier.Chevre;
|
|
136
|
+
},
|
|
137
|
+
object: { typeOf: { $eq: factory.action.authorize.paymentMethod.any.ResultType.Payment } }
|
|
142
138
|
});
|
|
139
|
+
authorizeActions = authorizeActionsOnTransaction.filter((a) => { var _a; return ((_a = a.instrument) === null || _a === void 0 ? void 0 : _a.identifier) === factory.action.authorize.paymentMethod.any.ServiceIdentifier.Chevre; });
|
|
143
140
|
switch (transaction.status) {
|
|
144
141
|
case factory.transactionStatusType.InProgress:
|
|
145
142
|
throw new factory.errors.NotImplemented(`${transaction.status} not implemented`);
|
|
@@ -14,7 +14,6 @@ const factory = require("../../../factory");
|
|
|
14
14
|
function createMoneyTransferActions(params) {
|
|
15
15
|
const moneyTransferActions = [];
|
|
16
16
|
const authorizeMoneyTransferActions = params.authorizeActions
|
|
17
|
-
.filter((a) => a.actionStatus === factory.actionStatusType.CompletedActionStatus)
|
|
18
17
|
.filter((a) => a.object.typeOf === factory.offerType.Offer)
|
|
19
18
|
.filter((a) => { var _a; return ((_a = a.object.itemOffered) === null || _a === void 0 ? void 0 : _a.typeOf) === factory.actionType.MoneyTransfer; });
|
|
20
19
|
authorizeMoneyTransferActions.forEach((a) => {
|
package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.js
CHANGED
|
@@ -16,7 +16,6 @@ function createMoneyTransferActions(params) {
|
|
|
16
16
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17
17
|
const moneyTransferActions = [];
|
|
18
18
|
const authorizeMoneyTransferActions = params.authorizeActions
|
|
19
|
-
.filter((a) => a.actionStatus === factory.actionStatusType.CompletedActionStatus)
|
|
20
19
|
.filter((a) => a.object.typeOf === factory.offerType.Offer)
|
|
21
20
|
.filter((a) => { var _a; return ((_a = a.object.itemOffered) === null || _a === void 0 ? void 0 : _a.typeOf) === factory.actionType.MoneyTransfer; });
|
|
22
21
|
const moneyTransferPurpose = {
|
package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.js
CHANGED
|
@@ -17,7 +17,6 @@ function createRegisterServiceActions(params) {
|
|
|
17
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
18
|
const registerServiceActions = [];
|
|
19
19
|
const authorizeProductOfferActions = params.authorizeActions
|
|
20
|
-
.filter((a) => a.actionStatus === factory.actionStatusType.CompletedActionStatus)
|
|
21
20
|
.filter((a) => Array.isArray(a.object)
|
|
22
21
|
&& a.object.length > 0
|
|
23
22
|
&& a.object[0].typeOf === factory.offerType.Offer
|
|
@@ -8,8 +8,7 @@ function createReservationAcceptedOffers(params) {
|
|
|
8
8
|
const orderedItems = [];
|
|
9
9
|
// 座席予約に対する承認アクション取り出す
|
|
10
10
|
const seatReservationAuthorizeActions = params.authorizeActions
|
|
11
|
-
.filter((a) => a.
|
|
12
|
-
&& a.object.typeOf === factory.action.authorize.offer.eventService.ObjectType.SeatReservation);
|
|
11
|
+
.filter((a) => a.object.typeOf === factory.action.authorize.offer.eventService.ObjectType.SeatReservation);
|
|
13
12
|
const eventIds = [];
|
|
14
13
|
seatReservationAuthorizeActions.forEach((authorizeSeatReservationAction) => {
|
|
15
14
|
var _a;
|
|
@@ -86,7 +85,6 @@ function createProductItems(params) {
|
|
|
86
85
|
const acceptedOffers = [];
|
|
87
86
|
const orderedItems = [];
|
|
88
87
|
const authorizePaymentCardOfferActions = params.authorizeActions
|
|
89
|
-
.filter((a) => a.actionStatus === factory.actionStatusType.CompletedActionStatus)
|
|
90
88
|
.filter((a) => Array.isArray(a.object)
|
|
91
89
|
&& a.object.length > 0
|
|
92
90
|
&& a.object[0].typeOf === factory.offerType.Offer
|
|
@@ -118,7 +116,6 @@ exports.createProductItems = createProductItems;
|
|
|
118
116
|
function createMoneyTransferAcceptedOffers(params) {
|
|
119
117
|
// 通貨転送承認アクション
|
|
120
118
|
const authorizeMoneyTansferActions = params.authorizeActions
|
|
121
|
-
.filter((a) => a.actionStatus === factory.actionStatusType.CompletedActionStatus)
|
|
122
119
|
.filter((a) => a.object.typeOf === factory.offerType.Offer)
|
|
123
120
|
.filter((a) => { var _a; return ((_a = a.object.itemOffered) === null || _a === void 0 ? void 0 : _a.typeOf) === factory.actionType.MoneyTransfer; });
|
|
124
121
|
const acceptedOffers = [];
|
|
@@ -69,8 +69,7 @@ function createPaymentMethods(params) {
|
|
|
69
69
|
const resultAsInvoice = (Array.isArray(a.result))
|
|
70
70
|
? (_a = a.result) === null || _a === void 0 ? void 0 : _a.find((resultObject) => resultObject.typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
|
|
71
71
|
: a.result;
|
|
72
|
-
return
|
|
73
|
-
&& (resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.typeOf) === factory.action.authorize.paymentMethod.any.ResultType.Payment;
|
|
72
|
+
return (resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.typeOf) === factory.action.authorize.paymentMethod.any.ResultType.Payment;
|
|
74
73
|
});
|
|
75
74
|
// 決済方法をセット
|
|
76
75
|
authorizePaymentActions.forEach((a) => {
|
package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js
CHANGED
|
@@ -16,15 +16,13 @@ function validateMovieTicket(paymentMethodType, transaction, authorizeActions) {
|
|
|
16
16
|
const resultAsInvoice = (Array.isArray(a.result))
|
|
17
17
|
? (_a = a.result) === null || _a === void 0 ? void 0 : _a.find((resultObject) => resultObject.typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
|
|
18
18
|
: a.result;
|
|
19
|
-
return
|
|
20
|
-
&& (resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.typeOf) === factory.action.authorize.paymentMethod.any.ResultType.Payment
|
|
19
|
+
return (resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.typeOf) === factory.action.authorize.paymentMethod.any.ResultType.Payment
|
|
21
20
|
&& (resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.issuedThrough.typeOf) === factory.service.paymentService.PaymentServiceType.MovieTicket
|
|
22
21
|
// 決済方法区分は必ず存在するはず(2023-08-15~)
|
|
23
22
|
&& ((_b = resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.paymentMethodAsObject) === null || _b === void 0 ? void 0 : _b.typeOf) === paymentMethodType;
|
|
24
23
|
// && a.result?.paymentMethod === paymentMethodType
|
|
25
24
|
});
|
|
26
|
-
const seatReservationAuthorizeActions = authorizeActions.filter((a) => a.
|
|
27
|
-
&& a.object.typeOf === factory.action.authorize.offer.eventService.ObjectType.SeatReservation);
|
|
25
|
+
const seatReservationAuthorizeActions = authorizeActions.filter((a) => a.object.typeOf === factory.action.authorize.offer.eventService.ObjectType.SeatReservation);
|
|
28
26
|
// 予約によって必要とされるMovieTicket
|
|
29
27
|
const requiredMovieTickets = authorizeSeatReservationActions2requiredMovieTickets({
|
|
30
28
|
paymentMethodType,
|
|
@@ -43,12 +43,10 @@ function findMovieTicketPaymentMethodTypesFromTransaction(authorizeActions) {
|
|
|
43
43
|
const resultAsInvoice = (Array.isArray(a.result))
|
|
44
44
|
? (_a = a.result) === null || _a === void 0 ? void 0 : _a.find((resultObject) => resultObject.typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
|
|
45
45
|
: a.result;
|
|
46
|
-
return
|
|
47
|
-
&& (resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.typeOf) === factory.action.authorize.paymentMethod.any.ResultType.Payment
|
|
46
|
+
return (resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.typeOf) === factory.action.authorize.paymentMethod.any.ResultType.Payment
|
|
48
47
|
&& (resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.issuedThrough.typeOf) === factory.service.paymentService.PaymentServiceType.MovieTicket;
|
|
49
48
|
});
|
|
50
|
-
const seatReservationAuthorizeActions = authorizeActions.filter((a) => a.
|
|
51
|
-
&& a.object.typeOf === factory.action.authorize.offer.eventService.ObjectType.SeatReservation);
|
|
49
|
+
const seatReservationAuthorizeActions = authorizeActions.filter((a) => a.object.typeOf === factory.action.authorize.offer.eventService.ObjectType.SeatReservation);
|
|
52
50
|
// MovieTicketオファーを受け付けた予約承認から抽出
|
|
53
51
|
const requiredMovieTicketPaymentMethodTypes = [];
|
|
54
52
|
seatReservationAuthorizeActions.forEach((action) => {
|
|
@@ -100,8 +98,7 @@ function validatePrice(transaction, authorizeActions) {
|
|
|
100
98
|
const resultAsInvoice = (Array.isArray(a.result))
|
|
101
99
|
? (_a = a.result) === null || _a === void 0 ? void 0 : _a.find((resultObject) => resultObject.typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
|
|
102
100
|
: a.result;
|
|
103
|
-
return
|
|
104
|
-
&& (resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.typeOf) === factory.action.authorize.paymentMethod.any.ResultType.Payment;
|
|
101
|
+
return (resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.typeOf) === factory.action.authorize.paymentMethod.any.ResultType.Payment;
|
|
105
102
|
}).forEach((authorizePaymentAction) => {
|
|
106
103
|
var _a, _b;
|
|
107
104
|
const resultAsInvoice = (Array.isArray(authorizePaymentAction.result))
|
|
@@ -113,21 +110,19 @@ function validatePrice(transaction, authorizeActions) {
|
|
|
113
110
|
priceByAgent += jpyAmount;
|
|
114
111
|
});
|
|
115
112
|
// 販売者が提供するアイテムの発生金額
|
|
116
|
-
authorizeActions.filter((authorizeAction) => authorizeAction.
|
|
117
|
-
&& authorizeAction.agent.id === transaction.seller.id)
|
|
113
|
+
authorizeActions.filter((authorizeAction) => authorizeAction.agent.id === transaction.seller.id)
|
|
118
114
|
.forEach((authorizeAction) => {
|
|
119
115
|
var _a;
|
|
120
116
|
const priceByAction = (_a = authorizeAction.result) === null || _a === void 0 ? void 0 : _a.price;
|
|
121
|
-
if (typeof priceByAction === 'number' && priceByAction
|
|
117
|
+
if (typeof priceByAction === 'number' && priceByAction >= 0) {
|
|
122
118
|
priceBySeller += priceByAction;
|
|
123
119
|
}
|
|
124
120
|
else {
|
|
125
121
|
// price未確定(オファー未指定)のオファー承認アクションが存在すれば確定不可能(2023-11-27~)
|
|
126
|
-
throw new factory.errors.Argument('id',
|
|
122
|
+
throw new factory.errors.Argument('id', `some actions with no offer specified. [${authorizeAction.id}]`);
|
|
127
123
|
}
|
|
128
124
|
});
|
|
129
125
|
// priceBySeller += authorizeActions
|
|
130
|
-
// .filter((authorizeAction) => authorizeAction.actionStatus === factory.actionStatusType.CompletedActionStatus)
|
|
131
126
|
// .filter((authorizeAction) => authorizeAction.agent.id === transaction.seller.id)
|
|
132
127
|
// .reduce((a, b) => a + (<IAuthorizeActionResultBySeller>b.result).price, 0);
|
|
133
128
|
// debug('priceByAgent priceBySeller:', priceByAgent, priceBySeller);
|
|
@@ -149,8 +144,7 @@ function validatePaymentUrl(transaction, authorizeActions) {
|
|
|
149
144
|
const resultAsInvoice = (Array.isArray(a.result))
|
|
150
145
|
? (_a = a.result) === null || _a === void 0 ? void 0 : _a.find((resultObject) => resultObject.typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
|
|
151
146
|
: a.result;
|
|
152
|
-
return
|
|
153
|
-
&& (resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.typeOf) === factory.action.authorize.paymentMethod.any.ResultType.Payment;
|
|
147
|
+
return (resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.typeOf) === factory.action.authorize.paymentMethod.any.ResultType.Payment;
|
|
154
148
|
});
|
|
155
149
|
// 決済承認を確認
|
|
156
150
|
const authorizePaymentAction4paymentUrlExists = authorizePaymentActions.some((a) => {
|
|
@@ -175,16 +169,14 @@ function validateMonetaryAmount(authorizeActions) {
|
|
|
175
169
|
const resultAsInvoice = (Array.isArray(a.result))
|
|
176
170
|
? (_a = a.result) === null || _a === void 0 ? void 0 : _a.find((resultObject) => resultObject.typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
|
|
177
171
|
: a.result;
|
|
178
|
-
return
|
|
179
|
-
&& (resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.typeOf) === factory.action.authorize.paymentMethod.any.ResultType.Payment
|
|
172
|
+
return (resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.typeOf) === factory.action.authorize.paymentMethod.any.ResultType.Payment
|
|
180
173
|
// JPY以外の通貨に対して承認可能なのはPaymentServiceType.PaymentCardのみ
|
|
181
174
|
&& resultAsInvoice.issuedThrough.typeOf === factory.service.paymentService.PaymentServiceType.PaymentCard
|
|
182
175
|
&& ((_b = resultAsInvoice.totalPaymentDue) === null || _b === void 0 ? void 0 : _b.currency) !== factory.priceCurrency.JPY;
|
|
183
176
|
});
|
|
184
177
|
const requiredMonetaryAmountByCurrencyType = [];
|
|
185
178
|
authorizeActions
|
|
186
|
-
.filter((a) => a.
|
|
187
|
-
&& a.object.typeOf === factory.action.authorize.offer.eventService.ObjectType.SeatReservation)
|
|
179
|
+
.filter((a) => a.object.typeOf === factory.action.authorize.offer.eventService.ObjectType.SeatReservation)
|
|
188
180
|
.forEach((a) => {
|
|
189
181
|
const amount = a.result.amount;
|
|
190
182
|
if (Array.isArray(amount)) {
|
|
@@ -277,7 +269,6 @@ function validateEventOffers(params) {
|
|
|
277
269
|
|| referenceInvoice.issuedThrough.typeOf === factory.service.paymentService.PaymentServiceType.FaceToFace;
|
|
278
270
|
}).length;
|
|
279
271
|
const seatReservationAuthorizeActions = params.authorizeActions
|
|
280
|
-
.filter((a) => a.actionStatus === factory.actionStatusType.CompletedActionStatus)
|
|
281
272
|
.filter((a) => a.object.typeOf === factory.action.authorize.offer.eventService.ObjectType.SeatReservation);
|
|
282
273
|
seatReservationAuthorizeActions.forEach((a) => {
|
|
283
274
|
// オファーIDごとにオファー適用条件を確認
|
|
@@ -93,14 +93,14 @@ function confirm(params) {
|
|
|
93
93
|
throw new factory.errors.Forbidden('Transaction not yours');
|
|
94
94
|
}
|
|
95
95
|
// 取引に対する全ての承認アクションをマージ
|
|
96
|
-
const
|
|
96
|
+
const completedAuthorizeActions = yield searchAuthorizeActions(params)(repos);
|
|
97
97
|
// 注文番号を発行
|
|
98
98
|
const orderNumber = yield publishOrderNumberIfNotExist({
|
|
99
99
|
project: { id: transaction.project.id },
|
|
100
100
|
id: transaction.id,
|
|
101
101
|
object: { orderDate: params.result.order.orderDate }
|
|
102
102
|
})(repos);
|
|
103
|
-
const result = createResult(Object.assign(Object.assign({}, params), { orderNumber, transaction: transaction, authorizeActions }));
|
|
103
|
+
const result = createResult(Object.assign(Object.assign({}, params), { orderNumber, transaction: transaction, authorizeActions: completedAuthorizeActions }));
|
|
104
104
|
// デフォルトEメールメッセージを検索
|
|
105
105
|
let emailMessageOnOrderSent;
|
|
106
106
|
if (repos.emailMessage !== undefined) {
|
|
@@ -118,7 +118,7 @@ function confirm(params) {
|
|
|
118
118
|
potentialActions: params.potentialActions,
|
|
119
119
|
transaction: transaction,
|
|
120
120
|
emailMessage: emailMessageOnOrderSent,
|
|
121
|
-
authorizeActions
|
|
121
|
+
authorizeActions: completedAuthorizeActions
|
|
122
122
|
});
|
|
123
123
|
// ステータス変更
|
|
124
124
|
try {
|
package/package.json
CHANGED