@chevre/domain 20.4.0-alpha.0 → 20.4.0-alpha.10
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/createManyEventsIfNotExist.ts +10 -10
- package/example/src/chevre/migrateMoneyTransferPendingTransactionIdentifier.ts +96 -0
- package/example/src/chevre/unsetUnnecessaryFields.ts +26 -0
- package/lib/chevre/repo/account.d.ts +4 -10
- package/lib/chevre/repo/account.js +72 -60
- package/lib/chevre/repo/accountTransaction.d.ts +0 -1
- package/lib/chevre/repo/accountTransaction.js +1 -1
- package/lib/chevre/repo/assetTransaction.d.ts +1 -0
- package/lib/chevre/repo/assetTransaction.js +5 -0
- package/lib/chevre/repo/comment.d.ts +31 -0
- package/lib/chevre/repo/comment.js +113 -0
- package/lib/chevre/repo/event.js +7 -1
- package/lib/chevre/repo/mongoose/model/{accountAction.d.ts → comments.d.ts} +2 -2
- package/lib/chevre/repo/mongoose/model/comments.js +82 -0
- package/lib/chevre/repo/mongoose/model/order.js +8 -2
- package/lib/chevre/repo/order.d.ts +6 -0
- package/lib/chevre/repo/order.js +58 -14
- package/lib/chevre/repo/serviceOutput.d.ts +4 -0
- package/lib/chevre/repo/serviceOutput.js +6 -0
- package/lib/chevre/repository.d.ts +6 -3
- package/lib/chevre/repository.js +8 -5
- package/lib/chevre/service/account.d.ts +0 -8
- package/lib/chevre/service/account.js +16 -37
- package/lib/chevre/service/accountTransaction/deposit.js +2 -5
- package/lib/chevre/service/accountTransaction/factory.js +36 -40
- package/lib/chevre/service/accountTransaction/transfer.js +4 -6
- package/lib/chevre/service/accountTransaction/withdraw.js +2 -5
- package/lib/chevre/service/accountTransaction.js +1 -1
- package/lib/chevre/service/assetTransaction/moneyTransfer.js +19 -11
- package/lib/chevre/service/assetTransaction/pay.js +17 -11
- package/lib/chevre/service/assetTransaction/registerService/factory.js +9 -4
- package/lib/chevre/service/delivery.js +12 -3
- package/lib/chevre/service/event.js +3 -23
- package/lib/chevre/service/moneyTransfer.d.ts +1 -1
- package/lib/chevre/service/moneyTransfer.js +8 -9
- package/lib/chevre/service/offer/moneyTransfer/authorize.js +0 -1
- package/lib/chevre/service/offer/moneyTransfer/returnMoneyTransfer.js +0 -1
- package/lib/chevre/service/payment/paymentCard.d.ts +6 -2
- package/lib/chevre/service/payment/paymentCard.js +16 -8
- package/lib/chevre/service/permit.d.ts +5 -1
- package/lib/chevre/service/permit.js +18 -11
- package/lib/chevre/service/transaction/moneyTransfer.js +0 -1
- package/lib/chevre/settings.d.ts +1 -0
- package/lib/chevre/settings.js +2 -2
- package/package.json +3 -3
- package/example/src/chevre/migrateAccountTitleAdditionalProperties.ts +0 -157
- package/example/src/chevre/migrateProjectSubscription.ts +0 -51
- package/example/src/chevre/migrateSection.ts +0 -105
- package/lib/chevre/repo/accountAction.d.ts +0 -42
- package/lib/chevre/repo/accountAction.js +0 -474
- package/lib/chevre/repo/mongoose/model/accountAction.js +0 -177
|
@@ -47,13 +47,15 @@ function start(params) {
|
|
|
47
47
|
amount: params.object.amount,
|
|
48
48
|
fromLocation: {
|
|
49
49
|
typeOf: fromAccount.typeOf,
|
|
50
|
-
|
|
50
|
+
// 廃止(2023-02-16~)
|
|
51
|
+
// accountType: fromAccount.accountType,
|
|
51
52
|
accountNumber: fromAccount.accountNumber,
|
|
52
53
|
name: fromAccount.name
|
|
53
54
|
},
|
|
54
55
|
toLocation: {
|
|
55
56
|
typeOf: toAccount.typeOf,
|
|
56
|
-
|
|
57
|
+
// 廃止(2023-02-16~)
|
|
58
|
+
// accountType: toAccount.accountType,
|
|
57
59
|
accountNumber: toAccount.accountNumber,
|
|
58
60
|
name: toAccount.name
|
|
59
61
|
},
|
|
@@ -95,10 +97,6 @@ function start(params) {
|
|
|
95
97
|
accountNumber: params.object.toLocation.accountNumber,
|
|
96
98
|
transaction: pendingTransaction
|
|
97
99
|
});
|
|
98
|
-
// 口座取引におけるAccountAction管理を廃止(2022-11-28~)
|
|
99
|
-
// アクション開始
|
|
100
|
-
// const moneyTransferActionAttributes = createMoneyTransferActionAttributes({ transaction });
|
|
101
|
-
// await repos.accountAction.startByIdentifier(moneyTransferActionAttributes);
|
|
102
100
|
// 結果返却
|
|
103
101
|
return transaction;
|
|
104
102
|
});
|
|
@@ -36,7 +36,8 @@ function start(params) {
|
|
|
36
36
|
amount: params.object.amount,
|
|
37
37
|
fromLocation: {
|
|
38
38
|
typeOf: fromAccount.typeOf,
|
|
39
|
-
|
|
39
|
+
// 廃止(2023-02-16~)
|
|
40
|
+
// accountType: fromAccount.accountType,
|
|
40
41
|
accountNumber: fromAccount.accountNumber,
|
|
41
42
|
name: fromAccount.name
|
|
42
43
|
},
|
|
@@ -74,10 +75,6 @@ function start(params) {
|
|
|
74
75
|
transaction: pendingTransaction,
|
|
75
76
|
force: forcibly
|
|
76
77
|
});
|
|
77
|
-
// 口座取引におけるAccountAction管理を廃止(2022-11-28~)
|
|
78
|
-
// アクション開始
|
|
79
|
-
// const moneyTransferActionAttributes = createMoneyTransferActionAttributes({ transaction });
|
|
80
|
-
// await repos.accountAction.startByIdentifier(moneyTransferActionAttributes);
|
|
81
78
|
// 結果返却
|
|
82
79
|
return transaction;
|
|
83
80
|
});
|
|
@@ -62,20 +62,29 @@ function start(params) {
|
|
|
62
62
|
recipient: params.recipient,
|
|
63
63
|
object: Object.assign(Object.assign({ amount,
|
|
64
64
|
fromLocation,
|
|
65
|
-
toLocation, pendingTransaction: Object.assign({ typeOf: transactionType,
|
|
65
|
+
toLocation, pendingTransaction: Object.assign({ typeOf: transactionType, transactionNumber: transactionNumber }, (typeof params.identifier === 'string') ? { identifier: params.identifier } : undefined) }, (typeof params.object.description === 'string') ? { description: params.object.description } : {}), { force: params.object.force === true }),
|
|
66
66
|
expires: params.expires
|
|
67
67
|
};
|
|
68
68
|
// 取引開始
|
|
69
69
|
let transaction;
|
|
70
70
|
try {
|
|
71
71
|
transaction = yield repos.assetTransaction.start(startParams);
|
|
72
|
-
const pendingTransaction =
|
|
73
|
-
yield
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
72
|
+
// const pendingTransaction = await authorizeAccount({ transaction })(repos);
|
|
73
|
+
yield authorizeAccount({ transaction })(repos);
|
|
74
|
+
// 更新不要(2023-02-20~)
|
|
75
|
+
// await repos.assetTransaction.findByIdAndUpdate<factory.assetTransactionType.MoneyTransfer>({
|
|
76
|
+
// id: transaction.id,
|
|
77
|
+
// update: {
|
|
78
|
+
// 'object.pendingTransaction': {
|
|
79
|
+
// typeOf: pendingTransaction.typeOf,
|
|
80
|
+
// id: pendingTransaction.id,
|
|
81
|
+
// transactionNumber: pendingTransaction.transactionNumber,
|
|
82
|
+
// ...(typeof pendingTransaction.identifier === 'string')
|
|
83
|
+
// ? { identifier: pendingTransaction.identifier }
|
|
84
|
+
// : undefined
|
|
85
|
+
// }
|
|
86
|
+
// }
|
|
87
|
+
// });
|
|
79
88
|
}
|
|
80
89
|
catch (error) {
|
|
81
90
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
@@ -113,13 +122,12 @@ function authorizeAccount(params) {
|
|
|
113
122
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
114
123
|
var _a, _b, _c;
|
|
115
124
|
const transaction = params.transaction;
|
|
116
|
-
let pendingTransaction;
|
|
117
125
|
const fromLocation = transaction.object.fromLocation;
|
|
118
126
|
const toLocation = transaction.object.toLocation;
|
|
119
127
|
if (typeof ((_a = transaction.object.pendingTransaction) === null || _a === void 0 ? void 0 : _a.typeOf) !== 'string') {
|
|
120
128
|
throw new factory.errors.NotFound('transaction.object.pendingTransaction.typeOf');
|
|
121
129
|
}
|
|
122
|
-
|
|
130
|
+
yield MoneyTransferService.authorize({
|
|
123
131
|
typeOf: transaction.object.pendingTransaction.typeOf,
|
|
124
132
|
identifier: transaction.object.pendingTransaction.identifier,
|
|
125
133
|
transactionNumber: transaction.object.pendingTransaction.transactionNumber,
|
|
@@ -143,7 +151,7 @@ function authorizeAccount(params) {
|
|
|
143
151
|
recipient: transaction.recipient,
|
|
144
152
|
purpose: { typeOf: transaction.typeOf, id: transaction.id }
|
|
145
153
|
})(repos);
|
|
146
|
-
return pendingTransaction;
|
|
154
|
+
// return pendingTransaction;
|
|
147
155
|
});
|
|
148
156
|
}
|
|
149
157
|
function fixMonetaryAmount(params, product) {
|
|
@@ -220,26 +220,32 @@ function validateSeller(params) {
|
|
|
220
220
|
}
|
|
221
221
|
function processAuthorizeAccount(params, transaction, paymentServiceId) {
|
|
222
222
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
223
|
+
var _a;
|
|
224
|
+
const amount = (_a = params.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.amount;
|
|
225
|
+
if (typeof amount !== 'number') {
|
|
226
|
+
throw new factory.errors.ArgumentNull('object.paymentMethod?.amount');
|
|
227
|
+
}
|
|
223
228
|
yield (0, validation_1.validateAccount)(params)(repos);
|
|
224
|
-
const
|
|
229
|
+
const { pendingTransaction, currency, accountNumber } = yield PaymentCardPayment.authorize(params, paymentServiceId)(repos);
|
|
225
230
|
const totalPaymentDue = {
|
|
226
231
|
typeOf: 'MonetaryAmount',
|
|
227
|
-
currency
|
|
228
|
-
value:
|
|
229
|
-
|
|
230
|
-
|
|
232
|
+
currency,
|
|
233
|
+
value: amount
|
|
234
|
+
// value: (typeof pendingTransaction.object.amount === 'number')
|
|
235
|
+
// ? pendingTransaction.object.amount
|
|
236
|
+
// : pendingTransaction.object.amount.value
|
|
231
237
|
};
|
|
232
|
-
const
|
|
233
|
-
typeOf:
|
|
234
|
-
id:
|
|
235
|
-
transactionNumber:
|
|
236
|
-
object: { fromLocation: { accountNumber
|
|
238
|
+
const savingPendingTransaction = {
|
|
239
|
+
typeOf: pendingTransaction.typeOf,
|
|
240
|
+
id: pendingTransaction.id,
|
|
241
|
+
transactionNumber: pendingTransaction.transactionNumber,
|
|
242
|
+
object: { fromLocation: { accountNumber } }
|
|
237
243
|
};
|
|
238
244
|
return saveAuthorizeResult({
|
|
239
245
|
id: transaction.id,
|
|
240
246
|
update: {
|
|
241
247
|
'object.paymentMethod.totalPaymentDue': totalPaymentDue,
|
|
242
|
-
'object.pendingTransaction':
|
|
248
|
+
'object.pendingTransaction': savingPendingTransaction
|
|
243
249
|
}
|
|
244
250
|
})(repos);
|
|
245
251
|
});
|
|
@@ -58,13 +58,15 @@ function createServiceOutput(params) {
|
|
|
58
58
|
throw new factory.errors.ArgumentNull('object.itemOffered.serviceOutput.accessCode');
|
|
59
59
|
}
|
|
60
60
|
paymentAccount = {
|
|
61
|
-
|
|
61
|
+
// 廃止(2023-02-20~)
|
|
62
|
+
// project: { typeOf: product.project.typeOf, id: product.project.id },
|
|
62
63
|
// ひとまず固定
|
|
63
64
|
// 口座は複数のプロダクトに結合する可能性もあり、どのように利用されるかは知らない。ただbalanceを管理するだけ。通貨は知っている。
|
|
64
65
|
typeOf: factory.accountType.Account,
|
|
65
66
|
// ひとまずPermit識別子と口座番号は同一
|
|
66
|
-
accountNumber: identifier
|
|
67
|
-
|
|
67
|
+
accountNumber: identifier
|
|
68
|
+
// 廃止(2023-02-16~)
|
|
69
|
+
// accountType: amount.currency
|
|
68
70
|
};
|
|
69
71
|
break;
|
|
70
72
|
case factory.product.ProductType.MembershipService:
|
|
@@ -73,7 +75,10 @@ function createServiceOutput(params) {
|
|
|
73
75
|
default:
|
|
74
76
|
throw new factory.errors.NotImplemented(`Product type ${product.typeOf} not implemented`);
|
|
75
77
|
}
|
|
76
|
-
const issuedThrough = Object.assign({
|
|
78
|
+
const issuedThrough = Object.assign({
|
|
79
|
+
// 廃止(2023-02-20~)
|
|
80
|
+
// project: { typeOf: product.project.typeOf, id: product.project.id },
|
|
81
|
+
typeOf: product.typeOf, id: product.id }, (typeof ((_m = product.serviceType) === null || _m === void 0 ? void 0 : _m.typeOf) === 'string') ? { serviceType: product.serviceType } : undefined);
|
|
77
82
|
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ project: { typeOf: product.project.typeOf, id: product.project.id }, identifier: identifier, issuedThrough, typeOf: serviceOutputType, dateIssued: params.dateIssued }, (typeof accessCode === 'string') ? { accessCode } : undefined), (Array.isArray(additionalProperty)) ? { additionalProperty } : undefined), (typeof validFor === 'string') ? { validFor } : undefined), (name !== undefined) ? { name } : undefined), (amount !== undefined) ? { amount } : undefined), (depositAmount !== undefined) ? { depositAmount } : undefined), (paymentAmount !== undefined) ? { paymentAmount } : undefined), (paymentAccount !== undefined) ? { paymentAccount } : undefined), (issuedBy !== undefined) ? { issuedBy } : undefined);
|
|
78
83
|
}
|
|
79
84
|
exports.createServiceOutput = createServiceOutput;
|
|
@@ -88,7 +88,10 @@ function createGivePointAwardStartParams4moneyTransfer(params, transactionNumber
|
|
|
88
88
|
: params.purpose.typeOf,
|
|
89
89
|
fromLocation: agent,
|
|
90
90
|
toLocation,
|
|
91
|
-
pendingTransaction: {
|
|
91
|
+
pendingTransaction: {
|
|
92
|
+
typeOf: factory.account.transactionType.Deposit,
|
|
93
|
+
transactionNumber
|
|
94
|
+
}
|
|
92
95
|
} }, (typeof params.object.identifier === 'string') ? { identifier: params.object.identifier } : undefined);
|
|
93
96
|
}
|
|
94
97
|
/**
|
|
@@ -181,7 +184,10 @@ function processReturnPointAwardByTransactionIdentifier(params) {
|
|
|
181
184
|
fromLocation,
|
|
182
185
|
toLocation: depositTransaction.object.fromLocation,
|
|
183
186
|
description: `[Return Award]${depositTransaction.object.description}`,
|
|
184
|
-
pendingTransaction: {
|
|
187
|
+
pendingTransaction: {
|
|
188
|
+
typeOf: factory.account.transactionType.Withdraw,
|
|
189
|
+
transactionNumber
|
|
190
|
+
},
|
|
185
191
|
force: true
|
|
186
192
|
}
|
|
187
193
|
})(repos);
|
|
@@ -260,7 +266,10 @@ function processReturnPointAwardByTransactionFromLocationIdentifier(params) {
|
|
|
260
266
|
// },
|
|
261
267
|
toLocation,
|
|
262
268
|
description: `[Return Award]${returningTransaction.object.description}`,
|
|
263
|
-
pendingTransaction: {
|
|
269
|
+
pendingTransaction: {
|
|
270
|
+
typeOf: factory.account.transactionType.Transfer,
|
|
271
|
+
transactionNumber
|
|
272
|
+
},
|
|
264
273
|
force: true
|
|
265
274
|
}
|
|
266
275
|
})(repos);
|
|
@@ -21,6 +21,7 @@ const difference = require("lodash.difference");
|
|
|
21
21
|
const moment = require("moment-timezone");
|
|
22
22
|
const credentials_1 = require("../credentials");
|
|
23
23
|
const factory = require("../factory");
|
|
24
|
+
const settings_1 = require("../settings");
|
|
24
25
|
const offer_1 = require("./offer");
|
|
25
26
|
// const customsearch = google.customsearch('v1');
|
|
26
27
|
const debug = createDebug('chevre-domain:service:event');
|
|
@@ -449,32 +450,11 @@ function createScreeningEventFromCOA(params) {
|
|
|
449
450
|
priceCurrency: factory.priceCurrency.JPY
|
|
450
451
|
};
|
|
451
452
|
const { additionalProperty, coaInfo } = createScreeningEventAdditionalPropertyFromCOA(params);
|
|
452
|
-
return {
|
|
453
|
-
project: { typeOf: params.project.typeOf, id: params.project.id },
|
|
454
|
-
typeOf: factory.eventType.ScreeningEvent,
|
|
455
|
-
id: id,
|
|
456
|
-
identifier: id,
|
|
457
|
-
name: params.superEvent.name,
|
|
458
|
-
eventStatus: factory.eventStatusType.EventScheduled,
|
|
459
|
-
workPerformed: params.superEvent.workPerformed,
|
|
460
|
-
location: {
|
|
461
|
-
// 不要なので廃止(2022-12-19~)
|
|
462
|
-
// project: { typeOf: params.project.typeOf, id: params.project.id },
|
|
453
|
+
return Object.assign({ project: { typeOf: params.project.typeOf, id: params.project.id }, typeOf: factory.eventType.ScreeningEvent, id: id, identifier: id, name: params.superEvent.name, eventStatus: factory.eventStatusType.EventScheduled, location: {
|
|
463
454
|
typeOf: params.screenRoom.typeOf,
|
|
464
455
|
branchCode: params.screenRoom.branchCode,
|
|
465
456
|
name: params.screenRoom.name
|
|
466
|
-
},
|
|
467
|
-
endDate: endDate,
|
|
468
|
-
startDate: startDate,
|
|
469
|
-
superEvent: params.superEvent,
|
|
470
|
-
coaInfo,
|
|
471
|
-
offers: offers,
|
|
472
|
-
checkInCount: 0,
|
|
473
|
-
attendeeCount: 0,
|
|
474
|
-
maximumAttendeeCapacity: params.screenRoom.maximumAttendeeCapacity,
|
|
475
|
-
remainingAttendeeCapacity: params.screenRoom.maximumAttendeeCapacity,
|
|
476
|
-
additionalProperty
|
|
477
|
-
};
|
|
457
|
+
}, endDate: endDate, startDate: startDate, superEvent: params.superEvent, coaInfo, offers: offers, checkInCount: 0, attendeeCount: 0, maximumAttendeeCapacity: params.screenRoom.maximumAttendeeCapacity, remainingAttendeeCapacity: params.screenRoom.maximumAttendeeCapacity, additionalProperty }, (settings_1.settings.useEventWorkPerformed) ? { workPerformed: params.superEvent.workPerformed } : undefined);
|
|
478
458
|
}
|
|
479
459
|
function createScreeningEventAdditionalPropertyFromCOA(params) {
|
|
480
460
|
const coaInfo = {
|
|
@@ -28,9 +28,9 @@ function authorize(params) {
|
|
|
28
28
|
id: params.purpose.id
|
|
29
29
|
});
|
|
30
30
|
// 口座取引開始
|
|
31
|
-
let pendingTransaction;
|
|
31
|
+
// let pendingTransaction: factory.action.transfer.moneyTransfer.IPendingTransaction;
|
|
32
32
|
try {
|
|
33
|
-
|
|
33
|
+
yield processAccountTransaction({
|
|
34
34
|
typeOf: params.typeOf,
|
|
35
35
|
identifier: params.identifier,
|
|
36
36
|
transactionNumber: params.transactionNumber,
|
|
@@ -46,13 +46,12 @@ function authorize(params) {
|
|
|
46
46
|
error = (0, errorHandler_1.handlePecorinoError)(error);
|
|
47
47
|
throw error;
|
|
48
48
|
}
|
|
49
|
-
return pendingTransaction;
|
|
49
|
+
// return pendingTransaction;
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
exports.authorize = authorize;
|
|
53
53
|
function processAccountTransaction(params) {
|
|
54
54
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
let pendingTransaction;
|
|
56
55
|
const transaction = params.transaction;
|
|
57
56
|
const agent = createAccountTransactionAgent(params);
|
|
58
57
|
const recipient = createAccountTransactionRecipient(params);
|
|
@@ -75,7 +74,7 @@ function processAccountTransaction(params) {
|
|
|
75
74
|
});
|
|
76
75
|
switch (params.typeOf) {
|
|
77
76
|
case factory.account.transactionType.Deposit:
|
|
78
|
-
|
|
77
|
+
yield processDepositTransaction({
|
|
79
78
|
identifier: params.identifier,
|
|
80
79
|
transactionNumber: params.transactionNumber,
|
|
81
80
|
project: params.project,
|
|
@@ -88,7 +87,7 @@ function processAccountTransaction(params) {
|
|
|
88
87
|
})({ permit: permitService });
|
|
89
88
|
break;
|
|
90
89
|
case factory.account.transactionType.Transfer:
|
|
91
|
-
|
|
90
|
+
yield processTransferTransaction({
|
|
92
91
|
identifier: params.identifier,
|
|
93
92
|
transactionNumber: params.transactionNumber,
|
|
94
93
|
project: params.project,
|
|
@@ -101,7 +100,7 @@ function processAccountTransaction(params) {
|
|
|
101
100
|
})({ permit: permitService });
|
|
102
101
|
break;
|
|
103
102
|
case factory.account.transactionType.Withdraw:
|
|
104
|
-
|
|
103
|
+
yield processWithdrawTransaction({
|
|
105
104
|
identifier: params.identifier,
|
|
106
105
|
transactionNumber: params.transactionNumber,
|
|
107
106
|
project: params.project,
|
|
@@ -116,7 +115,7 @@ function processAccountTransaction(params) {
|
|
|
116
115
|
default:
|
|
117
116
|
throw new factory.errors.Argument('Object', 'At least one of accounts from and to must be specified');
|
|
118
117
|
}
|
|
119
|
-
return pendingTransaction;
|
|
118
|
+
// return pendingTransaction;
|
|
120
119
|
});
|
|
121
120
|
}
|
|
122
121
|
function processDepositTransaction(params) {
|
|
@@ -513,7 +512,7 @@ function processDepositFromNow(params, permitServiceCredentials, transactionNumb
|
|
|
513
512
|
recipient, object: {
|
|
514
513
|
amount: { value: amount },
|
|
515
514
|
description: description,
|
|
516
|
-
fromLocation: params.fromLocation,
|
|
515
|
+
// fromLocation: params.fromLocation,
|
|
517
516
|
toLocation: { accountNumber: String((_a = permit.paymentAccount) === null || _a === void 0 ? void 0 : _a.accountNumber) }
|
|
518
517
|
} }, (typeof accountTransactionIdentifier === 'string') ? { identifier: accountTransactionIdentifier } : undefined));
|
|
519
518
|
try {
|
|
@@ -57,7 +57,6 @@ function returnMoneyTransfer(params) {
|
|
|
57
57
|
toLocation: depositTransaction.object.fromLocation,
|
|
58
58
|
pendingTransaction: {
|
|
59
59
|
typeOf: factory.account.transactionType.Withdraw,
|
|
60
|
-
id: '',
|
|
61
60
|
transactionNumber: publishTransactionNumber4returnMoneyTransferResult.transactionNumber
|
|
62
61
|
}
|
|
63
62
|
}
|
|
@@ -6,11 +6,15 @@ import { MongoRepository as ProductRepo } from '../../repo/product';
|
|
|
6
6
|
import { MongoRepository as ProjectRepo } from '../../repo/project';
|
|
7
7
|
import { MongoRepository as TaskRepo } from '../../repo/task';
|
|
8
8
|
import { RedisRepository as TransactionNumberRepo } from '../../repo/transactionNumber';
|
|
9
|
-
declare type IPendingTransaction = factory.account.transaction.withdraw.ITransaction
|
|
9
|
+
declare type IPendingTransaction = Pick<factory.account.transaction.withdraw.ITransaction, 'id' | 'transactionNumber' | 'typeOf'>;
|
|
10
10
|
declare function authorize(params: factory.assetTransaction.pay.IStartParamsWithoutDetail, paymentServiceId: string): (repos: {
|
|
11
11
|
product: ProductRepo;
|
|
12
12
|
project: ProjectRepo;
|
|
13
|
-
}) => Promise<
|
|
13
|
+
}) => Promise<{
|
|
14
|
+
pendingTransaction: IPendingTransaction;
|
|
15
|
+
currency: string;
|
|
16
|
+
accountNumber: string;
|
|
17
|
+
}>;
|
|
14
18
|
declare function voidTransaction(params: factory.task.voidPayment.IData): (repos: {
|
|
15
19
|
product: ProductRepo;
|
|
16
20
|
}) => Promise<void>;
|
|
@@ -29,7 +29,7 @@ function authorize(params, paymentServiceId) {
|
|
|
29
29
|
throw new factory.errors.ArgumentNull('transactionNumber');
|
|
30
30
|
}
|
|
31
31
|
// 決済方法検証
|
|
32
|
-
const permit = yield validatePaymentMethod(params, paymentServiceId)(repos);
|
|
32
|
+
const { permit, currency } = yield validatePaymentMethod(params, paymentServiceId)(repos);
|
|
33
33
|
const accountNumber = (_a = permit.paymentAccount) === null || _a === void 0 ? void 0 : _a.accountNumber;
|
|
34
34
|
if (typeof accountNumber !== 'string') {
|
|
35
35
|
throw new factory.errors.ArgumentNull('permit.paymentAccount.accountNumber');
|
|
@@ -55,13 +55,13 @@ function authorize(params, paymentServiceId) {
|
|
|
55
55
|
// PecorinoAPIのエラーをハンドリング
|
|
56
56
|
throw (0, errorHandler_1.handlePecorinoError)(error);
|
|
57
57
|
}
|
|
58
|
-
return pendingTransaction;
|
|
58
|
+
return { pendingTransaction, currency, accountNumber };
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
61
|
exports.authorize = authorize;
|
|
62
62
|
function validatePaymentMethod(params, paymentServiceId) {
|
|
63
63
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
64
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
64
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
65
65
|
const serviceOutputIdentifier = (_a = params.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.accountId;
|
|
66
66
|
const amount = (_b = params.object.paymentMethod) === null || _b === void 0 ? void 0 : _b.amount;
|
|
67
67
|
const paymentMethodType = (_c = params.object.paymentMethod) === null || _c === void 0 ? void 0 : _c.typeOf;
|
|
@@ -74,6 +74,14 @@ function validatePaymentMethod(params, paymentServiceId) {
|
|
|
74
74
|
if (typeof paymentMethodType !== 'string') {
|
|
75
75
|
throw new factory.errors.ArgumentNull('object.paymentMethod.typeOf');
|
|
76
76
|
}
|
|
77
|
+
// プロダクトから通貨区分を取得
|
|
78
|
+
const paymentCatdProduct = yield repos.product.findById({
|
|
79
|
+
id: paymentServiceId
|
|
80
|
+
});
|
|
81
|
+
const currency = (_e = (_d = paymentCatdProduct.serviceOutput) === null || _d === void 0 ? void 0 : _d.amount) === null || _e === void 0 ? void 0 : _e.currency;
|
|
82
|
+
if (typeof currency !== 'string') {
|
|
83
|
+
throw new factory.errors.NotFound('product.serviceOutput.amount.currency');
|
|
84
|
+
}
|
|
77
85
|
// プロダクトのavailableChannelを取得する
|
|
78
86
|
const availableChannel = yield repos.product.findAvailableChannel({
|
|
79
87
|
project: { id: params.project.id },
|
|
@@ -83,9 +91,9 @@ function validatePaymentMethod(params, paymentServiceId) {
|
|
|
83
91
|
const permitService = new pecorinoapi.service.Permit({
|
|
84
92
|
endpoint: String(availableChannel.serviceUrl),
|
|
85
93
|
auth: new pecorinoapi.auth.ClientCredentials({
|
|
86
|
-
domain: String((
|
|
87
|
-
clientId: String((
|
|
88
|
-
clientSecret: String((
|
|
94
|
+
domain: String((_f = availableChannel.credentials) === null || _f === void 0 ? void 0 : _f.authorizeServerDomain),
|
|
95
|
+
clientId: String((_g = availableChannel.credentials) === null || _g === void 0 ? void 0 : _g.clientId),
|
|
96
|
+
clientSecret: String((_h = availableChannel.credentials) === null || _h === void 0 ? void 0 : _h.clientSecret),
|
|
89
97
|
scopes: [],
|
|
90
98
|
state: ''
|
|
91
99
|
})
|
|
@@ -97,7 +105,7 @@ function validatePaymentMethod(params, paymentServiceId) {
|
|
|
97
105
|
issuedThrough: { typeOf: factory.product.ProductType.PaymentCard }
|
|
98
106
|
});
|
|
99
107
|
// サービスタイプを確認
|
|
100
|
-
if (((
|
|
108
|
+
if (((_k = (_j = serviceOutput.issuedThrough) === null || _j === void 0 ? void 0 : _j.serviceType) === null || _k === void 0 ? void 0 : _k.codeValue) !== paymentMethodType) {
|
|
101
109
|
throw new factory.errors.Argument('object.paymentMethod.accountId', 'paymentMethodType not matched');
|
|
102
110
|
}
|
|
103
111
|
// 出金金額設定を確認
|
|
@@ -112,7 +120,7 @@ function validatePaymentMethod(params, paymentServiceId) {
|
|
|
112
120
|
throw new factory.errors.Argument('object.paymentMethod.amount', `maximum payment amount requirement not satisfied`);
|
|
113
121
|
}
|
|
114
122
|
}
|
|
115
|
-
return serviceOutput;
|
|
123
|
+
return { permit: serviceOutput, currency };
|
|
116
124
|
});
|
|
117
125
|
}
|
|
118
126
|
function processAccountTransaction(params) {
|
|
@@ -30,6 +30,9 @@ export declare function activate(params: {
|
|
|
30
30
|
}): (repos: {
|
|
31
31
|
serviceOutput: ServiceOutputRepo;
|
|
32
32
|
}) => Promise<factory.permit.IPermit>;
|
|
33
|
+
declare type IPermitWithAccountDetail = Omit<factory.permit.IPermit, 'paymentAccount'> & {
|
|
34
|
+
paymentAccount?: factory.permit.IPaymentAccountWithDetail;
|
|
35
|
+
};
|
|
33
36
|
/**
|
|
34
37
|
* プロジェクト指定で、許可証を検索する(ペイメントカードプロダクトの場合、口座詳細込み)
|
|
35
38
|
*/
|
|
@@ -38,4 +41,5 @@ export declare function search(project: {
|
|
|
38
41
|
}, params: factory.product.IServiceOutputSearchConditions, projection?: any): (repos: {
|
|
39
42
|
account: AccountRepo;
|
|
40
43
|
serviceOutput: ServiceOutputRepo;
|
|
41
|
-
}) => Promise<
|
|
44
|
+
}) => Promise<IPermitWithAccountDetail[]>;
|
|
45
|
+
export {};
|
|
@@ -78,33 +78,40 @@ exports.activate = activate;
|
|
|
78
78
|
function search(project, params, projection) {
|
|
79
79
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
80
80
|
var _a, _b;
|
|
81
|
-
let
|
|
81
|
+
let permitsWithAccountDetail;
|
|
82
82
|
// アウトプット検索条件のプロジェクトは強制的に上書き
|
|
83
83
|
const searchConditions = Object.assign(Object.assign({}, params), { project: { id: { $eq: project.id } } });
|
|
84
84
|
const productType = (_b = (_a = params.issuedThrough) === null || _a === void 0 ? void 0 : _a.typeOf) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
85
85
|
switch (productType) {
|
|
86
86
|
case factory.product.ProductType.PaymentCard:
|
|
87
|
-
|
|
87
|
+
const permits = yield repos.serviceOutput.search(searchConditions, projection);
|
|
88
|
+
permitsWithAccountDetail = permits;
|
|
88
89
|
// 口座詳細取得
|
|
89
|
-
const accountNumbers =
|
|
90
|
-
.filter((
|
|
90
|
+
const accountNumbers = permits.map((permit) => { var _a; return (_a = permit.paymentAccount) === null || _a === void 0 ? void 0 : _a.accountNumber; })
|
|
91
|
+
.filter((accountNumber) => typeof accountNumber === 'string');
|
|
91
92
|
if (accountNumbers.length > 0) {
|
|
92
93
|
const accounts = yield repos.account.search({
|
|
93
94
|
project: { id: { $eq: project.id } },
|
|
94
95
|
accountNumbers: accountNumbers
|
|
95
96
|
});
|
|
96
|
-
|
|
97
|
-
const account = accounts.find((a) => { var _a; return a.accountNumber === ((_a =
|
|
98
|
-
|
|
99
|
-
? {
|
|
100
|
-
|
|
97
|
+
permitsWithAccountDetail = permits.map((permit) => {
|
|
98
|
+
const account = accounts.find((a) => { var _a; return a.accountNumber === ((_a = permit.paymentAccount) === null || _a === void 0 ? void 0 : _a.accountNumber); });
|
|
99
|
+
const paymentAccount = (typeof (account === null || account === void 0 ? void 0 : account.typeOf) === 'string')
|
|
100
|
+
? {
|
|
101
|
+
accountNumber: account.accountNumber,
|
|
102
|
+
availableBalance: account.availableBalance,
|
|
103
|
+
balance: account.balance,
|
|
104
|
+
typeOf: account.typeOf
|
|
105
|
+
}
|
|
106
|
+
: undefined;
|
|
107
|
+
return Object.assign(Object.assign({}, permit), { paymentAccount });
|
|
101
108
|
});
|
|
102
109
|
}
|
|
103
110
|
break;
|
|
104
111
|
default:
|
|
105
|
-
|
|
112
|
+
permitsWithAccountDetail = (yield repos.serviceOutput.search(searchConditions, projection));
|
|
106
113
|
}
|
|
107
|
-
return
|
|
114
|
+
return permitsWithAccountDetail;
|
|
108
115
|
});
|
|
109
116
|
}
|
|
110
117
|
exports.search = search;
|
package/lib/chevre/settings.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export declare type ISettings = factory.project.ISettings & {
|
|
|
21
21
|
userPoolIdOld: string;
|
|
22
22
|
userPoolIdNew: string;
|
|
23
23
|
maxNumCreditCardPaymentMethod?: number;
|
|
24
|
+
useEventWorkPerformed: boolean;
|
|
24
25
|
};
|
|
25
26
|
export declare const DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD: string;
|
|
26
27
|
export declare const USE_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
|
package/lib/chevre/settings.js
CHANGED
|
@@ -54,7 +54,7 @@ exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = process.env.USE_PAY_ASSET_TR
|
|
|
54
54
|
/**
|
|
55
55
|
* グローバル設定
|
|
56
56
|
*/
|
|
57
|
-
exports.settings = Object.assign({ transactionWebhookUrls, onOrderStatusChanged: {
|
|
57
|
+
exports.settings = Object.assign(Object.assign({ transactionWebhookUrls, onOrderStatusChanged: {
|
|
58
58
|
informOrder: informOrderUrls
|
|
59
59
|
.filter((url) => url.length > 0)
|
|
60
60
|
.map((url) => {
|
|
@@ -94,4 +94,4 @@ exports.settings = Object.assign({ transactionWebhookUrls, onOrderStatusChanged:
|
|
|
94
94
|
timeout: triggerWebhookTimeout
|
|
95
95
|
}, maximumReservationGracePeriodInDays: MAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS, userPoolIdOld: String(process.env.USERPOOL_ID_OLD), userPoolIdNew: String(process.env.USERPOOL_ID_NEW) }, (typeof MAX_NUM_CREDIT_CARD_PAYMENT_METHOD === 'number')
|
|
96
96
|
? { maxNumCreditCardPaymentMethod: MAX_NUM_CREDIT_CARD_PAYMENT_METHOD }
|
|
97
|
-
: undefined);
|
|
97
|
+
: undefined), { useEventWorkPerformed: process.env.USE_EVENT_WORK_PERFORMED === '1' });
|
package/package.json
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.289.0-alpha.
|
|
13
|
-
"@cinerino/sdk": "3.
|
|
12
|
+
"@chevre/factory": "4.289.0-alpha.9",
|
|
13
|
+
"@cinerino/sdk": "3.140.0-alpha.11",
|
|
14
14
|
"@motionpicture/coa-service": "9.2.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.2.0",
|
|
16
16
|
"@sendgrid/mail": "6.4.0",
|
|
@@ -120,5 +120,5 @@
|
|
|
120
120
|
"postversion": "git push origin --tags",
|
|
121
121
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
122
122
|
},
|
|
123
|
-
"version": "20.4.0-alpha.
|
|
123
|
+
"version": "20.4.0-alpha.10"
|
|
124
124
|
}
|