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

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 (106) 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 +3 -3
  11. package/lib/chevre/repo/action.js +4 -6
  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.js +2 -2
  39. package/lib/chevre/service/offer/moneyTransfer/authorize.d.ts +6 -1
  40. package/lib/chevre/service/offer/moneyTransfer/authorize.js +2 -1
  41. package/lib/chevre/service/offer/moneyTransfer/returnMoneyTransfer.js +1 -1
  42. package/lib/chevre/service/offer/moneyTransfer/settleTransaction.js +1 -1
  43. package/lib/chevre/service/offer/moneyTransfer/voidTransaction.js +1 -1
  44. package/lib/chevre/service/offer/product.js +1 -1
  45. package/lib/chevre/service/order/confirmPayTransaction.js +3 -3
  46. package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +11 -1
  47. package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +113 -5
  48. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.js +18 -19
  49. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +38 -25
  50. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +11 -0
  51. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.js +45 -0
  52. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.d.ts +14 -0
  53. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.js +37 -0
  54. package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.d.ts +10 -0
  55. package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +86 -0
  56. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +18 -12
  57. package/lib/chevre/service/order/onOrderStatusChanged.d.ts +3 -1
  58. package/lib/chevre/service/order/onOrderStatusChanged.js +5 -1
  59. package/lib/chevre/service/order/placeOrder.d.ts +2 -0
  60. package/lib/chevre/service/order/placeOrder.js +28 -29
  61. package/lib/chevre/service/order/returnOrder.js +25 -16
  62. package/lib/chevre/service/order/sendOrder.d.ts +5 -0
  63. package/lib/chevre/service/order/sendOrder.js +68 -30
  64. package/lib/chevre/service/payment/any.d.ts +6 -8
  65. package/lib/chevre/service/payment/any.js +46 -10
  66. package/lib/chevre/service/payment/creditCard.d.ts +9 -8
  67. package/lib/chevre/service/payment/creditCard.js +102 -133
  68. package/lib/chevre/service/payment/faceToFace.d.ts +0 -4
  69. package/lib/chevre/service/payment/movieTicket/checkByIdentifier.d.ts +0 -2
  70. package/lib/chevre/service/payment/movieTicket/checkByIdentifier.js +1 -0
  71. package/lib/chevre/service/payment/movieTicket/validation.d.ts +0 -2
  72. package/lib/chevre/service/payment/movieTicket.d.ts +0 -6
  73. package/lib/chevre/service/payment/movieTicket.js +1 -1
  74. package/lib/chevre/service/payment/paymentCard.d.ts +0 -2
  75. package/lib/chevre/service/payment/paymentCard.js +6 -6
  76. package/lib/chevre/service/payment.js +1 -1
  77. package/lib/chevre/service/product.js +1 -1
  78. package/lib/chevre/service/reserve/cancelReservation.js +2 -2
  79. package/lib/chevre/service/reserve/confirmReservation.js +1 -1
  80. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.d.ts +1 -1
  81. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +4 -4
  82. package/lib/chevre/service/reserve/useReservation.d.ts +1 -2
  83. package/lib/chevre/service/reserve/useReservation.js +4 -4
  84. package/lib/chevre/service/reserve/verifyToken4reservation.js +2 -0
  85. package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +1 -1
  86. package/lib/chevre/service/task/confirmReserveTransaction.d.ts +4 -1
  87. package/lib/chevre/service/task/confirmReserveTransaction.js +42 -3
  88. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +7 -7
  89. package/lib/chevre/service/task/placeOrder.js +9 -10
  90. package/lib/chevre/service/task/returnOrder.js +0 -3
  91. package/lib/chevre/service/task/returnPayTransaction.js +1 -1
  92. package/lib/chevre/service/task/returnReserveTransaction.js +1 -1
  93. package/lib/chevre/service/task/sendOrder.js +8 -4
  94. package/lib/chevre/service/task/voidPayTransaction.js +2 -2
  95. package/lib/chevre/service/task/voidReserveTransaction.js +8 -12
  96. package/lib/chevre/service/transaction/deleteTransaction.js +1 -1
  97. package/lib/chevre/service/transaction/moneyTransfer.js +1 -5
  98. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.js +6 -2
  99. package/lib/chevre/service/transaction/placeOrderInProgress.js +2 -2
  100. package/lib/chevre/service/transaction/returnOrder/preStart.d.ts +32 -0
  101. package/lib/chevre/service/transaction/returnOrder/preStart.js +632 -0
  102. package/lib/chevre/service/transaction/returnOrder.d.ts +8 -6
  103. package/lib/chevre/service/transaction/returnOrder.js +4 -616
  104. package/lib/chevre/settings.d.ts +3 -1
  105. package/lib/chevre/settings.js +7 -2
  106. package/package.json +3 -3
@@ -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
  }>;
@@ -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
  import type { MongoRepository as TaskRepo } from '../../repo/task';
9
8
  import * as factory from '../../factory';
@@ -14,7 +13,6 @@ interface ICheckOperationRepos {
14
13
  paymentAccepted: PaymentAcceptedRepo;
15
14
  paymentService: PaymentServiceRepo;
16
15
  paymentServiceProvider: PaymentServiceProviderRepo;
17
- project: ProjectRepo;
18
16
  }
19
17
  type ICheckOperation<T> = (repos: ICheckOperationRepos) => Promise<T>;
20
18
  interface IPayOperationRepos {
@@ -24,7 +22,6 @@ interface IPayOperationRepos {
24
22
  paymentAccepted: PaymentAcceptedRepo;
25
23
  paymentService: PaymentServiceRepo;
26
24
  paymentServiceProvider: PaymentServiceProviderRepo;
27
- project: ProjectRepo;
28
25
  task: TaskRepo;
29
26
  }
30
27
  type IPayOperation<T> = (repos: IPayOperationRepos) => Promise<T>;
@@ -32,7 +29,6 @@ interface IRefundOperationRepos {
32
29
  action: ActionRepo;
33
30
  accountingReport: AccountingReportRepo;
34
31
  paymentService: PaymentServiceRepo;
35
- project: ProjectRepo;
36
32
  task: TaskRepo;
37
33
  }
38
34
  type IRefundOperation<T> = (repos: IRefundOperationRepos) => Promise<T>;
@@ -58,14 +54,12 @@ declare function authorize(params: factory.assetTransaction.pay.IStartParamsWith
58
54
  paymentAccepted: PaymentAcceptedRepo;
59
55
  paymentService: PaymentServiceRepo;
60
56
  paymentServiceProvider: PaymentServiceProviderRepo;
61
- project: ProjectRepo;
62
57
  task: TaskRepo;
63
58
  }) => Promise<IAuthorizeResult>;
64
59
  declare function voidTransaction(params: factory.task.voidPayment.IData): (repos: {
65
60
  action: ActionRepo;
66
61
  accountingReport: AccountingReportRepo;
67
62
  paymentService: PaymentServiceRepo;
68
- project: ProjectRepo;
69
63
  task: TaskRepo;
70
64
  }) => Promise<void>;
71
65
  type IPayAction = factory.action.trade.pay.IAction;
@@ -85,7 +85,7 @@ function checkMovieTicket(params) {
85
85
  // action.resultへの保管を廃止(2023-03-24~)
86
86
  // movieTickets: []
87
87
  };
88
- yield repos.action.complete({ typeOf: actionAttributes.typeOf, id: action.id, result });
88
+ yield repos.action.completeWithVoid({ typeOf: actionAttributes.typeOf, id: action.id, result });
89
89
  return {
90
90
  result: checkResult
91
91
  };
@@ -3,13 +3,11 @@ import type { MongoRepository as AccountingReportRepo } from '../../repo/account
3
3
  import type { MongoRepository as ActionRepo } from '../../repo/action';
4
4
  import type { MongoRepository as AssetTransactionRepo } from '../../repo/assetTransaction';
5
5
  import type { MongoRepository as ProductRepo } from '../../repo/product';
6
- import type { MongoRepository as ProjectRepo } from '../../repo/project';
7
6
  import type { MongoRepository as TaskRepo } from '../../repo/task';
8
7
  import type { RedisRepository as TransactionNumberRepo } from '../../repo/transactionNumber';
9
8
  type IPendingTransaction = Pick<factory.account.transaction.withdraw.ITransaction, 'id' | 'transactionNumber' | 'typeOf'>;
10
9
  declare function authorize(params: factory.assetTransaction.pay.IStartParamsWithoutDetail, paymentServiceId: string): (repos: {
11
10
  product: ProductRepo;
12
- project: ProjectRepo;
13
11
  }) => Promise<{
14
12
  pendingTransaction: IPendingTransaction;
15
13
  currency: string;
@@ -22,12 +22,12 @@ const onRefund_1 = require("./any/onRefund");
22
22
  const accountTransactionIdentifier_1 = require("../../factory/accountTransactionIdentifier");
23
23
  function authorize(params, paymentServiceId) {
24
24
  return (repos) => __awaiter(this, void 0, void 0, function* () {
25
+ // const project = <Pick<factory.project.IProject, 'id' | 'typeOf'>>await repos.project.findById({
26
+ // id: params.project.id,
27
+ // inclusion: ['_id', 'typeOf'],
28
+ // exclusion: []
29
+ // });
25
30
  var _a;
26
- const project = yield repos.project.findById({
27
- id: params.project.id,
28
- inclusion: ['_id', 'typeOf'],
29
- exclusion: []
30
- });
31
31
  const transactionNumber = params.transactionNumber;
32
32
  if (typeof transactionNumber !== 'string') {
33
33
  throw new factory.errors.ArgumentNull('transactionNumber');
@@ -46,7 +46,7 @@ function authorize(params, paymentServiceId) {
46
46
  .toDate();
47
47
  pendingTransaction = yield processAccountTransaction({
48
48
  transactionNumber,
49
- project: project,
49
+ project: { id: params.project.id, typeOf: factory.organizationType.Project },
50
50
  paymentMethod: params.object.paymentMethod,
51
51
  agent: params.agent,
52
52
  recipient: params.recipient,
@@ -78,7 +78,7 @@ function refund(params) {
78
78
  yield PaymentCardPaymentService.refundPaymentCard(params)(repos);
79
79
  break;
80
80
  case factory.service.paymentService.PaymentServiceType.CreditCard:
81
- yield CreditCardPaymentService.refundCreditCard(params, true)(repos);
81
+ yield CreditCardPaymentService.refundCreditCard(params, { requirePayAction: true })(repos);
82
82
  break;
83
83
  case factory.service.paymentService.PaymentServiceType.MovieTicket:
84
84
  yield MovieTicketPaymentService.refundMovieTicket(params)(repos);
@@ -42,7 +42,7 @@ function registerService(params) {
42
42
  }
43
43
  // アクション完了
44
44
  const actionResult = {};
45
- yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult });
45
+ yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: actionResult });
46
46
  yield onRegistered(actionAttributes, serviceOutput)(repos);
47
47
  })));
48
48
  });
@@ -148,7 +148,7 @@ function cancelPengindIfNotYet(params, __) {
148
148
  // } : undefined
149
149
  // canceledReservationId: canceledReservation?.id
150
150
  };
151
- yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult });
151
+ yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: actionResult });
152
152
  }
153
153
  return { reserveTransaction };
154
154
  });
@@ -288,7 +288,7 @@ function cancelReservation(actionAttributesList) {
288
288
  } : undefined
289
289
  // canceledReservationId: canceledReservation?.id
290
290
  );
291
- yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult });
291
+ yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: actionResult });
292
292
  let canceledReservations = [];
293
293
  if (actionAttributes.object.typeOf === factory.reservationType.ReservationPackage) {
294
294
  const reservationNumber = actionAttributes.object.reservationNumber;
@@ -138,7 +138,7 @@ function reserveIfNotYet(params, options) {
138
138
  }
139
139
  // アクション完了
140
140
  const actionResult = {};
141
- yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult });
141
+ yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: actionResult });
142
142
  }
143
143
  });
144
144
  }
@@ -8,7 +8,7 @@ export type IUseReservationAction = factory.action.consume.use.reservation.IActi
8
8
  /**
9
9
  * 予約使用
10
10
  */
11
- export declare function onReservationUsed(action: IUseReservationAction, attendedReservation: IEventReservation): (repos: {
11
+ export declare function onReservationUsed(attendedReservation: IEventReservation): (repos: {
12
12
  task: TaskRepo;
13
13
  }) => Promise<void>;
14
14
  export {};
@@ -21,7 +21,7 @@ const informReservations = settings_1.settings.onReservationStatusChanged.inform
21
21
  /**
22
22
  * 予約使用
23
23
  */
24
- function onReservationUsed(action, attendedReservation) {
24
+ function onReservationUsed(attendedReservation) {
25
25
  // tslint:disable-next-line:max-func-body-length
26
26
  return (repos) => __awaiter(this, void 0, void 0, function* () {
27
27
  const tasks = [];
@@ -54,7 +54,7 @@ function onReservationUsed(action, attendedReservation) {
54
54
  typeOf: factory.actionType.InformAction
55
55
  };
56
56
  return {
57
- project: action.project,
57
+ project: attendedReservation.project,
58
58
  name: factory.taskName.TriggerWebhook,
59
59
  status: factory.taskStatus.Ready,
60
60
  runsAt: informTaskRunsAt,
@@ -67,9 +67,9 @@ function onReservationUsed(action, attendedReservation) {
67
67
  }
68
68
  // projectを限定する(2023-02-21~)
69
69
  // 使用アクション集計タスクを作成する(冗長な作成を避ける)
70
- if (settings_1.settings.useAggregateEntranceGateProjects.includes(action.project.id)) {
70
+ if (settings_1.settings.useAggregateEntranceGateProjects.includes(attendedReservation.project.id)) {
71
71
  const readyAggregateUseActionsTaskDoc = yield repos.task.taskModel.findOne({
72
- 'project.id': { $eq: action.project.id },
72
+ 'project.id': { $eq: attendedReservation.project.id },
73
73
  name: { $eq: factory.taskName.AggregateUseActionsOnEvent },
74
74
  status: { $eq: factory.taskStatus.Ready },
75
75
  'data.id': { $exists: true, $eq: attendedReservation.reservationFor.id }