@chevre/domain 21.2.0-alpha.45 → 21.2.0-alpha.46

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.
@@ -102,7 +102,9 @@ exports.invalidatePaymentUrl = invalidatePaymentUrl;
102
102
  * apiもしくはタスクから決済承認を取り消す
103
103
  */
104
104
  function processVoidPayTransaction(params) {
105
+ // tslint:disable-next-line:max-func-body-length
105
106
  return (repos) => __awaiter(this, void 0, void 0, function* () {
107
+ var _a, _b;
106
108
  let transaction;
107
109
  // アクションID指定の場合、進行中取引検証(2023-02-24~)
108
110
  if (typeof params.id === 'string') {
@@ -112,7 +114,7 @@ function processVoidPayTransaction(params) {
112
114
  transaction = (yield repos.transaction.findById({
113
115
  typeOf: params.purpose.typeOf,
114
116
  id: params.purpose.id,
115
- inclusion: ['_id', 'typeOf', 'status']
117
+ inclusion: ['_id', 'typeOf', 'status', 'result.order.paymentMethods']
116
118
  }));
117
119
  }
118
120
  // 承認アクションを取得
@@ -145,6 +147,23 @@ function processVoidPayTransaction(params) {
145
147
  case factory.transactionStatusType.Confirmed:
146
148
  // アクションステータスを検証する
147
149
  authorizeActions = authorizeActions.filter((a) => a.actionStatus !== factory.actionStatusType.CompletedActionStatus);
150
+ if (transaction.typeOf === factory.transactionType.PlaceOrder) {
151
+ const paymentMethodIds = (_b = (_a = transaction.result) === null || _a === void 0 ? void 0 : _a.order) === null || _b === void 0 ? void 0 : _b.paymentMethods.map((p) => {
152
+ return p.paymentMethodId;
153
+ });
154
+ if (!Array.isArray(paymentMethodIds)) {
155
+ throw new factory.errors.Argument('Transaction', `${transaction.id} must have result.order.paymentMethods`);
156
+ }
157
+ if (paymentMethodIds.length > 0) {
158
+ authorizeActions = authorizeActions.filter((a) => {
159
+ // paymentMethodIdが存在しない、あるいは、注文のpaymentMethodIdsに含まれなければ、アクション取消対象
160
+ const paymentMethodIdByAction = a.object.paymentMethodId;
161
+ const includedInOrder = typeof paymentMethodIdByAction === 'string'
162
+ && paymentMethodIds.includes(paymentMethodIdByAction);
163
+ return !includedInOrder;
164
+ });
165
+ }
166
+ }
148
167
  break;
149
168
  default:
150
169
  // no op
package/package.json CHANGED
@@ -117,5 +117,5 @@
117
117
  "postversion": "git push origin --tags",
118
118
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
119
119
  },
120
- "version": "21.2.0-alpha.45"
120
+ "version": "21.2.0-alpha.46"
121
121
  }