@chevre/domain 21.35.0-alpha.21 → 21.35.0-alpha.23
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/migrateAuthorizeEventServiceOfferResult.ts +10 -10
- package/lib/chevre/service/order/placeOrder.js +0 -3
- package/lib/chevre/service/payment/any/factory.d.ts +1 -1
- package/lib/chevre/service/payment/any.js +28 -2
- package/lib/chevre/service/transaction/placeOrderInProgress/confirm.js +0 -18
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.d.ts +3 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +6 -4
- package/package.json +2 -2
|
@@ -70,16 +70,16 @@ async function main() {
|
|
|
70
70
|
// optimize action
|
|
71
71
|
if (Array.isArray(authorizeAction.object.acceptedOffer)) {
|
|
72
72
|
let unsetResult: any;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
73
|
+
unsetResult = await actionRepo.unsetUnnecessaryFields({
|
|
74
|
+
filter: { _id: { $eq: authorizeAction.id } },
|
|
75
|
+
$unset: {
|
|
76
|
+
'object.acceptedOffer': 1
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
updateCount += 1;
|
|
80
|
+
console.log(
|
|
81
|
+
'result unset. unsetResult:', unsetResult,
|
|
82
|
+
authorizeAction.project.id, authorizeAction.id, authorizeAction.startDate, i, updateCount, saveResultCount);
|
|
83
83
|
}
|
|
84
84
|
} else {
|
|
85
85
|
console.log(
|
|
@@ -10,13 +10,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.placeOrder = void 0;
|
|
13
|
-
const createDebug = require("debug");
|
|
14
13
|
const factory = require("../../factory");
|
|
15
14
|
const onAssetTransactionStatusChanged_1 = require("./onAssetTransactionStatusChanged");
|
|
16
15
|
const onOrderStatusChanged_1 = require("./onOrderStatusChanged");
|
|
17
16
|
const createPlacingOrderFromExistingTransaction_1 = require("./placeOrder/createPlacingOrderFromExistingTransaction");
|
|
18
17
|
const voidAcceptedOfferIfNecessary_1 = require("./placeOrder/voidAcceptedOfferIfNecessary");
|
|
19
|
-
const debug = createDebug('chevre-domain:service:order');
|
|
20
18
|
/**
|
|
21
19
|
* 注文を作成する
|
|
22
20
|
*/
|
|
@@ -82,7 +80,6 @@ function placeOrder(params) {
|
|
|
82
80
|
// purpose: placeOrderTransaction,
|
|
83
81
|
serialNumbers
|
|
84
82
|
})(repos);
|
|
85
|
-
debug('placing an order...', JSON.stringify(order));
|
|
86
83
|
yield repos.orderInTransaction.placeOrder(order);
|
|
87
84
|
}
|
|
88
85
|
catch (error) {
|
|
@@ -12,7 +12,7 @@ export interface IOnPaymentStatusChangedRefundAction {
|
|
|
12
12
|
export type IOnPaymentStatusChangedParams = IOnPaymentStatusChangedPayAction | IOnPaymentStatusChangedRefundAction;
|
|
13
13
|
export declare function creatPayTransactionStartParams(params: {
|
|
14
14
|
accountId?: string;
|
|
15
|
-
object: factory.action.authorize.paymentMethod.any.
|
|
15
|
+
object: factory.action.authorize.paymentMethod.any.IObjectIncludingPaymentMethodDetails;
|
|
16
16
|
paymentServiceType: factory.service.paymentService.PaymentServiceType;
|
|
17
17
|
transaction: Pick<factory.transaction.ITransaction<factory.transactionType.PlaceOrder>, 'expires' | 'seller' | 'project'>;
|
|
18
18
|
transactionNumber: string;
|
|
@@ -8,12 +8,24 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
11
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
23
|
exports.publishPaymentUrl = exports.processVoidPayTransaction = exports.person2username = exports.voidPayTransaction = exports.invalidatePaymentUrl = exports.findCheckAction = exports.findAuthorizeAction = exports.findAcceptAction = exports.authorize = exports.onPaymentStatusChanged = void 0;
|
|
13
24
|
/**
|
|
14
25
|
* 汎用決済サービス
|
|
15
26
|
*/
|
|
16
27
|
const factory = require("../../factory");
|
|
28
|
+
const settings_1 = require("../../settings");
|
|
17
29
|
const PayTransactionService = require("../assetTransaction/pay");
|
|
18
30
|
const code_1 = require("../code");
|
|
19
31
|
const publishConfirmationNumberIfNotExist_1 = require("../transaction/placeOrderInProgress/publishConfirmationNumberIfNotExist");
|
|
@@ -289,6 +301,19 @@ function publishPaymentUrl(params) {
|
|
|
289
301
|
});
|
|
290
302
|
}
|
|
291
303
|
exports.publishPaymentUrl = publishPaymentUrl;
|
|
304
|
+
/**
|
|
305
|
+
* 承認アクションオブジェクトから冗長な属性を排除する
|
|
306
|
+
*/
|
|
307
|
+
function minimizeObjectIncludingPaymentMethodDetails(authorizeObjectIncludingPaymentMethodDetails) {
|
|
308
|
+
if (settings_1.USE_EXPERIMENTAL_FEATURE) {
|
|
309
|
+
// experimental(2024-06-21~)
|
|
310
|
+
const { creditCard, method, movieTickets } = authorizeObjectIncludingPaymentMethodDetails, authorizeObject = __rest(authorizeObjectIncludingPaymentMethodDetails, ["creditCard", "method", "movieTickets"]);
|
|
311
|
+
return { authorizeObject };
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
return { authorizeObject: authorizeObjectIncludingPaymentMethodDetails };
|
|
315
|
+
}
|
|
316
|
+
}
|
|
292
317
|
/**
|
|
293
318
|
* 決済承認
|
|
294
319
|
*/
|
|
@@ -345,7 +370,8 @@ function authorize(params) {
|
|
|
345
370
|
}
|
|
346
371
|
const movieTickets = (Array.isArray(params.object.movieTickets)) ? params.object.movieTickets.map(factory_1.createMovieTicket) : undefined;
|
|
347
372
|
const { accountId } = yield fixAccountIdIfPossible({ object: params.object, project: { id: transaction.project.id } })(repos);
|
|
348
|
-
const
|
|
373
|
+
const authorizeObjectIncludingPaymentMethodDetails = Object.assign(Object.assign(Object.assign(Object.assign({}, params.object), { accountId, paymentMethodId: transactionNumber, typeOf: factory.action.authorize.paymentMethod.any.ResultType.Payment }), (creditCard !== undefined) ? { creditCard } : undefined), (Array.isArray(movieTickets)) ? { movieTickets } : undefined);
|
|
374
|
+
const { authorizeObject } = minimizeObjectIncludingPaymentMethodDetails(authorizeObjectIncludingPaymentMethodDetails);
|
|
349
375
|
// 承認アクションを開始する
|
|
350
376
|
const taskId = (_a = params.sameAs) === null || _a === void 0 ? void 0 : _a.id;
|
|
351
377
|
const actionAttributes = Object.assign({ project: transaction.project, typeOf: factory.actionType.AuthorizeAction, object: authorizeObject, agent: {
|
|
@@ -368,7 +394,7 @@ function authorize(params) {
|
|
|
368
394
|
try {
|
|
369
395
|
const startParams = (0, factory_1.creatPayTransactionStartParams)({
|
|
370
396
|
accountId,
|
|
371
|
-
object:
|
|
397
|
+
object: authorizeObjectIncludingPaymentMethodDetails,
|
|
372
398
|
paymentServiceType,
|
|
373
399
|
transaction: transaction,
|
|
374
400
|
transactionNumber: transactionNumber,
|
|
@@ -228,24 +228,6 @@ function dissolveAuthorizeActions(completedAuthorizeActions) {
|
|
|
228
228
|
serialNumbers.push(serialNumber);
|
|
229
229
|
}
|
|
230
230
|
});
|
|
231
|
-
// authorizeEventServiceOfferActions.forEach(({ result }) => {
|
|
232
|
-
// const acceptedOffersByAuthorizeAction = result?.acceptedOffers; // discontinue(2024-06-17~)
|
|
233
|
-
// if (Array.isArray(acceptedOffersByAuthorizeAction)) {
|
|
234
|
-
// acceptedOffersFromAuthorizeAction.push(...acceptedOffersByAuthorizeAction);
|
|
235
|
-
// }
|
|
236
|
-
// });
|
|
237
|
-
// authorizeProductOfferActions.forEach(({ result }) => {
|
|
238
|
-
// const acceptedOffersByAuthorizeAction = result?.acceptedOffers; // discontinue(2024-06-17~)
|
|
239
|
-
// if (Array.isArray(acceptedOffersByAuthorizeAction)) {
|
|
240
|
-
// acceptedOffersFromAuthorizeAction.push(...acceptedOffersByAuthorizeAction);
|
|
241
|
-
// }
|
|
242
|
-
// });
|
|
243
|
-
// authorizeMoneyTansferActions.forEach(({ result }) => {
|
|
244
|
-
// const acceptedOffersByAuthorizeAction = result?.acceptedOffers; // discontinue(2024-06-17~)
|
|
245
|
-
// if (Array.isArray(acceptedOffersByAuthorizeAction)) {
|
|
246
|
-
// acceptedOffersFromAuthorizeAction.push(...acceptedOffersByAuthorizeAction);
|
|
247
|
-
// }
|
|
248
|
-
// });
|
|
249
231
|
debug('authorizeActions dissolved', serialNumbers, authorizeEventServiceOfferActions.length, 'authorizeEventServiceOfferActions', authorizePaymentActions.length, 'authorizePaymentActions');
|
|
250
232
|
return {
|
|
251
233
|
authorizePaymentActions,
|
|
@@ -3,7 +3,9 @@ import { placeOrder as PlaceOrderFactory } from '../../../factory/transaction';
|
|
|
3
3
|
export type IAuthorizeEventServiceOffer = factory.action.authorize.offer.eventService.IAction<factory.service.webAPI.Identifier>;
|
|
4
4
|
export type IAuthorizeProductOffer = factory.action.authorize.offer.product.IAction;
|
|
5
5
|
export type IAuthorizeMoneyTransferOffer = factory.action.authorize.offer.moneyTransfer.IAction;
|
|
6
|
-
export type IAuthorizePaymentAction = Pick<factory.action.authorize.paymentMethod.any.IAction, 'id' | '
|
|
6
|
+
export type IAuthorizePaymentAction = Pick<factory.action.authorize.paymentMethod.any.IAction, 'id' | 'result' | 'endDate' | 'instrument'> & {
|
|
7
|
+
object: Pick<factory.action.authorize.paymentMethod.any.IObject, 'typeOf'>;
|
|
8
|
+
};
|
|
7
9
|
export type IPayTransaction = Pick<factory.assetTransaction.pay.ITransaction, 'object'>;
|
|
8
10
|
/**
|
|
9
11
|
* 取引が確定可能な状態かどうかをチェックする
|
|
@@ -194,14 +194,16 @@ function validateMonetaryAmount(authorizePaymentActions, authorizeEventServiceOf
|
|
|
194
194
|
const requiredMonetaryAmount = requiredMonetaryAmountByCurrencyType
|
|
195
195
|
.filter((m) => m.currency === currencyType)
|
|
196
196
|
.reduce((a, b) => a + b.value, 0);
|
|
197
|
-
|
|
197
|
+
let authorizedMonetaryAmount = 0;
|
|
198
|
+
authorizeMonetaryAmountActions.forEach(({ result }) => {
|
|
198
199
|
var _a;
|
|
199
200
|
const resultAsInvoice = (Array.isArray(result))
|
|
200
201
|
? result.find(({ typeOf }) => typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
|
|
201
202
|
: undefined;
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
203
|
+
if (((_a = resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.totalPaymentDue) === null || _a === void 0 ? void 0 : _a.currency) === currencyType) {
|
|
204
|
+
authorizedMonetaryAmount += resultAsInvoice.totalPaymentDue.value;
|
|
205
|
+
}
|
|
206
|
+
});
|
|
205
207
|
return requiredMonetaryAmount === authorizedMonetaryAmount;
|
|
206
208
|
});
|
|
207
209
|
if (!requireMonetaryAmountSatisfied) {
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/credential-providers": "3.433.0",
|
|
13
|
-
"@chevre/factory": "4.375.0-alpha.
|
|
13
|
+
"@chevre/factory": "4.375.0-alpha.15",
|
|
14
14
|
"@cinerino/sdk": "7.3.0-alpha.2",
|
|
15
15
|
"@motionpicture/coa-service": "9.4.0",
|
|
16
16
|
"@motionpicture/gmo-service": "5.3.0",
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"postversion": "git push origin --tags",
|
|
111
111
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
112
112
|
},
|
|
113
|
-
"version": "21.35.0-alpha.
|
|
113
|
+
"version": "21.35.0-alpha.23"
|
|
114
114
|
}
|