@chevre/domain 22.7.0-alpha.7 → 22.7.0-alpha.9
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/lib/chevre/repo/passport.js +10 -2
- package/lib/chevre/service/assetTransaction/pay/factory.d.ts +4 -0
- package/lib/chevre/service/assetTransaction/pay/factory.js +4 -10
- package/lib/chevre/service/assetTransaction/pay.js +2 -1
- package/lib/chevre/service/payment/factory/createPayObjectServiceOutput.d.ts +3 -0
- package/lib/chevre/service/payment/factory/createPayObjectServiceOutput.js +15 -3
- package/lib/chevre/service/payment/factory.d.ts +3 -0
- package/lib/chevre/service/payment.d.ts +1 -3
- package/lib/chevre/service/payment.js +26 -3
- package/lib/chevre/service/task/pay.js +1 -0
- package/package.json +2 -2
|
@@ -96,12 +96,20 @@ class PassportRepo {
|
|
|
96
96
|
});
|
|
97
97
|
}
|
|
98
98
|
catch (error) {
|
|
99
|
-
|
|
99
|
+
let message = `Invalid token: ${error.message}`;
|
|
100
|
+
if (error instanceof jwt.JsonWebTokenError) {
|
|
101
|
+
// remove -> 'jwt issuer invalid. expected: [OPTIONS ISSUER]'
|
|
102
|
+
const indexOfExpected = message.indexOf('expected:');
|
|
103
|
+
if (indexOfExpected >= 0) {
|
|
104
|
+
message = message.substring(0, indexOfExpected);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
throw new factory.errors.Argument('passport.token', message);
|
|
100
108
|
}
|
|
101
109
|
// 許可証バリデーション
|
|
102
110
|
if (typeof this.options.passportValidator === 'function') {
|
|
103
111
|
if (!this.options.passportValidator({ passport })) {
|
|
104
|
-
throw new factory.errors.Argument('
|
|
112
|
+
throw new factory.errors.Argument('passport.token', 'passportValidator requirement not satisfied');
|
|
105
113
|
}
|
|
106
114
|
}
|
|
107
115
|
// カスタマータイプ決定(2023-11-20~)
|
|
@@ -8,4 +8,8 @@ export declare function createStartParams(params: factory.assetTransaction.pay.I
|
|
|
8
8
|
amount: number;
|
|
9
9
|
paymentService?: Pick<factory.service.paymentService.IService, 'availableChannel' | 'id' | 'serviceOutput' | 'serviceType'> | Pick<factory.product.IProduct, 'availableChannel' | 'id' | 'serviceOutput' | 'serviceType'>;
|
|
10
10
|
location?: factory.action.trade.pay.ILocation;
|
|
11
|
+
}, options: {
|
|
12
|
+
checkedAction: {
|
|
13
|
+
id: string;
|
|
14
|
+
};
|
|
11
15
|
}): factory.assetTransaction.IStartParams<factory.assetTransactionType.Pay>;
|
|
@@ -6,7 +6,7 @@ exports.createStartParams = void 0;
|
|
|
6
6
|
*/
|
|
7
7
|
const factory = require("../../../factory");
|
|
8
8
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
9
|
-
function createStartParams(params) {
|
|
9
|
+
function createStartParams(params, options) {
|
|
10
10
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
|
|
11
11
|
const paymentServiceId = (params.paymentService !== undefined)
|
|
12
12
|
? String(params.paymentService.id)
|
|
@@ -106,15 +106,9 @@ function createStartParams(params) {
|
|
|
106
106
|
: undefined), (params.paymentServiceType === factory.service.paymentService.PaymentServiceType.CreditCard)
|
|
107
107
|
? { paymentMethodId: params.transactionNumber } // 必要ないはずだが互換性維持対応(2024-06-14~)
|
|
108
108
|
: undefined);
|
|
109
|
-
const object = {
|
|
110
|
-
//
|
|
111
|
-
|
|
112
|
-
paymentMethodId: params.transactionNumber,
|
|
113
|
-
typeOf: params.paymentServiceType,
|
|
114
|
-
id: paymentServiceId,
|
|
115
|
-
onPaymentStatusChanged: { informPayment: informPaymentParams },
|
|
116
|
-
paymentMethod
|
|
117
|
-
};
|
|
109
|
+
const object = Object.assign({ accountId: (typeof accountId === 'string') ? accountId : '', paymentMethodId: params.transactionNumber, typeOf: params.paymentServiceType, id: paymentServiceId, onPaymentStatusChanged: { informPayment: informPaymentParams }, paymentMethod }, (params.paymentServiceType === factory.service.paymentService.PaymentServiceType.MovieTicket)
|
|
110
|
+
? { checkedAction: { id: options.checkedAction.id } } // add checkedAction(2024-12-13~)
|
|
111
|
+
: undefined);
|
|
118
112
|
return Object.assign({ project: { typeOf: factory.organizationType.Project, id: params.project.id }, transactionNumber: params.transactionNumber, typeOf: factory.assetTransactionType.Pay, agent: params.agent, recipient: params.recipient, object, expires: params.expires }, (typeof ((_0 = params.location) === null || _0 === void 0 ? void 0 : _0.typeOf) === 'string')
|
|
119
113
|
? { location: params.location }
|
|
120
114
|
: undefined);
|
|
@@ -205,7 +205,8 @@ function start(params, options) {
|
|
|
205
205
|
const startParams = (0, factory_1.createStartParams)(Object.assign(Object.assign({}, params), { transactionNumber,
|
|
206
206
|
paymentServiceType,
|
|
207
207
|
amount,
|
|
208
|
-
paymentService }))
|
|
208
|
+
paymentService }), { checkedAction: options.checkedAction } // 連携(2024-12-13~)
|
|
209
|
+
);
|
|
209
210
|
transaction = yield repos.assetTransaction.start(startParams);
|
|
210
211
|
switch (paymentServiceType) {
|
|
211
212
|
case factory.service.paymentService.PaymentServiceType.FaceToFace:
|
|
@@ -8,6 +8,9 @@ declare function createPayObjectServiceOutput(params: {
|
|
|
8
8
|
order: {
|
|
9
9
|
acceptedOffersMovieTicketUsed: IAcceptedOfferMovieTicketUsed[];
|
|
10
10
|
};
|
|
11
|
+
checkResult?: {
|
|
12
|
+
purchaseNumberAuthResult: factory.action.check.paymentMethod.movieTicket.IPurchaseNumberAuthResult;
|
|
13
|
+
};
|
|
11
14
|
}): factory.invoice.IPaymentServiceOutput | undefined;
|
|
12
15
|
type IAcceptedOfferMovieTicketUsed = Pick<factory.order.IAcceptedOffer<factory.order.IReservation>, 'itemOffered' | 'priceSpecification'>;
|
|
13
16
|
export { createPayObjectServiceOutput, IAcceptedOfferMovieTicketUsed };
|
|
@@ -36,12 +36,24 @@ function createPayObjectServiceOutput(params) {
|
|
|
36
36
|
return paymentServiceOutput;
|
|
37
37
|
}
|
|
38
38
|
exports.createPayObjectServiceOutput = createPayObjectServiceOutput;
|
|
39
|
-
function movieTicket2amount(transaction, movieTicket) {
|
|
40
|
-
var _a;
|
|
39
|
+
function movieTicket2amount(transaction, movieTicket, checkResult) {
|
|
40
|
+
var _a, _b, _c;
|
|
41
41
|
let amount;
|
|
42
|
+
// accountsReceivablesByServiceTypeへの依存をactionRecipeへ移行可能か?(2024-12-13~)
|
|
43
|
+
const ykknInfos = (_b = (_a = checkResult === null || checkResult === void 0 ? void 0 : checkResult.purchaseNumberAuthResult.knyknrNoInfoOut) === null || _a === void 0 ? void 0 : _a.find((knyknrNoInfoOut) => knyknrNoInfoOut.knyknrNo === movieTicket.identifier)) === null || _b === void 0 ? void 0 : _b.ykknInfo;
|
|
44
|
+
const ykknInfoOfServiceType = ykknInfos === null || ykknInfos === void 0 ? void 0 : ykknInfos.find((ykknInfo) => ykknInfo.ykknshTyp === movieTicket.serviceType);
|
|
45
|
+
const accountsReceivableByResponse = ykknInfoOfServiceType === null || ykknInfoOfServiceType === void 0 ? void 0 : ykknInfoOfServiceType.kijUnip;
|
|
46
|
+
// tslint:disable-next-line:no-console
|
|
47
|
+
console.log('movieTicket2amount:', transaction.object.paymentMethodId, movieTicket.identifier, movieTicket.serviceOutput, 'accountsReceivableByResponse:', accountsReceivableByResponse);
|
|
48
|
+
if (typeof accountsReceivableByResponse === 'string') {
|
|
49
|
+
// amount = {
|
|
50
|
+
// typeOf: 'MonetaryAmount',
|
|
51
|
+
// value: Number(accountsReceivableByResponse)
|
|
52
|
+
// };
|
|
53
|
+
}
|
|
42
54
|
const accountsReceivables = transaction.object.accountsReceivablesByServiceType;
|
|
43
55
|
if (Array.isArray(accountsReceivables)) {
|
|
44
|
-
const accountsReceivable = (
|
|
56
|
+
const accountsReceivable = (_c = accountsReceivables.find((a) => a.serviceType === movieTicket.serviceType)) === null || _c === void 0 ? void 0 : _c.accountsReceivable;
|
|
45
57
|
if (typeof accountsReceivable === 'number') {
|
|
46
58
|
amount = {
|
|
47
59
|
typeOf: 'MonetaryAmount',
|
|
@@ -9,5 +9,8 @@ declare function createPayOrderAction(params: {
|
|
|
9
9
|
order: Pick<factory.order.IOrder, 'typeOf' | 'confirmationNumber' | 'orderNumber'> & {
|
|
10
10
|
acceptedOffersMovieTicketUsed: IAcceptedOfferMovieTicketUsed[];
|
|
11
11
|
};
|
|
12
|
+
checkResult?: {
|
|
13
|
+
purchaseNumberAuthResult: factory.action.check.paymentMethod.movieTicket.IPurchaseNumberAuthResult;
|
|
14
|
+
};
|
|
12
15
|
}): Pick<factory.action.trade.pay.IAttributes, 'agent' | 'instrument' | 'location' | 'object' | 'potentialActions' | 'project' | 'purpose' | 'recipient' | 'typeOf'>;
|
|
13
16
|
export { createPayOrderAction, IAcceptedOfferMovieTicketUsed };
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 決済サービス
|
|
3
|
-
*/
|
|
4
1
|
import type { AcceptedOfferRepo } from '../repo/acceptedOffer';
|
|
5
2
|
import type { AccountingReportRepo } from '../repo/accountingReport';
|
|
6
3
|
import type { ActionRepo } from '../repo/action';
|
|
@@ -42,6 +39,7 @@ export declare function payTask2payActionAttributes(params: factory.task.pay.IDa
|
|
|
42
39
|
typeOf: 'Task';
|
|
43
40
|
};
|
|
44
41
|
}): (repos: {
|
|
42
|
+
action: ActionRepo;
|
|
45
43
|
acceptedOffer: AcceptedOfferRepo;
|
|
46
44
|
assetTransaction: AssetTransactionRepo;
|
|
47
45
|
order: OrderRepo;
|
|
@@ -10,12 +10,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.refund = exports.voidPayment = exports.pay = exports.payTask2payActionAttributes = exports.fixOrderAsPurpose = void 0;
|
|
13
|
+
/**
|
|
14
|
+
* 決済サービス
|
|
15
|
+
*/
|
|
16
|
+
const createDebug = require("debug");
|
|
13
17
|
const factory = require("../factory");
|
|
14
18
|
const CreditCardPaymentService = require("./payment/creditCard");
|
|
15
19
|
const FaceToFacePaymentService = require("./payment/faceToFace");
|
|
16
20
|
const factory_1 = require("./payment/factory");
|
|
17
21
|
const MovieTicketPaymentService = require("./payment/movieTicket");
|
|
18
22
|
const PaymentCardPaymentService = require("./payment/paymentCard");
|
|
23
|
+
const debug = createDebug('chevre-domain:service:payment');
|
|
19
24
|
function fixOrderAsPurpose(params, transaction) {
|
|
20
25
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
21
26
|
var _a;
|
|
@@ -57,7 +62,7 @@ function fixOrderAsPurpose(params, transaction) {
|
|
|
57
62
|
exports.fixOrderAsPurpose = fixOrderAsPurpose;
|
|
58
63
|
function payTask2payActionAttributes(params) {
|
|
59
64
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
60
|
-
var _a, _b;
|
|
65
|
+
var _a, _b, _c, _d, _e;
|
|
61
66
|
const { object, potentialActions, purpose, typeOf } = params;
|
|
62
67
|
if (typeOf === factory.actionType.PayAction) {
|
|
63
68
|
// 返金手数料決済の場合
|
|
@@ -87,12 +92,30 @@ function payTask2payActionAttributes(params) {
|
|
|
87
92
|
throw new factory.errors.ArgumentNull('object.paymentMethod.paymentMethodId');
|
|
88
93
|
}
|
|
89
94
|
const order = yield fixOrderAsPurpose({ potentialActions: { pay: { purpose: params.purpose } } }, transaction)(repos);
|
|
95
|
+
// 認証アクションのactionRecipeを検索(2024-12-13~)
|
|
96
|
+
let checkResult;
|
|
97
|
+
const checkedActionId = (_b = transaction.object.checkedAction) === null || _b === void 0 ? void 0 : _b.id;
|
|
98
|
+
if (typeof checkedActionId === 'string' && checkedActionId !== '') {
|
|
99
|
+
const recipe = yield repos.action.findRecipeByAction({
|
|
100
|
+
project: { id: transaction.project.id },
|
|
101
|
+
recipeFor: { id: checkedActionId }
|
|
102
|
+
});
|
|
103
|
+
const directionPurchaseNumberAuth = (_d = (_c = recipe === null || recipe === void 0 ? void 0 : recipe.step[0]) === null || _c === void 0 ? void 0 : _c.itemListElement[0]) === null || _d === void 0 ? void 0 : _d.itemListElement[0];
|
|
104
|
+
if (directionPurchaseNumberAuth !== undefined) {
|
|
105
|
+
const { beforeMedia, afterMedia } = directionPurchaseNumberAuth;
|
|
106
|
+
if (beforeMedia !== undefined && afterMedia !== undefined) {
|
|
107
|
+
checkResult = { purchaseNumberAuthIn: beforeMedia, purchaseNumberAuthResult: afterMedia };
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
debug('payTask2payActionAttributes: checkResult found.', checkResult);
|
|
111
|
+
}
|
|
90
112
|
const payOrderAction = (0, factory_1.createPayOrderAction)({
|
|
91
113
|
transaction: transaction,
|
|
92
114
|
potentialActions: { pay: { purpose: params.purpose } },
|
|
93
|
-
order
|
|
115
|
+
order,
|
|
116
|
+
checkResult
|
|
94
117
|
});
|
|
95
|
-
return Object.assign(Object.assign({}, payOrderAction), (typeof ((
|
|
118
|
+
return Object.assign(Object.assign({}, payOrderAction), (typeof ((_e = params.sameAs) === null || _e === void 0 ? void 0 : _e.id) === 'string') ? { sameAs: params.sameAs } : undefined);
|
|
96
119
|
}
|
|
97
120
|
});
|
|
98
121
|
}
|
|
@@ -37,6 +37,7 @@ function call(params) {
|
|
|
37
37
|
let payActionAttributes;
|
|
38
38
|
payActionAttributes = yield (0, payment_1.payTask2payActionAttributes)(Object.assign(Object.assign({}, params.data), { sameAs: { id: params.id, typeOf: 'Task' } // タスクIDを関連付け(2024-04-20~)
|
|
39
39
|
}))({
|
|
40
|
+
action: new action_1.ActionRepo(connection),
|
|
40
41
|
acceptedOffer: new acceptedOffer_1.AcceptedOfferRepo(connection),
|
|
41
42
|
assetTransaction: new assetTransaction_1.AssetTransactionRepo(connection),
|
|
42
43
|
order: new order_1.OrderRepo(connection)
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/client-cognito-identity-provider": "3.600.0",
|
|
13
13
|
"@aws-sdk/credential-providers": "3.600.0",
|
|
14
|
-
"@chevre/factory": "4.
|
|
14
|
+
"@chevre/factory": "4.391.0-alpha.0",
|
|
15
15
|
"@cinerino/sdk": "10.19.0-alpha.0",
|
|
16
16
|
"@motionpicture/coa-service": "9.6.0-alpha.0",
|
|
17
17
|
"@motionpicture/gmo-service": "5.3.0",
|
|
@@ -108,5 +108,5 @@
|
|
|
108
108
|
"postversion": "git push origin --tags",
|
|
109
109
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
110
110
|
},
|
|
111
|
-
"version": "22.7.0-alpha.
|
|
111
|
+
"version": "22.7.0-alpha.9"
|
|
112
112
|
}
|