@chevre/domain 21.8.0-alpha.2 → 21.8.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.
- package/example/src/chevre/db/stats.ts +22 -0
- package/example/src/chevre/migrateOrderPaymentMethodIdentifier.ts +81 -0
- package/example/src/chevre/migratePayTransactionPaymentMethodId.ts +72 -0
- package/example/src/chevre/migratePayTransactionPaymentMethodIdentifier.ts +75 -0
- package/example/src/chevre/processPay.ts +3 -4
- package/example/src/chevre/searchTasks.ts +31 -0
- package/lib/chevre/repo/assetTransaction.d.ts +16 -1
- package/lib/chevre/repo/assetTransaction.js +54 -2
- package/lib/chevre/repo/mongoose/schemas/order.d.ts +3 -0
- package/lib/chevre/repo/mongoose/schemas/order.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/task.js +6 -0
- package/lib/chevre/repo/order.d.ts +15 -0
- package/lib/chevre/repo/order.js +34 -1
- package/lib/chevre/repo/task.d.ts +4 -1
- package/lib/chevre/repo/task.js +108 -22
- package/lib/chevre/service/assetTransaction/pay/account/validation.js +2 -2
- package/lib/chevre/service/assetTransaction/pay/factory.js +5 -3
- package/lib/chevre/service/assetTransaction/pay/potentialActions.js +3 -3
- package/lib/chevre/service/assetTransaction/pay.js +65 -46
- package/lib/chevre/service/delivery.js +17 -0
- package/lib/chevre/service/offer/event/voidTransaction.js +7 -2
- package/lib/chevre/service/order/confirmPayTransaction.d.ts +0 -2
- package/lib/chevre/service/order/confirmPayTransaction.js +29 -40
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +27 -0
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +226 -0
- package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +8 -5
- package/lib/chevre/service/order/onOrderStatusChanged/factory.js +73 -87
- package/lib/chevre/service/order/onOrderStatusChanged.js +98 -73
- package/lib/chevre/service/order/payOrder.d.ts +2 -10
- package/lib/chevre/service/order/payOrder.js +4 -45
- package/lib/chevre/service/order/placeOrder.js +12 -11
- package/lib/chevre/service/order.d.ts +3 -1
- package/lib/chevre/service/order.js +6 -2
- package/lib/chevre/service/payment/any/factory.js +24 -7
- package/lib/chevre/service/payment/any.js +22 -18
- package/lib/chevre/service/payment/creditCard.js +12 -12
- package/lib/chevre/service/payment/movieTicket/validation.js +2 -2
- package/lib/chevre/service/payment/movieTicket.js +10 -11
- package/lib/chevre/service/payment/paymentCard.js +9 -12
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.d.ts +3 -0
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +1 -4
- package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +1 -5
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.d.ts +3 -0
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +1 -4
- package/lib/chevre/service/task/confirmPayTransaction.js +1 -3
- package/lib/chevre/service/task/onAssetTransactionStatusChanged.d.ts +6 -0
- package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +37 -0
- package/lib/chevre/service/task/onOrderPaymentCompleted.d.ts +6 -0
- package/lib/chevre/service/task/onOrderPaymentCompleted.js +35 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/result.js +16 -4
- package/lib/chevre/service/transaction/placeOrderInProgress.js +4 -1
- package/lib/chevre/settings.d.ts +1 -2
- package/lib/chevre/settings.js +2 -5
- package/package.json +2 -2
- package/example/src/chevre/migrateEventOrganizer.ts +0 -154
|
@@ -13,18 +13,20 @@ exports.onOrderStatusChanged = void 0;
|
|
|
13
13
|
/**
|
|
14
14
|
* 注文ステータス変更時処理
|
|
15
15
|
*/
|
|
16
|
+
const createDebug = require("debug");
|
|
16
17
|
const google_libphonenumber_1 = require("google-libphonenumber");
|
|
17
|
-
const moment = require("moment");
|
|
18
18
|
const factory = require("../../factory");
|
|
19
19
|
const order_1 = require("../../factory/order");
|
|
20
20
|
const product_1 = require("../offer/product");
|
|
21
21
|
const factory_1 = require("./onOrderStatusChanged/factory");
|
|
22
|
+
const debug = createDebug('chevre-domain:service:order');
|
|
22
23
|
const USE_CONFIRM_REGISTER_SERVICE_TRANSACTION = process.env.USE_CONFIRM_REGISTER_SERVICE_TRANSACTION === '1';
|
|
23
24
|
const TOKEN_EXPIRES_IN = 604800;
|
|
24
25
|
function onOrderStatusChanged(params) {
|
|
25
26
|
// tslint:disable-next-line:max-func-body-length
|
|
26
27
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
28
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
29
|
+
debug('onOrderStatusChanged called.', params.order.orderNumber, params.order.orderStatus, params.order.orderDate);
|
|
28
30
|
let tasks = [];
|
|
29
31
|
const maskedCustomer = (0, order_1.createMaskedCustomer)(params.order, { noProfile: true });
|
|
30
32
|
const simpleOrder = {
|
|
@@ -88,8 +90,10 @@ function onOrderStatusChanged(params) {
|
|
|
88
90
|
tasks = [
|
|
89
91
|
// 注文作成時のみトークン付加
|
|
90
92
|
...(0, factory_1.createInformTasks)(orderWithToken),
|
|
91
|
-
|
|
92
|
-
...
|
|
93
|
+
// 決済取引確定タスク作成はOrderPaymentDueへ完全移行(2023-08-26~)
|
|
94
|
+
// ...await createConfirmPayTransactionTasks(params.order, simpleOrder)(repos),
|
|
95
|
+
// createConfirmReserveTransactionTasksIfNotExistへ移行(2023-08-25~)
|
|
96
|
+
// ...await createConfirmReserveTransactionTasks(params.order, simpleOrder)(repos),
|
|
93
97
|
...yield createConfirmRegisterServiceTransactionTasks(params.order, simpleOrder)(repos),
|
|
94
98
|
// 取引のpotentialActionsを適用(2023-08-17~)
|
|
95
99
|
...(0, factory_1.createOnPlaceOrderTasksByTransaction)({
|
|
@@ -112,24 +116,40 @@ function onOrderStatusChanged(params) {
|
|
|
112
116
|
...(0, factory_1.createOnOrderReturnedTasksByTransaction)({ potentialActions: potentialActionsByTransaction })
|
|
113
117
|
];
|
|
114
118
|
break;
|
|
119
|
+
// OrderCancelled追加(2023-08-30~)
|
|
120
|
+
case factory.orderStatus.OrderCancelled:
|
|
121
|
+
// 注文取引中止時と同様の処理か
|
|
122
|
+
tasks = [
|
|
123
|
+
...(0, factory_1.createOnOrderCancelledTasksByTransaction)({ transaction: params.placeOrderTransaction })
|
|
124
|
+
];
|
|
125
|
+
break;
|
|
115
126
|
default:
|
|
116
127
|
}
|
|
117
128
|
yield repos.task.saveMany(tasks, { emitImmediately: true });
|
|
129
|
+
switch (params.order.orderStatus) {
|
|
130
|
+
case factory.orderStatus.OrderProcessing:
|
|
131
|
+
// 冗長なconfirmReserveTransactionタスク作成を回避(2023-08-25~)
|
|
132
|
+
yield createConfirmReserveTransactionTasksIfNotExist(params.order, simpleOrder)(repos);
|
|
133
|
+
// 冗長なsendOrderタスク作成を回避(2023-08-25~)
|
|
134
|
+
yield createSendOrderTransactionTaskIfNotExist({
|
|
135
|
+
object: params.order,
|
|
136
|
+
potentialActions: (_q = (_p = (_o = params.placeOrderTransaction) === null || _o === void 0 ? void 0 : _o.potentialActions) === null || _p === void 0 ? void 0 : _p.order) === null || _q === void 0 ? void 0 : _q.potentialActions
|
|
137
|
+
})(repos);
|
|
138
|
+
break;
|
|
139
|
+
default:
|
|
140
|
+
}
|
|
118
141
|
});
|
|
119
142
|
}
|
|
120
143
|
exports.onOrderStatusChanged = onOrderStatusChanged;
|
|
121
144
|
function createConfirmPayTransactionTasks(order, simpleOrder) {
|
|
122
145
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
123
|
-
const taskRunsAt =
|
|
124
|
-
.toDate();
|
|
146
|
+
const taskRunsAt = new Date();
|
|
125
147
|
const tasks = [];
|
|
126
148
|
yield Promise.all(order.paymentMethods.map((invoice) => __awaiter(this, void 0, void 0, function* () {
|
|
127
|
-
//
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
// return;
|
|
132
|
-
// }
|
|
149
|
+
// PaymentAutomaticallyAppliedであれば、自動決済処理を実行(2023-08-24~)
|
|
150
|
+
if (invoice.paymentStatus !== factory.paymentStatusType.PaymentAutomaticallyApplied) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
133
153
|
// 冗長なタスク作成を回避
|
|
134
154
|
const existingTasks = yield repos.task.search({
|
|
135
155
|
limit: 1,
|
|
@@ -173,69 +193,49 @@ function createConfirmPayTransactionTasks(order, simpleOrder) {
|
|
|
173
193
|
return tasks;
|
|
174
194
|
});
|
|
175
195
|
}
|
|
176
|
-
const COA_TASK_DELAY_IN_SECONDS = 0;
|
|
177
|
-
function
|
|
196
|
+
// const COA_TASK_DELAY_IN_SECONDS = 0;
|
|
197
|
+
function createConfirmReserveTransactionTasksIfNotExist(order, simpleOrder) {
|
|
178
198
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
179
|
-
const taskRunsAt =
|
|
180
|
-
|
|
181
|
-
const taskRunsAt4coa = moment(order.orderDate)
|
|
182
|
-
|
|
183
|
-
|
|
199
|
+
const taskRunsAt = new Date();
|
|
200
|
+
const taskRunsAt4coa = new Date();
|
|
201
|
+
// const taskRunsAt4coa = moment(order.orderDate)
|
|
202
|
+
// .add(COA_TASK_DELAY_IN_SECONDS, 'seconds')
|
|
203
|
+
// .toDate();
|
|
184
204
|
const confirmObjects = [
|
|
185
205
|
...(0, factory_1.createConfirmReservationActionObject4ChevreByOrder)({ order }),
|
|
186
206
|
...(0, factory_1.createConfirmReservationActionObject4COAByOrder)({ order })
|
|
187
207
|
];
|
|
188
|
-
const tasks = [];
|
|
189
208
|
yield Promise.all(confirmObjects.map((confirmObject) => __awaiter(this, void 0, void 0, function* () {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
209
|
+
const data = {
|
|
210
|
+
project: order.project,
|
|
211
|
+
typeOf: factory.actionType.ConfirmAction,
|
|
212
|
+
object: confirmObject,
|
|
213
|
+
agent: order.project,
|
|
214
|
+
purpose: simpleOrder,
|
|
215
|
+
instrument: {
|
|
216
|
+
typeOf: 'WebAPI',
|
|
217
|
+
identifier: (confirmObject.typeOf === 'COAReserveTransaction')
|
|
218
|
+
? factory.service.webAPI.Identifier.COA
|
|
219
|
+
: factory.service.webAPI.Identifier.Chevre
|
|
199
220
|
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
typeOf: 'WebAPI',
|
|
213
|
-
identifier: (confirmObject.typeOf === 'COAReserveTransaction')
|
|
214
|
-
? factory.service.webAPI.Identifier.COA
|
|
215
|
-
: factory.service.webAPI.Identifier.Chevre
|
|
216
|
-
}
|
|
217
|
-
};
|
|
218
|
-
tasks.push({
|
|
219
|
-
project: order.project,
|
|
220
|
-
name: factory.taskName.ConfirmReserveTransaction,
|
|
221
|
-
status: factory.taskStatus.Ready,
|
|
222
|
-
runsAt: (confirmObject.typeOf === 'COAReserveTransaction')
|
|
223
|
-
? taskRunsAt4coa
|
|
224
|
-
: taskRunsAt,
|
|
225
|
-
remainingNumberOfTries: 10,
|
|
226
|
-
numberOfTried: 0,
|
|
227
|
-
executionResults: [],
|
|
228
|
-
data
|
|
229
|
-
});
|
|
230
|
-
}
|
|
221
|
+
};
|
|
222
|
+
const confirmReserveTransactionTask = {
|
|
223
|
+
project: order.project,
|
|
224
|
+
name: factory.taskName.ConfirmReserveTransaction,
|
|
225
|
+
status: factory.taskStatus.Ready,
|
|
226
|
+
runsAt: (confirmObject.typeOf === 'COAReserveTransaction') ? taskRunsAt4coa : taskRunsAt,
|
|
227
|
+
remainingNumberOfTries: 10,
|
|
228
|
+
numberOfTried: 0,
|
|
229
|
+
executionResults: [],
|
|
230
|
+
data
|
|
231
|
+
};
|
|
232
|
+
yield repos.task.createConfirmReserveTransactionTaskIfNotExist(confirmReserveTransactionTask, { emitImmediately: true });
|
|
231
233
|
})));
|
|
232
|
-
return tasks;
|
|
233
234
|
});
|
|
234
235
|
}
|
|
235
236
|
function createConfirmRegisterServiceTransactionTasks(order, simpleOrder) {
|
|
236
237
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
237
|
-
const taskRunsAt =
|
|
238
|
-
.toDate();
|
|
238
|
+
const taskRunsAt = new Date();
|
|
239
239
|
if (USE_CONFIRM_REGISTER_SERVICE_TRANSACTION) {
|
|
240
240
|
const confirmObjects = (0, factory_1.createConfirmRegisterServiceActionObjectByOrder)({ order });
|
|
241
241
|
const tasks = [];
|
|
@@ -285,14 +285,38 @@ function createConfirmRegisterServiceTransactionTasks(order, simpleOrder) {
|
|
|
285
285
|
}
|
|
286
286
|
});
|
|
287
287
|
}
|
|
288
|
-
|
|
288
|
+
function createSendOrderTransactionTaskIfNotExist(params) {
|
|
289
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
290
|
+
var _a;
|
|
291
|
+
const now = new Date();
|
|
292
|
+
const sendOrderByTransaction = (_a = params.potentialActions) === null || _a === void 0 ? void 0 : _a.sendOrder;
|
|
293
|
+
if (sendOrderByTransaction !== undefined) {
|
|
294
|
+
const sendOrderTaskData = {
|
|
295
|
+
project: sendOrderByTransaction.project,
|
|
296
|
+
object: Object.assign(Object.assign({}, sendOrderByTransaction.object), { confirmationNumber: params.object.confirmationNumber })
|
|
297
|
+
};
|
|
298
|
+
const sendOrderTask = {
|
|
299
|
+
project: sendOrderByTransaction.project,
|
|
300
|
+
name: factory.taskName.SendOrder,
|
|
301
|
+
status: factory.taskStatus.Ready,
|
|
302
|
+
runsAt: now,
|
|
303
|
+
remainingNumberOfTries: 10,
|
|
304
|
+
numberOfTried: 0,
|
|
305
|
+
executionResults: [],
|
|
306
|
+
data: sendOrderTaskData
|
|
307
|
+
};
|
|
308
|
+
yield repos.task.createSendOrderTaskIfNotExist(sendOrderTask, { emitImmediately: true });
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
// const RETURN_COA_TASK_DELAY_IN_SECONDS = 0;
|
|
289
313
|
function createReturnReserveTransactionTasks(order, simpleOrder) {
|
|
290
314
|
var _a, _b;
|
|
291
|
-
const taskRunsAt =
|
|
292
|
-
|
|
293
|
-
const taskRunsAt4coa = moment(order.dateReturned)
|
|
294
|
-
|
|
295
|
-
|
|
315
|
+
const taskRunsAt = new Date();
|
|
316
|
+
const taskRunsAt4coa = new Date();
|
|
317
|
+
// const taskRunsAt4coa = moment(order.dateReturned)
|
|
318
|
+
// .add(RETURN_COA_TASK_DELAY_IN_SECONDS, 'seconds')
|
|
319
|
+
// .toDate();
|
|
296
320
|
const tasks = [];
|
|
297
321
|
const returnActionRecipient = {
|
|
298
322
|
typeOf: order.seller.typeOf,
|
|
@@ -367,12 +391,13 @@ function createReturnReserveTransactionTasks(order, simpleOrder) {
|
|
|
367
391
|
}
|
|
368
392
|
return tasks;
|
|
369
393
|
}
|
|
370
|
-
const RETURN_PAY_TASK_DELAY_IN_SECONDS = 0;
|
|
394
|
+
// const RETURN_PAY_TASK_DELAY_IN_SECONDS = 0;
|
|
371
395
|
function createReturnPayTransactionTasks(order, __, returnOrderTransaction) {
|
|
372
396
|
var _a, _b;
|
|
373
|
-
const taskRunsAt =
|
|
374
|
-
|
|
375
|
-
|
|
397
|
+
const taskRunsAt = new Date();
|
|
398
|
+
// const taskRunsAt = moment(order.dateReturned)
|
|
399
|
+
// .add(RETURN_PAY_TASK_DELAY_IN_SECONDS, 'seconds')
|
|
400
|
+
// .toDate();
|
|
376
401
|
const tasks = [];
|
|
377
402
|
const returnOrderPotentialActions = (_b = (_a = returnOrderTransaction === null || returnOrderTransaction === void 0 ? void 0 : returnOrderTransaction.potentialActions) === null || _a === void 0 ? void 0 : _a.returnOrder.find((action) => action.object.orderNumber === order.orderNumber)) === null || _b === void 0 ? void 0 : _b.potentialActions;
|
|
378
403
|
const returnPayActionsByReturnOrderTransaction = returnOrderPotentialActions === null || returnOrderPotentialActions === void 0 ? void 0 : returnOrderPotentialActions.returnPaymentMethod;
|
|
@@ -2,19 +2,11 @@ import { RedisRepository as RegisterServiceInProgressRepo } from '../../repo/act
|
|
|
2
2
|
import { MongoRepository as OrderRepo } from '../../repo/order';
|
|
3
3
|
import { MongoRepository as TaskRepo } from '../../repo/task';
|
|
4
4
|
import { MongoRepository as TransactionRepo } from '../../repo/transaction';
|
|
5
|
+
import * as factory from '../../factory';
|
|
5
6
|
/**
|
|
6
7
|
* 注文を決済する
|
|
7
8
|
*/
|
|
8
|
-
declare function payOrder(params: {
|
|
9
|
-
project: {
|
|
10
|
-
id: string;
|
|
11
|
-
};
|
|
12
|
-
object: {
|
|
13
|
-
confirmationNumber: string;
|
|
14
|
-
orderNumber: string;
|
|
15
|
-
};
|
|
16
|
-
useOnOrderStatusChanged: boolean;
|
|
17
|
-
}): (repos: {
|
|
9
|
+
declare function payOrder(params: factory.task.IData<factory.taskName.OnOrderPaymentCompleted>): (repos: {
|
|
18
10
|
order: OrderRepo;
|
|
19
11
|
registerActionInProgress: RegisterServiceInProgressRepo;
|
|
20
12
|
task: TaskRepo;
|
|
@@ -10,8 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.payOrder = void 0;
|
|
13
|
-
const
|
|
14
|
-
const onOrderStatusChanged_1 = require("./onOrderStatusChanged");
|
|
13
|
+
const onAssetTransactionStatusChanged_1 = require("./onAssetTransactionStatusChanged");
|
|
15
14
|
const factory = require("../../factory");
|
|
16
15
|
/**
|
|
17
16
|
* 注文を決済する
|
|
@@ -23,52 +22,12 @@ function payOrder(params) {
|
|
|
23
22
|
}
|
|
24
23
|
const orderNumber = params.object.orderNumber;
|
|
25
24
|
const confirmationNumber = params.object.confirmationNumber;
|
|
26
|
-
|
|
25
|
+
yield (0, onAssetTransactionStatusChanged_1.paymentDue2Processing)({
|
|
27
26
|
project: { id: params.project.id },
|
|
28
27
|
confirmationNumber,
|
|
29
|
-
orderNumber
|
|
30
|
-
})({ transaction: repos.transaction });
|
|
31
|
-
let order = yield repos.order.findByOrderNumber({
|
|
32
28
|
orderNumber,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
exclusion: []
|
|
36
|
-
});
|
|
37
|
-
try {
|
|
38
|
-
order = yield repos.order.changeStatus({
|
|
39
|
-
project: { id: order.project.id },
|
|
40
|
-
orderNumber,
|
|
41
|
-
orderStatus: factory.orderStatus.OrderProcessing,
|
|
42
|
-
previousOrderStatus: factory.orderStatus.OrderPaymentDue
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
catch (error) {
|
|
46
|
-
let throwsError = true;
|
|
47
|
-
// すでにステータスが煤でいた場合、OrderPaymentDue->OrderProcessingの処理自体は成功しているので、後処理を続行する
|
|
48
|
-
order = yield repos.order.findByOrderNumber({
|
|
49
|
-
orderNumber: params.object.orderNumber,
|
|
50
|
-
project: { id: params.project.id },
|
|
51
|
-
inclusion: [],
|
|
52
|
-
exclusion: []
|
|
53
|
-
});
|
|
54
|
-
if (order.orderStatus === factory.orderStatus.OrderDelivered
|
|
55
|
-
|| order.orderStatus === factory.orderStatus.OrderReturned) {
|
|
56
|
-
throwsError = false;
|
|
57
|
-
}
|
|
58
|
-
if (throwsError) {
|
|
59
|
-
throw error;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
if (params.useOnOrderStatusChanged) {
|
|
63
|
-
yield (0, onOrderStatusChanged_1.onOrderStatusChanged)({
|
|
64
|
-
order: Object.assign(Object.assign({}, order), { orderStatus: factory.orderStatus.OrderProcessing // 強制的にOrderProcessingとして処理する
|
|
65
|
-
}),
|
|
66
|
-
placeOrderTransaction
|
|
67
|
-
})({
|
|
68
|
-
registerActionInProgress: repos.registerActionInProgress,
|
|
69
|
-
task: repos.task
|
|
70
|
-
});
|
|
71
|
-
}
|
|
29
|
+
useOnOrderStatusChanged: params.useOnOrderStatusChanged
|
|
30
|
+
})(repos);
|
|
72
31
|
});
|
|
73
32
|
}
|
|
74
33
|
exports.payOrder = payOrder;
|
|
@@ -14,8 +14,8 @@ const moment = require("moment");
|
|
|
14
14
|
const order_1 = require("../../factory/order");
|
|
15
15
|
const createAccountingReportIfNotExist_1 = require("./createAccountingReportIfNotExist");
|
|
16
16
|
const findPlaceOrderTransaction_1 = require("./findPlaceOrderTransaction");
|
|
17
|
+
const onAssetTransactionStatusChanged_1 = require("./onAssetTransactionStatusChanged");
|
|
17
18
|
const onOrderStatusChanged_1 = require("./onOrderStatusChanged");
|
|
18
|
-
const payOrder_1 = require("./payOrder");
|
|
19
19
|
const factory = require("../../factory");
|
|
20
20
|
function createOrder(params) {
|
|
21
21
|
// 必要な属性についてDate型に変換(でないと検索クエリを効率的に使えない)
|
|
@@ -232,6 +232,7 @@ function placeOrder(params) {
|
|
|
232
232
|
});
|
|
233
233
|
}
|
|
234
234
|
else if (order.orderStatus === factory.orderStatus.OrderProcessing) {
|
|
235
|
+
// OrderPaymentDueをスキップしてOrderProcessingから開始する場合(2023-08-23~)
|
|
235
236
|
// OrderPaymentDueに対する処理をまず強制的に実行する(2023-08-24~)
|
|
236
237
|
yield (0, onOrderStatusChanged_1.onOrderStatusChanged)({
|
|
237
238
|
order: Object.assign(Object.assign({}, order), { orderStatus: factory.orderStatus.OrderPaymentDue }),
|
|
@@ -240,20 +241,20 @@ function placeOrder(params) {
|
|
|
240
241
|
registerActionInProgress: repos.registerActionInProgress,
|
|
241
242
|
task: repos.task
|
|
242
243
|
});
|
|
243
|
-
// OrderPaymentDueをスキップしてOrderProcessingから開始する場合(2023-08-23~)
|
|
244
|
-
// paymentMethods.length: 0の場合に、confirmPayTransactionは実行されないので、ここで強制的にpayOrderを実行する必要がある
|
|
245
|
-
yield (0, payOrder_1.payOrder)({
|
|
246
|
-
project: { id: order.project.id },
|
|
247
|
-
object: {
|
|
248
|
-
confirmationNumber: order.confirmationNumber,
|
|
249
|
-
orderNumber: order.orderNumber
|
|
250
|
-
},
|
|
251
|
-
useOnOrderStatusChanged: params.useOnOrderStatusChanged
|
|
252
|
-
})(repos);
|
|
253
244
|
}
|
|
254
245
|
else {
|
|
255
246
|
throw new factory.errors.NotImplemented(`placing an order on the status '${order.orderStatus}' not implemented`);
|
|
256
247
|
}
|
|
248
|
+
// paymentMethods.length: 0の場合を考慮(2023-08-24~)
|
|
249
|
+
if (order.paymentMethods.length === 0) {
|
|
250
|
+
// paymentMethods.length: 0の場合に、confirmPayTransactionは実行されないので、ここで強制的にpaymentDue2Processingを実行する必要がある
|
|
251
|
+
yield (0, onAssetTransactionStatusChanged_1.paymentDue2Processing)({
|
|
252
|
+
project: { id: order.project.id },
|
|
253
|
+
confirmationNumber: order.confirmationNumber,
|
|
254
|
+
orderNumber: order.orderNumber,
|
|
255
|
+
useOnOrderStatusChanged: params.useOnOrderStatusChanged === true
|
|
256
|
+
})(repos);
|
|
257
|
+
}
|
|
257
258
|
}
|
|
258
259
|
// onOrderStatusChangedへ移行(2023-08-17~)
|
|
259
260
|
// await onPlaceOrder({
|
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { confirmPayTransaction } from './order/confirmPayTransaction';
|
|
5
5
|
import { deleteOrder } from './order/deleteOrder';
|
|
6
|
+
import { onAssetTransactionStatusChanged, paymentDue2Processing } from './order/onAssetTransactionStatusChanged';
|
|
6
7
|
import { onOrderStatusChanged } from './order/onOrderStatusChanged';
|
|
7
8
|
import { onOrderUpdated } from './order/onOrderUpdated';
|
|
9
|
+
import { payOrder } from './order/payOrder';
|
|
8
10
|
import { placeOrder, placeOrderWithoutTransaction } from './order/placeOrder';
|
|
9
11
|
import { sendOrder } from './order/sendOrder';
|
|
10
|
-
export { confirmPayTransaction, deleteOrder, onOrderStatusChanged, onOrderUpdated, placeOrder, placeOrderWithoutTransaction, sendOrder };
|
|
12
|
+
export { confirmPayTransaction, deleteOrder, onAssetTransactionStatusChanged, onOrderStatusChanged, onOrderUpdated, paymentDue2Processing, payOrder, placeOrder, placeOrderWithoutTransaction, sendOrder };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sendOrder = exports.placeOrderWithoutTransaction = exports.placeOrder = exports.onOrderUpdated = exports.onOrderStatusChanged = exports.deleteOrder = exports.confirmPayTransaction = void 0;
|
|
3
|
+
exports.sendOrder = exports.placeOrderWithoutTransaction = exports.placeOrder = exports.payOrder = exports.paymentDue2Processing = exports.onOrderUpdated = exports.onOrderStatusChanged = exports.onAssetTransactionStatusChanged = exports.deleteOrder = exports.confirmPayTransaction = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* 注文サービス
|
|
6
6
|
*/
|
|
@@ -8,13 +8,17 @@ const confirmPayTransaction_1 = require("./order/confirmPayTransaction");
|
|
|
8
8
|
Object.defineProperty(exports, "confirmPayTransaction", { enumerable: true, get: function () { return confirmPayTransaction_1.confirmPayTransaction; } });
|
|
9
9
|
const deleteOrder_1 = require("./order/deleteOrder");
|
|
10
10
|
Object.defineProperty(exports, "deleteOrder", { enumerable: true, get: function () { return deleteOrder_1.deleteOrder; } });
|
|
11
|
+
const onAssetTransactionStatusChanged_1 = require("./order/onAssetTransactionStatusChanged");
|
|
12
|
+
Object.defineProperty(exports, "onAssetTransactionStatusChanged", { enumerable: true, get: function () { return onAssetTransactionStatusChanged_1.onAssetTransactionStatusChanged; } });
|
|
13
|
+
Object.defineProperty(exports, "paymentDue2Processing", { enumerable: true, get: function () { return onAssetTransactionStatusChanged_1.paymentDue2Processing; } });
|
|
11
14
|
const onOrderStatusChanged_1 = require("./order/onOrderStatusChanged");
|
|
12
15
|
Object.defineProperty(exports, "onOrderStatusChanged", { enumerable: true, get: function () { return onOrderStatusChanged_1.onOrderStatusChanged; } });
|
|
13
16
|
const onOrderUpdated_1 = require("./order/onOrderUpdated");
|
|
14
17
|
Object.defineProperty(exports, "onOrderUpdated", { enumerable: true, get: function () { return onOrderUpdated_1.onOrderUpdated; } });
|
|
18
|
+
const payOrder_1 = require("./order/payOrder");
|
|
19
|
+
Object.defineProperty(exports, "payOrder", { enumerable: true, get: function () { return payOrder_1.payOrder; } });
|
|
15
20
|
const placeOrder_1 = require("./order/placeOrder");
|
|
16
21
|
Object.defineProperty(exports, "placeOrder", { enumerable: true, get: function () { return placeOrder_1.placeOrder; } });
|
|
17
22
|
Object.defineProperty(exports, "placeOrderWithoutTransaction", { enumerable: true, get: function () { return placeOrder_1.placeOrderWithoutTransaction; } });
|
|
18
|
-
// import { returnOrder } from './order/returnOrder';
|
|
19
23
|
const sendOrder_1 = require("./order/sendOrder");
|
|
20
24
|
Object.defineProperty(exports, "sendOrder", { enumerable: true, get: function () { return sendOrder_1.sendOrder; } });
|
|
@@ -5,9 +5,17 @@ const moment = require("moment");
|
|
|
5
5
|
const factory = require("../../../factory");
|
|
6
6
|
function creatPayTransactionStartParams(params) {
|
|
7
7
|
var _a, _b, _c, _d;
|
|
8
|
-
|
|
8
|
+
let expires = moment(params.transaction.expires)
|
|
9
9
|
.add(1, 'month')
|
|
10
10
|
.toDate(); // 余裕を持って
|
|
11
|
+
// 実験的にPaymentDueに対応(2023-08-30~)
|
|
12
|
+
if (params.paymentServiceType === factory.service.paymentService.PaymentServiceType.FaceToFace) {
|
|
13
|
+
if (params.object.paymentMethod.length === 0) {
|
|
14
|
+
expires = moment(params.transaction.expires)
|
|
15
|
+
.add(1, 'hour')
|
|
16
|
+
.toDate();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
11
19
|
const confirmationNumber = params.transaction.object.confirmationNumber;
|
|
12
20
|
const issuedThroughId = (_a = params.object.issuedThrough) === null || _a === void 0 ? void 0 : _a.id;
|
|
13
21
|
const accountId = (typeof params.accountId === 'string')
|
|
@@ -39,7 +47,9 @@ function creatPayTransactionStartParams(params) {
|
|
|
39
47
|
typeOf: params.paymentServiceType,
|
|
40
48
|
// 決済サービスIDを連携(2022-04-12~)
|
|
41
49
|
id: issuedThroughId,
|
|
42
|
-
paymentMethod: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({
|
|
50
|
+
paymentMethod: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ identifier: params.object.paymentMethod,
|
|
51
|
+
// typeOf: params.object.paymentMethod, // identifierへ移行(2023-08-30~)
|
|
52
|
+
amount: params.object.amount, additionalProperty: (Array.isArray(params.object.additionalProperty)) ? params.object.additionalProperty : [] }, (typeof params.object.method === 'string') ? { method: params.object.method } : undefined), (typeof params.object.name === 'string') ? { name: params.object.name } : undefined), (typeof accountId === 'string') ? { accountId } : undefined), (typeof params.object.description === 'string') ? { description: params.object.description } : undefined), (typeof params.object.fromLocation === 'string') ? { fromLocation: params.object.fromLocation } : undefined), (params.object.creditCard !== undefined) ? { creditCard: params.object.creditCard } : undefined), (Array.isArray(movieTickets)) ? { movieTickets } : undefined)
|
|
43
53
|
}, expires: expires }, (typeof confirmationNumber === 'string')
|
|
44
54
|
? {
|
|
45
55
|
purpose: {
|
|
@@ -80,7 +90,7 @@ function createMovieTicket(params) {
|
|
|
80
90
|
};
|
|
81
91
|
}
|
|
82
92
|
function createAuthorizeResult(params) {
|
|
83
|
-
var _a, _b, _c, _d, _e, _f
|
|
93
|
+
var _a, _b, _c, _d, _e, _f;
|
|
84
94
|
const payTransactionObject = params.payTransaction.object;
|
|
85
95
|
const totalPaymentDue = (_a = payTransactionObject.paymentMethod) === null || _a === void 0 ? void 0 : _a.totalPaymentDue;
|
|
86
96
|
if (typeof (totalPaymentDue === null || totalPaymentDue === void 0 ? void 0 : totalPaymentDue.typeOf) !== 'string') {
|
|
@@ -98,6 +108,13 @@ function createAuthorizeResult(params) {
|
|
|
98
108
|
&& typeof paymentMethodAmountCurrencyByPayTransaction === 'string')
|
|
99
109
|
? { amount: { currency: paymentMethodAmountCurrencyByPayTransaction } }
|
|
100
110
|
: undefined);
|
|
111
|
+
// FaceToFaceの場合、決済方法区分未指定に対応(2023-08-29~)
|
|
112
|
+
let paymentStatus = factory.paymentStatusType.PaymentAutomaticallyApplied;
|
|
113
|
+
if (issuedThrough.typeOf === factory.service.paymentService.PaymentServiceType.FaceToFace) {
|
|
114
|
+
if (paymentMethodAsObject.typeOf.length === 0) {
|
|
115
|
+
paymentStatus = factory.paymentStatusType.PaymentDue;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
101
118
|
return {
|
|
102
119
|
accountId: (typeof ((_e = payTransactionObject.paymentMethod) === null || _e === void 0 ? void 0 : _e.accountId) === 'string')
|
|
103
120
|
? payTransactionObject.paymentMethod.accountId
|
|
@@ -108,11 +125,11 @@ function createAuthorizeResult(params) {
|
|
|
108
125
|
// 完全廃止(paymentMethodAsObjectへ完全移行)(2023-08-16~)
|
|
109
126
|
// paymentMethod: params.object.paymentMethod,
|
|
110
127
|
paymentMethodAsObject,
|
|
111
|
-
paymentStatus
|
|
112
|
-
paymentMethodId: (typeof
|
|
113
|
-
? payTransactionObject.
|
|
128
|
+
paymentStatus,
|
|
129
|
+
paymentMethodId: (typeof payTransactionObject.paymentMethodId === 'string')
|
|
130
|
+
? payTransactionObject.paymentMethodId
|
|
114
131
|
: '',
|
|
115
|
-
name: (typeof ((
|
|
132
|
+
name: (typeof ((_f = payTransactionObject.paymentMethod) === null || _f === void 0 ? void 0 : _f.name) === 'string')
|
|
116
133
|
? payTransactionObject.paymentMethod.name
|
|
117
134
|
: params.object.paymentMethod,
|
|
118
135
|
totalPaymentDue: totalPaymentDue,
|
|
@@ -104,7 +104,7 @@ exports.invalidatePaymentUrl = invalidatePaymentUrl;
|
|
|
104
104
|
function processVoidPayTransaction(params) {
|
|
105
105
|
// tslint:disable-next-line:max-func-body-length
|
|
106
106
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
107
|
-
var _a, _b;
|
|
107
|
+
var _a, _b, _c, _d;
|
|
108
108
|
let transaction;
|
|
109
109
|
// アクションID指定の場合、進行中取引検証(2023-02-24~)
|
|
110
110
|
if (typeof params.id === 'string') {
|
|
@@ -145,23 +145,27 @@ function processVoidPayTransaction(params) {
|
|
|
145
145
|
throw new factory.errors.NotImplemented(`${transaction.status} not implemented`);
|
|
146
146
|
// 確定取引に対応(2023-05-03~)
|
|
147
147
|
case factory.transactionStatusType.Confirmed:
|
|
148
|
-
//
|
|
149
|
-
|
|
150
|
-
if (
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
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;
|
|
148
|
+
// OrderCancelledを考慮(2023-08-30~)
|
|
149
|
+
const orderCancelled = ((_b = (_a = params.purpose.result) === null || _a === void 0 ? void 0 : _a.order) === null || _b === void 0 ? void 0 : _b.orderStatus) === factory.orderStatus.OrderCancelled;
|
|
150
|
+
if (!orderCancelled) {
|
|
151
|
+
// 取り消すべきアクションに絞る
|
|
152
|
+
authorizeActions = authorizeActions.filter((a) => a.actionStatus !== factory.actionStatusType.CompletedActionStatus);
|
|
153
|
+
if (transaction.typeOf === factory.transactionType.PlaceOrder) {
|
|
154
|
+
const paymentMethodIds = (_d = (_c = transaction.result) === null || _c === void 0 ? void 0 : _c.order) === null || _d === void 0 ? void 0 : _d.paymentMethods.map((p) => {
|
|
155
|
+
return p.paymentMethodId;
|
|
164
156
|
});
|
|
157
|
+
if (!Array.isArray(paymentMethodIds)) {
|
|
158
|
+
throw new factory.errors.Argument('Transaction', `${transaction.id} must have result.order.paymentMethods`);
|
|
159
|
+
}
|
|
160
|
+
if (paymentMethodIds.length > 0) {
|
|
161
|
+
authorizeActions = authorizeActions.filter((a) => {
|
|
162
|
+
// paymentMethodIdが存在しない、あるいは、注文のpaymentMethodIdsに含まれなければ、アクション取消対象
|
|
163
|
+
const paymentMethodIdByAction = a.object.paymentMethodId;
|
|
164
|
+
const includedInOrder = typeof paymentMethodIdByAction === 'string'
|
|
165
|
+
&& paymentMethodIds.includes(paymentMethodIdByAction);
|
|
166
|
+
return !includedInOrder;
|
|
167
|
+
});
|
|
168
|
+
}
|
|
165
169
|
}
|
|
166
170
|
}
|
|
167
171
|
break;
|
|
@@ -339,7 +343,7 @@ function authorize(params) {
|
|
|
339
343
|
if (error.name !== 'AbortError') {
|
|
340
344
|
yield processVoidPayTransaction({
|
|
341
345
|
project: action.project,
|
|
342
|
-
agent: { id: action.project.id },
|
|
346
|
+
// agent: { id: action.project.id },
|
|
343
347
|
id: action.id,
|
|
344
348
|
purpose: action.purpose
|
|
345
349
|
})(repos);
|
|
@@ -34,9 +34,9 @@ function authorize(params, paymentServiceId, searchTrade4accountId) {
|
|
|
34
34
|
exclusion: []
|
|
35
35
|
});
|
|
36
36
|
// CreditCard系統の決済方法タイプは動的
|
|
37
|
-
const paymentMethodType = (_a = params.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.
|
|
37
|
+
const paymentMethodType = (_a = params.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.identifier;
|
|
38
38
|
if (typeof paymentMethodType !== 'string') {
|
|
39
|
-
throw new factory.errors.ArgumentNull('object.paymentMethod.
|
|
39
|
+
throw new factory.errors.ArgumentNull('object.paymentMethod.identifier');
|
|
40
40
|
}
|
|
41
41
|
const availableChannel = yield repos.product.findAvailableChannel({
|
|
42
42
|
project: params.project,
|
|
@@ -205,16 +205,16 @@ function handleAuthorizeError(error) {
|
|
|
205
205
|
*/
|
|
206
206
|
function voidTransaction(params) {
|
|
207
207
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
208
|
-
var _a, _b, _c, _d, _e, _f
|
|
208
|
+
var _a, _b, _c, _d, _e, _f;
|
|
209
209
|
const transaction = params.object;
|
|
210
210
|
// CreditCard系統の決済方法タイプは動的
|
|
211
|
-
const paymentMethodType = (_a = transaction.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.
|
|
211
|
+
const paymentMethodType = (_a = transaction.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.identifier;
|
|
212
212
|
if (typeof paymentMethodType !== 'string') {
|
|
213
|
-
throw new factory.errors.ArgumentNull('object.paymentMethod.
|
|
213
|
+
throw new factory.errors.ArgumentNull('object.paymentMethod.identifier');
|
|
214
214
|
}
|
|
215
|
-
const paymentMethodId =
|
|
215
|
+
const paymentMethodId = transaction.object.paymentMethodId;
|
|
216
216
|
if (typeof paymentMethodId !== 'string') {
|
|
217
|
-
throw new factory.errors.ArgumentNull('object.
|
|
217
|
+
throw new factory.errors.ArgumentNull('object.paymentMethodId');
|
|
218
218
|
}
|
|
219
219
|
const paymentServiceId = String(transaction.object.id);
|
|
220
220
|
const availableChannel = yield repos.product.findAvailableChannel({
|
|
@@ -222,7 +222,7 @@ function voidTransaction(params) {
|
|
|
222
222
|
typeOf: factory.service.paymentService.PaymentServiceType.CreditCard,
|
|
223
223
|
id: paymentServiceId
|
|
224
224
|
});
|
|
225
|
-
const sellerId = (
|
|
225
|
+
const sellerId = (_b = transaction.recipient) === null || _b === void 0 ? void 0 : _b.id;
|
|
226
226
|
if (typeof sellerId !== 'string') {
|
|
227
227
|
throw new factory.errors.ArgumentNull('object.recipient.id');
|
|
228
228
|
}
|
|
@@ -236,8 +236,8 @@ function voidTransaction(params) {
|
|
|
236
236
|
shopId: shopId,
|
|
237
237
|
shopPass: shopPass,
|
|
238
238
|
orderId: paymentMethodId,
|
|
239
|
-
siteId: (
|
|
240
|
-
sitePass: (
|
|
239
|
+
siteId: (_c = availableChannel.credentials) === null || _c === void 0 ? void 0 : _c.siteId,
|
|
240
|
+
sitePass: (_d = availableChannel.credentials) === null || _d === void 0 ? void 0 : _d.sitePass
|
|
241
241
|
});
|
|
242
242
|
debug('searchTradeResult:', searchTradeResult);
|
|
243
243
|
// 仮売上であれば取消
|
|
@@ -248,8 +248,8 @@ function voidTransaction(params) {
|
|
|
248
248
|
accessId: searchTradeResult.accessId,
|
|
249
249
|
accessPass: searchTradeResult.accessPass,
|
|
250
250
|
jobCd: GMO.utils.util.JobCd.Void,
|
|
251
|
-
siteId: (
|
|
252
|
-
sitePass: (
|
|
251
|
+
siteId: (_e = availableChannel.credentials) === null || _e === void 0 ? void 0 : _e.siteId,
|
|
252
|
+
sitePass: (_f = availableChannel.credentials) === null || _f === void 0 ? void 0 : _f.sitePass
|
|
253
253
|
});
|
|
254
254
|
debug('alterTran processed', alterTranResult);
|
|
255
255
|
}
|
|
@@ -39,9 +39,9 @@ function validateMovieTicket(params, paymentServiceId, useCheckMovieTicketBefore
|
|
|
39
39
|
throw new factory.errors.Argument('movieTickets', 'Number of movie ticket accessCodes must be 1');
|
|
40
40
|
}
|
|
41
41
|
// ムビチケ系統の決済方法タイプは動的
|
|
42
|
-
const paymentMethodType = (_b = params.object.paymentMethod) === null || _b === void 0 ? void 0 : _b.
|
|
42
|
+
const paymentMethodType = (_b = params.object.paymentMethod) === null || _b === void 0 ? void 0 : _b.identifier;
|
|
43
43
|
if (typeof paymentMethodType !== 'string') {
|
|
44
|
-
throw new factory.errors.ArgumentNull('object.paymentMethod.
|
|
44
|
+
throw new factory.errors.ArgumentNull('object.paymentMethod.identifier');
|
|
45
45
|
}
|
|
46
46
|
// イベント取得属性最適化(2023-01-23~)
|
|
47
47
|
const screeningEvent = yield repos.event.findMinimizedIndividualEventById({
|