@chevre/domain 21.20.0-alpha.2 → 21.20.0-alpha.22

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.
Files changed (113) hide show
  1. package/example/src/chevre/onAssetTransactionStatusChanged.ts +36 -0
  2. package/example/src/chevre/retryTasks.ts +39 -0
  3. package/example/src/chevre/searchOrders.ts +13 -15
  4. package/example/src/chevre/searchSlicedAcceptedOffersByOrderNumber.ts +28 -0
  5. package/example/src/chevre/sendOrder.ts +37 -0
  6. package/example/src/chevre/transaction/processAcceptOffer.ts +48 -0
  7. package/example/src/chevre/transaction/processPlaceOrder.ts +82 -53
  8. package/lib/chevre/repo/acceptedOffer.d.ts +21 -1
  9. package/lib/chevre/repo/acceptedOffer.js +32 -2
  10. package/lib/chevre/repo/action.d.ts +13 -7
  11. package/lib/chevre/repo/action.js +33 -11
  12. package/lib/chevre/repo/mongoose/schemas/order.d.ts +1 -1
  13. package/lib/chevre/repo/mongoose/schemas/order.js +20 -11
  14. package/lib/chevre/repo/order.js +28 -9
  15. package/lib/chevre/repo/orderInTransaction.d.ts +27 -0
  16. package/lib/chevre/repo/orderInTransaction.js +77 -0
  17. package/lib/chevre/repo/task.d.ts +0 -2
  18. package/lib/chevre/repo/task.js +56 -46
  19. package/lib/chevre/repo/transaction.d.ts +1 -1
  20. package/lib/chevre/repository.d.ts +5 -0
  21. package/lib/chevre/repository.js +15 -2
  22. package/lib/chevre/service/assetTransaction/pay.d.ts +0 -10
  23. package/lib/chevre/service/assetTransaction/pay.js +4 -4
  24. package/lib/chevre/service/code.js +1 -1
  25. package/lib/chevre/service/delivery.js +2 -2
  26. package/lib/chevre/service/event/createEvent.js +1 -1
  27. package/lib/chevre/service/event.js +2 -2
  28. package/lib/chevre/service/moneyTransfer.js +1 -1
  29. package/lib/chevre/service/notification.js +2 -5
  30. package/lib/chevre/service/offer/any.d.ts +29 -0
  31. package/lib/chevre/service/offer/any.js +55 -0
  32. package/lib/chevre/service/offer/event/authorize.d.ts +7 -0
  33. package/lib/chevre/service/offer/event/authorize.js +11 -0
  34. package/lib/chevre/service/offer/event/cancel.d.ts +2 -0
  35. package/lib/chevre/service/offer/event/cancel.js +12 -1
  36. package/lib/chevre/service/offer/event/voidTransaction.d.ts +2 -0
  37. package/lib/chevre/service/offer/event/voidTransaction.js +12 -5
  38. package/lib/chevre/service/offer/eventServiceByCOA/authorize.d.ts +48 -0
  39. package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +133 -0
  40. package/lib/chevre/service/offer/eventServiceByCOA/cancel.d.ts +39 -0
  41. package/lib/chevre/service/offer/eventServiceByCOA/cancel.js +58 -0
  42. package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.d.ts +25 -0
  43. package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +156 -0
  44. package/lib/chevre/service/offer/eventServiceByCOA.d.ts +4 -89
  45. package/lib/chevre/service/offer/eventServiceByCOA.js +7 -292
  46. package/lib/chevre/service/offer/moneyTransfer/authorize.d.ts +6 -1
  47. package/lib/chevre/service/offer/moneyTransfer/authorize.js +2 -1
  48. package/lib/chevre/service/offer/moneyTransfer/returnMoneyTransfer.js +1 -1
  49. package/lib/chevre/service/offer/moneyTransfer/settleTransaction.js +1 -1
  50. package/lib/chevre/service/offer/moneyTransfer/voidTransaction.js +1 -1
  51. package/lib/chevre/service/offer/product.js +1 -1
  52. package/lib/chevre/service/order/confirmPayTransaction.js +3 -3
  53. package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +11 -1
  54. package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +113 -5
  55. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.js +18 -19
  56. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +38 -25
  57. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +11 -0
  58. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.js +45 -0
  59. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.d.ts +14 -0
  60. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.js +37 -0
  61. package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.d.ts +10 -0
  62. package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +86 -0
  63. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +51 -36
  64. package/lib/chevre/service/order/onOrderStatusChanged.d.ts +3 -1
  65. package/lib/chevre/service/order/onOrderStatusChanged.js +5 -1
  66. package/lib/chevre/service/order/placeOrder.d.ts +2 -0
  67. package/lib/chevre/service/order/placeOrder.js +28 -29
  68. package/lib/chevre/service/order/returnOrder.js +25 -16
  69. package/lib/chevre/service/order/sendOrder.d.ts +5 -0
  70. package/lib/chevre/service/order/sendOrder.js +68 -30
  71. package/lib/chevre/service/payment/any.d.ts +6 -8
  72. package/lib/chevre/service/payment/any.js +46 -10
  73. package/lib/chevre/service/payment/creditCard.d.ts +9 -8
  74. package/lib/chevre/service/payment/creditCard.js +102 -133
  75. package/lib/chevre/service/payment/faceToFace.d.ts +0 -4
  76. package/lib/chevre/service/payment/movieTicket/checkByIdentifier.d.ts +0 -2
  77. package/lib/chevre/service/payment/movieTicket/checkByIdentifier.js +1 -0
  78. package/lib/chevre/service/payment/movieTicket/validation.d.ts +0 -2
  79. package/lib/chevre/service/payment/movieTicket.d.ts +0 -6
  80. package/lib/chevre/service/payment/movieTicket.js +1 -1
  81. package/lib/chevre/service/payment/paymentCard.d.ts +0 -2
  82. package/lib/chevre/service/payment/paymentCard.js +6 -6
  83. package/lib/chevre/service/payment.js +1 -1
  84. package/lib/chevre/service/product.js +1 -1
  85. package/lib/chevre/service/reserve/cancelReservation.js +2 -2
  86. package/lib/chevre/service/reserve/confirmReservation.js +1 -1
  87. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.d.ts +1 -1
  88. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +4 -4
  89. package/lib/chevre/service/reserve/useReservation.d.ts +1 -2
  90. package/lib/chevre/service/reserve/useReservation.js +4 -4
  91. package/lib/chevre/service/reserve/verifyToken4reservation.js +2 -0
  92. package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +1 -1
  93. package/lib/chevre/service/task/confirmReserveTransaction.d.ts +4 -1
  94. package/lib/chevre/service/task/confirmReserveTransaction.js +42 -3
  95. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +7 -7
  96. package/lib/chevre/service/task/placeOrder.js +9 -10
  97. package/lib/chevre/service/task/returnOrder.js +0 -3
  98. package/lib/chevre/service/task/returnPayTransaction.js +1 -1
  99. package/lib/chevre/service/task/returnReserveTransaction.js +1 -1
  100. package/lib/chevre/service/task/sendOrder.js +8 -4
  101. package/lib/chevre/service/task/voidPayTransaction.js +2 -2
  102. package/lib/chevre/service/task/voidReserveTransaction.js +8 -12
  103. package/lib/chevre/service/transaction/deleteTransaction.js +1 -1
  104. package/lib/chevre/service/transaction/moneyTransfer.js +1 -5
  105. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.js +18 -13
  106. package/lib/chevre/service/transaction/placeOrderInProgress.js +2 -2
  107. package/lib/chevre/service/transaction/returnOrder/preStart.d.ts +32 -0
  108. package/lib/chevre/service/transaction/returnOrder/preStart.js +632 -0
  109. package/lib/chevre/service/transaction/returnOrder.d.ts +8 -6
  110. package/lib/chevre/service/transaction/returnOrder.js +4 -616
  111. package/lib/chevre/settings.d.ts +3 -1
  112. package/lib/chevre/settings.js +7 -2
  113. package/package.json +3 -3
@@ -79,7 +79,11 @@ function invalidatePaymentUrl(params) {
79
79
  : String((_c = transaction.seller.name) === null || _c === void 0 ? void 0 : _c.ja),
80
80
  id: transaction.seller.id
81
81
  },
82
- recipient: { typeOf: transaction.agent.typeOf, name: transaction.agent.name },
82
+ recipient: {
83
+ typeOf: transaction.agent.typeOf,
84
+ id: transaction.agent.id,
85
+ name: transaction.agent.name
86
+ },
83
87
  object: [{
84
88
  typeOf: factory.service.paymentService.PaymentServiceType.CreditCard,
85
89
  id: (_e = (_d = transaction.object.paymentMethods) === null || _d === void 0 ? void 0 : _d.issuedThrough) === null || _e === void 0 ? void 0 : _e.id,
@@ -193,7 +197,7 @@ function processVoidPayTransaction(params) {
193
197
  }
194
198
  }
195
199
  }
196
- yield repos.action.cancel({ typeOf: action.typeOf, id: action.id });
200
+ yield repos.action.cancelWithVoid({ typeOf: action.typeOf, id: action.id });
197
201
  }
198
202
  catch (error) {
199
203
  errors.push(error);
@@ -237,7 +241,8 @@ function publishPaymentUrl(params) {
237
241
  entryTranArgs: result.entryTranArgs,
238
242
  entryTranResult: result.entryTranResult,
239
243
  execTranArgs: result.execTranArgs,
240
- execTranResult: result.execTranResult
244
+ execTranResult: result.execTranResult,
245
+ paymentMethod: startParams.object.paymentMethod // 拡張(2024-01-04~)
241
246
  };
242
247
  yield repos.transaction.findByIdAndUpdateInProgress({
243
248
  id: transaction.id,
@@ -256,16 +261,24 @@ exports.publishPaymentUrl = publishPaymentUrl;
256
261
  function authorize(params) {
257
262
  // tslint:disable-next-line:max-func-body-length
258
263
  return (repos) => __awaiter(this, void 0, void 0, function* () {
259
- var _a;
264
+ var _a, _b;
260
265
  const transaction = yield repos.transaction.findInProgressById({ typeOf: params.purpose.typeOf, id: params.purpose.id });
261
266
  const paymentServiceType = params.paymentServiceType;
262
267
  // 取引番号生成
263
268
  let transactionNumber;
264
269
  let pendingPaymentAgencyTransaction;
270
+ let creditCard = params.object.creditCard;
265
271
  // リクエストでpaymentMethodIdを指定された場合、取引に保管されたpaymentMethodIdに一致すればそちらを適用(外部サイト決済対応)
266
272
  if (typeof params.object.paymentMethodId === 'string' && params.object.paymentMethodId.length > 0) {
267
273
  const paymentMethodByTransaction = transaction.object.paymentMethods;
268
274
  if (params.object.paymentMethodId === (paymentMethodByTransaction === null || paymentMethodByTransaction === void 0 ? void 0 : paymentMethodByTransaction.paymentMethodId)) {
275
+ // 検証強化(2024-01-04~)
276
+ validatePaymentMethodByTransaction({
277
+ object: params.object,
278
+ paymentMethodByTransaction
279
+ });
280
+ // creditCardを決済URL発行時の情報で上書き(2024-01-08~)
281
+ creditCard = (_a = paymentMethodByTransaction.paymentMethod) === null || _a === void 0 ? void 0 : _a.creditCard;
269
282
  transactionNumber = params.object.paymentMethodId;
270
283
  const { entryTranArgs, entryTranResult, execTranArgs, execTranResult } = paymentMethodByTransaction;
271
284
  if (entryTranArgs !== undefined && entryTranResult !== undefined
@@ -297,11 +310,12 @@ function authorize(params) {
297
310
  const publishTransactionNumberResult = yield repos.transactionNumber.publishByTimestamp({ startDate: new Date() });
298
311
  transactionNumber = publishTransactionNumberResult.transactionNumber;
299
312
  }
313
+ const authorizeObject = Object.assign(Object.assign(Object.assign({}, params.object), { paymentMethodId: transactionNumber, typeOf: factory.action.authorize.paymentMethod.any.ResultType.Payment }), (creditCard !== undefined) ? { creditCard } : undefined);
300
314
  // 承認アクションを開始する
301
315
  const actionAttributes = {
302
316
  project: transaction.project,
303
317
  typeOf: factory.actionType.AuthorizeAction,
304
- object: Object.assign(Object.assign({}, params.object), { paymentMethodId: transactionNumber, typeOf: factory.action.authorize.paymentMethod.any.ResultType.Payment }),
318
+ object: authorizeObject,
305
319
  agent: {
306
320
  typeOf: transaction.agent.typeOf,
307
321
  id: transaction.agent.id
@@ -315,7 +329,7 @@ function authorize(params) {
315
329
  id: transaction.seller.id,
316
330
  name: (typeof transaction.seller.name === 'string')
317
331
  ? transaction.seller.name
318
- : String((_a = transaction.seller.name) === null || _a === void 0 ? void 0 : _a.ja)
332
+ : String((_b = transaction.seller.name) === null || _b === void 0 ? void 0 : _b.ja)
319
333
  },
320
334
  purpose: { typeOf: transaction.typeOf, id: transaction.id }
321
335
  };
@@ -323,12 +337,12 @@ function authorize(params) {
323
337
  let payTransaction;
324
338
  try {
325
339
  const { accountId } = yield validateFromLocation({
326
- object: params.object,
340
+ object: authorizeObject,
327
341
  project: { id: transaction.project.id }
328
342
  })({ action: repos.action });
329
343
  const startParams = (0, factory_1.creatPayTransactionStartParams)({
330
344
  accountId,
331
- object: params.object,
345
+ object: authorizeObject,
332
346
  paymentServiceType,
333
347
  transaction: transaction,
334
348
  transactionNumber: transactionNumber,
@@ -363,11 +377,33 @@ function authorize(params) {
363
377
  throw error;
364
378
  }
365
379
  // アクションを完了
366
- const result = (0, factory_1.createAuthorizeResult)({ payTransaction, object: params.object });
367
- return yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: result });
380
+ const result = (0, factory_1.createAuthorizeResult)({ payTransaction, object: authorizeObject });
381
+ yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: result });
382
+ return { id: action.id };
368
383
  });
369
384
  }
370
385
  exports.authorize = authorize;
386
+ function validatePaymentMethodByTransaction(params) {
387
+ var _a, _b;
388
+ const paymentServiceIdByObject = params.object.issuedThrough.id;
389
+ const amountByObject = params.object.amount;
390
+ const paymentMethodTypeByObject = params.object.paymentMethod;
391
+ const paymentServiceIdByTransaction = params.paymentMethodByTransaction.issuedThrough.id;
392
+ const amountByTransaction = (_a = params.paymentMethodByTransaction.paymentMethod) === null || _a === void 0 ? void 0 : _a.amount;
393
+ const paymentMethodTypeByTransaction = (_b = params.paymentMethodByTransaction.paymentMethod) === null || _b === void 0 ? void 0 : _b.identifier;
394
+ // 決済サービスID検証
395
+ if (paymentServiceIdByObject !== paymentServiceIdByTransaction) {
396
+ throw new factory.errors.Argument('object.issuedThrough.id', 'issuedThrough.id must match the target of the paymentUrl');
397
+ }
398
+ // 金額検証
399
+ if (amountByObject !== amountByTransaction) {
400
+ throw new factory.errors.Argument('object.amount', 'amount must match the target of the paymentUrl');
401
+ }
402
+ // 決済方法区分検証
403
+ if (paymentMethodTypeByObject !== paymentMethodTypeByTransaction) {
404
+ throw new factory.errors.Argument('object.paymentMethod', 'paymentMethod must match the target of the paymentUrl');
405
+ }
406
+ }
371
407
  function validateFromLocation(params) {
372
408
  return (repos) => __awaiter(this, void 0, void 0, function* () {
373
409
  var _a, _b;
@@ -7,8 +7,6 @@ import type { MongoRepository as AccountingReportRepo } from '../../repo/account
7
7
  import type { MongoRepository as ActionRepo } from '../../repo/action';
8
8
  import type { MongoRepository as PaymentServiceRepo } from '../../repo/paymentService';
9
9
  import type { MongoRepository as PaymentServiceProviderRepo } from '../../repo/paymentServiceProvider';
10
- import type { CognitoRepository as PersonRepo } from '../../repo/person';
11
- import type { MongoRepository as ProjectRepo } from '../../repo/project';
12
10
  import type { MongoRepository as PaymentAcceptedRepo } from '../../repo/sellerPaymentAccepted';
13
11
  import type { MongoRepository as TaskRepo } from '../../repo/task';
14
12
  interface IPaymentAgencyTransaction {
@@ -28,12 +26,14 @@ type IAuthorizeResult = IPaymentAgencyTransaction & {
28
26
  declare function authorize(params: factory.assetTransaction.pay.IStartParamsWithoutDetail, paymentServiceId: string, options: {
29
27
  searchTrade4accountId: boolean;
30
28
  pendingPaymentAgencyTransaction?: IPaymentAgencyTransaction;
29
+ /**
30
+ * 決済URL発行処理かどうか
31
+ */
32
+ processPublishPaymentUrl: boolean;
31
33
  }): (repos: {
32
34
  paymentAccepted: PaymentAcceptedRepo;
33
35
  paymentService: PaymentServiceRepo;
34
36
  paymentServiceProvider: PaymentServiceProviderRepo;
35
- person: PersonRepo;
36
- project: ProjectRepo;
37
37
  }) => Promise<IAuthorizeResult>;
38
38
  /**
39
39
  * クレジットカード決済中止
@@ -42,7 +42,6 @@ declare function voidTransaction(params: factory.task.voidPayment.IData): (repos
42
42
  paymentAccepted: PaymentAcceptedRepo;
43
43
  paymentService: PaymentServiceRepo;
44
44
  paymentServiceProvider: PaymentServiceProviderRepo;
45
- project: ProjectRepo;
46
45
  }) => Promise<void>;
47
46
  /**
48
47
  * クレジットカード決済
@@ -53,24 +52,26 @@ declare function payCreditCard(params: factory.task.pay.IData): (repos: {
53
52
  paymentAccepted: PaymentAcceptedRepo;
54
53
  paymentService: PaymentServiceRepo;
55
54
  paymentServiceProvider: PaymentServiceProviderRepo;
56
- project: ProjectRepo;
57
55
  task: TaskRepo;
58
56
  }) => Promise<import("@chevre/factory/lib/action/trade/pay").IAction>;
59
57
  /**
60
58
  * クレジットカード返金
61
59
  */
62
- declare function refundCreditCard(params: factory.task.refund.IData, requirePayAction: boolean): (repos: {
60
+ declare function refundCreditCard(params: factory.task.refund.IData, options: {
61
+ requirePayAction: boolean;
62
+ }): (repos: {
63
63
  action: ActionRepo;
64
64
  accountingReport: AccountingReportRepo;
65
65
  paymentAccepted: PaymentAcceptedRepo;
66
66
  paymentService: PaymentServiceRepo;
67
67
  paymentServiceProvider: PaymentServiceProviderRepo;
68
- project: ProjectRepo;
69
68
  task: TaskRepo;
70
69
  }) => Promise<import("@chevre/factory/lib/action/trade/refund").IAction>;
71
70
  interface IGMOInfo {
72
71
  shopId: string;
73
72
  shopPass: string;
73
+ returnUrls3ds: string[];
74
+ callbackType3ds?: factory.service.paymentService.ICallbackType3ds;
74
75
  }
75
76
  declare function getGMOInfoFromSeller(params: {
76
77
  paymentMethodType: string;
@@ -20,7 +20,7 @@ const credentials_1 = require("../../credentials");
20
20
  const factory = require("../../factory");
21
21
  const onPaid_1 = require("./any/onPaid");
22
22
  const onRefund_1 = require("./any/onRefund");
23
- const person2username_1 = require("./any/person2username");
23
+ // import { person2username } from './any/person2username';
24
24
  const debug = createDebug('chevre-domain:service:payment');
25
25
  /**
26
26
  * クレジットカード決済承認
@@ -28,12 +28,12 @@ const debug = createDebug('chevre-domain:service:payment');
28
28
  function authorize(params, paymentServiceId, options) {
29
29
  // tslint:disable-next-line:max-func-body-length
30
30
  return (repos) => __awaiter(this, void 0, void 0, function* () {
31
+ // const project = <Pick<factory.project.IProject, 'settings'>>await repos.project.findById({
32
+ // id: params.project.id,
33
+ // inclusion: ['settings'],
34
+ // exclusion: []
35
+ // });
31
36
  var _a, _b, _c, _d, _e;
32
- const project = yield repos.project.findById({
33
- id: params.project.id,
34
- inclusion: ['settings'],
35
- exclusion: []
36
- });
37
37
  // CreditCard系統の決済方法タイプは動的
38
38
  const paymentMethodType = (_a = params.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.identifier;
39
39
  if (typeof paymentMethodType !== 'string') {
@@ -48,7 +48,7 @@ function authorize(params, paymentServiceId, options) {
48
48
  if (typeof sellerId !== 'string') {
49
49
  throw new factory.errors.ArgumentNull('recipient.id');
50
50
  }
51
- const { shopId, shopPass } = yield getGMOInfoFromSeller({ paymentMethodType, seller: { id: sellerId }, paymentServiceId })(repos);
51
+ const { shopId, shopPass, returnUrls3ds, callbackType3ds } = yield getGMOInfoFromSeller({ paymentMethodType, seller: { id: sellerId }, paymentServiceId })(repos);
52
52
  // GMOオーダーIDはカスタム指定可能
53
53
  const orderId = params.transactionNumber;
54
54
  if (typeof orderId !== 'string') {
@@ -69,13 +69,16 @@ function authorize(params, paymentServiceId, options) {
69
69
  }
70
70
  else {
71
71
  authorizeResult = yield processAuthorizeCreditCard({
72
- projectSettings: project.settings,
72
+ // projectSettings: project.settings,
73
73
  shopId: shopId,
74
74
  shopPass: shopPass,
75
+ returnUrls3ds,
76
+ callbackType3ds,
75
77
  orderId: orderId,
76
78
  availableChannel: availableChannel,
77
- object: params.object.paymentMethod
78
- })(repos);
79
+ object: params.object.paymentMethod,
80
+ processPublishPaymentUrl: options.processPublishPaymentUrl
81
+ })();
79
82
  }
80
83
  }
81
84
  catch (error) {
@@ -108,8 +111,8 @@ function authorize(params, paymentServiceId, options) {
108
111
  exports.authorize = authorize;
109
112
  function processAuthorizeCreditCard(params) {
110
113
  // tslint:disable-next-line:max-func-body-length
111
- return (repos) => __awaiter(this, void 0, void 0, function* () {
112
- var _a, _b, _c, _d, _e;
114
+ return () => __awaiter(this, void 0, void 0, function* () {
115
+ var _a, _b, _c, _d, _e, _f;
113
116
  // GMOオーソリ取得
114
117
  let entryTranArgs;
115
118
  let entryTranResult;
@@ -117,25 +120,36 @@ function processAuthorizeCreditCard(params) {
117
120
  let execTranResult;
118
121
  const creditCardService = new GMO.service.Credit({ endpoint: String(params.availableChannel.serviceUrl) }, { timeout: credentials_1.credentials.gmo.timeout });
119
122
  const creditCard = params.object.creditCard;
120
- let memberId = creditCard.memberId;
123
+ const memberId = creditCard.memberId;
121
124
  const cardSeq = creditCard.cardSeq;
122
125
  if (typeof memberId === 'string' && memberId.length > 0 && typeof cardSeq === 'number') {
126
+ // 決済承認時のuseUsernameAsGMOMemberId判定を廃止(2024-01-04~)
123
127
  // 特殊なプロジェクトのみユーザーネームに自動変換(新旧会員互換性維持対応)
124
128
  // memberIdはPersonIDが指定されてくる想定
125
- const useUsernameAsGMOMemberId = ((_a = params.projectSettings) === null || _a === void 0 ? void 0 : _a.useUsernameAsGMOMemberId) === true;
126
- if (useUsernameAsGMOMemberId) {
127
- try {
128
- const customer = yield repos.person.findById({ userId: memberId });
129
- memberId = yield (0, person2username_1.person2username)(customer);
130
- }
131
- catch (error) {
132
- throw error;
133
- }
134
- }
129
+ // const useUsernameAsGMOMemberId = params.projectSettings?.useUsernameAsGMOMemberId === true;
130
+ // if (useUsernameAsGMOMemberId) {
131
+ // try {
132
+ // const customer = await repos.person.findById({ userId: memberId });
133
+ // memberId = await person2username(customer);
134
+ // } catch (error) {
135
+ // throw error;
136
+ // }
137
+ // }
135
138
  }
136
139
  const retUrl = creditCard === null || creditCard === void 0 ? void 0 : creditCard.retUrl;
137
140
  // 3DS拡張(2024-01-02~)
138
- if (typeof retUrl === 'string' && retUrl.length > 0) {
141
+ if (params.processPublishPaymentUrl === true && typeof retUrl === 'string' && retUrl.length > 0) {
142
+ let returnUrlObject;
143
+ try {
144
+ returnUrlObject = new URL(retUrl);
145
+ }
146
+ catch (error) {
147
+ throw new factory.errors.Argument('object.creditCard.retUrl', 'retUrl unparsable');
148
+ }
149
+ const returnUrlShouldBeIncluded = `${returnUrlObject.origin}${returnUrlObject.pathname}`;
150
+ if (!params.returnUrls3ds.includes(returnUrlShouldBeIncluded)) {
151
+ throw new factory.errors.Argument('object.creditCard.retUrl', 'invalid returnUrl');
152
+ }
139
153
  entryTranArgs = {
140
154
  shopId: params.shopId,
141
155
  shopPass: params.shopPass,
@@ -156,8 +170,8 @@ function processAuthorizeCreditCard(params) {
156
170
  accessPass: entryTranResult.accessPass,
157
171
  orderId: params.orderId,
158
172
  method: params.object.method,
159
- // siteId: params.availableChannel.credentials?.siteId,
160
- // sitePass: params.availableChannel.credentials?.sitePass,
173
+ siteId: (_a = params.availableChannel.credentials) === null || _a === void 0 ? void 0 : _a.siteId,
174
+ sitePass: (_b = params.availableChannel.credentials) === null || _b === void 0 ? void 0 : _b.sitePass,
161
175
  cardNo: creditCard.cardNo,
162
176
  cardPass: creditCard.cardPass,
163
177
  expire: creditCard.expire,
@@ -166,7 +180,7 @@ function processAuthorizeCreditCard(params) {
166
180
  cardSeq: cardSeq,
167
181
  seqMode: GMO.utils.util.SeqMode.Physics,
168
182
  retUrl,
169
- callbackType: GMO.utils.util.CallbackType.Get
183
+ callbackType: (params.callbackType3ds === 'GET') ? GMO.utils.util.CallbackType.Get : GMO.utils.util.CallbackType.Post
170
184
  };
171
185
  execTranResult = yield creditCardService.execTran3ds(execTranArgs);
172
186
  }
@@ -179,8 +193,8 @@ function processAuthorizeCreditCard(params) {
179
193
  amount: (typeof params.object.amount === 'number')
180
194
  ? params.object.amount
181
195
  : params.object.amount.value,
182
- siteId: (_b = params.availableChannel.credentials) === null || _b === void 0 ? void 0 : _b.siteId,
183
- sitePass: (_c = params.availableChannel.credentials) === null || _c === void 0 ? void 0 : _c.sitePass
196
+ siteId: (_c = params.availableChannel.credentials) === null || _c === void 0 ? void 0 : _c.siteId,
197
+ sitePass: (_d = params.availableChannel.credentials) === null || _d === void 0 ? void 0 : _d.sitePass
184
198
  };
185
199
  entryTranResult = yield creditCardService.entryTran(entryTranArgs);
186
200
  execTranArgs = {
@@ -188,8 +202,8 @@ function processAuthorizeCreditCard(params) {
188
202
  accessPass: entryTranResult.accessPass,
189
203
  orderId: params.orderId,
190
204
  method: params.object.method,
191
- siteId: (_d = params.availableChannel.credentials) === null || _d === void 0 ? void 0 : _d.siteId,
192
- sitePass: (_e = params.availableChannel.credentials) === null || _e === void 0 ? void 0 : _e.sitePass,
205
+ siteId: (_e = params.availableChannel.credentials) === null || _e === void 0 ? void 0 : _e.siteId,
206
+ sitePass: (_f = params.availableChannel.credentials) === null || _f === void 0 ? void 0 : _f.sitePass,
193
207
  cardNo: creditCard.cardNo,
194
208
  cardPass: creditCard.cardPass,
195
209
  expire: creditCard.expire,
@@ -281,31 +295,28 @@ function voidTransaction(params) {
281
295
  // オーソリ取消
282
296
  // 現時点では、ここで失敗したらオーソリ取消をあきらめる
283
297
  // GMO混雑エラーはここでも発生する(取消処理でも混雑エラーが発生することは確認済)
284
- try {
285
- const searchTradeResult = yield creditCardService.searchTrade({
298
+ // try {
299
+ // } catch (error) {
300
+ // // no op
301
+ // }
302
+ const searchTradeResult = yield creditCardService.searchTrade({
303
+ shopId: shopId,
304
+ shopPass: shopPass,
305
+ orderId: paymentMethodId,
306
+ siteId: (_c = availableChannel.credentials) === null || _c === void 0 ? void 0 : _c.siteId,
307
+ sitePass: (_d = availableChannel.credentials) === null || _d === void 0 ? void 0 : _d.sitePass
308
+ });
309
+ // 仮売上であれば取消
310
+ if (searchTradeResult.status === GMO.utils.util.JobCd.Auth) {
311
+ yield creditCardService.alterTran({
286
312
  shopId: shopId,
287
313
  shopPass: shopPass,
288
- orderId: paymentMethodId,
289
- siteId: (_c = availableChannel.credentials) === null || _c === void 0 ? void 0 : _c.siteId,
290
- sitePass: (_d = availableChannel.credentials) === null || _d === void 0 ? void 0 : _d.sitePass
314
+ accessId: searchTradeResult.accessId,
315
+ accessPass: searchTradeResult.accessPass,
316
+ jobCd: GMO.utils.util.JobCd.Void,
317
+ siteId: (_e = availableChannel.credentials) === null || _e === void 0 ? void 0 : _e.siteId,
318
+ sitePass: (_f = availableChannel.credentials) === null || _f === void 0 ? void 0 : _f.sitePass
291
319
  });
292
- debug('searchTradeResult:', searchTradeResult);
293
- // 仮売上であれば取消
294
- if (searchTradeResult.status === GMO.utils.util.JobCd.Auth) {
295
- const alterTranResult = yield creditCardService.alterTran({
296
- shopId: shopId,
297
- shopPass: shopPass,
298
- accessId: searchTradeResult.accessId,
299
- accessPass: searchTradeResult.accessPass,
300
- jobCd: GMO.utils.util.JobCd.Void,
301
- siteId: (_e = availableChannel.credentials) === null || _e === void 0 ? void 0 : _e.siteId,
302
- sitePass: (_f = availableChannel.credentials) === null || _f === void 0 ? void 0 : _f.sitePass
303
- });
304
- debug('alterTran processed', alterTranResult);
305
- }
306
- }
307
- catch (error) {
308
- // no op
309
320
  }
310
321
  });
311
322
  }
@@ -434,7 +445,7 @@ function processAlterTran(params) {
434
445
  /**
435
446
  * クレジットカード返金
436
447
  */
437
- function refundCreditCard(params, requirePayAction) {
448
+ function refundCreditCard(params, options) {
438
449
  return (repos) => __awaiter(this, void 0, void 0, function* () {
439
450
  var _a, _b, _c, _d, _e;
440
451
  const paymentMethodType = (_a = params.object[0]) === null || _a === void 0 ? void 0 : _a.paymentMethod.typeOf;
@@ -442,7 +453,7 @@ function refundCreditCard(params, requirePayAction) {
442
453
  const paymentServiceId = (_c = params.object[0]) === null || _c === void 0 ? void 0 : _c.id;
443
454
  // 本アクションに対応するPayActionを取り出す(Cinerino側で決済していた時期に関してはpayActionが存在しないので注意)
444
455
  let payAction;
445
- if (requirePayAction) {
456
+ if (options.requirePayAction) {
446
457
  payAction = yield repos.action.findPayAction({ project: { id: params.project.id }, paymentMethodId });
447
458
  if (payAction === undefined) {
448
459
  throw new factory.errors.NotFound('PayAction');
@@ -491,7 +502,6 @@ function processChangeTransaction(params) {
491
502
  const alterTranResult = [];
492
503
  const creditCardService = new GMO.service.Credit({ endpoint: String(params.availableChannel.serviceUrl) }, { timeout: credentials_1.credentials.gmo.timeout });
493
504
  // 取引状態参照
494
- debug('searching trade...', params.paymentMethodId);
495
505
  const searchTradeResult = yield creditCardService.searchTrade({
496
506
  shopId: params.shopId,
497
507
  shopPass: params.shopPass,
@@ -507,7 +517,7 @@ function processChangeTransaction(params) {
507
517
  let alreadyRefunded = false;
508
518
  // 決済時のGMO取引を確認できれば、既に返金済かどうかを判定
509
519
  if (typeof (creditCardSalesBefore === null || creditCardSalesBefore === void 0 ? void 0 : creditCardSalesBefore.tranId) === 'string') {
510
- // // GMO取引状態に変更がなければ金額変更
520
+ // GMO取引状態に変更がなければ金額変更
511
521
  if (searchTradeResult.tranId !== creditCardSalesBefore.tranId) {
512
522
  alreadyRefunded = true;
513
523
  }
@@ -523,71 +533,43 @@ function processChangeTransaction(params) {
523
533
  });
524
534
  }
525
535
  else {
526
- // if (USE_GMO_CHANGE_TRAN) {
527
- // // 手数料0円であれば、決済取り消し(返品)処理
528
- // if (typeof params.refundFee === 'number' && params.refundFee > 0) {
529
- // debug('changeTran processing...');
530
- // const changeTranResult = await creditCardService.changeTran({
531
- // shopId: params.shopId,
532
- // shopPass: params.shopPass,
533
- // accessId: searchTradeResult.accessId,
534
- // accessPass: searchTradeResult.accessPass,
535
- // jobCd: GMO.utils.util.JobCd.Capture,
536
- // amount: params.refundFee,
537
- // siteId: params.availableChannel.credentials?.siteId,
538
- // sitePass: params.availableChannel.credentials?.sitePass
539
- // });
540
- // debug('changeTran processed.');
541
- // alterTranResult.push(changeTranResult);
542
- // } else {
543
- // debug('alterTran processing...');
544
- // alterTranResult.push(await creditCardService.alterTran({
545
- // shopId: params.shopId,
546
- // shopPass: params.shopPass,
547
- // accessId: searchTradeResult.accessId,
548
- // accessPass: searchTradeResult.accessPass,
549
- // jobCd: GMO.utils.util.JobCd.Void,
550
- // siteId: params.availableChannel.credentials?.siteId,
551
- // sitePass: params.availableChannel.credentials?.sitePass
552
- // }));
553
- // debug('alterTran processed.');
554
- // debug('GMO alterTranResult is', alterTranResult);
555
- // }
556
- // } else {
557
- // }
558
- // 手数料決済については、取消→即時売上の流れ
559
- debug('alterTran processing...');
560
- alterTranResult.push(yield creditCardService.alterTran({
561
- shopId: params.shopId,
562
- shopPass: params.shopPass,
563
- accessId: searchTradeResult.accessId,
564
- accessPass: searchTradeResult.accessPass,
565
- jobCd: GMO.utils.util.JobCd.Void,
566
- siteId: (_g = params.availableChannel.credentials) === null || _g === void 0 ? void 0 : _g.siteId,
567
- sitePass: (_h = params.availableChannel.credentials) === null || _h === void 0 ? void 0 : _h.sitePass
568
- }));
569
- debug('alterTran processed.');
536
+ try {
537
+ // 手数料決済については、取消→即時売上の流れ
538
+ debug('alterTran processing... searchTradeResult:', searchTradeResult);
539
+ alterTranResult.push(yield creditCardService.alterTran({
540
+ shopId: params.shopId,
541
+ shopPass: params.shopPass,
542
+ accessId: searchTradeResult.accessId,
543
+ accessPass: searchTradeResult.accessPass,
544
+ jobCd: GMO.utils.util.JobCd.Void,
545
+ siteId: (_g = params.availableChannel.credentials) === null || _g === void 0 ? void 0 : _g.siteId,
546
+ sitePass: (_h = params.availableChannel.credentials) === null || _h === void 0 ? void 0 : _h.sitePass
547
+ }));
548
+ debug('alterTran processed.');
549
+ }
550
+ catch (error) {
551
+ let throwsError = true;
552
+ // 未決済(3D 登録済)->取消をトライするとE01050004エラーとなるが、この場合何もする必要はない(2024-01-09~)
553
+ if (error.name === 'GMOServiceBadRequestError') {
554
+ // 会員が存在しない場合このエラーになる
555
+ if (Array.isArray(error.errors) && error.errors.length === 1 && error.errors[0].info === 'E01050004') {
556
+ if (searchTradeResult.status === GMO.utils.util.Status.Authenticated) {
557
+ debug('status:', searchTradeResult.status, 'nothing to do');
558
+ throwsError = false;
559
+ }
560
+ }
561
+ }
562
+ if (throwsError) {
563
+ throw error;
564
+ }
565
+ }
570
566
  }
571
567
  return alterTranResult;
572
568
  });
573
569
  }
574
570
  function getGMOInfoFromSeller(params) {
575
571
  return (repos) => __awaiter(this, void 0, void 0, function* () {
576
- // const sellers = <Pick<factory.seller.ISeller, 'paymentAccepted' | 'project'>[]>await repos.seller.search(
577
- // {
578
- // limit: 1,
579
- // page: 1,
580
- // id: { $eq: String(params.seller.id) }
581
- // },
582
- // ['paymentAccepted', 'project'],
583
- // []
584
- // );
585
- // const seller = sellers.shift();
586
- // if (seller === undefined) {
587
- // throw new factory.errors.NotFound(factory.organizationType.Corporation);
588
- // }
589
- var _a, _b;
590
- // const paymentAccepted = seller.paymentAccepted?.some((a) => a.paymentMethodType === params.paymentMethodType);
572
+ var _a, _b, _c, _d;
591
573
  const paymentAccepted = yield repos.paymentAccepted.isAcceptedBySeller({
592
574
  seller: { id: params.seller.id },
593
575
  codeValue: params.paymentMethodType
@@ -602,33 +584,20 @@ function getGMOInfoFromSeller(params) {
602
584
  provider: { id: { $eq: params.seller.id } },
603
585
  id: { $eq: params.paymentServiceId }
604
586
  });
605
- // const paymentServices = <factory.service.paymentService.IService[]>await repos.product.search(
606
- // {
607
- // limit: 1,
608
- // page: 1,
609
- // project: { id: { $eq: seller.project.id } },
610
- // typeOf: { $eq: factory.service.paymentService.PaymentServiceType.CreditCard },
611
- // // serviceType: { codeValue: { $eq: params.paymentMethodType } },
612
- // id: { $eq: params.paymentServiceId }
613
- // },
614
- // [],
615
- // []
616
- // );
617
587
  const paymentService = paymentServices.shift();
618
588
  if (paymentService === undefined) {
619
589
  throw new factory.errors.NotFound('PaymentService');
620
590
  }
621
591
  const provider = paymentService.provider;
622
- // const provider = paymentService.provider?.find((p) => p.id === params.seller.id);
623
- // if (provider === undefined) {
624
- // throw new factory.errors.NotFound('PaymentService provider');
625
- // }
626
592
  const shopId = (_a = provider.credentials) === null || _a === void 0 ? void 0 : _a.shopId;
627
593
  const shopPass = (_b = provider.credentials) === null || _b === void 0 ? void 0 : _b.shopPass;
628
594
  if (typeof shopId !== 'string' || typeof shopPass !== 'string') {
629
595
  throw new factory.errors.Argument('transaction', 'Provider credentials not enough');
630
596
  }
631
- return { shopId, shopPass };
597
+ const returnUrls3dsSetting = (_c = provider.credentials) === null || _c === void 0 ? void 0 : _c.returnUrls3ds;
598
+ const returnUrls3ds = (Array.isArray(returnUrls3dsSetting)) ? returnUrls3dsSetting : [];
599
+ const callbackType3ds = (_d = provider.credentials) === null || _d === void 0 ? void 0 : _d.callbackType3ds;
600
+ return { shopId, shopPass, returnUrls3ds, callbackType3ds };
632
601
  });
633
602
  }
634
603
  exports.getGMOInfoFromSeller = getGMOInfoFromSeller;
@@ -5,24 +5,20 @@ import * as factory from '../../factory';
5
5
  import type { MongoRepository as AccountingReportRepo } from '../../repo/accountingReport';
6
6
  import type { MongoRepository as ActionRepo } from '../../repo/action';
7
7
  import type { MongoRepository as ProductRepo } from '../../repo/product';
8
- import type { MongoRepository as ProjectRepo } from '../../repo/project';
9
8
  import type { MongoRepository as TaskRepo } from '../../repo/task';
10
9
  declare function voidTransaction(__: factory.task.voidPayment.IData): (___: {
11
10
  product: ProductRepo;
12
- project: ProjectRepo;
13
11
  }) => Promise<void>;
14
12
  declare function payFaceToFace(params: factory.task.pay.IData): (repos: {
15
13
  action: ActionRepo;
16
14
  accountingReport: AccountingReportRepo;
17
15
  product: ProductRepo;
18
- project: ProjectRepo;
19
16
  task: TaskRepo;
20
17
  }) => Promise<import("@chevre/factory/lib/action/trade/pay").IAction>;
21
18
  declare function refundFaceToFace(params: factory.task.refund.IData): (repos: {
22
19
  action: ActionRepo;
23
20
  accountingReport: AccountingReportRepo;
24
21
  product: ProductRepo;
25
- project: ProjectRepo;
26
22
  task: TaskRepo;
27
23
  }) => Promise<import("@chevre/factory/lib/action/trade/refund").IAction>;
28
24
  export { payFaceToFace, refundFaceToFace, voidTransaction };
@@ -1,7 +1,6 @@
1
1
  import type { IMinimizedIndividualEvent } from '../../../repo/event';
2
2
  import type { MongoRepository as PaymentServiceRepo } from '../../../repo/paymentService';
3
3
  import type { MongoRepository as PaymentServiceProviderRepo } from '../../../repo/paymentServiceProvider';
4
- import type { MongoRepository as ProjectRepo } from '../../../repo/project';
5
4
  import * as factory from '../../../factory';
6
5
  interface ICheckResult {
7
6
  purchaseNumberAuthIn: factory.action.check.paymentMethod.movieTicket.IPurchaseNumberAuthIn;
@@ -19,6 +18,5 @@ interface ICheckByIdentifierParams {
19
18
  declare function checkByIdentifier(params: ICheckByIdentifierParams): (repos: {
20
19
  paymentService: PaymentServiceRepo;
21
20
  paymentServiceProvider: PaymentServiceProviderRepo;
22
- project: ProjectRepo;
23
21
  }) => Promise<ICheckResult>;
24
22
  export { ICheckByIdentifierParams, ICheckResult, checkByIdentifier };
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.checkByIdentifier = void 0;
13
13
  const surfrock = require("@surfrock/sdk");
14
14
  const moment = require("moment-timezone");
15
+ // import type { MongoRepository as ProjectRepo } from '../../../repo/project';
15
16
  const credentials_1 = require("../../../credentials");
16
17
  const factory = require("../../../factory");
17
18
  const getCredentials_1 = require("./getCredentials");
@@ -3,7 +3,6 @@ import type { MongoRepository as ActionRepo } from '../../../repo/action';
3
3
  import type { MongoRepository as EventRepo } from '../../../repo/event';
4
4
  import type { MongoRepository as PaymentServiceRepo } from '../../../repo/paymentService';
5
5
  import type { MongoRepository as PaymentServiceProviderRepo } from '../../../repo/paymentServiceProvider';
6
- import type { MongoRepository as ProjectRepo } from '../../../repo/project';
7
6
  import type { MongoRepository as PaymentAcceptedRepo } from '../../../repo/sellerPaymentAccepted';
8
7
  export declare function validateMovieTicket(params: factory.assetTransaction.pay.IStartParamsWithoutDetail, paymentServiceId: string, useCheckMovieTicketBeforePay: boolean, useCheckByIdentifierIfNotYet: boolean): (repos: {
9
8
  action: ActionRepo;
@@ -11,7 +10,6 @@ export declare function validateMovieTicket(params: factory.assetTransaction.pay
11
10
  paymentAccepted: PaymentAcceptedRepo;
12
11
  paymentService: PaymentServiceRepo;
13
12
  paymentServiceProvider: PaymentServiceProviderRepo;
14
- project: ProjectRepo;
15
13
  }) => Promise<{
16
14
  accountsReceivablesByServiceType: factory.assetTransaction.pay.IAccountsReceivableByServiceType[];
17
15
  }>;