@chevre/domain 20.2.0-alpha.52 → 20.2.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.
@@ -201,7 +201,7 @@ async function main() {
201
201
  }
202
202
  ]);
203
203
  console.log(result);
204
- console.log('upsertedIds:', (Array.isArray(result?.result.upserted)) ? result?.result.upserted.map((u) => u._id) : []);
204
+ console.log('upsertedIds:', (Array.isArray(result?.result.upserted)) ? result?.result.upserted.map((u: any) => u._id) : []);
205
205
  }
206
206
 
207
207
  main()
@@ -10,6 +10,9 @@ export declare class MongoRepository {
10
10
  findById(conditions: {
11
11
  id: string;
12
12
  }, projection?: any): Promise<factory.project.IProject>;
13
+ findAlternateNameById(params: {
14
+ id: string;
15
+ }): Promise<Pick<factory.project.IProject, 'alternateName'>>;
13
16
  /**
14
17
  * プロジェクト検索
15
18
  */
@@ -61,6 +61,16 @@ class MongoRepository {
61
61
  return doc.toObject();
62
62
  });
63
63
  }
64
+ findAlternateNameById(params) {
65
+ return __awaiter(this, void 0, void 0, function* () {
66
+ const doc = yield this.projectModel.findOne({ _id: params.id }, { alternateName: 1 })
67
+ .exec();
68
+ if (doc === null) {
69
+ throw new factory.errors.NotFound(this.projectModel.modelName);
70
+ }
71
+ return doc.toObject();
72
+ });
73
+ }
64
74
  /**
65
75
  * プロジェクト検索
66
76
  */
@@ -50,6 +50,18 @@ export declare class MongoRepository {
50
50
  typeOf: T;
51
51
  id: string;
52
52
  }): Promise<factory.transaction.ITransaction<T>>;
53
+ /**
54
+ * 取引の注文番号を検索する
55
+ */
56
+ findInProgressOrderNumberById(params: {
57
+ id: string;
58
+ }): Promise<string | undefined>;
59
+ /**
60
+ * 取引の確認番号を検索する
61
+ */
62
+ findInProgressConfirmationNumberById(params: {
63
+ id: string;
64
+ }): Promise<string | undefined>;
53
65
  /**
54
66
  * 取引進行者プロフィールを更新
55
67
  */
@@ -274,8 +274,8 @@ class MongoRepository {
274
274
  findById(params) {
275
275
  return __awaiter(this, void 0, void 0, function* () {
276
276
  const doc = yield this.transactionModel.findOne({
277
- _id: params.id,
278
- typeOf: params.typeOf
277
+ _id: { $eq: params.id },
278
+ typeOf: { $eq: params.typeOf }
279
279
  })
280
280
  .exec();
281
281
  if (doc === null) {
@@ -290,9 +290,9 @@ class MongoRepository {
290
290
  findInProgressById(params) {
291
291
  return __awaiter(this, void 0, void 0, function* () {
292
292
  const doc = yield this.transactionModel.findOne({
293
- _id: params.id,
294
- typeOf: params.typeOf,
295
- status: factory.transactionStatusType.InProgress
293
+ _id: { $eq: params.id },
294
+ typeOf: { $eq: params.typeOf },
295
+ status: { $eq: factory.transactionStatusType.InProgress }
296
296
  })
297
297
  .exec();
298
298
  if (doc === null) {
@@ -301,6 +301,42 @@ class MongoRepository {
301
301
  return doc.toObject();
302
302
  });
303
303
  }
304
+ /**
305
+ * 取引の注文番号を検索する
306
+ */
307
+ findInProgressOrderNumberById(params) {
308
+ return __awaiter(this, void 0, void 0, function* () {
309
+ const doc = yield this.transactionModel.findOne({
310
+ _id: { $eq: params.id },
311
+ typeOf: { $eq: factory.transactionType.PlaceOrder },
312
+ status: { $eq: factory.transactionStatusType.InProgress }
313
+ }, { 'object.orderNumber': 1 })
314
+ .exec();
315
+ if (doc === null) {
316
+ throw new factory.errors.NotFound(this.transactionModel.modelName);
317
+ }
318
+ const transaction = doc.toObject();
319
+ return transaction.object.orderNumber;
320
+ });
321
+ }
322
+ /**
323
+ * 取引の確認番号を検索する
324
+ */
325
+ findInProgressConfirmationNumberById(params) {
326
+ return __awaiter(this, void 0, void 0, function* () {
327
+ const doc = yield this.transactionModel.findOne({
328
+ _id: { $eq: params.id },
329
+ typeOf: { $eq: factory.transactionType.PlaceOrder },
330
+ status: { $eq: factory.transactionStatusType.InProgress }
331
+ }, { 'object.confirmationNumber': 1 })
332
+ .exec();
333
+ if (doc === null) {
334
+ throw new factory.errors.NotFound(this.transactionModel.modelName);
335
+ }
336
+ const transaction = doc.toObject();
337
+ return transaction.object.confirmationNumber;
338
+ });
339
+ }
304
340
  /**
305
341
  * 取引進行者プロフィールを更新
306
342
  */
@@ -117,6 +117,7 @@ function authorize(params) {
117
117
  }
118
118
  // ポイント特典の識別子に利用するため注文番号を先に発行
119
119
  const orderNumber = yield (0, placeOrderInProgress_1.publishOrderNumberIfNotExist)({
120
+ project: { id: transaction.project.id },
120
121
  id: transaction.id,
121
122
  object: { orderDate: new Date() }
122
123
  })(repos);
@@ -144,6 +144,7 @@ function processPlaceOrder(params) {
144
144
  }
145
145
  // 注文番号を先に発行
146
146
  const orderNumber = yield TransactionService.placeOrderInProgress.publishOrderNumberIfNotExist({
147
+ project: { id: transaction.project.id },
147
148
  id: transaction.id,
148
149
  object: { orderDate: now }
149
150
  })(repos);
@@ -193,9 +194,7 @@ function processPlaceOrder(params) {
193
194
  orderDate: new Date()
194
195
  }
195
196
  },
196
- potentialActions: params.potentialActions,
197
- createConfirmPayActions: false,
198
- createConfirmReserveActions: false
197
+ potentialActions: params.potentialActions
199
198
  })(repos);
200
199
  });
201
200
  }
@@ -1,2 +1,2 @@
1
1
  import * as factory from '../../../factory';
2
- export declare function createStartParams(params: factory.transaction.placeOrder.IStartParamsWithoutDetail, passport: factory.waiter.passport.IPassport | undefined, seller: factory.seller.ISeller, broker?: factory.order.IBroker): factory.transaction.placeOrder.IStartParams;
2
+ export declare function createStartParams(params: factory.transaction.placeOrder.IStartParamsWithoutDetail, passport: factory.waiter.passport.IPassport | undefined, seller: Pick<factory.seller.ISeller, 'id' | 'name' | 'typeOf' | 'project'>, broker?: factory.order.IBroker): factory.transaction.placeOrder.IStartParams;
@@ -7,6 +7,4 @@ export declare function createPotentialActions(params: {
7
7
  potentialActions?: factory.transaction.placeOrder.IPotentialActionsParams;
8
8
  transaction: factory.transaction.placeOrder.ITransaction;
9
9
  emailMessage?: factory.creativeWork.message.email.ICreativeWork;
10
- createConfirmPayActions: boolean;
11
- createConfirmReserveActions: boolean;
12
10
  }): Promise<factory.transaction.placeOrder.IPotentialActions>;
@@ -10,8 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.createPotentialActions = void 0;
13
- const confirmPay_1 = require("./potentialActions/confirmPay");
14
- // import { createConfirmReservationActions } from './potentialActions/confirmReservation';
15
13
  const givePointAward_1 = require("./potentialActions/givePointAward");
16
14
  const moneyTransfer_1 = require("./potentialActions/moneyTransfer");
17
15
  const registerService_1 = require("./potentialActions/registerService");
@@ -23,13 +21,9 @@ const order_1 = require("../../../factory/order");
23
21
  */
24
22
  function createPotentialActions(params) {
25
23
  return __awaiter(this, void 0, void 0, function* () {
26
- // 予約確定アクション
27
- // const confirmReservationActions = await createConfirmReservationActions(params);
28
24
  const registerServiceActions = yield (0, registerService_1.createRegisterServiceActions)(params);
29
25
  // 通貨転送アクション
30
26
  const moneyTransferActions = yield (0, moneyTransfer_1.createMoneyTransferActions)(params);
31
- // 決済確定アクション
32
- const confirmPayActions = yield (0, confirmPay_1.createConfirmPayActions)(params);
33
27
  // ポイントインセンティブに対する承認アクションの分だけ、ポイントインセンティブ付与アクションを作成する
34
28
  const givePointAwardActions = yield (0, givePointAward_1.createGivePointAwardActions)(params);
35
29
  // 注文配送メール送信設定
@@ -53,16 +47,13 @@ function createPotentialActions(params) {
53
47
  typeOf: factory.actionType.SendAction,
54
48
  // 取引から注文作成するように変更したのでminimizeする(2022-04-18~)
55
49
  object: simpleOrder,
56
- // agentをプロジェクトに変更(2022-05-18~)
57
50
  agent: params.transaction.project,
58
- // agent: params.transaction.seller,
59
51
  recipient: {
60
52
  typeOf: params.order.customer.typeOf,
61
53
  id: params.order.customer.id,
62
54
  name: String(params.order.customer.name)
63
55
  },
64
56
  potentialActions: {
65
- // confirmReservation: confirmReservationActions,
66
57
  moneyTransfer: moneyTransferActions,
67
58
  registerService: registerServiceActions,
68
59
  sendEmailMessage: sendEmailMessageActions
@@ -75,10 +66,10 @@ function createPotentialActions(params) {
75
66
  // 取引から注文作成するように変更したのでminimizeする(2022-04-18~)
76
67
  object: simpleOrder,
77
68
  agent: params.transaction.project,
78
- // agent: params.transaction.agent,
79
69
  potentialActions: {
80
70
  givePointAward: givePointAwardActions,
81
- pay: confirmPayActions,
71
+ // 完全廃止(2023-02-03~)
72
+ // pay: confirmPayActions,
82
73
  sendOrder: sendOrderActionAttributes
83
74
  },
84
75
  purpose: {
@@ -1,6 +1,6 @@
1
1
  import * as factory from '../../../../factory';
2
2
  export declare function validateSeller(params: {
3
- seller: factory.seller.ISeller;
3
+ seller: Pick<factory.seller.ISeller, 'makesOffer'>;
4
4
  clientUser?: factory.clientUser.IClientUser;
5
5
  }): {
6
6
  makesOfferFromClient: factory.seller.IMakesOffer;
@@ -60,14 +60,6 @@ export declare type IConfirmParams = factory.transaction.placeOrder.IConfirmPara
60
60
  result: {
61
61
  order: IResultOrderParams;
62
62
  };
63
- /**
64
- * confirmPayActionをchevreへ完全移行後に廃止
65
- */
66
- createConfirmPayActions: boolean;
67
- /**
68
- * confirmReserveActionをchevreへ完全移行後に廃止
69
- */
70
- createConfirmReserveActions: boolean;
71
63
  };
72
64
  /**
73
65
  * 注文取引を確定する
@@ -92,6 +84,9 @@ export declare function publishConfirmationNumberIfNotExist(params: {
92
84
  * 未発行であれば、注文番号を発行して取引に保管する
93
85
  */
94
86
  export declare function publishOrderNumberIfNotExist(params: {
87
+ project: {
88
+ id: string;
89
+ };
95
90
  /**
96
91
  * 取引ID
97
92
  */
@@ -28,7 +28,10 @@ exports.POINT_AWARD_IDENTIFIER_NAME = 'pointAwardIdentifiers';
28
28
  function start(params) {
29
29
  return (repos) => __awaiter(this, void 0, void 0, function* () {
30
30
  var _a;
31
- const seller = yield repos.seller.findById({ id: params.seller.id });
31
+ const seller = yield repos.seller.findById({ id: params.seller.id }, {
32
+ hasMerchantReturnPolicy: 0,
33
+ paymentAccepted: 0
34
+ });
32
35
  let makesOfferFromClient;
33
36
  // 販売者オファー検証(2022-10-14~)
34
37
  if (params.validateSeller === true) {
@@ -95,10 +98,11 @@ function confirm(params) {
95
98
  transaction.object.authorizeActions = yield searchAuthorizeActions(params)(repos);
96
99
  // 注文番号を発行
97
100
  const orderNumber = yield publishOrderNumberIfNotExist({
101
+ project: { id: transaction.project.id },
98
102
  id: transaction.id,
99
103
  object: { orderDate: params.result.order.orderDate }
100
104
  })(repos);
101
- const result = yield createResult(Object.assign(Object.assign({}, params), { orderNumber, transaction: transaction }))();
105
+ const result = createResult(Object.assign(Object.assign({}, params), { orderNumber, transaction: transaction }));
102
106
  // デフォルトEメールメッセージを検索
103
107
  let emailMessageOnOrderSent;
104
108
  if (repos.emailMessage !== undefined) {
@@ -115,9 +119,7 @@ function confirm(params) {
115
119
  order: result.order,
116
120
  potentialActions: params.potentialActions,
117
121
  transaction: transaction,
118
- emailMessage: emailMessageOnOrderSent,
119
- createConfirmPayActions: params.createConfirmPayActions,
120
- createConfirmReserveActions: params.createConfirmReserveActions
122
+ emailMessage: emailMessageOnOrderSent
121
123
  });
122
124
  // ステータス変更
123
125
  try {
@@ -152,33 +154,27 @@ exports.confirm = confirm;
152
154
  */
153
155
  function publishConfirmationNumberIfNotExist(params) {
154
156
  return (repos) => __awaiter(this, void 0, void 0, function* () {
155
- let transaction = yield repos.transaction.findInProgressById({
156
- typeOf: factory.transactionType.PlaceOrder,
157
- id: params.id
158
- });
157
+ // 最適化(2023-02-03~)
158
+ let confirmationNumber = yield repos.transaction.findInProgressConfirmationNumberById({ id: params.id });
159
159
  // すでに発行済であれば何もしない
160
- if (typeof transaction.object.confirmationNumber === 'string') {
161
- return transaction.object.confirmationNumber;
160
+ if (typeof confirmationNumber === 'string') {
161
+ return confirmationNumber;
162
162
  }
163
163
  // 確認番号を発行
164
- const confirmationNumber = (yield repos.confirmationNumber.publish({
165
- orderDate: params.object.orderDate
166
- })).toString();
164
+ confirmationNumber = yield repos.confirmationNumber.publish({ orderDate: params.object.orderDate });
167
165
  // 取引に存在しなければ保管
168
166
  yield repos.transaction.saveConfirmationNumberIfNotExist({
169
- id: transaction.id,
167
+ id: params.id,
170
168
  confirmationNumber
171
169
  });
172
170
  // 確認番号を取引から再取得
173
- transaction = yield repos.transaction.findInProgressById({
174
- typeOf: factory.transactionType.PlaceOrder,
175
- id: params.id
176
- });
171
+ // 最適化(2023-02-03~)
172
+ confirmationNumber = yield repos.transaction.findInProgressConfirmationNumberById({ id: params.id });
177
173
  // 万が一処理が想定通りでない場合confirmationNumberが存在しない
178
- if (typeof transaction.object.confirmationNumber !== 'string') {
174
+ if (typeof confirmationNumber !== 'string') {
179
175
  throw new factory.errors.ServiceUnavailable('transaction.object.confirmationNumber not found');
180
176
  }
181
- return transaction.object.confirmationNumber;
177
+ return confirmationNumber;
182
178
  });
183
179
  }
184
180
  exports.publishConfirmationNumberIfNotExist = publishConfirmationNumberIfNotExist;
@@ -187,75 +183,66 @@ exports.publishConfirmationNumberIfNotExist = publishConfirmationNumberIfNotExis
187
183
  */
188
184
  function publishOrderNumberIfNotExist(params) {
189
185
  return (repos) => __awaiter(this, void 0, void 0, function* () {
190
- let transaction = yield repos.transaction.findInProgressById({
191
- typeOf: factory.transactionType.PlaceOrder,
192
- id: params.id
193
- });
186
+ // 最適化(2023-02-03~)
187
+ let orderNumber = yield repos.transaction.findInProgressOrderNumberById({ id: params.id });
194
188
  // すでに発行済であれば何もしない
195
- if (typeof transaction.object.orderNumber === 'string') {
196
- return transaction.object.orderNumber;
189
+ if (typeof orderNumber === 'string') {
190
+ return orderNumber;
197
191
  }
198
192
  // 注文番号を発行
199
- const project = yield repos.project.findById({ id: transaction.project.id });
200
- if (typeof project.alternateName !== 'string') {
193
+ const { alternateName } = yield repos.project.findAlternateNameById({ id: params.project.id });
194
+ if (typeof alternateName !== 'string') {
201
195
  throw new factory.errors.NotFound('project.alternateName');
202
196
  }
203
- const orderNumber = yield repos.orderNumber.publishByTimestamp({
204
- project: { alternateName: project.alternateName },
197
+ orderNumber = yield repos.orderNumber.publishByTimestamp({
198
+ project: { alternateName },
205
199
  orderDate: params.object.orderDate
206
200
  });
207
201
  // 取引に存在しなければ保管
208
- yield repos.transaction.saveOrderNumberIfNotExist({
209
- id: transaction.id,
210
- orderNumber
211
- });
202
+ yield repos.transaction.saveOrderNumberIfNotExist({ id: params.id, orderNumber });
212
203
  // 注文番号を取引から再取得
213
- transaction = yield repos.transaction.findInProgressById({
214
- typeOf: factory.transactionType.PlaceOrder,
215
- id: params.id
216
- });
204
+ // 最適化(2023-02-03~)
205
+ orderNumber = yield repos.transaction.findInProgressOrderNumberById({ id: params.id });
217
206
  // 万が一処理が想定通りでない場合orderNumberが存在しない
218
- if (typeof transaction.object.orderNumber !== 'string') {
207
+ if (typeof orderNumber !== 'string') {
219
208
  throw new factory.errors.ServiceUnavailable('transaction.object.orderNumber not found');
220
209
  }
221
- return transaction.object.orderNumber;
210
+ return orderNumber;
222
211
  });
223
212
  }
224
213
  exports.publishOrderNumberIfNotExist = publishOrderNumberIfNotExist;
225
214
  function createResult(params) {
226
- return () => __awaiter(this, void 0, void 0, function* () {
227
- const transaction = params.transaction;
228
- // 取引の確定条件が全て整っているかどうか確認
229
- (0, validation_1.validateTransaction)(transaction);
230
- // 注文作成
231
- const order = (0, result_1.createOrder)({
232
- orderNumber: params.orderNumber,
233
- transaction: transaction,
234
- orderDate: params.result.order.orderDate,
235
- orderStatus: factory.orderStatus.OrderProcessing,
236
- isGift: false
237
- });
238
- (0, validation_1.validateEventOffers)({
239
- transaction: transaction,
240
- order: order
241
- });
242
- // 注文アイテム数制限確認
243
- (0, validation_1.validateNumItems)({
244
- order: order,
245
- result: params.result
246
- });
247
- (0, validation_1.validatePaymentMethods)({ order });
248
- // 確認番号を発行
249
- const { confirmationNumber, identifier, url } = yield createConfirmationNumber({
250
- order: order,
251
- transaction: transaction,
252
- result: params.result
253
- })();
254
- order.confirmationNumber = confirmationNumber;
255
- order.identifier = identifier;
256
- order.url = url;
257
- return { order };
215
+ const transaction = params.transaction;
216
+ // 取引の確定条件が全て整っているかどうか確認
217
+ (0, validation_1.validateTransaction)(transaction);
218
+ // 注文作成
219
+ const order = (0, result_1.createOrder)({
220
+ orderNumber: params.orderNumber,
221
+ transaction: transaction,
222
+ orderDate: params.result.order.orderDate,
223
+ orderStatus: factory.orderStatus.OrderProcessing,
224
+ isGift: false
225
+ });
226
+ (0, validation_1.validateEventOffers)({
227
+ transaction: transaction,
228
+ order: order
258
229
  });
230
+ // 注文アイテム数制限確認
231
+ (0, validation_1.validateNumItems)({
232
+ order: order,
233
+ result: params.result
234
+ });
235
+ (0, validation_1.validatePaymentMethods)({ order });
236
+ // 確認番号を発行
237
+ const { confirmationNumber, identifier, url } = createConfirmationNumber({
238
+ order: order,
239
+ transaction: transaction,
240
+ result: params.result
241
+ });
242
+ order.confirmationNumber = confirmationNumber;
243
+ order.identifier = identifier;
244
+ order.url = url;
245
+ return { order };
259
246
  }
260
247
  function searchAuthorizeActions(params) {
261
248
  return (repos) => __awaiter(this, void 0, void 0, function* () {
@@ -273,34 +260,32 @@ function searchAuthorizeActions(params) {
273
260
  });
274
261
  }
275
262
  function createConfirmationNumber(params) {
276
- return () => __awaiter(this, void 0, void 0, function* () {
277
- const confirmationNumber = params.transaction.object.confirmationNumber;
278
- let url = '';
279
- let identifier = [];
280
- // 取引に確認番号が保管されていなければ、確認番号を発行
281
- if (typeof confirmationNumber !== 'string') {
282
- // 事前に発行済なはずなので、ありえないフロー
283
- throw new factory.errors.ServiceUnavailable('object.confirmationNumber undefined');
284
- }
285
- // URLの指定があれば上書き
263
+ const confirmationNumber = params.transaction.object.confirmationNumber;
264
+ let url = '';
265
+ let identifier = [];
266
+ // 取引に確認番号が保管されていなければ、確認番号を発行
267
+ if (typeof confirmationNumber !== 'string') {
268
+ // 事前に発行済なはずなので、ありえないフロー
269
+ throw new factory.errors.ServiceUnavailable('object.confirmationNumber undefined');
270
+ }
271
+ // URLの指定があれば上書き
272
+ // tslint:disable-next-line:no-single-line-block-comment
273
+ /* istanbul ignore if */
274
+ if (typeof params.result.order.url === 'string') {
275
+ url = params.result.order.url;
276
+ }
277
+ else /* istanbul ignore next */ if (typeof params.result.order.url === 'function') {
286
278
  // tslint:disable-next-line:no-single-line-block-comment
287
- /* istanbul ignore if */
288
- if (typeof params.result.order.url === 'string') {
289
- url = params.result.order.url;
290
- }
291
- else /* istanbul ignore next */ if (typeof params.result.order.url === 'function') {
292
- // tslint:disable-next-line:no-single-line-block-comment
293
- /* istanbul ignore next */
294
- url = params.result.order.url(params.order);
295
- }
296
- // 識別子の指定があれば上書き
297
- identifier = [
298
- ...(Array.isArray(params.result.order.identifier)) ? params.result.order.identifier : [],
299
- // 取引に指定があれば追加
300
- ...(Array.isArray(params.transaction.object.identifier)) ? params.transaction.object.identifier : []
301
- ];
302
- return { confirmationNumber, url, identifier };
303
- });
279
+ /* istanbul ignore next */
280
+ url = params.result.order.url(params.order);
281
+ }
282
+ // 識別子の指定があれば上書き
283
+ identifier = [
284
+ ...(Array.isArray(params.result.order.identifier)) ? params.result.order.identifier : [],
285
+ // 取引に指定があれば追加
286
+ ...(Array.isArray(params.transaction.object.identifier)) ? params.transaction.object.identifier : []
287
+ ];
288
+ return { confirmationNumber, url, identifier };
304
289
  }
305
290
  /**
306
291
  * インセンティブ承認
package/package.json CHANGED
@@ -9,8 +9,8 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.285.0",
13
- "@cinerino/sdk": "3.137.0",
12
+ "@chevre/factory": "4.286.0",
13
+ "@cinerino/sdk": "3.138.1",
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.0",
16
16
  "@sendgrid/mail": "6.4.0",
@@ -120,5 +120,5 @@
120
120
  "postversion": "git push origin --tags",
121
121
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
122
122
  },
123
- "version": "20.2.0-alpha.52"
123
+ "version": "20.2.0-alpha.53"
124
124
  }
@@ -1,6 +0,0 @@
1
- import * as factory from '../../../../factory';
2
- export declare function createConfirmPayActions(params: {
3
- order: factory.order.IOrder;
4
- transaction: factory.transaction.placeOrder.ITransaction;
5
- createConfirmPayActions: boolean;
6
- }): Promise<factory.action.interact.confirm.pay.IAttributes[]>;
@@ -1,65 +0,0 @@
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.createConfirmPayActions = void 0;
13
- const factory = require("../../../../factory");
14
- const order_1 = require("../../../../factory/order");
15
- function createConfirmPayActions(params) {
16
- return __awaiter(this, void 0, void 0, function* () {
17
- if (!params.createConfirmPayActions) {
18
- return [];
19
- }
20
- const authorizePaymentActions = params.transaction.object.authorizeActions
21
- .filter((a) => a.actionStatus === factory.actionStatusType.CompletedActionStatus
22
- && a.object.typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment
23
- // ↓もはやFaceToFaceも含めて全てPaymentDue(Chevre決済取引進行中)なので、確認は不要(2022-05-16~)
24
- // && a.result?.paymentStatus === factory.paymentStatusType.PaymentDue
25
- );
26
- return authorizePaymentActions.map((a) => {
27
- var _a;
28
- const result = a.result;
29
- const confirmingPayAssetTransaction = {
30
- typeOf: factory.assetTransactionType.Pay,
31
- // paymentMethod: {
32
- // paymentMethodId: result.paymentMethodId
33
- // },
34
- transactionNumber: result.paymentMethodId
35
- };
36
- if (typeof ((_a = a.instrument) === null || _a === void 0 ? void 0 : _a.typeOf) !== 'string') {
37
- throw new factory.errors.Argument('authorizePaymentActions.instrument.typeOf undefined');
38
- }
39
- return {
40
- project: params.transaction.project,
41
- typeOf: factory.actionType.ConfirmAction,
42
- object: [confirmingPayAssetTransaction],
43
- // agent: Projectに統一(2022-05-16~)
44
- agent: params.transaction.project,
45
- // agent: params.transaction.agent,
46
- // recipient: params.transaction.seller,
47
- purpose: {
48
- project: params.order.project,
49
- typeOf: params.order.typeOf,
50
- seller: params.order.seller,
51
- // mask
52
- customer: (0, order_1.createMaskedCustomer)(params.order),
53
- confirmationNumber: params.order.confirmationNumber,
54
- orderNumber: params.order.orderNumber,
55
- price: params.order.price,
56
- priceCurrency: params.order.priceCurrency,
57
- orderDate: params.order.orderDate
58
- },
59
- instrument: a.instrument
60
- // ...(typeof a.instrument?.typeOf === 'string') ? { instrument: a.instrument } : undefined
61
- };
62
- });
63
- });
64
- }
65
- exports.createConfirmPayActions = createConfirmPayActions;