@chevre/domain 21.8.0-alpha.24 → 21.8.0-alpha.26
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/publishPermitOwnershipInfoToken.ts +56 -0
- package/lib/chevre/service/offer/event/authorize.js +3 -0
- package/lib/chevre/service/payment/any/factory.js +9 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/result.js +23 -19
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js +9 -7
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +53 -17
- package/lib/chevre/settings.d.ts +1 -0
- package/lib/chevre/settings.js +2 -1
- package/package.json +2 -2
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as jwt from 'jsonwebtoken';
|
|
3
|
+
import { chevre } from '../../../lib/index';
|
|
4
|
+
|
|
5
|
+
function getToken(params: {
|
|
6
|
+
expiresIn: number;
|
|
7
|
+
payload: chevre.factory.authorization.IOwnershipInfoAsObject;
|
|
8
|
+
}) {
|
|
9
|
+
return async (__: {}) => {
|
|
10
|
+
// const now = new Date();
|
|
11
|
+
|
|
12
|
+
// const data = authorization.object;
|
|
13
|
+
|
|
14
|
+
return new Promise<string>((resolve, reject) => {
|
|
15
|
+
// 所有権を暗号化する
|
|
16
|
+
jwt.sign(
|
|
17
|
+
params.payload,
|
|
18
|
+
chevre.credentials.jwt.secret,
|
|
19
|
+
// params.secret,
|
|
20
|
+
{
|
|
21
|
+
issuer: chevre.credentials.jwt.issuer,
|
|
22
|
+
// issuer: params.issuer,
|
|
23
|
+
expiresIn: params.expiresIn
|
|
24
|
+
},
|
|
25
|
+
(err, encoded) => {
|
|
26
|
+
if (err instanceof Error) {
|
|
27
|
+
reject(err);
|
|
28
|
+
} else {
|
|
29
|
+
if (typeof encoded !== 'string') {
|
|
30
|
+
reject(new chevre.factory.errors.ServiceUnavailable('authorization.object cannot be signed unexpectedly'));
|
|
31
|
+
} else {
|
|
32
|
+
resolve(encoded);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
getToken({
|
|
42
|
+
expiresIn: 2678400,
|
|
43
|
+
payload: {
|
|
44
|
+
typeOf: 'OwnershipInfo',
|
|
45
|
+
id: '',
|
|
46
|
+
typeOfGood: {
|
|
47
|
+
typeOf: chevre.factory.permit.PermitType.Permit,
|
|
48
|
+
identifier: 'xxxxxxxxxxxx',
|
|
49
|
+
issuedThrough: { id: '64f193ad5e79fe8a06ca3156', typeOf: chevre.factory.service.paymentService.PaymentServiceType.CreditCard }
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
})({})
|
|
53
|
+
.then((token) => {
|
|
54
|
+
console.log('token:', token);
|
|
55
|
+
})
|
|
56
|
+
.catch(console.error);
|
|
@@ -188,6 +188,7 @@ function validateObjectWithoutDetail(params) {
|
|
|
188
188
|
var _a, _b, _c, _d;
|
|
189
189
|
const objectWithoutDetail = params.object;
|
|
190
190
|
if (Array.isArray(objectWithoutDetail.acceptedOffer)) {
|
|
191
|
+
const validatedAcceptedOffersWithoutDetail = [];
|
|
191
192
|
for (let acceptedOffer of objectWithoutDetail.acceptedOffer) {
|
|
192
193
|
let programMembershipUsed = (_b = (_a = acceptedOffer.itemOffered) === null || _a === void 0 ? void 0 : _a.serviceOutput) === null || _b === void 0 ? void 0 : _b.programMembershipUsed;
|
|
193
194
|
// トークン化されたメンバーシップがリクエストされた場合、実メンバーシップ情報へ変換する
|
|
@@ -214,7 +215,9 @@ function validateObjectWithoutDetail(params) {
|
|
|
214
215
|
};
|
|
215
216
|
acceptedOffer = Object.assign(Object.assign({}, acceptedOffer), { itemOffered: Object.assign(Object.assign({}, acceptedOffer.itemOffered), { serviceOutput: Object.assign(Object.assign({}, (_d = acceptedOffer.itemOffered) === null || _d === void 0 ? void 0 : _d.serviceOutput), { typeOf: factory.reservationType.EventReservation, programMembershipUsed }) }) });
|
|
216
217
|
}
|
|
218
|
+
validatedAcceptedOffersWithoutDetail.push(acceptedOffer);
|
|
217
219
|
}
|
|
220
|
+
objectWithoutDetail.acceptedOffer = validatedAcceptedOffersWithoutDetail;
|
|
218
221
|
}
|
|
219
222
|
return objectWithoutDetail;
|
|
220
223
|
});
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.optimizeAction4inform = exports.createAuthorizeResult = exports.creatPayTransactionStartParams = void 0;
|
|
4
4
|
const moment = require("moment");
|
|
5
5
|
const factory = require("../../../factory");
|
|
6
|
+
const settings_1 = require("../../../settings");
|
|
6
7
|
function creatPayTransactionStartParams(params) {
|
|
7
8
|
var _a, _b, _c, _d;
|
|
8
9
|
let expires = moment(params.transaction.expires)
|
|
@@ -115,7 +116,8 @@ function createAuthorizeResult(params) {
|
|
|
115
116
|
paymentStatus = factory.paymentStatusType.PaymentDue;
|
|
116
117
|
}
|
|
117
118
|
}
|
|
118
|
-
|
|
119
|
+
// Array対応(2023-09-02~)
|
|
120
|
+
const resultAsInvoice = {
|
|
119
121
|
accountId: (typeof ((_e = payTransactionObject.paymentMethod) === null || _e === void 0 ? void 0 : _e.accountId) === 'string')
|
|
120
122
|
? payTransactionObject.paymentMethod.accountId
|
|
121
123
|
: '',
|
|
@@ -136,6 +138,12 @@ function createAuthorizeResult(params) {
|
|
|
136
138
|
additionalProperty: (Array.isArray(params.object.additionalProperty)) ? params.object.additionalProperty : [],
|
|
137
139
|
typeOf: factory.action.authorize.paymentMethod.any.ResultType.Payment
|
|
138
140
|
};
|
|
141
|
+
if (settings_1.USE_AUTHORIZE_PAYMENT_RESULT_AS_ARRAY) {
|
|
142
|
+
return [resultAsInvoice];
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
return resultAsInvoice;
|
|
146
|
+
}
|
|
139
147
|
}
|
|
140
148
|
exports.createAuthorizeResult = createAuthorizeResult;
|
|
141
149
|
function payActionObject2invoice(params) {
|
|
@@ -65,16 +65,22 @@ function createPaymentMethods(params) {
|
|
|
65
65
|
const authorizePaymentActions = params.authorizeActions
|
|
66
66
|
.filter((a) => {
|
|
67
67
|
var _a;
|
|
68
|
+
const resultAsInvoice = (Array.isArray(a.result))
|
|
69
|
+
? (_a = a.result) === null || _a === void 0 ? void 0 : _a.find((resultObject) => resultObject.typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
|
|
70
|
+
: a.result;
|
|
68
71
|
return a.actionStatus === factory.actionStatusType.CompletedActionStatus
|
|
69
|
-
&& (
|
|
72
|
+
&& (resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.typeOf) === factory.action.authorize.paymentMethod.any.ResultType.Payment;
|
|
70
73
|
});
|
|
71
74
|
// 決済方法をセット
|
|
72
75
|
authorizePaymentActions.forEach((a) => {
|
|
73
|
-
var _a, _b, _c;
|
|
74
|
-
const result = a.result;
|
|
75
|
-
const
|
|
76
|
+
var _a, _b, _c, _d;
|
|
77
|
+
// const result = (<factory.action.authorize.paymentMethod.any.IResult>a.result);
|
|
78
|
+
const resultAsInvoice = (Array.isArray(a.result))
|
|
79
|
+
? (_a = a.result) === null || _a === void 0 ? void 0 : _a.find((resultObject) => resultObject.typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
|
|
80
|
+
: a.result;
|
|
81
|
+
const paymentMethodAmountCurrencyByAuthorizeAction = (_c = (_b = resultAsInvoice.paymentMethodAsObject) === null || _b === void 0 ? void 0 : _b.amount) === null || _c === void 0 ? void 0 : _c.currency;
|
|
76
82
|
// 決済方法区分は必ず存在するはず(2023-08-15~)
|
|
77
|
-
const paymentMethodType = (
|
|
83
|
+
const paymentMethodType = (_d = resultAsInvoice.paymentMethodAsObject) === null || _d === void 0 ? void 0 : _d.typeOf;
|
|
78
84
|
if (typeof paymentMethodType !== 'string') {
|
|
79
85
|
throw new factory.errors.NotFound('authorizePaymentAction.result.paymentMethodAsObject.typeOf');
|
|
80
86
|
}
|
|
@@ -82,13 +88,13 @@ function createPaymentMethods(params) {
|
|
|
82
88
|
{ amount: { currency: paymentMethodAmountCurrencyByAuthorizeAction } }
|
|
83
89
|
: undefined);
|
|
84
90
|
paymentMethods.push({
|
|
85
|
-
accountId:
|
|
86
|
-
additionalProperty: (Array.isArray(
|
|
87
|
-
issuedThrough:
|
|
88
|
-
name:
|
|
89
|
-
paymentMethodId:
|
|
90
|
-
paymentStatus:
|
|
91
|
-
totalPaymentDue:
|
|
91
|
+
accountId: resultAsInvoice.accountId,
|
|
92
|
+
additionalProperty: (Array.isArray(resultAsInvoice.additionalProperty)) ? resultAsInvoice.additionalProperty : [],
|
|
93
|
+
issuedThrough: resultAsInvoice.issuedThrough,
|
|
94
|
+
name: resultAsInvoice.name,
|
|
95
|
+
paymentMethodId: resultAsInvoice.paymentMethodId,
|
|
96
|
+
paymentStatus: resultAsInvoice.paymentStatus,
|
|
97
|
+
totalPaymentDue: resultAsInvoice.totalPaymentDue,
|
|
92
98
|
typeOf: paymentMethodType,
|
|
93
99
|
// CreditCardIFのカード通貨区分を追加(2023-08-15~)
|
|
94
100
|
// 決済方法区分を保証(2023-08-28~)
|
|
@@ -96,16 +102,14 @@ function createPaymentMethods(params) {
|
|
|
96
102
|
});
|
|
97
103
|
});
|
|
98
104
|
// 決済方法から注文金額の計算
|
|
99
|
-
// price += authorizePaymentActions
|
|
100
|
-
// .filter((a) => {
|
|
101
|
-
// return a.result?.totalPaymentDue?.currency === factory.priceCurrency.JPY;
|
|
102
|
-
// })
|
|
103
|
-
// .reduce((a, b) => a + (<IAuthorizeAnyPaymentResult>b.result).amount, 0);
|
|
104
105
|
price += authorizePaymentActions
|
|
105
106
|
.reduce((a, b) => {
|
|
106
107
|
var _a, _b;
|
|
107
|
-
const
|
|
108
|
-
? b.result.
|
|
108
|
+
const resultAsInvoice = (Array.isArray(b.result))
|
|
109
|
+
? (_a = b.result) === null || _a === void 0 ? void 0 : _a.find((resultObject) => resultObject.typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
|
|
110
|
+
: b.result;
|
|
111
|
+
const jpyAmount = (((_b = resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.totalPaymentDue) === null || _b === void 0 ? void 0 : _b.currency) === factory.priceCurrency.JPY)
|
|
112
|
+
? resultAsInvoice.totalPaymentDue.value
|
|
109
113
|
: 0;
|
|
110
114
|
return a + jpyAmount;
|
|
111
115
|
}, 0);
|
package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js
CHANGED
|
@@ -12,15 +12,17 @@ const debug = createDebug('cinerino-domain:service:validateMovieTicket');
|
|
|
12
12
|
*/
|
|
13
13
|
function validateMovieTicket(paymentMethodType, transaction, authorizeActions) {
|
|
14
14
|
const authorizeMovieTicketActions = authorizeActions.filter((a) => {
|
|
15
|
-
var _a, _b
|
|
15
|
+
var _a, _b;
|
|
16
|
+
const resultAsInvoice = (Array.isArray(a.result))
|
|
17
|
+
? (_a = a.result) === null || _a === void 0 ? void 0 : _a.find((resultObject) => resultObject.typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
|
|
18
|
+
: a.result;
|
|
16
19
|
return a.actionStatus === factory.actionStatusType.CompletedActionStatus
|
|
17
|
-
&& (
|
|
18
|
-
&& (
|
|
20
|
+
&& (resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.typeOf) === factory.action.authorize.paymentMethod.any.ResultType.Payment
|
|
21
|
+
&& (resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.issuedThrough.typeOf) === factory.service.paymentService.PaymentServiceType.MovieTicket
|
|
19
22
|
// 決済方法区分は必ず存在するはず(2023-08-15~)
|
|
20
|
-
&& ((
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
);
|
|
23
|
+
&& ((_b = resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.paymentMethodAsObject) === null || _b === void 0 ? void 0 : _b.typeOf) === paymentMethodType;
|
|
24
|
+
// && a.result?.paymentMethod === paymentMethodType
|
|
25
|
+
});
|
|
24
26
|
const seatReservationAuthorizeActions = authorizeActions.filter((a) => a.actionStatus === factory.actionStatusType.CompletedActionStatus
|
|
25
27
|
&& a.object.typeOf === factory.action.authorize.offer.seatReservation.ObjectType.SeatReservation);
|
|
26
28
|
// 予約によって必要とされるMovieTicket
|
|
@@ -40,10 +40,13 @@ function validateTransaction(transaction, authorizeActions) {
|
|
|
40
40
|
exports.validateTransaction = validateTransaction;
|
|
41
41
|
function findMovieTicketPaymentMethodTypesFromTransaction(authorizeActions) {
|
|
42
42
|
const authorizeMovieTicketPaymentActions = authorizeActions.filter((a) => {
|
|
43
|
-
var _a
|
|
43
|
+
var _a;
|
|
44
|
+
const resultAsInvoice = (Array.isArray(a.result))
|
|
45
|
+
? (_a = a.result) === null || _a === void 0 ? void 0 : _a.find((resultObject) => resultObject.typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
|
|
46
|
+
: a.result;
|
|
44
47
|
return a.actionStatus === factory.actionStatusType.CompletedActionStatus
|
|
45
|
-
&& (
|
|
46
|
-
&& (
|
|
48
|
+
&& (resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.typeOf) === factory.action.authorize.paymentMethod.any.ResultType.Payment
|
|
49
|
+
&& (resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.issuedThrough.typeOf) === factory.service.paymentService.PaymentServiceType.MovieTicket;
|
|
47
50
|
});
|
|
48
51
|
const seatReservationAuthorizeActions = authorizeActions.filter((a) => a.actionStatus === factory.actionStatusType.CompletedActionStatus
|
|
49
52
|
&& a.object.typeOf === factory.action.authorize.offer.seatReservation.ObjectType.SeatReservation);
|
|
@@ -67,7 +70,13 @@ function findMovieTicketPaymentMethodTypesFromTransaction(authorizeActions) {
|
|
|
67
70
|
});
|
|
68
71
|
const paymentMethodTypes = [
|
|
69
72
|
// 決済方法区分は必ず存在するはず(2023-08-15~)
|
|
70
|
-
...authorizeMovieTicketPaymentActions.map((a) => {
|
|
73
|
+
...authorizeMovieTicketPaymentActions.map((a) => {
|
|
74
|
+
var _a, _b;
|
|
75
|
+
const resultAsInvoice = (Array.isArray(a.result))
|
|
76
|
+
? (_a = a.result) === null || _a === void 0 ? void 0 : _a.find((resultObject) => resultObject.typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
|
|
77
|
+
: a.result;
|
|
78
|
+
return String((_b = resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.paymentMethodAsObject) === null || _b === void 0 ? void 0 : _b.typeOf);
|
|
79
|
+
}),
|
|
71
80
|
// ...authorizeMovieTicketPaymentActions.map((a) => String(a.result?.paymentMethod)),
|
|
72
81
|
...requiredMovieTicketPaymentMethodTypes
|
|
73
82
|
];
|
|
@@ -90,17 +99,20 @@ function validatePrice(transaction, authorizeActions) {
|
|
|
90
99
|
const authorizePaymentActions = authorizeActions
|
|
91
100
|
.filter((a) => {
|
|
92
101
|
var _a;
|
|
102
|
+
const resultAsInvoice = (Array.isArray(a.result))
|
|
103
|
+
? (_a = a.result) === null || _a === void 0 ? void 0 : _a.find((resultObject) => resultObject.typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
|
|
104
|
+
: a.result;
|
|
93
105
|
return a.actionStatus === factory.actionStatusType.CompletedActionStatus
|
|
94
|
-
&& (
|
|
106
|
+
&& (resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.typeOf) === factory.action.authorize.paymentMethod.any.ResultType.Payment;
|
|
95
107
|
});
|
|
96
|
-
// priceByAgent += authorizePaymentActions
|
|
97
|
-
// .filter((a) => a.result?.totalPaymentDue?.currency === factory.priceCurrency.JPY)
|
|
98
|
-
// .reduce((a, b) => a + (<IAuthorizeAnyPaymentResult>b.result).amount, 0);
|
|
99
108
|
priceByAgent += authorizePaymentActions
|
|
100
109
|
.reduce((a, b) => {
|
|
101
110
|
var _a, _b;
|
|
102
|
-
const
|
|
103
|
-
? b.result.
|
|
111
|
+
const resultAsInvoice = (Array.isArray(b.result))
|
|
112
|
+
? (_a = b.result) === null || _a === void 0 ? void 0 : _a.find((resultObject) => resultObject.typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
|
|
113
|
+
: b.result;
|
|
114
|
+
const jpyAmount = (((_b = resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.totalPaymentDue) === null || _b === void 0 ? void 0 : _b.currency) === factory.priceCurrency.JPY)
|
|
115
|
+
? resultAsInvoice.totalPaymentDue.value
|
|
104
116
|
: 0;
|
|
105
117
|
return a + jpyAmount;
|
|
106
118
|
}, 0);
|
|
@@ -125,11 +137,20 @@ function validatePaymentUrl(transaction, authorizeActions) {
|
|
|
125
137
|
const authorizePaymentActions = authorizeActions
|
|
126
138
|
.filter((a) => {
|
|
127
139
|
var _a;
|
|
140
|
+
const resultAsInvoice = (Array.isArray(a.result))
|
|
141
|
+
? (_a = a.result) === null || _a === void 0 ? void 0 : _a.find((resultObject) => resultObject.typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
|
|
142
|
+
: a.result;
|
|
128
143
|
return a.actionStatus === factory.actionStatusType.CompletedActionStatus
|
|
129
|
-
&& (
|
|
144
|
+
&& (resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.typeOf) === factory.action.authorize.paymentMethod.any.ResultType.Payment;
|
|
130
145
|
});
|
|
131
146
|
// 決済承認を確認
|
|
132
|
-
const authorizePaymentAction4paymentUrlExists = authorizePaymentActions.some((a) => {
|
|
147
|
+
const authorizePaymentAction4paymentUrlExists = authorizePaymentActions.some((a) => {
|
|
148
|
+
var _a;
|
|
149
|
+
const resultAsInvoice = (Array.isArray(a.result))
|
|
150
|
+
? (_a = a.result) === null || _a === void 0 ? void 0 : _a.find((resultObject) => resultObject.typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
|
|
151
|
+
: a.result;
|
|
152
|
+
return (resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.paymentMethodId) === paymentMethodId;
|
|
153
|
+
});
|
|
133
154
|
if (!authorizePaymentAction4paymentUrlExists) {
|
|
134
155
|
throw new factory.errors.Argument('Transaction', 'Payment for published payment URL required');
|
|
135
156
|
}
|
|
@@ -142,11 +163,14 @@ function validateMonetaryAmount(authorizeActions) {
|
|
|
142
163
|
const authorizeMonetaryAmountActions = authorizeActions
|
|
143
164
|
.filter((a) => {
|
|
144
165
|
var _a, _b;
|
|
166
|
+
const resultAsInvoice = (Array.isArray(a.result))
|
|
167
|
+
? (_a = a.result) === null || _a === void 0 ? void 0 : _a.find((resultObject) => resultObject.typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
|
|
168
|
+
: a.result;
|
|
145
169
|
return a.actionStatus === factory.actionStatusType.CompletedActionStatus
|
|
146
|
-
&& (
|
|
170
|
+
&& (resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.typeOf) === factory.action.authorize.paymentMethod.any.ResultType.Payment
|
|
147
171
|
// JPY以外の通貨に対して承認可能なのはPaymentServiceType.PaymentCardのみ
|
|
148
|
-
&&
|
|
149
|
-
&& ((_b =
|
|
172
|
+
&& resultAsInvoice.issuedThrough.typeOf === factory.service.paymentService.PaymentServiceType.PaymentCard
|
|
173
|
+
&& ((_b = resultAsInvoice.totalPaymentDue) === null || _b === void 0 ? void 0 : _b.currency) !== factory.priceCurrency.JPY;
|
|
150
174
|
});
|
|
151
175
|
const requiredMonetaryAmountByCurrencyType = [];
|
|
152
176
|
authorizeActions
|
|
@@ -163,7 +187,13 @@ function validateMonetaryAmount(authorizeActions) {
|
|
|
163
187
|
}
|
|
164
188
|
}, 0);
|
|
165
189
|
const requiredCurrencyTypes = [...new Set(requiredMonetaryAmountByCurrencyType.map((m) => m.currency))];
|
|
166
|
-
const authorizedCurrencyTypes = [...new Set(authorizeMonetaryAmountActions.map((
|
|
190
|
+
const authorizedCurrencyTypes = [...new Set(authorizeMonetaryAmountActions.map((a) => {
|
|
191
|
+
var _a, _b;
|
|
192
|
+
const resultAsInvoice = (Array.isArray(a.result))
|
|
193
|
+
? (_a = a.result) === null || _a === void 0 ? void 0 : _a.find((resultObject) => resultObject.typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
|
|
194
|
+
: a.result;
|
|
195
|
+
return (_b = resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.totalPaymentDue) === null || _b === void 0 ? void 0 : _b.currency;
|
|
196
|
+
}))];
|
|
167
197
|
if (requiredCurrencyTypes.length !== authorizedCurrencyTypes.length) {
|
|
168
198
|
throw new factory.errors.Argument('Transaction', 'MonetaryAmount account types not matched');
|
|
169
199
|
}
|
|
@@ -172,7 +202,13 @@ function validateMonetaryAmount(authorizeActions) {
|
|
|
172
202
|
.filter((m) => m.currency === currencyType)
|
|
173
203
|
.reduce((a, b) => a + b.value, 0);
|
|
174
204
|
const authorizedMonetaryAmount = authorizeMonetaryAmountActions
|
|
175
|
-
.filter((a) => {
|
|
205
|
+
.filter((a) => {
|
|
206
|
+
var _a, _b;
|
|
207
|
+
const resultAsInvoice = (Array.isArray(a.result))
|
|
208
|
+
? (_a = a.result) === null || _a === void 0 ? void 0 : _a.find((resultObject) => resultObject.typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
|
|
209
|
+
: a.result;
|
|
210
|
+
return ((_b = resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.totalPaymentDue) === null || _b === void 0 ? void 0 : _b.currency) === currencyType;
|
|
211
|
+
})
|
|
176
212
|
.reduce((a, b) => a + b.object.amount, 0);
|
|
177
213
|
return requiredMonetaryAmount === authorizedMonetaryAmount;
|
|
178
214
|
});
|
package/lib/chevre/settings.d.ts
CHANGED
|
@@ -42,6 +42,7 @@ export declare const USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT: boolean;
|
|
|
42
42
|
export declare const USE_DELETE_EVENT_BY_ORDER: boolean;
|
|
43
43
|
export declare const USE_CUSTOM_SENDER_EMAIL: boolean;
|
|
44
44
|
export declare const USE_ORDER_PAYMENT_DUE_ON_PLACED: boolean;
|
|
45
|
+
export declare const USE_AUTHORIZE_PAYMENT_RESULT_AS_ARRAY: boolean;
|
|
45
46
|
export declare const MONGO_MAX_TIME_MS: number;
|
|
46
47
|
/**
|
|
47
48
|
* グローバル設定
|
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.MONGO_MAX_TIME_MS = exports.USE_ORDER_PAYMENT_DUE_ON_PLACED = exports.USE_CUSTOM_SENDER_EMAIL = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT = exports.USE_ADVANCE_BOOKING_REQUIREMENT = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = 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;
|
|
3
|
+
exports.settings = exports.MONGO_MAX_TIME_MS = exports.USE_AUTHORIZE_PAYMENT_RESULT_AS_ARRAY = exports.USE_ORDER_PAYMENT_DUE_ON_PLACED = exports.USE_CUSTOM_SENDER_EMAIL = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT = exports.USE_ADVANCE_BOOKING_REQUIREMENT = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = 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')
|
|
@@ -74,6 +74,7 @@ exports.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT = process.env.USE_OBJECT_AS_PAY_TRA
|
|
|
74
74
|
exports.USE_DELETE_EVENT_BY_ORDER = process.env.USE_DELETE_EVENT_BY_ORDER === '1';
|
|
75
75
|
exports.USE_CUSTOM_SENDER_EMAIL = process.env.USE_CUSTOM_SENDER_EMAIL === '1';
|
|
76
76
|
exports.USE_ORDER_PAYMENT_DUE_ON_PLACED = process.env.USE_ORDER_PAYMENT_DUE_ON_PLACED === '1';
|
|
77
|
+
exports.USE_AUTHORIZE_PAYMENT_RESULT_AS_ARRAY = process.env.USE_AUTHORIZE_PAYMENT_RESULT_AS_ARRAY === '1';
|
|
77
78
|
exports.MONGO_MAX_TIME_MS = (typeof process.env.MONGO_MAX_TIME_MS === 'string')
|
|
78
79
|
? Number(process.env.MONGO_MAX_TIME_MS)
|
|
79
80
|
// tslint:disable-next-line:no-magic-numbers
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.329.0-alpha.
|
|
12
|
+
"@chevre/factory": "4.329.0-alpha.3",
|
|
13
13
|
"@cinerino/sdk": "3.166.0-alpha.5",
|
|
14
14
|
"@motionpicture/coa-service": "9.2.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.2.0",
|
|
@@ -117,5 +117,5 @@
|
|
|
117
117
|
"postversion": "git push origin --tags",
|
|
118
118
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
119
119
|
},
|
|
120
|
-
"version": "21.8.0-alpha.
|
|
120
|
+
"version": "21.8.0-alpha.26"
|
|
121
121
|
}
|