@chevre/domain 24.0.0-alpha.50 → 24.0.0-alpha.53
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/paymentService.d.ts +2 -2
- package/lib/chevre/repo/reservation.d.ts +3 -0
- package/lib/chevre/repo/reservation.js +22 -24
- package/lib/chevre/service/assetTransaction/pay/publishPaymentUrl.d.ts +2 -0
- package/lib/chevre/service/assetTransaction/pay/start/preStart/validateAcceptedPaymentMethodIfNeeded.d.ts +4 -7
- package/lib/chevre/service/assetTransaction/pay/start/preStart/validateAcceptedPaymentMethodIfNeeded.js +257 -36
- package/lib/chevre/service/assetTransaction/pay/start.d.ts +2 -0
- package/lib/chevre/service/payment/any/authorize.d.ts +2 -0
- package/lib/chevre/service/payment/any/publishPaymentUrl.d.ts +2 -0
- package/lib/chevre/service/task/authorizePayment.js +2 -0
- package/lib/chevre/service/task/publishPaymentUrl.js +2 -0
- package/package.json +2 -2
|
@@ -51,7 +51,7 @@ export declare class PaymentServiceRepo {
|
|
|
51
51
|
* payment service ID
|
|
52
52
|
*/
|
|
53
53
|
id: string;
|
|
54
|
-
}): Promise<Pick<factory.service.paymentService.
|
|
54
|
+
}): Promise<Pick<factory.service.paymentService.IAvailableChannelCreditCard, 'totalPaymentDue' | 'typeOf' | 'id'> & Pick<factory.serviceChannel.IServiceChannel, 'serviceUrl'> & {
|
|
55
55
|
id: string;
|
|
56
56
|
credentials: factory.serviceChannel.ICredentialsCreditCard;
|
|
57
57
|
}>;
|
|
@@ -63,7 +63,7 @@ export declare class PaymentServiceRepo {
|
|
|
63
63
|
* payment service ID
|
|
64
64
|
*/
|
|
65
65
|
id: string;
|
|
66
|
-
}): Promise<Pick<factory.service.paymentService.
|
|
66
|
+
}): Promise<Pick<factory.service.paymentService.IAvailableChannelMovieTicket, 'totalPaymentDue' | 'typeOf' | 'id'> & Pick<factory.serviceChannel.IServiceChannel, 'serviceUrl'> & {
|
|
67
67
|
id: string;
|
|
68
68
|
credentials: factory.serviceChannel.ICredentialsMovieTicket;
|
|
69
69
|
}>;
|
|
@@ -7,6 +7,9 @@ export interface IUpdatePartiallyParams {
|
|
|
7
7
|
}
|
|
8
8
|
export type ICancelResult = UpdateWriteOpResult;
|
|
9
9
|
export type ICheckedInResult = UpdateWriteOpResult;
|
|
10
|
+
/**
|
|
11
|
+
* ドキュメントとして保管する予約
|
|
12
|
+
*/
|
|
10
13
|
export type ICreatingReservation = Omit<factory.reservation.eventReservation.IReservation, 'id' | 'price' | 'reservedTicket'> & {
|
|
11
14
|
_id: string;
|
|
12
15
|
/**
|
|
@@ -28,6 +28,7 @@ const reservation_1 = require("./mongoose/schemas/reservation");
|
|
|
28
28
|
const factory = __importStar(require("../factory"));
|
|
29
29
|
const createMongoConditions_1 = require("./factory/reservation/createMongoConditions");
|
|
30
30
|
const settings_1 = require("../settings");
|
|
31
|
+
const USE_DISCONTINUED_RESERVATION_PRICE = process.env.USE_DISCONTINUED_RESERVATION_PRICE === '1';
|
|
31
32
|
/**
|
|
32
33
|
* 予約リポジトリ
|
|
33
34
|
*/
|
|
@@ -136,30 +137,27 @@ class ReservationRepo {
|
|
|
136
137
|
const bulkWriteOps = [];
|
|
137
138
|
if (Array.isArray(params.subReservation)) {
|
|
138
139
|
params.subReservation.forEach((subReservation) => {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
default:
|
|
161
|
-
throw new factory.errors.NotImplemented(`${subReservation.typeOf} not implemented`);
|
|
162
|
-
}
|
|
140
|
+
const { price, reservedTicket, ...subReservationWithoutPrice } = subReservation;
|
|
141
|
+
// const { ticketType, ...reservedTicketWithoutTicketType } = reservedTicket;
|
|
142
|
+
const setOnInsert = {
|
|
143
|
+
...subReservationWithoutPrice,
|
|
144
|
+
typeOf: factory.reservationType.EventReservation,
|
|
145
|
+
_id: subReservation.id,
|
|
146
|
+
bookingTime: params.bookingTime,
|
|
147
|
+
checkedIn: false,
|
|
148
|
+
attended: false,
|
|
149
|
+
issuedThrough: params.issuedThrough,
|
|
150
|
+
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
151
|
+
reservationFor: params.reservationFor,
|
|
152
|
+
reservationNumber: params.reservationNumber,
|
|
153
|
+
reservationStatus: factory.reservationStatusType.ReservationConfirmed,
|
|
154
|
+
modifiedTime,
|
|
155
|
+
provider: params.provider,
|
|
156
|
+
reservedTicket,
|
|
157
|
+
...(params.underName !== undefined) ? { underName: params.underName } : undefined,
|
|
158
|
+
...(typeof params.broker?.typeOf === 'string') ? { broker: params.broker } : undefined,
|
|
159
|
+
...((USE_DISCONTINUED_RESERVATION_PRICE) && { price }) // discontinue price(2026-03-31~)
|
|
160
|
+
};
|
|
163
161
|
bulkWriteOps.push({
|
|
164
162
|
updateOne: {
|
|
165
163
|
filter: { _id: { $eq: subReservation.id } },
|
|
@@ -5,6 +5,7 @@ import type { AcceptPayActionRepo } from '../../../repo/action/acceptPay';
|
|
|
5
5
|
import type { AuthorizeInvoiceActionRepo } from '../../../repo/action/authorizeInvoice';
|
|
6
6
|
import type { EventRepo } from '../../../repo/event';
|
|
7
7
|
import type { EventSeriesRepo } from '../../../repo/eventSeries';
|
|
8
|
+
import type { IssuerRepo } from '../../../repo/issuer';
|
|
8
9
|
import type { PaymentServiceRepo } from '../../../repo/paymentService';
|
|
9
10
|
import type { PaymentServiceProviderRepo } from '../../../repo/paymentServiceProvider';
|
|
10
11
|
import type { SellerPaymentAcceptedRepo } from '../../../repo/sellerPaymentAccepted';
|
|
@@ -15,6 +16,7 @@ export interface IPublishPaymentUrlRepos {
|
|
|
15
16
|
acceptPayAction: AcceptPayActionRepo;
|
|
16
17
|
event: EventRepo;
|
|
17
18
|
eventSeries: EventSeriesRepo;
|
|
19
|
+
issuer: IssuerRepo;
|
|
18
20
|
paymentAccepted: SellerPaymentAcceptedRepo;
|
|
19
21
|
paymentService: PaymentServiceRepo;
|
|
20
22
|
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
@@ -2,20 +2,17 @@ import * as factory from '../../../../../factory';
|
|
|
2
2
|
import type { AcceptedPaymentMethodRepo } from '../../../../../repo/acceptedPaymentMethod';
|
|
3
3
|
import type { EventRepo } from '../../../../../repo/event';
|
|
4
4
|
import type { EventSeriesRepo } from '../../../../../repo/eventSeries';
|
|
5
|
+
import type { IssuerRepo } from '../../../../../repo/issuer';
|
|
6
|
+
import type { PaymentServiceRepo } from '../../../../../repo/paymentService';
|
|
5
7
|
/**
|
|
6
8
|
* 必要あらば関連リソースの対応決済方法を検証する
|
|
7
9
|
*/
|
|
8
10
|
export declare function validateAcceptedPaymentMethodIfNeeded(params: Pick<factory.assetTransaction.pay.IStartParamsWithoutDetail, 'object'> & {
|
|
9
11
|
instrument: factory.action.trade.pay.IPlaceOrderRelatedInstrument[];
|
|
10
|
-
} | {
|
|
11
|
-
object: factory.action.accept.pay.IPayObject & {
|
|
12
|
-
paymentMethod: factory.action.accept.pay.IPaymentMethod & {
|
|
13
|
-
movieTickets: never;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
instrument: factory.action.accept.pay.IInstrument[];
|
|
17
12
|
}): (repos: {
|
|
18
13
|
acceptedPaymentMethod: AcceptedPaymentMethodRepo;
|
|
19
14
|
event: EventRepo;
|
|
20
15
|
eventSeries: EventSeriesRepo;
|
|
16
|
+
issuer: IssuerRepo;
|
|
17
|
+
paymentService: PaymentServiceRepo;
|
|
21
18
|
}) => Promise<void>;
|
|
@@ -28,18 +28,29 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.validateAcceptedPaymentMethodIfNeeded = validateAcceptedPaymentMethodIfNeeded;
|
|
30
30
|
const debug_1 = __importDefault(require("debug"));
|
|
31
|
+
// import * as jwt from 'jsonwebtoken';
|
|
31
32
|
const factory = __importStar(require("../../../../../factory"));
|
|
32
33
|
const debug = (0, debug_1.default)('chevre-domain:service:assetTransaction:pay');
|
|
33
34
|
/**
|
|
34
35
|
* 必要あらば関連リソースの対応決済方法を検証する
|
|
35
36
|
*/
|
|
36
|
-
function validateAcceptedPaymentMethodIfNeeded(params
|
|
37
|
+
function validateAcceptedPaymentMethodIfNeeded(params
|
|
38
|
+
// | {
|
|
39
|
+
// object: factory.action.accept.pay.IPayObject & {
|
|
40
|
+
// paymentMethod: factory.action.accept.pay.IPaymentMethod & {
|
|
41
|
+
// movieTickets: never;
|
|
42
|
+
// };
|
|
43
|
+
// };
|
|
44
|
+
// instrument: factory.action.accept.pay.IInstrument[];
|
|
45
|
+
// }
|
|
46
|
+
) {
|
|
37
47
|
return async (repos) => {
|
|
38
48
|
const now = new Date();
|
|
39
49
|
/**
|
|
40
50
|
* 検証対象のイベントIDリスト
|
|
41
51
|
*/
|
|
42
52
|
let checkingEventIds;
|
|
53
|
+
let paymentService;
|
|
43
54
|
const paymentServiceType = params.object.typeOf;
|
|
44
55
|
const paymentServiceId = params.object.id;
|
|
45
56
|
// CreditCard or MovieTicket?
|
|
@@ -49,6 +60,16 @@ function validateAcceptedPaymentMethodIfNeeded(params) {
|
|
|
49
60
|
if (Array.isArray(orderedItems)) {
|
|
50
61
|
checkingEventIds = orderedItems.map((orderedItem) => orderedItem.orderedItem.serviceOutput.reservationFor.id);
|
|
51
62
|
}
|
|
63
|
+
paymentService = (await repos.paymentService.projectFields({
|
|
64
|
+
limit: 1,
|
|
65
|
+
page: 1,
|
|
66
|
+
// project: { id: { $eq: params.project.id } },
|
|
67
|
+
typeOf: { $eq: paymentServiceType },
|
|
68
|
+
id: { $eq: paymentServiceId }
|
|
69
|
+
}, ['availableChannel', 'serviceType'])).shift();
|
|
70
|
+
if (paymentService === undefined) {
|
|
71
|
+
throw new factory.errors.NotFound(factory.service.paymentService.PaymentServiceType.CreditCard);
|
|
72
|
+
}
|
|
52
73
|
}
|
|
53
74
|
else if (paymentServiceType === factory.service.paymentService.PaymentServiceType.MovieTicket) {
|
|
54
75
|
const movieTickets = params.object.paymentMethod.movieTickets;
|
|
@@ -59,6 +80,16 @@ function validateAcceptedPaymentMethodIfNeeded(params) {
|
|
|
59
80
|
throw new factory.errors.Argument('movieTickets', 'Number of events must be 1');
|
|
60
81
|
}
|
|
61
82
|
}
|
|
83
|
+
paymentService = (await repos.paymentService.projectFields({
|
|
84
|
+
limit: 1,
|
|
85
|
+
page: 1,
|
|
86
|
+
// project: { id: { $eq: params.project.id } },
|
|
87
|
+
typeOf: { $eq: paymentServiceType },
|
|
88
|
+
id: { $eq: paymentServiceId }
|
|
89
|
+
}, ['availableChannel', 'serviceType'])).shift();
|
|
90
|
+
if (paymentService === undefined) {
|
|
91
|
+
throw new factory.errors.NotFound(factory.service.paymentService.PaymentServiceType.MovieTicket);
|
|
92
|
+
}
|
|
62
93
|
}
|
|
63
94
|
else {
|
|
64
95
|
// 対面決済ではひとまず対応決済方法検証なし
|
|
@@ -81,47 +112,237 @@ function validateAcceptedPaymentMethodIfNeeded(params) {
|
|
|
81
112
|
}
|
|
82
113
|
const uniqueEventSeriesIds = [...new Set(eventSeriesIds)];
|
|
83
114
|
debug('validateAcceptedPaymentMethodIfNeeded: eventSeries with AggregateOffer?', uniqueEventSeriesIds);
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
// 対応決済方法オファーIDの指定が必要
|
|
95
|
-
const acceptedPaymentMethodOfferIds = [];
|
|
96
|
-
params.instrument.forEach((instrument) => {
|
|
97
|
-
if (instrument.typeOf === factory.offerType.Offer) {
|
|
98
|
-
acceptedPaymentMethodOfferIds.push(instrument.id);
|
|
99
|
-
}
|
|
115
|
+
// 決済方法に設定されたカスタム検証URLに依存する場合はこちら↓
|
|
116
|
+
if (paymentService !== undefined) {
|
|
117
|
+
const customValidationUrl = paymentService.availableChannel?.customValidationUrl;
|
|
118
|
+
if (typeof customValidationUrl === 'string' && customValidationUrl !== '') {
|
|
119
|
+
await validateByCustomUrl({
|
|
120
|
+
customValidationUrl,
|
|
121
|
+
eventSeriesIds: uniqueEventSeriesIds,
|
|
122
|
+
paymentMethodType: paymentService.serviceType.codeValue,
|
|
123
|
+
// amount: number,
|
|
124
|
+
now
|
|
100
125
|
});
|
|
101
|
-
if (acceptedPaymentMethodOfferIds.length === 0) {
|
|
102
|
-
throw new factory.errors.ArgumentNull('acceptedPaymentMethodOfferIds');
|
|
103
|
-
}
|
|
104
|
-
// 全施設コンテンツについて有効な対応決済方法オファーの存在を検証
|
|
105
|
-
const validAcceptedPaymentMethodOffer = (await repos.acceptedPaymentMethod.findAcceptedPaymentMethods({
|
|
106
|
-
limit: 1,
|
|
107
|
-
page: 1,
|
|
108
|
-
id: { $in: acceptedPaymentMethodOfferIds }, // 指定されたIDで
|
|
109
|
-
itemOffered: { id: { $eq: eventSeriesId } }, // リソースに対して
|
|
110
|
-
acceptedPaymentMethod: { id: { $eq: paymentServiceId } }, // 決済方法を許可
|
|
111
|
-
validFrom: { $lte: now }, // 現在有効
|
|
112
|
-
validThrough: { $gte: now } // 現在有効
|
|
113
|
-
}, ['identifier'])).shift();
|
|
114
|
-
if (validAcceptedPaymentMethodOffer === undefined) {
|
|
115
|
-
throw new factory.errors.NotFound(factory.offerType.Offer, `payment not accepted. eventSeriesId: ${eventSeriesId}`);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
// 集約オファーでなければ検証の必要なし
|
|
120
126
|
}
|
|
121
127
|
}
|
|
128
|
+
// トークンで検証する場合はこち↓
|
|
129
|
+
// // 指定された全トークンを抽出
|
|
130
|
+
// const acceptedPaymentMethodOfferTokens: string[] = [];
|
|
131
|
+
// params.instrument.forEach((instrument) => {
|
|
132
|
+
// if (instrument.typeOf === factory.offerType.Offer) {
|
|
133
|
+
// acceptedPaymentMethodOfferTokens.push(instrument.id);
|
|
134
|
+
// }
|
|
135
|
+
// });
|
|
136
|
+
// await validateAllItemTokens(
|
|
137
|
+
// paymentServiceId,
|
|
138
|
+
// uniqueEventSeriesIds,
|
|
139
|
+
// acceptedPaymentMethodOfferTokens,
|
|
140
|
+
// now
|
|
141
|
+
// )(repos);
|
|
122
142
|
}
|
|
123
143
|
else {
|
|
124
144
|
// 関連注文の指定がなければ検証の必要なし
|
|
125
145
|
}
|
|
126
146
|
};
|
|
127
147
|
}
|
|
148
|
+
const TIMEOUT = 2000;
|
|
149
|
+
// interface ICustomValidationResponse {
|
|
150
|
+
// isAllowed: boolean;
|
|
151
|
+
// };
|
|
152
|
+
async function validateByCustomUrl(params) {
|
|
153
|
+
try {
|
|
154
|
+
// 判定エンジンへのリクエスト
|
|
155
|
+
const validationRequest = {
|
|
156
|
+
eventSeriesIds: params.eventSeriesIds,
|
|
157
|
+
paymentMethodType: params.paymentMethodType,
|
|
158
|
+
// amount: params.amount
|
|
159
|
+
};
|
|
160
|
+
const res = await fetch(params.customValidationUrl, {
|
|
161
|
+
method: 'POST',
|
|
162
|
+
headers: { 'Content-Type': 'application/json' },
|
|
163
|
+
body: JSON.stringify(validationRequest),
|
|
164
|
+
// body data type must match "Content-Type" header
|
|
165
|
+
signal: AbortSignal.timeout(TIMEOUT)
|
|
166
|
+
});
|
|
167
|
+
if (!res.ok) {
|
|
168
|
+
throw new factory.errors.Argument('paymentMethod', `paymentMethod denied by the customValidation. statusCode: ${res.status}`);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
// ネットワークエラーやタイムアウト時のハンドリング
|
|
173
|
+
// サービス継続を優先するか、安全側に倒してエラーにするかはポリシー次第
|
|
174
|
+
debug('Custom validation failed:', error.message);
|
|
175
|
+
throw error;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
// /**
|
|
179
|
+
// * トークンのペイロード構造
|
|
180
|
+
// */
|
|
181
|
+
// interface IPaymentOfferPayload extends Pick<factory.acceptedPaymentMethodOffer.IAcceptedPaymentMethodOffer, 'acceptedPaymentMethod' | 'itemOffered' | 'validFrom' | 'validThrough'> {
|
|
182
|
+
// iss: string;
|
|
183
|
+
// // sub: string; // 商品ID
|
|
184
|
+
// // paymentOffer: {
|
|
185
|
+
// // allowedMethods: string[];
|
|
186
|
+
// // limitAmount: number;
|
|
187
|
+
// // currency: string;
|
|
188
|
+
// // };
|
|
189
|
+
// }
|
|
190
|
+
// async function verifyOfferToken(params: {
|
|
191
|
+
// token: string;
|
|
192
|
+
// secret: string;
|
|
193
|
+
// issuer?: string;
|
|
194
|
+
// }): Promise<IPaymentOfferPayload> {
|
|
195
|
+
// let result: IPaymentOfferPayload;
|
|
196
|
+
// const { issuer, secret, token } = params;
|
|
197
|
+
// try {
|
|
198
|
+
// result = await new Promise<IPaymentOfferPayload>((resolve, reject) => {
|
|
199
|
+
// jwt.verify(
|
|
200
|
+
// token,
|
|
201
|
+
// secret,
|
|
202
|
+
// {
|
|
203
|
+
// algorithms: ['HS256'],
|
|
204
|
+
// issuer
|
|
205
|
+
// // ...(Array.isArray(params.audience)) ? { audience: params.audience } : undefined
|
|
206
|
+
// },
|
|
207
|
+
// (err, decoded: any) => {
|
|
208
|
+
// if (err instanceof Error) {
|
|
209
|
+
// reject(err);
|
|
210
|
+
// } else {
|
|
211
|
+
// resolve(decoded);
|
|
212
|
+
// }
|
|
213
|
+
// });
|
|
214
|
+
// });
|
|
215
|
+
// } catch (error) {
|
|
216
|
+
// // JWTエラーをハンドリング
|
|
217
|
+
// if (error instanceof jwt.TokenExpiredError) {
|
|
218
|
+
// throw new factory.errors.Argument('token', `invalid token. [${error.message} expiredAt:${error.expiredAt}]`);
|
|
219
|
+
// } else if (error instanceof jwt.JsonWebTokenError) {
|
|
220
|
+
// throw new factory.errors.Argument('token', `invalid token. [${error.message}]`);
|
|
221
|
+
// }
|
|
222
|
+
// throw error;
|
|
223
|
+
// }
|
|
224
|
+
// return result;
|
|
225
|
+
// }
|
|
226
|
+
// /**
|
|
227
|
+
// * 複数アイテムのトークン検証メイン関数
|
|
228
|
+
// */
|
|
229
|
+
// function validateAllItemTokens(
|
|
230
|
+
// selectedMethodId: string, // ユーザーが選択した決済方法ID
|
|
231
|
+
// eventSeriesIds: string[], // DBから取得した注文商品リスト
|
|
232
|
+
// providedTokens: string[], // クライアントから送られたJWT配列
|
|
233
|
+
// now: Date
|
|
234
|
+
// ) {
|
|
235
|
+
// return async (repos: {
|
|
236
|
+
// eventSeries: EventSeriesRepo;
|
|
237
|
+
// issuer: IssuerRepo;
|
|
238
|
+
// }) => {
|
|
239
|
+
// // 1. トークンをデコードして、商品ID(sub)をキーにしたマップを作成
|
|
240
|
+
// // ※ここでは署名検証前なので、decodeのみ行う
|
|
241
|
+
// const tokenMap = new Map<string, string>();
|
|
242
|
+
// providedTokens.forEach(t => {
|
|
243
|
+
// try {
|
|
244
|
+
// const decoded = jwt.decode(t) as IPaymentOfferPayload;
|
|
245
|
+
// if (decoded && typeof decoded.itemOffered?.id === 'string') {
|
|
246
|
+
// tokenMap.set(decoded.itemOffered.id, t);
|
|
247
|
+
// }
|
|
248
|
+
// } catch {
|
|
249
|
+
// // no op
|
|
250
|
+
// }
|
|
251
|
+
// });
|
|
252
|
+
// // 2. 全アイテムについてループを回して検証
|
|
253
|
+
// for (const eventSeriesId of eventSeriesIds) {
|
|
254
|
+
// const eventSeries = (await repos.eventSeries.projectEventSeriesFields(
|
|
255
|
+
// {
|
|
256
|
+
// limit: 1,
|
|
257
|
+
// page: 1,
|
|
258
|
+
// id: { $eq: eventSeriesId }
|
|
259
|
+
// },
|
|
260
|
+
// ['offers', 'project']
|
|
261
|
+
// )).shift();
|
|
262
|
+
// if (eventSeries === undefined) {
|
|
263
|
+
// throw new factory.errors.NotFound(factory.eventType.ScreeningEventSeries);
|
|
264
|
+
// }
|
|
265
|
+
// if (eventSeries.offers?.typeOf === factory.offerType.AggregateOffer) {
|
|
266
|
+
// // // 対応決済方法オファーIDの指定が必要
|
|
267
|
+
// // const acceptedPaymentMethodOfferTokens: string[] = [];
|
|
268
|
+
// // // const acceptedPaymentMethodOfferIds: string[] = [];
|
|
269
|
+
// // params.instrument.forEach((instrument) => {
|
|
270
|
+
// // if (instrument.typeOf === factory.offerType.Offer) {
|
|
271
|
+
// // acceptedPaymentMethodOfferTokens.push(instrument.id);
|
|
272
|
+
// // // acceptedPaymentMethodOfferIds.push(instrument.id);
|
|
273
|
+
// // }
|
|
274
|
+
// // });
|
|
275
|
+
// // if (acceptedPaymentMethodOfferTokens.length === 0) {
|
|
276
|
+
// // throw new factory.errors.ArgumentNull('acceptedPaymentMethodOfferTokens');
|
|
277
|
+
// // }
|
|
278
|
+
// // // if (acceptedPaymentMethodOfferIds.length === 0) {
|
|
279
|
+
// // // throw new factory.errors.ArgumentNull('acceptedPaymentMethodOfferIds');
|
|
280
|
+
// // // }
|
|
281
|
+
// const token = tokenMap.get(eventSeriesId);
|
|
282
|
+
// if (!token) {
|
|
283
|
+
// // throw new Error(`商品[${eventSeriesId}]の決済許可トークンが不足しています。`);
|
|
284
|
+
// throw new factory.errors.ArgumentNull(
|
|
285
|
+
// factory.offerType.Offer,
|
|
286
|
+
// `token required. eventSeriesId: ${eventSeriesId}`
|
|
287
|
+
// );
|
|
288
|
+
// }
|
|
289
|
+
// console.log('check token...:', token);
|
|
290
|
+
// // 3. 既存の「発行者管理」から公開鍵を取得
|
|
291
|
+
// const issuerCode = 'DefaultTokenIssuer';
|
|
292
|
+
// const issuer = await repos.issuer.findByIdentifier({
|
|
293
|
+
// project: { id: eventSeries.project.id },
|
|
294
|
+
// identifier: issuerCode
|
|
295
|
+
// });
|
|
296
|
+
// if (typeof issuer.tokenSecret !== 'string' || issuer.tokenSecret === '') {
|
|
297
|
+
// throw new factory.errors.NotFound('issuer.tokenSecret');
|
|
298
|
+
// }
|
|
299
|
+
// const verifiedOffer = await verifyOfferToken({
|
|
300
|
+
// secret: issuer.tokenSecret,
|
|
301
|
+
// issuer: issuer.url,
|
|
302
|
+
// token
|
|
303
|
+
// });
|
|
304
|
+
// // 5. ビジネスルールの厳密な検証
|
|
305
|
+
// // (a) トークン内の商品IDが、現在のアイテムと一致するか(すり替え防止)
|
|
306
|
+
// if (verifiedOffer.itemOffered.id !== eventSeriesId) {
|
|
307
|
+
// throw new factory.errors.Argument('token', `invalid token. [itemOffered.id not matched]`);
|
|
308
|
+
// }
|
|
309
|
+
// // (b) 選択された決済方法が、この商品の許可リストに含まれているか
|
|
310
|
+
// if (verifiedOffer.acceptedPaymentMethod.id !== selectedMethodId) {
|
|
311
|
+
// throw new factory.errors.NotFound(
|
|
312
|
+
// factory.offerType.Offer,
|
|
313
|
+
// `payment not accepted. eventSeriesId: ${eventSeriesId}`
|
|
314
|
+
// );
|
|
315
|
+
// }
|
|
316
|
+
// // // (c) 金額の検証(判定時より金額が上がっていないか)
|
|
317
|
+
// // if (item.amount > payload.paymentOffer.limitAmount) {
|
|
318
|
+
// // throw new Error(`商品[${item.productId}]の金額が承認された上限を超えています。`);
|
|
319
|
+
// // }
|
|
320
|
+
// // 現在有効検証
|
|
321
|
+
// console.log('check validFrom?:', now);
|
|
322
|
+
// // // 全施設コンテンツについて有効な対応決済方法オファーの存在を検証
|
|
323
|
+
// // const validAcceptedPaymentMethodOffer = (await repos.acceptedPaymentMethod.findAcceptedPaymentMethods(
|
|
324
|
+
// // {
|
|
325
|
+
// // limit: 1,
|
|
326
|
+
// // page: 1,
|
|
327
|
+
// // id: { $in: acceptedPaymentMethodOfferIds }, // 指定されたIDで
|
|
328
|
+
// // itemOffered: { id: { $eq: eventSeriesId } }, // リソースに対して
|
|
329
|
+
// // acceptedPaymentMethod: { id: { $eq: paymentServiceId } }, // 決済方法を許可
|
|
330
|
+
// // validFrom: { $lte: now }, // 現在有効
|
|
331
|
+
// // validThrough: { $gte: now } // 現在有効
|
|
332
|
+
// // },
|
|
333
|
+
// // ['identifier']
|
|
334
|
+
// // )).shift();
|
|
335
|
+
// // if (validAcceptedPaymentMethodOffer === undefined) {
|
|
336
|
+
// // throw new factory.errors.NotFound(
|
|
337
|
+
// // factory.offerType.Offer,
|
|
338
|
+
// // `payment not accepted. eventSeriesId: ${eventSeriesId}`
|
|
339
|
+
// // );
|
|
340
|
+
// // }
|
|
341
|
+
// } else {
|
|
342
|
+
// // 集約オファーでなければ検証の必要なし
|
|
343
|
+
// }
|
|
344
|
+
// }
|
|
345
|
+
// // 全てのアイテムで検証が通れば true
|
|
346
|
+
// return true;
|
|
347
|
+
// }
|
|
348
|
+
// }
|
|
@@ -10,6 +10,7 @@ import type { AssetTransactionRepo } from '../../../repo/assetTransaction';
|
|
|
10
10
|
import type { CredentialsRepo } from '../../../repo/credentials';
|
|
11
11
|
import type { EventRepo } from '../../../repo/event';
|
|
12
12
|
import type { EventSeriesRepo } from '../../../repo/eventSeries';
|
|
13
|
+
import type { IssuerRepo } from '../../../repo/issuer';
|
|
13
14
|
import type { PaymentServiceRepo } from '../../../repo/paymentService';
|
|
14
15
|
import type { PaymentServiceProviderRepo } from '../../../repo/paymentServiceProvider';
|
|
15
16
|
import type { PotentialActionRepo } from '../../../repo/potentialAction';
|
|
@@ -29,6 +30,7 @@ export interface IStartOperationRepos {
|
|
|
29
30
|
authorizeInvoiceAction: AuthorizeInvoiceActionRepo;
|
|
30
31
|
credentials: CredentialsRepo;
|
|
31
32
|
event: EventRepo;
|
|
33
|
+
issuer: IssuerRepo;
|
|
32
34
|
eventSeries: EventSeriesRepo;
|
|
33
35
|
paymentAccepted: SellerPaymentAcceptedRepo;
|
|
34
36
|
paymentService: PaymentServiceRepo;
|
|
@@ -14,6 +14,7 @@ import type { ConfirmationNumberRepo } from '../../../repo/confirmationNumber';
|
|
|
14
14
|
import type { CredentialsRepo } from '../../../repo/credentials';
|
|
15
15
|
import type { EventRepo } from '../../../repo/event';
|
|
16
16
|
import type { EventSeriesRepo } from '../../../repo/eventSeries';
|
|
17
|
+
import type { IssuerRepo } from '../../../repo/issuer';
|
|
17
18
|
import type { OrderNumberRepo } from '../../../repo/orderNumber';
|
|
18
19
|
import type { PaymentServiceRepo } from '../../../repo/paymentService';
|
|
19
20
|
import type { PaymentServiceProviderRepo } from '../../../repo/paymentServiceProvider';
|
|
@@ -43,6 +44,7 @@ interface IAuthorizeRepos {
|
|
|
43
44
|
credentials: CredentialsRepo;
|
|
44
45
|
event: EventRepo;
|
|
45
46
|
eventSeries: EventSeriesRepo;
|
|
47
|
+
issuer: IssuerRepo;
|
|
46
48
|
orderNumber: OrderNumberRepo;
|
|
47
49
|
paymentAccepted: SellerPaymentAcceptedRepo;
|
|
48
50
|
paymentService: PaymentServiceRepo;
|
|
@@ -7,6 +7,7 @@ import type { AssetTransactionRepo } from '../../../repo/assetTransaction';
|
|
|
7
7
|
import type { AuthorizationRepo } from '../../../repo/authorization';
|
|
8
8
|
import type { EventRepo } from '../../../repo/event';
|
|
9
9
|
import type { EventSeriesRepo } from '../../../repo/eventSeries';
|
|
10
|
+
import type { IssuerRepo } from '../../../repo/issuer';
|
|
10
11
|
import type { OrderNumberRepo } from '../../../repo/orderNumber';
|
|
11
12
|
import type { PaymentServiceRepo } from '../../../repo/paymentService';
|
|
12
13
|
import type { PaymentServiceProviderRepo } from '../../../repo/paymentServiceProvider';
|
|
@@ -24,6 +25,7 @@ interface IPublishPaymentUrlRepos {
|
|
|
24
25
|
authorization: AuthorizationRepo;
|
|
25
26
|
event: EventRepo;
|
|
26
27
|
eventSeries: EventSeriesRepo;
|
|
28
|
+
issuer: IssuerRepo;
|
|
27
29
|
orderNumber: OrderNumberRepo;
|
|
28
30
|
paymentAccepted: SellerPaymentAcceptedRepo;
|
|
29
31
|
paymentService: PaymentServiceRepo;
|
|
@@ -40,6 +40,7 @@ const confirmationNumber_1 = require("../../repo/confirmationNumber");
|
|
|
40
40
|
const credentials_1 = require("../../repo/credentials");
|
|
41
41
|
const event_1 = require("../../repo/event");
|
|
42
42
|
const eventSeries_1 = require("../../repo/eventSeries");
|
|
43
|
+
const issuer_1 = require("../../repo/issuer");
|
|
43
44
|
const orderNumber_1 = require("../../repo/orderNumber");
|
|
44
45
|
const paymentService_1 = require("../../repo/paymentService");
|
|
45
46
|
const paymentServiceProvider_1 = require("../../repo/paymentServiceProvider");
|
|
@@ -100,6 +101,7 @@ function call(params) {
|
|
|
100
101
|
}),
|
|
101
102
|
event: new event_1.EventRepo(connection),
|
|
102
103
|
eventSeries: new eventSeries_1.EventSeriesRepo(connection),
|
|
104
|
+
issuer: new issuer_1.IssuerRepo(connection),
|
|
103
105
|
orderNumber: new orderNumber_1.OrderNumberRepo({ connection }),
|
|
104
106
|
paymentAccepted: new sellerPaymentAccepted_1.SellerPaymentAcceptedRepo(connection),
|
|
105
107
|
paymentService: new paymentService_1.PaymentServiceRepo(connection),
|
|
@@ -33,6 +33,7 @@ const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
|
33
33
|
const authorization_1 = require("../../repo/authorization");
|
|
34
34
|
const event_1 = require("../../repo/event");
|
|
35
35
|
const eventSeries_1 = require("../../repo/eventSeries");
|
|
36
|
+
const issuer_1 = require("../../repo/issuer");
|
|
36
37
|
const orderNumber_1 = require("../../repo/orderNumber");
|
|
37
38
|
const paymentService_1 = require("../../repo/paymentService");
|
|
38
39
|
const paymentServiceProvider_1 = require("../../repo/paymentServiceProvider");
|
|
@@ -72,6 +73,7 @@ function call(params) {
|
|
|
72
73
|
authorization: new authorization_1.AuthorizationRepo(connection),
|
|
73
74
|
event: new event_1.EventRepo(connection),
|
|
74
75
|
eventSeries: new eventSeries_1.EventSeriesRepo(connection),
|
|
76
|
+
issuer: new issuer_1.IssuerRepo(connection),
|
|
75
77
|
orderNumber: new orderNumber_1.OrderNumberRepo({ connection }),
|
|
76
78
|
paymentAccepted: new sellerPaymentAccepted_1.SellerPaymentAcceptedRepo(connection),
|
|
77
79
|
paymentService: new paymentService_1.PaymentServiceRepo(connection),
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/client-cognito-identity-provider": "3.600.0",
|
|
13
13
|
"@aws-sdk/credential-providers": "3.600.0",
|
|
14
|
-
"@chevre/factory": "6.2.0-alpha.
|
|
14
|
+
"@chevre/factory": "6.2.0-alpha.2",
|
|
15
15
|
"@cinerino/sdk": "13.4.0-alpha.0",
|
|
16
16
|
"@motionpicture/coa-service": "9.6.0",
|
|
17
17
|
"@motionpicture/gmo-service": "5.4.0-alpha.1",
|
|
@@ -99,5 +99,5 @@
|
|
|
99
99
|
"postversion": "git push origin --tags",
|
|
100
100
|
"prepublishOnly": "npm run clean && npm run build"
|
|
101
101
|
},
|
|
102
|
-
"version": "24.0.0-alpha.
|
|
102
|
+
"version": "24.0.0-alpha.53"
|
|
103
103
|
}
|