@chevre/domain 22.1.0 → 22.2.0-alpha.0

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.
@@ -37,7 +37,9 @@ export declare class PaymentServiceRepo {
37
37
  /**
38
38
  * 決済サービスを検索する
39
39
  */
40
- searchPaymentServices(conditions: ISearchConditions4paymentService, inclusion: IKeyOfProjection4paymentService[], exclusion: IKeyOfProjection4paymentService[]): Promise<factory.service.paymentService.IService[]>;
40
+ searchPaymentServices(conditions: ISearchConditions4paymentService, inclusion: IKeyOfProjection4paymentService[], exclusion: IKeyOfProjection4paymentService[]): Promise<(factory.service.paymentService.IService & {
41
+ id: string;
42
+ })[]>;
41
43
  deletePaymentServiceById(params: {
42
44
  id: string;
43
45
  }): Promise<void>;
@@ -41,7 +41,9 @@ export declare class ProductRepo {
41
41
  /**
42
42
  * プロダクトを検索する
43
43
  */
44
- searchProducts(conditions: ISearchConditions4product, inclusion: IKeyOfProjection4product[], exclusion: IKeyOfProjection4product[]): Promise<factory.product.IProduct[]>;
44
+ searchProducts(conditions: ISearchConditions4product, inclusion: IKeyOfProjection4product[], exclusion: IKeyOfProjection4product[]): Promise<(factory.product.IProduct & {
45
+ id: string;
46
+ })[]>;
45
47
  deleteProductById(params: {
46
48
  id: string;
47
49
  }): Promise<void>;
@@ -12,7 +12,9 @@ export declare function createPointAward(params: {
12
12
  */
13
13
  export declare function createServiceOutput(params: {
14
14
  dateIssued: Date;
15
- product: factory.product.IProduct;
15
+ product: factory.product.IProduct & {
16
+ id: string;
17
+ };
16
18
  acceptedOffer: factory.assetTransaction.registerService.IAcceptedOfferWithoutDetail;
17
19
  offer: factory.product.ITicketOffer;
18
20
  transactionNumber: string;
@@ -26,10 +26,15 @@ function createRegisterServiceStartParams(params) {
26
26
  // ]
27
27
  },
28
28
  object: params.object.map((o) => {
29
+ // 許可証コードは自動発行されているはず
30
+ const permitIdentifier = o.itemOffered.serviceOutput.identifier;
31
+ if (typeof permitIdentifier !== 'string' || permitIdentifier === '') {
32
+ throw new factory.errors.ArgumentNull('itemOffered.serviceOutput.identifier');
33
+ }
29
34
  return {
30
35
  typeOf: o.typeOf,
31
36
  id: String(o.id),
32
- itemOffered: o.itemOffered
37
+ itemOffered: Object.assign(Object.assign({}, o.itemOffered), { serviceOutput: Object.assign(Object.assign({}, o.itemOffered.serviceOutput), { identifier: permitIdentifier }) })
33
38
  };
34
39
  }),
35
40
  expires: moment(params.transaction.expires)
@@ -9,16 +9,17 @@ function createPaymentMethods(params) {
9
9
  let price = 0;
10
10
  // 決済方法をセット
11
11
  params.authorizePaymentActions.forEach((a) => {
12
- var _a, _b, _c, _d;
12
+ var _a, _b, _c;
13
13
  const resultAsInvoice = (Array.isArray(a.result))
14
- ? (_a = a.result) === null || _a === void 0 ? void 0 : _a.find(({ typeOf }) => typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
15
- : a.result;
14
+ // ? a.result?.find(({ typeOf }) => typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
15
+ ? a.result[0]
16
+ : undefined;
16
17
  if (resultAsInvoice === undefined) {
17
18
  throw new factory.errors.NotFound('authorizePaymentAction.resultAsInvoice'); // resultは必ず存在するはず
18
19
  }
19
- const paymentMethodAmountCurrencyByAuthorizeAction = (_c = (_b = resultAsInvoice.paymentMethodAsObject) === null || _b === void 0 ? void 0 : _b.amount) === null || _c === void 0 ? void 0 : _c.currency;
20
+ const paymentMethodAmountCurrencyByAuthorizeAction = (_b = (_a = resultAsInvoice.paymentMethodAsObject) === null || _a === void 0 ? void 0 : _a.amount) === null || _b === void 0 ? void 0 : _b.currency;
20
21
  // 決済方法区分は必ず存在するはず(2023-08-15~)
21
- const paymentMethodType = (_d = resultAsInvoice.paymentMethodAsObject) === null || _d === void 0 ? void 0 : _d.typeOf;
22
+ const paymentMethodType = (_c = resultAsInvoice.paymentMethodAsObject) === null || _c === void 0 ? void 0 : _c.typeOf;
22
23
  if (typeof paymentMethodType !== 'string') {
23
24
  throw new factory.errors.NotFound('authorizePaymentAction.result.paymentMethodAsObject.typeOf');
24
25
  }
@@ -34,11 +35,12 @@ function createPaymentMethods(params) {
34
35
  // 決済方法から注文金額の計算
35
36
  price += params.authorizePaymentActions
36
37
  .reduce((a, b) => {
37
- var _a, _b;
38
+ var _a;
38
39
  const resultAsInvoice = (Array.isArray(b.result))
39
- ? (_a = b.result) === null || _a === void 0 ? void 0 : _a.find(({ typeOf }) => typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
40
- : b.result;
41
- const jpyAmount = (((_b = resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.totalPaymentDue) === null || _b === void 0 ? void 0 : _b.currency) === factory.priceCurrency.JPY)
40
+ // ? b.result?.find(({ typeOf }) => typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
41
+ ? b.result[0]
42
+ : undefined;
43
+ const jpyAmount = (((_a = resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.totalPaymentDue) === null || _a === void 0 ? void 0 : _a.currency) === factory.priceCurrency.JPY)
42
44
  ? resultAsInvoice.totalPaymentDue.value
43
45
  : 0;
44
46
  return a + jpyAmount;
@@ -28,7 +28,8 @@ export declare function createMovieTicket(params: factory.action.trade.pay.IMovi
28
28
  export declare function createAuthorizeResult(params: {
29
29
  object: factory.action.authorize.paymentMethod.any.IObjectIncludingPaymentMethodDetails;
30
30
  payTransaction: factory.assetTransaction.pay.ITransaction;
31
- }): factory.action.authorize.paymentMethod.any.IResultAsInvoice[];
31
+ permit?: Pick<factory.ownershipInfo.IPermitAsGood, 'identifier'>;
32
+ }): factory.action.authorize.paymentMethod.any.IResult;
32
33
  /**
33
34
  * 通知対象としてのアクションを最適化
34
35
  */
@@ -129,8 +129,6 @@ function createAuthorizeResult(params) {
129
129
  accountId: (typeof ((_e = payTransactionObject.paymentMethod) === null || _e === void 0 ? void 0 : _e.accountId) === 'string')
130
130
  ? payTransactionObject.paymentMethod.accountId
131
131
  : '',
132
- // 廃止(2023-08-07~)
133
- // amount: params.object.amount,
134
132
  issuedThrough,
135
133
  // 完全廃止(paymentMethodAsObjectへ完全移行)(2023-08-16~)
136
134
  // paymentMethod: params.object.paymentMethod,
@@ -146,7 +144,23 @@ function createAuthorizeResult(params) {
146
144
  additionalProperty: (Array.isArray(params.object.additionalProperty)) ? params.object.additionalProperty : [],
147
145
  typeOf: factory.action.authorize.paymentMethod.any.ResultType.Payment
148
146
  };
149
- return [resultAsInvoice]; // Arrayに統一(2023-09-04~)
147
+ // tslint:disable-next-line:no-suspicious-comment
148
+ // TODO 保留 resultにメンバーシップを追加(2024-08-13~)
149
+ // let resultAsPermit: factory.action.authorize.paymentMethod.any.IResultAsPermit | undefined;
150
+ // if (typeof params.permit?.identifier === 'string') {
151
+ // resultAsPermit = {
152
+ // typeOf: factory.permit.PermitType.Permit,
153
+ // identifier: params.permit.identifier,
154
+ // issuedThrough: { serviceType: params.permit.issuedThrough?.serviceType }
155
+ // };
156
+ // }
157
+ // Arrayに統一(2023-09-04~)
158
+ // if (resultAsPermit !== undefined) {
159
+ // return [resultAsInvoice, resultAsPermit];
160
+ // } else {
161
+ // return [resultAsInvoice];
162
+ // }
163
+ return [resultAsInvoice];
150
164
  }
151
165
  exports.createAuthorizeResult = createAuthorizeResult;
152
166
  function payActionObject2invoice(params) {
@@ -0,0 +1,11 @@
1
+ import * as factory from '../../../factory';
2
+ import type { ConfirmationNumberRepo } from '../../../repo/confirmationNumber';
3
+ import type { TransactionRepo } from '../../../repo/transaction';
4
+ declare function fixConfirmationNumberAsNeeded(params: {
5
+ purpose: factory.action.authorize.paymentMethod.any.IPurpose;
6
+ paymentServiceType: factory.service.paymentService.PaymentServiceType;
7
+ }): (repos: {
8
+ transaction: TransactionRepo;
9
+ confirmationNumber: ConfirmationNumberRepo;
10
+ }) => Promise<string | undefined>;
11
+ export { fixConfirmationNumberAsNeeded };
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.fixConfirmationNumberAsNeeded = void 0;
13
+ const factory = require("../../../factory");
14
+ const publishConfirmationNumberIfNotExist_1 = require("../../transaction/placeOrder/publishConfirmationNumberIfNotExist");
15
+ function fixConfirmationNumberAsNeeded(params) {
16
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
17
+ // MovieTicketの場合、確認番号を発行(着券に連携するため)(2024-05-27~)
18
+ let confirmationNumber;
19
+ if (params.paymentServiceType === factory.service.paymentService.PaymentServiceType.MovieTicket) {
20
+ confirmationNumber = yield (0, publishConfirmationNumberIfNotExist_1.publishConfirmationNumberIfNotExist)({
21
+ id: params.purpose.id,
22
+ status: { $in: [factory.transactionStatusType.InProgress] },
23
+ object: { orderDate: new Date() }
24
+ })({
25
+ confirmationNumber: repos.confirmationNumber,
26
+ transaction: repos.transaction
27
+ });
28
+ }
29
+ return confirmationNumber;
30
+ });
31
+ }
32
+ exports.fixConfirmationNumberAsNeeded = fixConfirmationNumberAsNeeded;
@@ -0,0 +1,22 @@
1
+ import * as factory from '../../../factory';
2
+ import type { AuthorizationRepo } from '../../../repo/authorization';
3
+ import type { OwnershipInfoRepo } from '../../../repo/ownershipInfo';
4
+ import type { TicketRepo } from '../../../repo/ticket';
5
+ type IObjectWithoutDetail = factory.action.authorize.paymentMethod.any.IObjectWithoutDetail & {
6
+ ticketToken?: string;
7
+ };
8
+ declare function verifyTicketTokenAsNeeded(params: {
9
+ project: {
10
+ id: string;
11
+ };
12
+ object: IObjectWithoutDetail;
13
+ paymentServiceType: factory.service.paymentService.PaymentServiceType;
14
+ purpose: factory.action.authorize.paymentMethod.any.IPurpose;
15
+ }): (repos: {
16
+ authorization: AuthorizationRepo;
17
+ ownershipInfo: OwnershipInfoRepo;
18
+ ticket: TicketRepo;
19
+ }) => Promise<{
20
+ permit: Pick<factory.ownershipInfo.IPermitAsGood, 'identifier'> | undefined;
21
+ }>;
22
+ export { verifyTicketTokenAsNeeded };
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.verifyTicketTokenAsNeeded = void 0;
13
+ const factory = require("../../../factory");
14
+ function verifyTicketTokenAsNeeded(params) {
15
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
16
+ var _a;
17
+ const { paymentServiceType, object, project } = params;
18
+ const { ticketToken } = object;
19
+ let permit;
20
+ switch (paymentServiceType) {
21
+ case factory.service.paymentService.PaymentServiceType.CreditCard:
22
+ case factory.service.paymentService.PaymentServiceType.FaceToFace:
23
+ // トークン化されたメンバーシップがリクエストされた場合、実メンバーシップ情報へ変換する
24
+ if (typeof ticketToken === 'string' && ticketToken !== '') {
25
+ let authorizedObject;
26
+ const ticket = (yield repos.ticket.search({
27
+ limit: 1,
28
+ page: 1,
29
+ project: { id: { $eq: project.id } },
30
+ ticketToken: { $eq: ticketToken }
31
+ })).shift();
32
+ if (ticket === undefined) {
33
+ throw new factory.errors.NotFound('Ticket');
34
+ }
35
+ // 承認を参照
36
+ const validAuthorization = yield repos.authorization.findValidOneByCode({
37
+ project: { id: params.project.id },
38
+ code: ticket.ticketToken
39
+ });
40
+ authorizedObject = validAuthorization.object;
41
+ if (authorizedObject.typeOf !== 'OwnershipInfo') {
42
+ throw new factory.errors.Argument('ticketToken', 'must be OwnershipInfo');
43
+ }
44
+ const ownershipInfoId = authorizedObject.id;
45
+ const permitOwnershipInfo = (yield repos.ownershipInfo.search({
46
+ limit: 1,
47
+ page: 1,
48
+ project: { id: { $eq: params.project.id } },
49
+ ids: [ownershipInfoId]
50
+ })).shift();
51
+ if (permitOwnershipInfo === undefined) {
52
+ throw new factory.errors.NotFound('OwnershipInfo');
53
+ }
54
+ const { ownedBy, typeOfGood } = permitOwnershipInfo;
55
+ if (typeOfGood.typeOf !== factory.permit.PermitType.Permit) {
56
+ throw new factory.errors.Argument('ticketToken', 'must be Permit');
57
+ }
58
+ if (((_a = typeOfGood.issuedThrough) === null || _a === void 0 ? void 0 : _a.typeOf) !== paymentServiceType) {
59
+ throw new factory.errors.Argument('ticketToken', 'paymentServiceType not matched');
60
+ }
61
+ if (!Array.isArray(ownedBy)) {
62
+ throw new factory.errors.Argument('ticketToken', 'ownershipInfo.ownedBy must be Array');
63
+ }
64
+ if (ownedBy[0].typeOf !== factory.transactionType.PlaceOrder) {
65
+ throw new factory.errors.Argument('ticketToken', 'ownershipInfo.ownedBy.typeOf must be PlaceOrder');
66
+ }
67
+ if (ownedBy[0].id !== params.purpose.id) {
68
+ throw new factory.errors.Argument('ticketToken', 'ownershipInfo.ownedBy.id not matched');
69
+ }
70
+ permit = { identifier: typeOfGood.identifier };
71
+ }
72
+ break;
73
+ default:
74
+ // no op
75
+ }
76
+ return { permit };
77
+ });
78
+ }
79
+ exports.verifyTicketTokenAsNeeded = verifyTicketTokenAsNeeded;
@@ -10,6 +10,7 @@ import type { AssetTransactionRepo } from '../../repo/assetTransaction';
10
10
  import type { AuthorizationRepo } from '../../repo/authorization';
11
11
  import type { ConfirmationNumberRepo } from '../../repo/confirmationNumber';
12
12
  import type { EventRepo } from '../../repo/event';
13
+ import type { OwnershipInfoRepo } from '../../repo/ownershipInfo';
13
14
  import type { PaymentServiceRepo } from '../../repo/paymentService';
14
15
  import type { PaymentServiceProviderRepo } from '../../repo/paymentServiceProvider';
15
16
  import type { ProductRepo } from '../../repo/product';
@@ -79,6 +80,7 @@ interface IAuthorizeRepos {
79
80
  authorization: AuthorizationRepo;
80
81
  confirmationNumber: ConfirmationNumberRepo;
81
82
  event: EventRepo;
83
+ ownershipInfo: OwnershipInfoRepo;
82
84
  paymentAccepted: SellerPaymentAcceptedRepo;
83
85
  paymentService: PaymentServiceRepo;
84
86
  paymentServiceProvider: PaymentServiceProviderRepo;
@@ -102,6 +104,9 @@ interface IPublishPaymentUrlRepos {
102
104
  transactionNumber: TransactionNumberRepo;
103
105
  }
104
106
  type IPublishPaymentUrlOperation<T> = (repos: IPublishPaymentUrlRepos, settings: Settings) => Promise<T>;
107
+ type IObjectWithoutDetail = factory.action.authorize.paymentMethod.any.IObjectWithoutDetail & {
108
+ ticketToken?: string;
109
+ };
105
110
  /**
106
111
  * 外部決済ロケーションを発行する
107
112
  */
@@ -123,7 +128,6 @@ declare function publishPaymentUrl(params: {
123
128
  id: string;
124
129
  };
125
130
  }): IPublishPaymentUrlOperation<Pick<PayTransactionService.IPublishPaymentUrlResult, 'paymentMethodId' | 'paymentUrl'>>;
126
- type IObjectWithoutDetail = factory.action.authorize.paymentMethod.any.IObjectWithoutDetail;
127
131
  /**
128
132
  * 決済承認
129
133
  */
@@ -16,13 +16,14 @@ exports.publishPaymentUrl = exports.processVoidPayTransaction = exports.person2u
16
16
  const factory = require("../../factory");
17
17
  const PayTransactionService = require("../assetTransaction/pay");
18
18
  const code_1 = require("../code");
19
- const publishConfirmationNumberIfNotExist_1 = require("../transaction/placeOrder/publishConfirmationNumberIfNotExist");
20
19
  const factory_1 = require("./any/factory");
20
+ const fixConfirmationNumberAsNeeded_1 = require("./any/fixConfirmationNumberAsNeeded");
21
21
  const handlePrePublishedPaymentMethodIdOnAuthorizing_1 = require("./any/handlePrePublishedPaymentMethodIdOnAuthorizing");
22
22
  const onPaymentStatusChanged_1 = require("./any/onPaymentStatusChanged");
23
23
  Object.defineProperty(exports, "onPaymentStatusChanged", { enumerable: true, get: function () { return onPaymentStatusChanged_1.onPaymentStatusChanged; } });
24
24
  const person2username_1 = require("./any/person2username");
25
25
  Object.defineProperty(exports, "person2username", { enumerable: true, get: function () { return person2username_1.person2username; } });
26
+ const verifyTicketTokenAsNeeded_1 = require("./any/verifyTicketTokenAsNeeded");
26
27
  /**
27
28
  * 決済承認中止
28
29
  * タスクから決済承認を取り消す
@@ -304,29 +305,29 @@ function authorize(params) {
304
305
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
305
306
  return (repos, settings, credentials) => __awaiter(this, void 0, void 0, function* () {
306
307
  var _a, _b;
307
- if (params.purpose.typeOf !== factory.transactionType.PlaceOrder) {
308
- throw new factory.errors.NotImplemented(`purpose.typeOf '${params.purpose.typeOf} not implemented'`);
309
- }
310
- // MovieTicketの場合、確認番号を発行(着券に連携するため)(2024-05-27~)
311
- let confirmationNumber;
312
- if (params.paymentServiceType === factory.service.paymentService.PaymentServiceType.MovieTicket) {
313
- confirmationNumber = yield (0, publishConfirmationNumberIfNotExist_1.publishConfirmationNumberIfNotExist)({
314
- id: params.purpose.id,
315
- status: { $in: [factory.transactionStatusType.InProgress] },
316
- object: { orderDate: new Date() }
317
- })({
318
- confirmationNumber: repos.confirmationNumber,
319
- transaction: repos.transaction
320
- });
308
+ const { paymentServiceType, purpose, project } = params;
309
+ if (purpose.typeOf !== factory.transactionType.PlaceOrder) {
310
+ throw new factory.errors.NotImplemented(`purpose.typeOf '${purpose.typeOf} not implemented'`);
321
311
  }
322
- const transaction = yield repos.transaction.findInProgressById({ typeOf: params.purpose.typeOf, id: params.purpose.id }, ['agent', 'expires', 'typeOf', 'project', 'seller']);
323
- const paymentServiceType = params.paymentServiceType;
312
+ const confirmationNumber = yield (0, fixConfirmationNumberAsNeeded_1.fixConfirmationNumberAsNeeded)({ purpose, paymentServiceType })(repos);
313
+ const transaction = yield repos.transaction.findInProgressById({ typeOf: purpose.typeOf, id: purpose.id }, ['agent', 'expires', 'typeOf', 'project', 'seller']);
324
314
  // 取引番号生成
325
315
  let transactionNumber;
326
316
  let pendingPaymentAgencyTransaction;
327
317
  let creditCard = params.object.creditCard;
318
+ // ticketTokenを解釈(2024-08-13~)
319
+ const { permit } = yield (0, verifyTicketTokenAsNeeded_1.verifyTicketTokenAsNeeded)({ project, object: params.object, paymentServiceType, purpose })(repos);
320
+ const paymentMethodIdByPermit = permit === null || permit === void 0 ? void 0 : permit.identifier;
321
+ if (typeof paymentMethodIdByPermit === 'string') {
322
+ transactionNumber = paymentMethodIdByPermit; // メンバーシップ指定の場合、取引番号に適用(2024-08-13~)
323
+ }
328
324
  // リクエストでpaymentMethodIdを指定された場合、取引に保管されたpaymentMethodIdに一致すればそちらを適用(外部サイト決済対応)
329
325
  if (typeof params.object.paymentMethodId === 'string' && params.object.paymentMethodId.length > 0) {
326
+ if (typeof paymentMethodIdByPermit === 'string') {
327
+ if (paymentMethodIdByPermit !== params.object.paymentMethodId) {
328
+ throw new factory.errors.Argument('ticketToken', 'not matched with paymentMethodId');
329
+ }
330
+ }
330
331
  const { authorizeParams, existingCompletedAuthorizeAction } = yield (0, handlePrePublishedPaymentMethodIdOnAuthorizing_1.handlePrePublishedPaymentMethodIdOnAuthorizing)({
331
332
  object: params.object,
332
333
  prePublishedPaymentMethodId: params.object.paymentMethodId,
@@ -420,7 +421,7 @@ function authorize(params) {
420
421
  throw error;
421
422
  }
422
423
  }
423
- const result = (0, factory_1.createAuthorizeResult)({ payTransaction, object: authorizeObjectIncludingPaymentMethodDetails });
424
+ const result = (0, factory_1.createAuthorizeResult)(Object.assign({ payTransaction, object: authorizeObjectIncludingPaymentMethodDetails }, (permit !== undefined) ? { permit } : undefined));
424
425
  yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: result });
425
426
  return { id: action.id };
426
427
  });
@@ -65,7 +65,7 @@ function authorize(params, paymentServiceId) {
65
65
  exports.authorize = authorize;
66
66
  function validatePaymentMethod(params, paymentServiceId) {
67
67
  return (repos) => __awaiter(this, void 0, void 0, function* () {
68
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
68
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
69
69
  const serviceOutputIdentifier = (_a = params.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.accountId;
70
70
  const amount = (_b = params.object.paymentMethod) === null || _b === void 0 ? void 0 : _b.amount;
71
71
  const paymentMethodType = (_c = params.object.paymentMethod) === null || _c === void 0 ? void 0 : _c.identifier;
@@ -114,7 +114,10 @@ function validatePaymentMethod(params, paymentServiceId) {
114
114
  issuedThrough: { typeOf: factory.product.ProductType.PaymentCard }
115
115
  });
116
116
  // サービスタイプを確認
117
- if (((_k = (_j = serviceOutput.issuedThrough) === null || _j === void 0 ? void 0 : _j.serviceType) === null || _k === void 0 ? void 0 : _k.codeValue) !== paymentMethodType) {
117
+ if (((_j = serviceOutput.issuedThrough) === null || _j === void 0 ? void 0 : _j.typeOf) !== factory.product.ProductType.PaymentCard) {
118
+ throw new factory.errors.Argument('object.paymentMethod.accountId', 'serviceOutput.issuedThrough?.typeOf must be PaymentCard');
119
+ }
120
+ if (((_l = (_k = serviceOutput.issuedThrough) === null || _k === void 0 ? void 0 : _k.serviceType) === null || _l === void 0 ? void 0 : _l.codeValue) !== paymentMethodType) {
118
121
  throw new factory.errors.Argument('object.paymentMethod.accountId', 'paymentMethodType not matched');
119
122
  }
120
123
  // 出金金額設定を確認
@@ -17,6 +17,7 @@ const assetTransaction_1 = require("../../repo/assetTransaction");
17
17
  const authorization_1 = require("../../repo/authorization");
18
18
  const confirmationNumber_1 = require("../../repo/confirmationNumber");
19
19
  const event_1 = require("../../repo/event");
20
+ const ownershipInfo_1 = require("../../repo/ownershipInfo");
20
21
  const paymentService_1 = require("../../repo/paymentService");
21
22
  const paymentServiceProvider_1 = require("../../repo/paymentServiceProvider");
22
23
  const product_1 = require("../../repo/product");
@@ -54,6 +55,7 @@ function call(params) {
54
55
  authorization: new authorization_1.AuthorizationRepo(connection),
55
56
  confirmationNumber: new confirmationNumber_1.ConfirmationNumberRepo(redisClient),
56
57
  event: new event_1.EventRepo(connection),
58
+ ownershipInfo: new ownershipInfo_1.OwnershipInfoRepo(connection),
57
59
  paymentAccepted: new sellerPaymentAccepted_1.SellerPaymentAcceptedRepo(connection),
58
60
  paymentService: new paymentService_1.PaymentServiceRepo(connection),
59
61
  paymentServiceProvider: new paymentServiceProvider_1.PaymentServiceProviderRepo(connection),
@@ -27,7 +27,8 @@ function validateTransaction(transaction, authorizePaymentActions, authorizeEven
27
27
  const authorizeMovieTicketActions = authorizePaymentActions.filter((a) => {
28
28
  var _a;
29
29
  const resultAsInvoice = (Array.isArray(a.result))
30
- ? a.result.find(({ typeOf }) => typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
30
+ // ? a.result.find(({ typeOf }) => typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
31
+ ? a.result[0]
31
32
  : undefined;
32
33
  return (resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.issuedThrough.typeOf) === factory.service.paymentService.PaymentServiceType.MovieTicket
33
34
  // 決済方法区分は必ず存在するはず(2023-08-15~)
@@ -65,7 +66,8 @@ function findMovieTicketPaymentMethodTypesFromTransaction(authorizePaymentAction
65
66
  const paymentMethodTypes = [];
66
67
  authorizePaymentActions.forEach(({ result }) => {
67
68
  const resultAsInvoice = (Array.isArray(result))
68
- ? result.find(({ typeOf }) => typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
69
+ // ? result.find(({ typeOf }) => typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
70
+ ? result[0]
69
71
  : undefined;
70
72
  if ((resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.issuedThrough.typeOf) === factory.service.paymentService.PaymentServiceType.MovieTicket) {
71
73
  // 決済方法区分は必ず存在するはず(2023-08-15~)
@@ -123,7 +125,8 @@ function validatePrice(authorizePaymentActions, authorizeEventServiceOfferAction
123
125
  authorizePaymentActions.forEach(({ result }) => {
124
126
  var _a;
125
127
  const resultAsInvoice = (Array.isArray(result))
126
- ? result.find(({ typeOf }) => typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
128
+ // ? result.find(({ typeOf }) => typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
129
+ ? result[0]
127
130
  : undefined;
128
131
  const jpyAmount = (((_a = resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.totalPaymentDue) === null || _a === void 0 ? void 0 : _a.currency) === factory.priceCurrency.JPY)
129
132
  ? resultAsInvoice.totalPaymentDue.value
@@ -160,7 +163,8 @@ function validatePaymentUrl(transaction, authorizePaymentActions) {
160
163
  // 発行された決済URLに対する決済承認を確認する
161
164
  const authorizePaymentAction4paymentUrlExists = authorizePaymentActions.some(({ result }) => {
162
165
  const resultAsInvoice = (Array.isArray(result))
163
- ? result.find(({ typeOf }) => typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
166
+ // ? result.find(({ typeOf }) => typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
167
+ ? result[0]
164
168
  : undefined;
165
169
  return (resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.paymentMethodId) === paymentMethodId;
166
170
  });
@@ -176,7 +180,8 @@ function validateMonetaryAmount(authorizePaymentActions, authorizeEventServiceOf
176
180
  const authorizeMonetaryAmountActions = authorizePaymentActions.filter(({ result }) => {
177
181
  var _a;
178
182
  const resultAsInvoice = (Array.isArray(result))
179
- ? result.find(({ typeOf }) => typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
183
+ // ? result.find(({ typeOf }) => typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
184
+ ? result[0]
180
185
  : undefined;
181
186
  // JPY以外の通貨に対して承認可能なのはPaymentServiceType.PaymentCardのみ
182
187
  return (resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.issuedThrough.typeOf) === factory.service.paymentService.PaymentServiceType.PaymentCard
@@ -198,7 +203,8 @@ function validateMonetaryAmount(authorizePaymentActions, authorizeEventServiceOf
198
203
  const authorizedCurrencyTypes = [...new Set(authorizeMonetaryAmountActions.map(({ result }) => {
199
204
  var _a;
200
205
  const resultAsInvoice = (Array.isArray(result))
201
- ? result.find(({ typeOf }) => typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
206
+ // ? result.find(({ typeOf }) => typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
207
+ ? result[0]
202
208
  : undefined;
203
209
  return (_a = resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.totalPaymentDue) === null || _a === void 0 ? void 0 : _a.currency;
204
210
  }))];
@@ -213,7 +219,8 @@ function validateMonetaryAmount(authorizePaymentActions, authorizeEventServiceOf
213
219
  authorizeMonetaryAmountActions.forEach(({ result }) => {
214
220
  var _a;
215
221
  const resultAsInvoice = (Array.isArray(result))
216
- ? result.find(({ typeOf }) => typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
222
+ // ? result.find(({ typeOf }) => typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
223
+ ? result[0]
217
224
  : undefined;
218
225
  if (((_a = resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.totalPaymentDue) === null || _a === void 0 ? void 0 : _a.currency) === currencyType) {
219
226
  authorizedMonetaryAmount += resultAsInvoice.totalPaymentDue.value;
package/package.json CHANGED
@@ -9,8 +9,8 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.380.0",
13
- "@cinerino/sdk": "10.4.0",
12
+ "@chevre/factory": "4.381.0-alpha.1",
13
+ "@cinerino/sdk": "10.5.0-alpha.0",
14
14
  "@motionpicture/coa-service": "9.4.0",
15
15
  "@motionpicture/gmo-service": "5.3.0",
16
16
  "@sendgrid/mail": "6.4.0",
@@ -110,5 +110,5 @@
110
110
  "postversion": "git push origin --tags",
111
111
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
112
112
  },
113
- "version": "22.1.0"
113
+ "version": "22.2.0-alpha.0"
114
114
  }
@@ -1,78 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as moment from 'moment';
3
- import * as mongoose from 'mongoose';
4
-
5
- import { chevre } from '../../../lib/index';
6
-
7
- // const project = { id: String(process.env.PROJECT_ID) };
8
-
9
- const MOVIE_TICKET_IDENTIFIER_REGEX = '^[0-9a-zA-Z*]+$';
10
- // const MOVIE_TICKET_IDENTIFIER_REGEX = '^.+$';
11
-
12
- // tslint:disable-next-line:max-func-body-length
13
- async function main() {
14
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
15
-
16
- const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
17
-
18
- const cursor = actionRepo.getCursor(
19
- {
20
- typeOf: { $eq: chevre.factory.actionType.AuthorizeAction },
21
- 'object.typeOf': { $eq: chevre.factory.action.authorize.paymentMethod.any.ResultType.Payment },
22
- startDate: {
23
- $gte: moment()
24
- // tslint:disable-next-line:no-magic-numbers
25
- .add(-30, 'days')
26
- .toDate()
27
- }
28
- },
29
- {
30
- project: 1,
31
- typeOf: 1,
32
- startDate: 1,
33
- object: 1,
34
- result: 1
35
- }
36
- );
37
- console.log('actions found');
38
-
39
- let i = 0;
40
- await cursor.eachAsync(async (doc) => {
41
- i += 1;
42
- const action: Pick<
43
- chevre.factory.action.authorize.paymentMethod.any.IAction,
44
- 'project' | 'typeOf' | 'startDate' | 'object' | 'result'
45
- > = doc.toObject();
46
-
47
- const accountId = (Array.isArray(action.result)) ? action.result[0].accountId : action.result?.accountId;
48
- const issuedThroughTypeOf = (Array.isArray(action.result))
49
- ? action.result[0].issuedThrough.typeOf
50
- : action.result?.issuedThrough.typeOf;
51
- if (issuedThroughTypeOf === chevre.factory.service.paymentService.PaymentServiceType.MovieTicket) {
52
- const regExp = new RegExp(MOVIE_TICKET_IDENTIFIER_REGEX);
53
- console.log(
54
- 'checking...',
55
- accountId,
56
- action.project.id, action.startDate, i
57
- );
58
- if (typeof accountId !== 'string') {
59
- throw new Error(`${accountId} must be string`);
60
- }
61
- if (!accountId.match(regExp)) {
62
- throw new Error(`${accountId} invalid`);
63
- }
64
- } else {
65
- // console.log(
66
- // 'no check',
67
- // issuedThroughTypeOf,
68
- // action.project.id, action.startDate, i
69
- // );
70
- }
71
- });
72
-
73
- console.log(i, 'actions checked');
74
- }
75
-
76
- main()
77
- .then()
78
- .catch(console.error);