@chevre/domain 22.6.0-alpha.33 → 22.6.0-alpha.35
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.
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as factory from '../../../factory';
|
|
2
2
|
import type { AuthorizationRepo } from '../../../repo/authorization';
|
|
3
3
|
import type { TicketRepo } from '../../../repo/ticket';
|
|
4
|
+
type IPermitOrInvoice = Pick<factory.ownershipInfo.IPermitAsGood, 'identifier' | 'typeOf'> | Pick<factory.invoice.IInvoice, 'paymentMethodId' | 'typeOf'>;
|
|
4
5
|
declare function verifyTicketTokenAsNeeded(params: {
|
|
5
6
|
project: {
|
|
6
7
|
id: string;
|
|
@@ -12,6 +13,6 @@ declare function verifyTicketTokenAsNeeded(params: {
|
|
|
12
13
|
authorization: AuthorizationRepo;
|
|
13
14
|
ticket: TicketRepo;
|
|
14
15
|
}) => Promise<{
|
|
15
|
-
|
|
16
|
+
permitOrInvoice?: IPermitOrInvoice | undefined;
|
|
16
17
|
}>;
|
|
17
18
|
export { verifyTicketTokenAsNeeded };
|
|
@@ -16,11 +16,12 @@ function verifyTicketTokenAsNeeded(params) {
|
|
|
16
16
|
var _a, _b;
|
|
17
17
|
const { paymentServiceType, object, project } = params;
|
|
18
18
|
const { issuedThrough, ticketToken } = object;
|
|
19
|
-
let
|
|
19
|
+
let permitOrInvoice;
|
|
20
20
|
// メンバーシップチケットが指定された場合、メンバーシップコードへ変換する
|
|
21
21
|
if (typeof ticketToken === 'string' && ticketToken !== '') {
|
|
22
22
|
switch (paymentServiceType) {
|
|
23
23
|
case factory.service.paymentService.PaymentServiceType.CreditCard:
|
|
24
|
+
case factory.service.paymentService.PaymentServiceType.MovieTicket:
|
|
24
25
|
case factory.service.paymentService.PaymentServiceType.FaceToFace:
|
|
25
26
|
const ticket = (yield repos.ticket.projectFields({
|
|
26
27
|
limit: 1,
|
|
@@ -37,35 +38,43 @@ function verifyTicketTokenAsNeeded(params) {
|
|
|
37
38
|
code: ticket.ticketToken
|
|
38
39
|
});
|
|
39
40
|
const authorizedObject = validAuthorization.object;
|
|
40
|
-
if (authorizedObject.typeOf !== 'OwnershipInfo') {
|
|
41
|
-
throw new factory.errors.Argument('ticketToken', 'must be OwnershipInfo');
|
|
42
|
-
}
|
|
43
41
|
// audience検証
|
|
44
42
|
if (((_a = validAuthorization.audience) === null || _a === void 0 ? void 0 : _a.typeOf) !== factory.transactionType.PlaceOrder
|
|
45
43
|
|| validAuthorization.audience.id !== params.purpose.id) {
|
|
46
44
|
throw new factory.errors.Argument('ticketToken', 'audience not matched with placeOrder');
|
|
47
45
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
throw new factory.errors.Argument('ticketToken', 'issuedThrough.id not matched');
|
|
46
|
+
if (authorizedObject.typeOf === 'OwnershipInfo') {
|
|
47
|
+
const { typeOfGood } = authorizedObject;
|
|
48
|
+
if (((_b = typeOfGood.issuedThrough) === null || _b === void 0 ? void 0 : _b.typeOf) !== paymentServiceType) {
|
|
49
|
+
throw new factory.errors.Argument('ticketToken', 'paymentServiceType not matched');
|
|
50
|
+
}
|
|
51
|
+
// FaceToFace以外の場合、発行サービスIDを検証
|
|
52
|
+
if (typeOfGood.issuedThrough.typeOf !== factory.service.paymentService.PaymentServiceType.FaceToFace) {
|
|
53
|
+
if (typeOfGood.issuedThrough.id !== issuedThrough.id) {
|
|
54
|
+
throw new factory.errors.Argument('ticketToken', 'issuedThrough.id not matched');
|
|
55
|
+
}
|
|
59
56
|
}
|
|
57
|
+
if (typeOfGood.typeOf === factory.permit.PermitType.Permit) {
|
|
58
|
+
permitOrInvoice = { identifier: typeOfGood.identifier, typeOf: factory.permit.PermitType.Permit };
|
|
59
|
+
}
|
|
60
|
+
else if (typeOfGood.typeOf === 'Invoice') {
|
|
61
|
+
// support paymentServiceType.MovieTicket(2024-11-23~)
|
|
62
|
+
permitOrInvoice = { paymentMethodId: typeOfGood.paymentMethodId, typeOf: 'Invoice' };
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
throw new factory.errors.Argument('ticketToken', 'must be Permit or Invoice');
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
throw new factory.errors.Argument('ticketToken', 'must be OwnershipInfo');
|
|
60
70
|
}
|
|
61
|
-
permit = { identifier: typeOfGood.identifier };
|
|
62
71
|
break;
|
|
63
72
|
default:
|
|
64
73
|
// no op
|
|
65
74
|
throw new factory.errors.NotImplemented(`ticketToken issued through ${paymentServiceType} not implemented`);
|
|
66
75
|
}
|
|
67
76
|
}
|
|
68
|
-
return {
|
|
77
|
+
return { permitOrInvoice };
|
|
69
78
|
});
|
|
70
79
|
}
|
|
71
80
|
exports.verifyTicketTokenAsNeeded = verifyTicketTokenAsNeeded;
|
|
@@ -237,10 +237,12 @@ function publishPaymentUrl(params) {
|
|
|
237
237
|
// 取引番号生成
|
|
238
238
|
let transactionNumber;
|
|
239
239
|
// support ticketToken(2024-08-21~)
|
|
240
|
-
const {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
240
|
+
const { permitOrInvoice } = yield (0, verifyTicketTokenAsNeeded_1.verifyTicketTokenAsNeeded)({ project, object: params.object, paymentServiceType, purpose })(repos);
|
|
241
|
+
if ((permitOrInvoice === null || permitOrInvoice === void 0 ? void 0 : permitOrInvoice.typeOf) === factory.permit.PermitType.Permit) {
|
|
242
|
+
const paymentMethodIdByPermit = permitOrInvoice === null || permitOrInvoice === void 0 ? void 0 : permitOrInvoice.identifier;
|
|
243
|
+
if (typeof paymentMethodIdByPermit === 'string') {
|
|
244
|
+
transactionNumber = paymentMethodIdByPermit;
|
|
245
|
+
}
|
|
244
246
|
}
|
|
245
247
|
if (typeof transactionNumber !== 'string') {
|
|
246
248
|
const publishTransactionNumberResult = yield repos.transactionNumber.publishByTimestamp({ startDate: new Date() });
|
|
@@ -324,15 +326,30 @@ function authorize(params) {
|
|
|
324
326
|
let pendingPaymentAgencyTransaction;
|
|
325
327
|
let creditCard = params.object.creditCard;
|
|
326
328
|
// ticketTokenを解釈(2024-08-13~)
|
|
327
|
-
const {
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
329
|
+
const { permitOrInvoice } = yield (0, verifyTicketTokenAsNeeded_1.verifyTicketTokenAsNeeded)({ project, object: params.object, paymentServiceType, purpose })(repos);
|
|
330
|
+
/**
|
|
331
|
+
* ticketTokenによって指定された決済方法ID
|
|
332
|
+
*/
|
|
333
|
+
let paymentMethodIdByTicketToken;
|
|
334
|
+
if ((permitOrInvoice === null || permitOrInvoice === void 0 ? void 0 : permitOrInvoice.typeOf) === factory.permit.PermitType.Permit) {
|
|
335
|
+
paymentMethodIdByTicketToken = permitOrInvoice === null || permitOrInvoice === void 0 ? void 0 : permitOrInvoice.identifier;
|
|
336
|
+
if (typeof paymentMethodIdByTicketToken === 'string') {
|
|
337
|
+
transactionNumber = paymentMethodIdByTicketToken; // メンバーシップ指定の場合、取引番号に適用(2024-08-13~)
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
else if ((permitOrInvoice === null || permitOrInvoice === void 0 ? void 0 : permitOrInvoice.typeOf) === 'Invoice') {
|
|
341
|
+
// support paymentServiceType.MovieTicket(2024-11-23~)
|
|
342
|
+
if (typeof (permitOrInvoice === null || permitOrInvoice === void 0 ? void 0 : permitOrInvoice.paymentMethodId) === 'string') {
|
|
343
|
+
paymentMethodIdByTicketToken = permitOrInvoice === null || permitOrInvoice === void 0 ? void 0 : permitOrInvoice.paymentMethodId;
|
|
344
|
+
if (typeof paymentMethodIdByTicketToken === 'string') {
|
|
345
|
+
transactionNumber = paymentMethodIdByTicketToken;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
331
348
|
}
|
|
332
349
|
// リクエストでpaymentMethodIdを指定された場合、取引に保管されたpaymentMethodIdに一致すればそちらを適用(外部サイト決済対応)
|
|
333
350
|
if (typeof params.object.paymentMethodId === 'string' && params.object.paymentMethodId.length > 0) {
|
|
334
|
-
if (typeof
|
|
335
|
-
if (
|
|
351
|
+
if (typeof paymentMethodIdByTicketToken === 'string') {
|
|
352
|
+
if (paymentMethodIdByTicketToken !== params.object.paymentMethodId) {
|
|
336
353
|
throw new factory.errors.Argument('ticketToken', 'not matched with paymentMethodId');
|
|
337
354
|
}
|
|
338
355
|
}
|
|
@@ -429,7 +446,7 @@ function authorize(params) {
|
|
|
429
446
|
throw error;
|
|
430
447
|
}
|
|
431
448
|
}
|
|
432
|
-
const result = (0, factory_1.createAuthorizeResult)(Object.assign({ payTransaction, object: authorizeObjectIncludingPaymentMethodDetails }, (
|
|
449
|
+
const result = (0, factory_1.createAuthorizeResult)(Object.assign({ payTransaction, object: authorizeObjectIncludingPaymentMethodDetails }, ((permitOrInvoice === null || permitOrInvoice === void 0 ? void 0 : permitOrInvoice.typeOf) === factory.permit.PermitType.Permit) ? { permit: permitOrInvoice } : undefined));
|
|
433
450
|
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: result });
|
|
434
451
|
return { id: action.id };
|
|
435
452
|
});
|
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": "4.389.0-alpha.
|
|
14
|
+
"@chevre/factory": "4.389.0-alpha.22",
|
|
15
15
|
"@cinerino/sdk": "10.16.0-alpha.9",
|
|
16
16
|
"@motionpicture/coa-service": "9.6.0-alpha.0",
|
|
17
17
|
"@motionpicture/gmo-service": "5.3.0",
|
|
@@ -108,5 +108,5 @@
|
|
|
108
108
|
"postversion": "git push origin --tags",
|
|
109
109
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
110
110
|
},
|
|
111
|
-
"version": "22.6.0-alpha.
|
|
111
|
+
"version": "22.6.0-alpha.35"
|
|
112
112
|
}
|