@chevre/domain 21.20.0-alpha.6 → 21.20.0-alpha.7

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.
@@ -40,7 +40,7 @@ function publishPaymentUrl(params) {
40
40
  let result;
41
41
  switch (paymentServiceType) {
42
42
  case factory.service.paymentService.PaymentServiceType.CreditCard:
43
- const authorizeResult = yield CreditCardPayment.authorize(params, paymentServiceId, { searchTrade4accountId: false })(repos);
43
+ const authorizeResult = yield CreditCardPayment.authorize(params, paymentServiceId, { searchTrade4accountId: false, processPublishPaymentUrl: true })(repos);
44
44
  let paymentUrl;
45
45
  // 3DS拡張(2024-01-02~)
46
46
  const retUrl = (_c = params.object.paymentMethod.creditCard) === null || _c === void 0 ? void 0 : _c.retUrl;
@@ -304,7 +304,7 @@ function processAuthorizeAccount(params, transaction, paymentServiceId) {
304
304
  }
305
305
  function processAuthorizeCreditCard(params, transaction, paymentServiceId, options) {
306
306
  return (repos) => __awaiter(this, void 0, void 0, function* () {
307
- const authorizeResult = yield CreditCardPayment.authorize(params, paymentServiceId, Object.assign({ searchTrade4accountId: options.searchTrade4accountId }, (options.pendingPaymentAgencyTransaction !== undefined)
307
+ const authorizeResult = yield CreditCardPayment.authorize(params, paymentServiceId, Object.assign({ processPublishPaymentUrl: false, searchTrade4accountId: options.searchTrade4accountId }, (options.pendingPaymentAgencyTransaction !== undefined)
308
308
  ? { pendingPaymentAgencyTransaction: options.pendingPaymentAgencyTransaction }
309
309
  : undefined))(repos);
310
310
  return saveAuthorizeResult({
@@ -257,12 +257,13 @@ exports.publishPaymentUrl = publishPaymentUrl;
257
257
  function authorize(params) {
258
258
  // tslint:disable-next-line:max-func-body-length
259
259
  return (repos) => __awaiter(this, void 0, void 0, function* () {
260
- var _a;
260
+ var _a, _b;
261
261
  const transaction = yield repos.transaction.findInProgressById({ typeOf: params.purpose.typeOf, id: params.purpose.id });
262
262
  const paymentServiceType = params.paymentServiceType;
263
263
  // 取引番号生成
264
264
  let transactionNumber;
265
265
  let pendingPaymentAgencyTransaction;
266
+ let creditCard = params.object.creditCard;
266
267
  // リクエストでpaymentMethodIdを指定された場合、取引に保管されたpaymentMethodIdに一致すればそちらを適用(外部サイト決済対応)
267
268
  if (typeof params.object.paymentMethodId === 'string' && params.object.paymentMethodId.length > 0) {
268
269
  const paymentMethodByTransaction = transaction.object.paymentMethods;
@@ -272,6 +273,8 @@ function authorize(params) {
272
273
  object: params.object,
273
274
  paymentMethodByTransaction
274
275
  });
276
+ // creditCardを決済URL発行時の情報で上書き(2024-01-08~)
277
+ creditCard = (_a = paymentMethodByTransaction.paymentMethod) === null || _a === void 0 ? void 0 : _a.creditCard;
275
278
  transactionNumber = params.object.paymentMethodId;
276
279
  const { entryTranArgs, entryTranResult, execTranArgs, execTranResult } = paymentMethodByTransaction;
277
280
  if (entryTranArgs !== undefined && entryTranResult !== undefined
@@ -303,11 +306,12 @@ function authorize(params) {
303
306
  const publishTransactionNumberResult = yield repos.transactionNumber.publishByTimestamp({ startDate: new Date() });
304
307
  transactionNumber = publishTransactionNumberResult.transactionNumber;
305
308
  }
309
+ const authorizeObject = Object.assign(Object.assign(Object.assign({}, params.object), { paymentMethodId: transactionNumber, typeOf: factory.action.authorize.paymentMethod.any.ResultType.Payment }), (creditCard !== undefined) ? { creditCard } : undefined);
306
310
  // 承認アクションを開始する
307
311
  const actionAttributes = {
308
312
  project: transaction.project,
309
313
  typeOf: factory.actionType.AuthorizeAction,
310
- object: Object.assign(Object.assign({}, params.object), { paymentMethodId: transactionNumber, typeOf: factory.action.authorize.paymentMethod.any.ResultType.Payment }),
314
+ object: authorizeObject,
311
315
  agent: {
312
316
  typeOf: transaction.agent.typeOf,
313
317
  id: transaction.agent.id
@@ -321,7 +325,7 @@ function authorize(params) {
321
325
  id: transaction.seller.id,
322
326
  name: (typeof transaction.seller.name === 'string')
323
327
  ? transaction.seller.name
324
- : String((_a = transaction.seller.name) === null || _a === void 0 ? void 0 : _a.ja)
328
+ : String((_b = transaction.seller.name) === null || _b === void 0 ? void 0 : _b.ja)
325
329
  },
326
330
  purpose: { typeOf: transaction.typeOf, id: transaction.id }
327
331
  };
@@ -329,12 +333,12 @@ function authorize(params) {
329
333
  let payTransaction;
330
334
  try {
331
335
  const { accountId } = yield validateFromLocation({
332
- object: params.object,
336
+ object: authorizeObject,
333
337
  project: { id: transaction.project.id }
334
338
  })({ action: repos.action });
335
339
  const startParams = (0, factory_1.creatPayTransactionStartParams)({
336
340
  accountId,
337
- object: params.object,
341
+ object: authorizeObject,
338
342
  paymentServiceType,
339
343
  transaction: transaction,
340
344
  transactionNumber: transactionNumber,
@@ -369,17 +373,19 @@ function authorize(params) {
369
373
  throw error;
370
374
  }
371
375
  // アクションを完了
372
- const result = (0, factory_1.createAuthorizeResult)({ payTransaction, object: params.object });
376
+ const result = (0, factory_1.createAuthorizeResult)({ payTransaction, object: authorizeObject });
373
377
  return yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: result });
374
378
  });
375
379
  }
376
380
  exports.authorize = authorize;
377
381
  function validatePaymentMethodByTransaction(params) {
378
- var _a;
382
+ var _a, _b;
379
383
  const paymentServiceIdByObject = params.object.issuedThrough.id;
380
384
  const amountByObject = params.object.amount;
385
+ const paymentMethodTypeByObject = params.object.paymentMethod;
381
386
  const paymentServiceIdByTransaction = params.paymentMethodByTransaction.issuedThrough.id;
382
- const amountByTransaction = (_a = params.paymentMethodByTransaction.entryTranArgs) === null || _a === void 0 ? void 0 : _a.amount;
387
+ const amountByTransaction = (_a = params.paymentMethodByTransaction.paymentMethod) === null || _a === void 0 ? void 0 : _a.amount;
388
+ const paymentMethodTypeByTransaction = (_b = params.paymentMethodByTransaction.paymentMethod) === null || _b === void 0 ? void 0 : _b.identifier;
383
389
  // 決済サービスID検証
384
390
  if (paymentServiceIdByObject !== paymentServiceIdByTransaction) {
385
391
  throw new factory.errors.Argument('object.issuedThrough.id', 'issuedThrough.id must match the target of the paymentUrl');
@@ -388,9 +394,9 @@ function validatePaymentMethodByTransaction(params) {
388
394
  if (amountByObject !== amountByTransaction) {
389
395
  throw new factory.errors.Argument('object.amount', 'amount must match the target of the paymentUrl');
390
396
  }
391
- if (params.paymentMethodByTransaction.paymentMethod !== undefined) {
392
- // tslint:disable-next-line:no-suspicious-comment
393
- // TODO params.objectを上書きするか?
397
+ // 決済方法区分検証
398
+ if (paymentMethodTypeByObject !== paymentMethodTypeByTransaction) {
399
+ throw new factory.errors.Argument('object.paymentMethod', 'paymentMethod must match the target of the paymentUrl');
394
400
  }
395
401
  }
396
402
  function validateFromLocation(params) {
@@ -26,6 +26,10 @@ type IAuthorizeResult = IPaymentAgencyTransaction & {
26
26
  declare function authorize(params: factory.assetTransaction.pay.IStartParamsWithoutDetail, paymentServiceId: string, options: {
27
27
  searchTrade4accountId: boolean;
28
28
  pendingPaymentAgencyTransaction?: IPaymentAgencyTransaction;
29
+ /**
30
+ * 決済URL発行処理かどうか
31
+ */
32
+ processPublishPaymentUrl: boolean;
29
33
  }): (repos: {
30
34
  paymentAccepted: PaymentAcceptedRepo;
31
35
  paymentService: PaymentServiceRepo;
@@ -76,7 +76,8 @@ function authorize(params, paymentServiceId, options) {
76
76
  callbackType3ds,
77
77
  orderId: orderId,
78
78
  availableChannel: availableChannel,
79
- object: params.object.paymentMethod
79
+ object: params.object.paymentMethod,
80
+ processPublishPaymentUrl: options.processPublishPaymentUrl
80
81
  })();
81
82
  }
82
83
  }
@@ -137,7 +138,7 @@ function processAuthorizeCreditCard(params) {
137
138
  }
138
139
  const retUrl = creditCard === null || creditCard === void 0 ? void 0 : creditCard.retUrl;
139
140
  // 3DS拡張(2024-01-02~)
140
- if (typeof retUrl === 'string' && retUrl.length > 0) {
141
+ if (params.processPublishPaymentUrl === true && typeof retUrl === 'string' && retUrl.length > 0) {
141
142
  let returnUrlObject;
142
143
  try {
143
144
  returnUrlObject = new URL(retUrl);
package/package.json CHANGED
@@ -115,5 +115,5 @@
115
115
  "postversion": "git push origin --tags",
116
116
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
117
117
  },
118
- "version": "21.20.0-alpha.6"
118
+ "version": "21.20.0-alpha.7"
119
119
  }