@chevre/domain 21.2.0-alpha.44 → 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.
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
3
|
import * as factory from '../factory';
|
|
4
4
|
interface IListenArgsOnTaskStatusChanged {
|
|
5
|
-
id
|
|
6
|
-
name
|
|
5
|
+
id: string;
|
|
6
|
+
name?: factory.taskName;
|
|
7
7
|
status: factory.taskStatus;
|
|
8
8
|
}
|
|
9
9
|
type IOnTaskStatusChangedListener = (listenArgs: IListenArgsOnTaskStatusChanged) => void;
|
package/lib/chevre/repo/task.js
CHANGED
|
@@ -163,12 +163,18 @@ class MongoRepository {
|
|
|
163
163
|
return { id: objectId.toHexString() };
|
|
164
164
|
});
|
|
165
165
|
if (emitImmediately) {
|
|
166
|
-
|
|
166
|
+
savedTasks.forEach((savedTask) => {
|
|
167
167
|
task_2.taskEventEmitter.emitTaskStatusChanged({
|
|
168
|
-
|
|
168
|
+
id: savedTask.id,
|
|
169
169
|
status: factory.taskStatus.Ready
|
|
170
170
|
});
|
|
171
171
|
});
|
|
172
|
+
// taskAttributes.forEach((savedTask) => {
|
|
173
|
+
// taskEventEmitter.emitTaskStatusChanged({
|
|
174
|
+
// name: savedTask.name,
|
|
175
|
+
// status: factory.taskStatus.Ready
|
|
176
|
+
// });
|
|
177
|
+
// });
|
|
172
178
|
}
|
|
173
179
|
// return result.ops;
|
|
174
180
|
return savedTasks;
|
|
@@ -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