@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.
- package/example/src/chevre/onAssetTransactionStatusChanged.ts +36 -0
- package/example/src/chevre/retryTasks.ts +39 -0
- package/example/src/chevre/searchOrders.ts +13 -15
- package/example/src/chevre/searchSlicedAcceptedOffersByOrderNumber.ts +28 -0
- package/example/src/chevre/sendOrder.ts +37 -0
- package/example/src/chevre/transaction/processAcceptOffer.ts +48 -0
- package/example/src/chevre/transaction/processPlaceOrder.ts +82 -53
- package/lib/chevre/repo/acceptedOffer.d.ts +21 -1
- package/lib/chevre/repo/acceptedOffer.js +32 -2
- package/lib/chevre/repo/action.d.ts +3 -3
- package/lib/chevre/repo/action.js +4 -6
- package/lib/chevre/repo/mongoose/schemas/order.d.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/order.js +20 -11
- package/lib/chevre/repo/order.js +28 -9
- package/lib/chevre/repo/orderInTransaction.d.ts +27 -0
- package/lib/chevre/repo/orderInTransaction.js +77 -0
- package/lib/chevre/repo/task.d.ts +0 -2
- package/lib/chevre/repo/task.js +56 -46
- package/lib/chevre/repo/transaction.d.ts +1 -1
- package/lib/chevre/repository.d.ts +5 -0
- package/lib/chevre/repository.js +15 -2
- package/lib/chevre/service/assetTransaction/pay.d.ts +0 -10
- package/lib/chevre/service/assetTransaction/pay.js +4 -4
- package/lib/chevre/service/code.js +1 -1
- package/lib/chevre/service/delivery.js +2 -2
- package/lib/chevre/service/event/createEvent.js +1 -1
- package/lib/chevre/service/event.js +2 -2
- package/lib/chevre/service/moneyTransfer.js +1 -1
- package/lib/chevre/service/notification.js +2 -5
- package/lib/chevre/service/offer/any.d.ts +29 -0
- package/lib/chevre/service/offer/any.js +55 -0
- package/lib/chevre/service/offer/event/authorize.d.ts +7 -0
- package/lib/chevre/service/offer/event/authorize.js +11 -0
- package/lib/chevre/service/offer/event/cancel.d.ts +2 -0
- package/lib/chevre/service/offer/event/cancel.js +12 -1
- package/lib/chevre/service/offer/event/voidTransaction.d.ts +2 -0
- package/lib/chevre/service/offer/event/voidTransaction.js +12 -5
- package/lib/chevre/service/offer/eventServiceByCOA.js +2 -2
- package/lib/chevre/service/offer/moneyTransfer/authorize.d.ts +6 -1
- package/lib/chevre/service/offer/moneyTransfer/authorize.js +2 -1
- package/lib/chevre/service/offer/moneyTransfer/returnMoneyTransfer.js +1 -1
- package/lib/chevre/service/offer/moneyTransfer/settleTransaction.js +1 -1
- package/lib/chevre/service/offer/moneyTransfer/voidTransaction.js +1 -1
- package/lib/chevre/service/offer/product.js +1 -1
- package/lib/chevre/service/order/confirmPayTransaction.js +3 -3
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +11 -1
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +113 -5
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.js +18 -19
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +38 -25
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +11 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.js +45 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.d.ts +14 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.js +37 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.d.ts +10 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +86 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +18 -12
- package/lib/chevre/service/order/onOrderStatusChanged.d.ts +3 -1
- package/lib/chevre/service/order/onOrderStatusChanged.js +5 -1
- package/lib/chevre/service/order/placeOrder.d.ts +2 -0
- package/lib/chevre/service/order/placeOrder.js +28 -29
- package/lib/chevre/service/order/returnOrder.js +25 -16
- package/lib/chevre/service/order/sendOrder.d.ts +5 -0
- package/lib/chevre/service/order/sendOrder.js +68 -30
- package/lib/chevre/service/payment/any.d.ts +6 -8
- package/lib/chevre/service/payment/any.js +46 -10
- package/lib/chevre/service/payment/creditCard.d.ts +9 -8
- package/lib/chevre/service/payment/creditCard.js +102 -133
- package/lib/chevre/service/payment/faceToFace.d.ts +0 -4
- package/lib/chevre/service/payment/movieTicket/checkByIdentifier.d.ts +0 -2
- package/lib/chevre/service/payment/movieTicket/checkByIdentifier.js +1 -0
- package/lib/chevre/service/payment/movieTicket/validation.d.ts +0 -2
- package/lib/chevre/service/payment/movieTicket.d.ts +0 -6
- package/lib/chevre/service/payment/movieTicket.js +1 -1
- package/lib/chevre/service/payment/paymentCard.d.ts +0 -2
- package/lib/chevre/service/payment/paymentCard.js +6 -6
- package/lib/chevre/service/payment.js +1 -1
- package/lib/chevre/service/product.js +1 -1
- package/lib/chevre/service/reserve/cancelReservation.js +2 -2
- package/lib/chevre/service/reserve/confirmReservation.js +1 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.d.ts +1 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +4 -4
- package/lib/chevre/service/reserve/useReservation.d.ts +1 -2
- package/lib/chevre/service/reserve/useReservation.js +4 -4
- package/lib/chevre/service/reserve/verifyToken4reservation.js +2 -0
- package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +1 -1
- package/lib/chevre/service/task/confirmReserveTransaction.d.ts +4 -1
- package/lib/chevre/service/task/confirmReserveTransaction.js +42 -3
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +7 -7
- package/lib/chevre/service/task/placeOrder.js +9 -10
- package/lib/chevre/service/task/returnOrder.js +0 -3
- package/lib/chevre/service/task/returnPayTransaction.js +1 -1
- package/lib/chevre/service/task/returnReserveTransaction.js +1 -1
- package/lib/chevre/service/task/sendOrder.js +8 -4
- package/lib/chevre/service/task/voidPayTransaction.js +2 -2
- package/lib/chevre/service/task/voidReserveTransaction.js +8 -12
- package/lib/chevre/service/transaction/deleteTransaction.js +1 -1
- package/lib/chevre/service/transaction/moneyTransfer.js +1 -5
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.js +6 -2
- package/lib/chevre/service/transaction/placeOrderInProgress.js +2 -2
- package/lib/chevre/service/transaction/returnOrder/preStart.d.ts +32 -0
- package/lib/chevre/service/transaction/returnOrder/preStart.js +632 -0
- package/lib/chevre/service/transaction/returnOrder.d.ts +8 -6
- package/lib/chevre/service/transaction/returnOrder.js +4 -616
- package/lib/chevre/settings.d.ts +3 -1
- package/lib/chevre/settings.js +7 -2
- package/package.json +3 -3
|
@@ -10,21 +10,35 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.sendOrder = void 0;
|
|
13
|
+
const createDebug = require("debug");
|
|
13
14
|
const order_1 = require("../../factory/order");
|
|
14
15
|
const factory_1 = require("../delivery/factory");
|
|
15
16
|
const findPlaceOrderTransaction_1 = require("./findPlaceOrderTransaction");
|
|
16
17
|
const onOrderStatusChanged_1 = require("./onOrderStatusChanged");
|
|
17
18
|
const factory = require("../../factory");
|
|
19
|
+
const debug = createDebug('chevre-domain:service:order');
|
|
18
20
|
/**
|
|
19
21
|
* 注文を配送する
|
|
20
22
|
*/
|
|
21
23
|
function sendOrder(params) {
|
|
22
24
|
// tslint:disable-next-line:max-func-body-length
|
|
23
25
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
var _a;
|
|
26
|
+
var _a, _b, _c;
|
|
25
27
|
if (typeof params.useOnOrderStatusChanged !== 'boolean') {
|
|
26
28
|
throw new factory.errors.Argument('useOnOrderStatusChanged', 'must be boolean');
|
|
27
29
|
}
|
|
30
|
+
if (typeof ((_a = params.object.acceptedOffers) === null || _a === void 0 ? void 0 : _a.limit) !== 'number') {
|
|
31
|
+
throw new factory.errors.Argument('object.acceptedOffers.limit', 'must be number');
|
|
32
|
+
}
|
|
33
|
+
if (typeof ((_b = params.object.acceptedOffers) === null || _b === void 0 ? void 0 : _b.page) !== 'number') {
|
|
34
|
+
throw new factory.errors.Argument('object.acceptedOffers.page', 'must be number');
|
|
35
|
+
}
|
|
36
|
+
if (params.object.acceptedOffers.limit <= 0) {
|
|
37
|
+
throw new factory.errors.Argument('object.acceptedOffers.limit', 'must be greater than 1');
|
|
38
|
+
}
|
|
39
|
+
if (params.object.acceptedOffers.page <= 0) {
|
|
40
|
+
throw new factory.errors.Argument('object.acceptedOffers.page', 'must be greater than 1');
|
|
41
|
+
}
|
|
28
42
|
try {
|
|
29
43
|
const orderNumber = params.object.orderNumber;
|
|
30
44
|
const confirmationNumber = params.object.confirmationNumber;
|
|
@@ -62,9 +76,11 @@ function sendOrder(params) {
|
|
|
62
76
|
priceCurrency: order.priceCurrency,
|
|
63
77
|
orderDate: order.orderDate
|
|
64
78
|
};
|
|
79
|
+
const { limit, page } = params.object.acceptedOffers;
|
|
80
|
+
const sendOrderObject = Object.assign(Object.assign({}, simpleOrder), { acceptedOffers: { limit, page } });
|
|
65
81
|
const sendOrderActionAttributes = {
|
|
66
|
-
agent: (typeof ((
|
|
67
|
-
object:
|
|
82
|
+
agent: (typeof ((_c = params.agent) === null || _c === void 0 ? void 0 : _c.typeOf) === 'string') ? params.agent : order.project,
|
|
83
|
+
object: sendOrderObject,
|
|
68
84
|
potentialActions: {
|
|
69
85
|
// sendEmailMessage: undefined
|
|
70
86
|
},
|
|
@@ -74,23 +90,34 @@ function sendOrder(params) {
|
|
|
74
90
|
};
|
|
75
91
|
const action = yield repos.action.start(sendOrderActionAttributes);
|
|
76
92
|
let ownershipInfos;
|
|
93
|
+
let allOffersDelivered = false;
|
|
77
94
|
try {
|
|
78
|
-
//
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
95
|
+
// const acceptedOffers = await repos.acceptedOffer.searchAcceptedOffersByOrderNumber({
|
|
96
|
+
// orderNumber: { $eq: order.orderNumber },
|
|
97
|
+
// project: { id: { $eq: order.project.id } }
|
|
98
|
+
// });
|
|
99
|
+
const { acceptedOffers, numAcceptedOffers } = yield repos.acceptedOffer.searchSlicedAcceptedOffersByOrderNumber({
|
|
100
|
+
$slice: [limit * (page - 1), limit],
|
|
101
|
+
orderNumber: { $eq: order.orderNumber },
|
|
102
|
+
project: { id: { $eq: order.project.id } }
|
|
84
103
|
});
|
|
104
|
+
debug('delivering...', order.orderNumber, acceptedOffers.map((offer) => `${offer.itemOffered.id}`), params.object.acceptedOffers);
|
|
105
|
+
// 所有権作成
|
|
106
|
+
ownershipInfos = (0, factory_1.createOwnershipInfosFromOrder)({ order: Object.assign(Object.assign({}, order), { acceptedOffers }) });
|
|
85
107
|
ownershipInfos = yield Promise.all(ownershipInfos.map((ownershipInfo) => __awaiter(this, void 0, void 0, function* () {
|
|
86
108
|
return repos.ownershipInfo.createIfNotExistByIdentifier(ownershipInfo);
|
|
87
109
|
})));
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
110
|
+
const deliveredCount = limit * page;
|
|
111
|
+
debug(deliveredCount, 'delivered.', order.orderNumber, params.object.acceptedOffers);
|
|
112
|
+
if (deliveredCount >= numAcceptedOffers) {
|
|
113
|
+
order = yield repos.order.changeStatus({
|
|
114
|
+
project: { id: order.project.id },
|
|
115
|
+
orderNumber,
|
|
116
|
+
orderStatus: factory.orderStatus.OrderDelivered,
|
|
117
|
+
previousOrderStatus: params.object.previousOrderStatus
|
|
118
|
+
});
|
|
119
|
+
allOffersDelivered = true;
|
|
120
|
+
}
|
|
94
121
|
}
|
|
95
122
|
catch (error) {
|
|
96
123
|
try {
|
|
@@ -102,22 +129,33 @@ function sendOrder(params) {
|
|
|
102
129
|
throw error;
|
|
103
130
|
}
|
|
104
131
|
const result = ownershipInfos;
|
|
105
|
-
yield repos.action.
|
|
132
|
+
yield repos.action.completeWithVoid({ typeOf: sendOrderActionAttributes.typeOf, id: action.id, result: result });
|
|
133
|
+
debug('allOffersDelivered?:', allOffersDelivered, order.orderNumber);
|
|
106
134
|
if (params.useOnOrderStatusChanged) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
135
|
+
if (allOffersDelivered) {
|
|
136
|
+
yield (0, onOrderStatusChanged_1.onOrderDelivered)({
|
|
137
|
+
order: {
|
|
138
|
+
id: order.id,
|
|
139
|
+
customer: order.customer,
|
|
140
|
+
orderDate: order.orderDate,
|
|
141
|
+
orderNumber: order.orderNumber,
|
|
142
|
+
project: order.project,
|
|
143
|
+
typeOf: order.typeOf,
|
|
144
|
+
orderStatus: factory.orderStatus.OrderDelivered
|
|
145
|
+
},
|
|
146
|
+
placeOrderTransaction
|
|
147
|
+
})({
|
|
148
|
+
task: repos.task
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
yield (0, onOrderStatusChanged_1.onOrderDeliveredPartially)({
|
|
153
|
+
order: Object.assign(Object.assign({}, order), { acceptedOffers: params.object.acceptedOffers, orderStatus: params.object.previousOrderStatus })
|
|
154
|
+
// placeOrderTransaction
|
|
155
|
+
})({
|
|
156
|
+
task: repos.task
|
|
157
|
+
});
|
|
158
|
+
}
|
|
121
159
|
}
|
|
122
160
|
}
|
|
123
161
|
catch (error) {
|
|
@@ -10,7 +10,6 @@ import type { MongoRepository as PaymentServiceRepo } from '../../repo/paymentSe
|
|
|
10
10
|
import type { MongoRepository as PaymentServiceProviderRepo } from '../../repo/paymentServiceProvider';
|
|
11
11
|
import type { CognitoRepository as PersonRepo } from '../../repo/person';
|
|
12
12
|
import type { MongoRepository as ProductRepo } from '../../repo/product';
|
|
13
|
-
import type { MongoRepository as ProjectRepo } from '../../repo/project';
|
|
14
13
|
import type { MongoRepository as PaymentAcceptedRepo } from '../../repo/sellerPaymentAccepted';
|
|
15
14
|
import type { MongoRepository as TaskRepo } from '../../repo/task';
|
|
16
15
|
import type { MongoRepository as TransactionRepo } from '../../repo/transaction';
|
|
@@ -18,7 +17,6 @@ import type { RedisRepository as TransactionNumberRepo } from '../../repo/transa
|
|
|
18
17
|
import * as PayTransactionService from '../assetTransaction/pay';
|
|
19
18
|
import { onPaymentStatusChanged } from './any/onPaymentStatusChanged';
|
|
20
19
|
import { person2username } from './any/person2username';
|
|
21
|
-
type IAuthorizePaymentAction = factory.action.authorize.paymentMethod.any.IAction;
|
|
22
20
|
/**
|
|
23
21
|
* 決済承認中止
|
|
24
22
|
* タスクから決済承認を取り消す
|
|
@@ -30,7 +28,6 @@ declare function voidPayTransaction(params: factory.task.IData<factory.taskName.
|
|
|
30
28
|
paymentAccepted: PaymentAcceptedRepo;
|
|
31
29
|
paymentService: PaymentServiceRepo;
|
|
32
30
|
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
33
|
-
project: ProjectRepo;
|
|
34
31
|
task: TaskRepo;
|
|
35
32
|
transaction: TransactionRepo;
|
|
36
33
|
}) => Promise<void>;
|
|
@@ -41,7 +38,6 @@ declare function invalidatePaymentUrl(params: factory.task.IData<factory.taskNam
|
|
|
41
38
|
paymentAccepted: PaymentAcceptedRepo;
|
|
42
39
|
paymentService: PaymentServiceRepo;
|
|
43
40
|
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
44
|
-
project: ProjectRepo;
|
|
45
41
|
task: TaskRepo;
|
|
46
42
|
transaction: TransactionRepo;
|
|
47
43
|
}) => Promise<void>;
|
|
@@ -53,7 +49,6 @@ declare function processVoidPayTransaction(params: factory.task.IData<factory.ta
|
|
|
53
49
|
action: ActionRepo;
|
|
54
50
|
accountingReport: AccountingReportRepo;
|
|
55
51
|
assetTransaction: AssetTransactionRepo;
|
|
56
|
-
project: ProjectRepo;
|
|
57
52
|
task: TaskRepo;
|
|
58
53
|
transaction: TransactionRepo;
|
|
59
54
|
}) => Promise<void>;
|
|
@@ -67,7 +62,6 @@ interface IAuthorizeRepos {
|
|
|
67
62
|
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
68
63
|
person: PersonRepo;
|
|
69
64
|
product: ProductRepo;
|
|
70
|
-
project: ProjectRepo;
|
|
71
65
|
task: TaskRepo;
|
|
72
66
|
transaction: TransactionRepo;
|
|
73
67
|
transactionNumber: TransactionNumberRepo;
|
|
@@ -79,7 +73,6 @@ interface IPublishPaymentUrlRepos {
|
|
|
79
73
|
paymentService: PaymentServiceRepo;
|
|
80
74
|
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
81
75
|
person: PersonRepo;
|
|
82
|
-
project: ProjectRepo;
|
|
83
76
|
transaction: TransactionRepo;
|
|
84
77
|
transactionNumber: TransactionNumberRepo;
|
|
85
78
|
}
|
|
@@ -122,5 +115,10 @@ declare function authorize(params: {
|
|
|
122
115
|
useCheckByIdentifierIfNotYet: boolean;
|
|
123
116
|
useSearchTrade4accountId: boolean;
|
|
124
117
|
};
|
|
125
|
-
}): IAuthorizeOperation<
|
|
118
|
+
}): IAuthorizeOperation<{
|
|
119
|
+
/**
|
|
120
|
+
* 承認アクションID
|
|
121
|
+
*/
|
|
122
|
+
id: string;
|
|
123
|
+
}>;
|
|
126
124
|
export { onPaymentStatusChanged, authorize, invalidatePaymentUrl, voidPayTransaction, person2username, processVoidPayTransaction, publishPaymentUrl };
|
|
@@ -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: {
|
|
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.
|
|
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:
|
|
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((
|
|
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:
|
|
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:
|
|
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:
|
|
367
|
-
|
|
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,
|
|
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;
|