@chevre/domain 24.0.0-alpha.10 → 24.0.0-alpha.12
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/service/order/onAssetTransactionStatusChanged/paymentDue2Processing.d.ts +21 -0
- package/lib/chevre/service/order/onAssetTransactionStatusChanged/paymentDue2Processing.js +108 -0
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +5 -17
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +4 -76
- package/lib/chevre/service/order/placeOrder.d.ts +12 -11
- package/lib/chevre/service/order.d.ts +3 -6
- package/lib/chevre/service/order.js +3 -9
- package/lib/chevre/service/payment/any/{fixOrderAsNeeded.d.ts → authorize/fixOrderAsNeeded.d.ts} +5 -5
- package/lib/chevre/service/payment/any/{fixOrderAsNeeded.js → authorize/fixOrderAsNeeded.js} +3 -3
- package/lib/chevre/service/payment/any/authorize.d.ts +90 -0
- package/lib/chevre/service/payment/any/authorize.js +225 -0
- package/lib/chevre/service/payment/any/findAcceptAction.d.ts +43 -0
- package/lib/chevre/service/payment/any/findAcceptAction.js +94 -0
- package/lib/chevre/service/payment/any/findAuthorizeAction.d.ts +41 -0
- package/lib/chevre/service/payment/any/findAuthorizeAction.js +83 -0
- package/lib/chevre/service/payment/any/findCheckAction.d.ts +44 -0
- package/lib/chevre/service/payment/any/findCheckAction.js +89 -0
- package/lib/chevre/service/payment/any/invalidatePaymentUrl.d.ts +28 -0
- package/lib/chevre/service/payment/any/invalidatePaymentUrl.js +185 -0
- package/lib/chevre/service/payment/any/processVoidPayTransaction.d.ts +29 -0
- package/lib/chevre/service/payment/any/processVoidPayTransaction.js +125 -0
- package/lib/chevre/service/payment/any/publishPaymentUrl.d.ts +64 -0
- package/lib/chevre/service/payment/any/publishPaymentUrl.js +133 -0
- package/lib/chevre/service/payment/any/voidPayTransaction.d.ts +31 -0
- package/lib/chevre/service/payment/any/voidPayTransaction.js +38 -0
- package/lib/chevre/service/payment/any.d.ts +8 -305
- package/lib/chevre/service/payment/any.js +17 -857
- package/lib/chevre/service/transaction/placeOrder/exportTasksById.d.ts +5 -4
- package/package.json +1 -1
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.authorize = authorize;
|
|
27
|
+
const util = __importStar(require("util"));
|
|
28
|
+
const factory = __importStar(require("../../../factory"));
|
|
29
|
+
const PayTransactionService = __importStar(require("../../assetTransaction/pay"));
|
|
30
|
+
const fixTransactionNumber_1 = require("./authorize/fixTransactionNumber");
|
|
31
|
+
const factory_1 = require("./factory");
|
|
32
|
+
const fixOrderAsNeeded_1 = require("./authorize/fixOrderAsNeeded");
|
|
33
|
+
const processVoidPayTransaction_1 = require("./processVoidPayTransaction");
|
|
34
|
+
/**
|
|
35
|
+
* 承認アクションオブジェクトから冗長な属性を排除する
|
|
36
|
+
*/
|
|
37
|
+
function minimizeObjectIncludingPaymentMethodDetails(authorizeObjectIncludingPaymentMethodDetails) {
|
|
38
|
+
const { accountId, paymentMethodId, typeOf } = authorizeObjectIncludingPaymentMethodDetails;
|
|
39
|
+
return { authorizeObject: { accountId, paymentMethodId, typeOf } }; // optimize(2024-06-26~)
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 決済承認
|
|
43
|
+
* CreditCard,MovieTicket -> 決済承認タスクから呼ばれる
|
|
44
|
+
* FaceToFace,PaymentCard -> apiから呼ばれる
|
|
45
|
+
*/
|
|
46
|
+
function authorize(params) {
|
|
47
|
+
return async (repos, settings) => {
|
|
48
|
+
const { paymentServiceType, purpose, project } = params;
|
|
49
|
+
if (purpose.typeOf !== factory.transactionType.PlaceOrder) {
|
|
50
|
+
throw new factory.errors.NotImplemented(`purpose.typeOf '${purpose.typeOf} not implemented'`);
|
|
51
|
+
}
|
|
52
|
+
const transaction = await repos.placeOrder.findPlaceOrderInProgressById({ typeOf: purpose.typeOf, id: purpose.id }, ['agent', 'expires', 'typeOf', 'project', 'seller']);
|
|
53
|
+
if (project.id !== transaction.project.id) {
|
|
54
|
+
throw new factory.errors.NotFound(factory.transactionType.PlaceOrder);
|
|
55
|
+
}
|
|
56
|
+
const { confirmationNumber, orderNumber } = await (0, fixOrderAsNeeded_1.fixOrderAsNeeded)({
|
|
57
|
+
project: { id: transaction.project.id },
|
|
58
|
+
purpose
|
|
59
|
+
// paymentServiceType
|
|
60
|
+
})(repos);
|
|
61
|
+
// 取引番号生成
|
|
62
|
+
const fixTransactionNumberResult = await (0, fixTransactionNumber_1.fixTransactionNumber)({
|
|
63
|
+
object: params.object,
|
|
64
|
+
transaction,
|
|
65
|
+
paymentServiceType
|
|
66
|
+
})(repos);
|
|
67
|
+
if (typeof fixTransactionNumberResult.id === 'string') {
|
|
68
|
+
return { id: fixTransactionNumberResult.id };
|
|
69
|
+
}
|
|
70
|
+
const { transactionNumber, pendingPaymentAgencyTransaction, creditCard, invoiceByTicketToken, ticketToken } = fixTransactionNumberResult;
|
|
71
|
+
const movieTickets = (Array.isArray(params.object.movieTickets)) ? params.object.movieTickets.map(factory_1.createMovieTicket) : undefined;
|
|
72
|
+
const { accountId } = await fixAccountIdIfPossible({
|
|
73
|
+
object: params.object, project: { id: transaction.project.id }
|
|
74
|
+
})();
|
|
75
|
+
const authorizeObjectIncludingPaymentMethodDetails = {
|
|
76
|
+
...params.object,
|
|
77
|
+
accountId,
|
|
78
|
+
paymentMethodId: transactionNumber,
|
|
79
|
+
typeOf: factory.action.authorize.paymentMethod.any.ResultType.Payment,
|
|
80
|
+
// support referencesOrder(2025-11-24~)
|
|
81
|
+
referencesOrder: (params.object.referencesOrder?.typeOf === factory.order.OrderType.Order)
|
|
82
|
+
? params.object.referencesOrder
|
|
83
|
+
: { typeOf: factory.order.OrderType.Order },
|
|
84
|
+
...(creditCard !== undefined) ? { creditCard } : undefined,
|
|
85
|
+
...(Array.isArray(movieTickets)) ? { movieTickets } : undefined
|
|
86
|
+
};
|
|
87
|
+
const { authorizeObject } = minimizeObjectIncludingPaymentMethodDetails(authorizeObjectIncludingPaymentMethodDetails);
|
|
88
|
+
// 承認アクションを開始する
|
|
89
|
+
const taskId = params.sameAs?.id;
|
|
90
|
+
const uniqueActionIdentifier = util.format(`%s:%s:%s`, factory.actionType.AuthorizeAction, factory.action.authorize.paymentMethod.any.ResultType.Payment, authorizeObject.paymentMethodId);
|
|
91
|
+
const actionAttributes = {
|
|
92
|
+
project: transaction.project,
|
|
93
|
+
typeOf: factory.actionType.AuthorizeAction,
|
|
94
|
+
object: authorizeObject,
|
|
95
|
+
agent: {
|
|
96
|
+
typeOf: transaction.agent.typeOf,
|
|
97
|
+
id: transaction.agent.id
|
|
98
|
+
},
|
|
99
|
+
instrument: {
|
|
100
|
+
typeOf: factory.assetTransactionType.Pay, // 資産取引化(2024-03-11~)
|
|
101
|
+
identifier: factory.action.authorize.paymentMethod.any.ServiceIdentifier.Chevre,
|
|
102
|
+
transactionNumber
|
|
103
|
+
},
|
|
104
|
+
recipient: {
|
|
105
|
+
typeOf: transaction.seller.typeOf,
|
|
106
|
+
id: transaction.seller.id,
|
|
107
|
+
name: (typeof transaction.seller.name === 'string')
|
|
108
|
+
? transaction.seller.name
|
|
109
|
+
: String(transaction.seller.name?.ja)
|
|
110
|
+
},
|
|
111
|
+
purpose: { typeOf: transaction.typeOf, id: transaction.id },
|
|
112
|
+
identifier: uniqueActionIdentifier, // add unique identifier(2025-02-25~)
|
|
113
|
+
...(typeof taskId === 'string') ? { sameAs: { id: taskId, typeOf: 'Task' } } : undefined // タスク関連付け(2024-04-22~)
|
|
114
|
+
};
|
|
115
|
+
const action = await repos.action.start(actionAttributes);
|
|
116
|
+
let payTransaction;
|
|
117
|
+
try {
|
|
118
|
+
const startParams = (0, factory_1.creatPayTransactionStartParams)({
|
|
119
|
+
accountId,
|
|
120
|
+
object: authorizeObjectIncludingPaymentMethodDetails,
|
|
121
|
+
paymentServiceType,
|
|
122
|
+
transaction: transaction,
|
|
123
|
+
transactionNumber: transactionNumber,
|
|
124
|
+
location: params.location,
|
|
125
|
+
// confirmationNumber required(2025-02-12~)
|
|
126
|
+
// orderNumber required(2025-02-14~)
|
|
127
|
+
order: { confirmationNumber, orderNumber },
|
|
128
|
+
action: { id: action.id, typeOf: action.typeOf },
|
|
129
|
+
ticketToken,
|
|
130
|
+
instrument: params.instrument
|
|
131
|
+
});
|
|
132
|
+
payTransaction = await PayTransactionService.start(startParams, {
|
|
133
|
+
// useCheckByIdentifierIfNotYet: params.options.useCheckByIdentifierIfNotYet,
|
|
134
|
+
executor: (typeof taskId === 'string') ? { id: taskId } : {}, // タスク関連付け(2024-05-18~)
|
|
135
|
+
purpose: { id: transaction.id },
|
|
136
|
+
checkedAction: params.options.checkedAction,
|
|
137
|
+
...(pendingPaymentAgencyTransaction !== undefined) ? { pendingPaymentAgencyTransaction } : undefined
|
|
138
|
+
})(repos, settings);
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
try {
|
|
142
|
+
await repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error });
|
|
143
|
+
}
|
|
144
|
+
catch (__) {
|
|
145
|
+
// no op
|
|
146
|
+
}
|
|
147
|
+
// 即時に決済取引を中止するか?(2023-02-03~)
|
|
148
|
+
if (params.options.useCancelPayTransactionOnFailed) {
|
|
149
|
+
// abortエラーの場合は状態不明なので即時中止しない(2023-06-01~)
|
|
150
|
+
// {
|
|
151
|
+
// "type": "aborted",
|
|
152
|
+
// "message": "The user aborted a request.",
|
|
153
|
+
// "name": "AbortError"
|
|
154
|
+
// }
|
|
155
|
+
const rawError = Array.isArray(error) ? error[1] : undefined;
|
|
156
|
+
if (rawError !== undefined && rawError.name !== 'AbortError') {
|
|
157
|
+
await (0, processVoidPayTransaction_1.processVoidPayTransaction)({
|
|
158
|
+
project: actionAttributes.project,
|
|
159
|
+
id: action.id,
|
|
160
|
+
purpose: actionAttributes.purpose
|
|
161
|
+
})(repos);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
// 複数対応(決済代行IFの場合、0:ChevreError,1:rawError)(2024-03-27~)
|
|
165
|
+
if (Array.isArray(error)) {
|
|
166
|
+
throw error[0];
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
throw error;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
const result = (0, factory_1.createAuthorizeResult)({
|
|
173
|
+
payTransaction,
|
|
174
|
+
object: authorizeObjectIncludingPaymentMethodDetails,
|
|
175
|
+
invoiceByTicketToken
|
|
176
|
+
});
|
|
177
|
+
await repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: result });
|
|
178
|
+
return { id: action.id };
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* 承認しようとしているobjectからaccountIdを決定する
|
|
183
|
+
*/
|
|
184
|
+
function fixAccountIdIfPossible(params) {
|
|
185
|
+
return async (
|
|
186
|
+
// repos: {
|
|
187
|
+
// action: ActionRepo;
|
|
188
|
+
// authorization: AuthorizationRepo;
|
|
189
|
+
// ticket: TicketRepo;
|
|
190
|
+
// }
|
|
191
|
+
// credentials: {
|
|
192
|
+
// jwt: JWTCredentials;
|
|
193
|
+
// }
|
|
194
|
+
) => {
|
|
195
|
+
let accountId = '';
|
|
196
|
+
const fromLocation = params.object?.fromLocation;
|
|
197
|
+
const movieTickets = params.object?.movieTickets;
|
|
198
|
+
// discontinue token as fromLocation(ticketTokenへ移行するべき)(2024-12-18~)
|
|
199
|
+
if (typeof fromLocation === 'string') {
|
|
200
|
+
throw new factory.errors.NotImplemented('object.fromLocation as string not implemented');
|
|
201
|
+
// トークン化されたペイメントカード情報でリクエストされた場合、実ペイメントカード情報へ変換する
|
|
202
|
+
// const { authorizedObject } = await verifyToken({
|
|
203
|
+
// project: { id: params.project.id },
|
|
204
|
+
// agent: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
205
|
+
// token: fromLocation
|
|
206
|
+
// })(repos);
|
|
207
|
+
// const paymentCardOwnershipInfo = authorizedObject;
|
|
208
|
+
// if (Array.isArray(paymentCardOwnershipInfo)) {
|
|
209
|
+
// throw new factory.errors.NotImplemented('fromLocation as an array not implemented');
|
|
210
|
+
// }
|
|
211
|
+
// if (paymentCardOwnershipInfo.typeOf !== 'OwnershipInfo') {
|
|
212
|
+
// throw new factory.errors.Argument('fromLocation', 'must be OwnershipInfo');
|
|
213
|
+
// }
|
|
214
|
+
// if (paymentCardOwnershipInfo.typeOfGood.typeOf !== factory.permit.PermitType.Permit) {
|
|
215
|
+
// throw new factory.errors.Argument('fromLocation', 'must be Permit');
|
|
216
|
+
// }
|
|
217
|
+
// accountId = paymentCardOwnershipInfo.typeOfGood.identifier;
|
|
218
|
+
}
|
|
219
|
+
// 購入番号管理番号をaccountIdにセット(2024-03-24~)
|
|
220
|
+
if (Array.isArray(movieTickets) && movieTickets.length > 0) {
|
|
221
|
+
accountId = movieTickets[0].identifier; // 決済カードidentifierは1つのみ許可の前提
|
|
222
|
+
}
|
|
223
|
+
return { accountId };
|
|
224
|
+
};
|
|
225
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as factory from '../../../factory';
|
|
2
|
+
import type { ActionRepo } from '../../../repo/action';
|
|
3
|
+
import type { TaskRepo } from '../../../repo/task';
|
|
4
|
+
interface IFindAcceptActionResult {
|
|
5
|
+
/**
|
|
6
|
+
* アクションID
|
|
7
|
+
*/
|
|
8
|
+
id?: string;
|
|
9
|
+
/**
|
|
10
|
+
* アクションスタータス
|
|
11
|
+
*/
|
|
12
|
+
actionStatus: factory.actionStatusType;
|
|
13
|
+
object?: Pick<factory.action.accept.pay.IObject, 'transactionNumber'>;
|
|
14
|
+
/**
|
|
15
|
+
* エラー
|
|
16
|
+
*/
|
|
17
|
+
error?: {
|
|
18
|
+
name?: string;
|
|
19
|
+
message?: string;
|
|
20
|
+
};
|
|
21
|
+
result?: factory.action.accept.pay.IResult;
|
|
22
|
+
}
|
|
23
|
+
declare function findAcceptAction(params: {
|
|
24
|
+
project: {
|
|
25
|
+
id: string;
|
|
26
|
+
};
|
|
27
|
+
sameAs: {
|
|
28
|
+
/**
|
|
29
|
+
* task ID
|
|
30
|
+
*/
|
|
31
|
+
id: string;
|
|
32
|
+
};
|
|
33
|
+
purpose: {
|
|
34
|
+
/**
|
|
35
|
+
* transaction ID
|
|
36
|
+
*/
|
|
37
|
+
id: string;
|
|
38
|
+
};
|
|
39
|
+
}): (repos: {
|
|
40
|
+
action: ActionRepo;
|
|
41
|
+
task: TaskRepo;
|
|
42
|
+
}) => Promise<IFindAcceptActionResult>;
|
|
43
|
+
export { findAcceptAction, };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.findAcceptAction = findAcceptAction;
|
|
27
|
+
const factory = __importStar(require("../../../factory"));
|
|
28
|
+
function findAcceptAction(params) {
|
|
29
|
+
return async (repos) => {
|
|
30
|
+
// タスク検索
|
|
31
|
+
const task = (await repos.task.projectFields({
|
|
32
|
+
limit: 1,
|
|
33
|
+
page: 1,
|
|
34
|
+
id: { $eq: params.sameAs.id },
|
|
35
|
+
project: { id: { $eq: params.project.id } },
|
|
36
|
+
name: factory.taskName.PublishPaymentUrl
|
|
37
|
+
}, ['status', 'executionResults'])).shift();
|
|
38
|
+
if (task === undefined) {
|
|
39
|
+
throw new factory.errors.NotFound(factory.taskName.PublishPaymentUrl);
|
|
40
|
+
}
|
|
41
|
+
const errorByTask = task.executionResults.shift()?.error;
|
|
42
|
+
let defaultActionError;
|
|
43
|
+
if (typeof errorByTask === 'string') {
|
|
44
|
+
defaultActionError = { message: errorByTask };
|
|
45
|
+
}
|
|
46
|
+
else if (typeof errorByTask?.message === 'string') {
|
|
47
|
+
defaultActionError = { message: errorByTask.message, name: errorByTask.name };
|
|
48
|
+
}
|
|
49
|
+
let action = {
|
|
50
|
+
actionStatus: factory.actionStatusType.PotentialActionStatus,
|
|
51
|
+
...(defaultActionError !== undefined) ? { error: defaultActionError } : undefined
|
|
52
|
+
};
|
|
53
|
+
switch (task.status) {
|
|
54
|
+
case factory.taskStatus.Ready:
|
|
55
|
+
break;
|
|
56
|
+
default:
|
|
57
|
+
// タスクがReadyでなければアクション検索
|
|
58
|
+
const acceptAction = (await repos.action.searchBySameAs({
|
|
59
|
+
sameAs: { id: { $eq: task.id } },
|
|
60
|
+
typeOf: { $eq: factory.actionType.AcceptAction }
|
|
61
|
+
// purpose: { id: { $eq: String(params.purpose.id) } }
|
|
62
|
+
})).shift();
|
|
63
|
+
if (acceptAction !== undefined) {
|
|
64
|
+
// purpose検証
|
|
65
|
+
if (acceptAction.purpose?.id !== params.purpose.id) {
|
|
66
|
+
throw new factory.errors.NotFound('Action');
|
|
67
|
+
}
|
|
68
|
+
const acceptActionWithResult = await repos.action.findById({ id: acceptAction.id, typeOf: factory.actionType.AcceptAction }, ['result', 'object'], []);
|
|
69
|
+
action = {
|
|
70
|
+
id: acceptAction.id,
|
|
71
|
+
actionStatus: acceptAction.actionStatus,
|
|
72
|
+
// add object.transactionNumber(2025-08-26~)
|
|
73
|
+
object: { transactionNumber: acceptActionWithResult.object.transactionNumber },
|
|
74
|
+
...(acceptAction.error !== undefined)
|
|
75
|
+
? {
|
|
76
|
+
error: (Array.isArray(acceptAction.error))
|
|
77
|
+
? acceptAction.error[0]
|
|
78
|
+
: acceptAction.error
|
|
79
|
+
}
|
|
80
|
+
: undefined,
|
|
81
|
+
...(acceptActionWithResult?.result !== undefined)
|
|
82
|
+
? {
|
|
83
|
+
result: {
|
|
84
|
+
paymentMethodId: acceptActionWithResult.result.paymentMethodId,
|
|
85
|
+
paymentUrl: acceptActionWithResult.result.paymentUrl
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
: undefined
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return action;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as factory from '../../../factory';
|
|
2
|
+
import type { ActionRepo } from '../../../repo/action';
|
|
3
|
+
import type { TaskRepo } from '../../../repo/task';
|
|
4
|
+
interface IFindAuthorizeActionResult {
|
|
5
|
+
/**
|
|
6
|
+
* アクションID
|
|
7
|
+
*/
|
|
8
|
+
id?: string;
|
|
9
|
+
/**
|
|
10
|
+
* アクションスタータス
|
|
11
|
+
*/
|
|
12
|
+
actionStatus: factory.actionStatusType;
|
|
13
|
+
/**
|
|
14
|
+
* エラー
|
|
15
|
+
*/
|
|
16
|
+
error?: {
|
|
17
|
+
name?: string;
|
|
18
|
+
message?: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
declare function findAuthorizeAction(params: {
|
|
22
|
+
project: {
|
|
23
|
+
id: string;
|
|
24
|
+
};
|
|
25
|
+
sameAs: {
|
|
26
|
+
/**
|
|
27
|
+
* task ID
|
|
28
|
+
*/
|
|
29
|
+
id: string;
|
|
30
|
+
};
|
|
31
|
+
purpose: {
|
|
32
|
+
/**
|
|
33
|
+
* transaction ID
|
|
34
|
+
*/
|
|
35
|
+
id: string;
|
|
36
|
+
};
|
|
37
|
+
}): (repos: {
|
|
38
|
+
action: ActionRepo;
|
|
39
|
+
task: TaskRepo;
|
|
40
|
+
}) => Promise<IFindAuthorizeActionResult>;
|
|
41
|
+
export { findAuthorizeAction, };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.findAuthorizeAction = findAuthorizeAction;
|
|
27
|
+
const factory = __importStar(require("../../../factory"));
|
|
28
|
+
function findAuthorizeAction(params) {
|
|
29
|
+
return async (repos) => {
|
|
30
|
+
// タスク検索
|
|
31
|
+
const task = (await repos.task.projectFields({
|
|
32
|
+
limit: 1,
|
|
33
|
+
page: 1,
|
|
34
|
+
id: { $eq: params.sameAs.id },
|
|
35
|
+
project: { id: { $eq: params.project.id } },
|
|
36
|
+
name: factory.taskName.AuthorizePayment
|
|
37
|
+
}, ['status', 'executionResults'])).shift();
|
|
38
|
+
if (task === undefined) {
|
|
39
|
+
throw new factory.errors.NotFound(factory.taskName.AuthorizePayment);
|
|
40
|
+
}
|
|
41
|
+
const errorByTask = task.executionResults.shift()?.error;
|
|
42
|
+
let defaultActionError;
|
|
43
|
+
if (typeof errorByTask === 'string') {
|
|
44
|
+
defaultActionError = { message: errorByTask };
|
|
45
|
+
}
|
|
46
|
+
else if (typeof errorByTask?.message === 'string') {
|
|
47
|
+
defaultActionError = { message: errorByTask.message, name: errorByTask.name };
|
|
48
|
+
}
|
|
49
|
+
let action = {
|
|
50
|
+
actionStatus: factory.actionStatusType.PotentialActionStatus,
|
|
51
|
+
...(defaultActionError !== undefined) ? { error: defaultActionError } : undefined
|
|
52
|
+
};
|
|
53
|
+
switch (task.status) {
|
|
54
|
+
case factory.taskStatus.Ready:
|
|
55
|
+
break;
|
|
56
|
+
default:
|
|
57
|
+
// タスクがReadyでなければアクション検索
|
|
58
|
+
const authorizeAction = (await repos.action.searchBySameAs({
|
|
59
|
+
sameAs: { id: { $eq: task.id } },
|
|
60
|
+
typeOf: { $eq: factory.actionType.AuthorizeAction }
|
|
61
|
+
// purpose: { id: { $eq: String(params.purpose.id) } }
|
|
62
|
+
})).shift();
|
|
63
|
+
if (authorizeAction !== undefined) {
|
|
64
|
+
// purpose検証
|
|
65
|
+
if (authorizeAction.purpose?.id !== params.purpose.id) {
|
|
66
|
+
throw new factory.errors.NotFound('Action');
|
|
67
|
+
}
|
|
68
|
+
action = {
|
|
69
|
+
id: authorizeAction.id,
|
|
70
|
+
actionStatus: authorizeAction.actionStatus,
|
|
71
|
+
...(authorizeAction.error !== undefined)
|
|
72
|
+
? {
|
|
73
|
+
error: (Array.isArray(authorizeAction.error))
|
|
74
|
+
? authorizeAction.error[0]
|
|
75
|
+
: authorizeAction.error
|
|
76
|
+
}
|
|
77
|
+
: undefined
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return action;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as factory from '../../../factory';
|
|
2
|
+
import type { ActionRepo, IMinimizedPurchaseNumberAuthResult } from '../../../repo/action';
|
|
3
|
+
import type { TaskRepo } from '../../../repo/task';
|
|
4
|
+
interface IFindCheckActionResult {
|
|
5
|
+
/**
|
|
6
|
+
* アクションID
|
|
7
|
+
*/
|
|
8
|
+
id?: string;
|
|
9
|
+
/**
|
|
10
|
+
* アクションスタータス
|
|
11
|
+
*/
|
|
12
|
+
actionStatus: factory.actionStatusType;
|
|
13
|
+
/**
|
|
14
|
+
* エラー
|
|
15
|
+
*/
|
|
16
|
+
error?: {
|
|
17
|
+
name?: string;
|
|
18
|
+
message?: string;
|
|
19
|
+
};
|
|
20
|
+
result?: {
|
|
21
|
+
purchaseNumberAuthResult: IMinimizedPurchaseNumberAuthResult;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
declare function findCheckAction(params: {
|
|
25
|
+
project: {
|
|
26
|
+
id: string;
|
|
27
|
+
};
|
|
28
|
+
sameAs: {
|
|
29
|
+
/**
|
|
30
|
+
* task ID
|
|
31
|
+
*/
|
|
32
|
+
id: string;
|
|
33
|
+
};
|
|
34
|
+
purpose: {
|
|
35
|
+
/**
|
|
36
|
+
* transaction ID
|
|
37
|
+
*/
|
|
38
|
+
id: string;
|
|
39
|
+
};
|
|
40
|
+
}): (repos: {
|
|
41
|
+
action: ActionRepo;
|
|
42
|
+
task: TaskRepo;
|
|
43
|
+
}) => Promise<IFindCheckActionResult>;
|
|
44
|
+
export { findCheckAction, };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.findCheckAction = findCheckAction;
|
|
27
|
+
const factory = __importStar(require("../../../factory"));
|
|
28
|
+
function findCheckAction(params) {
|
|
29
|
+
return async (repos) => {
|
|
30
|
+
// タスク検索
|
|
31
|
+
const task = (await repos.task.projectFields({
|
|
32
|
+
limit: 1,
|
|
33
|
+
page: 1,
|
|
34
|
+
id: { $eq: params.sameAs.id },
|
|
35
|
+
project: { id: { $eq: params.project.id } },
|
|
36
|
+
name: factory.taskName.CheckMovieTicket
|
|
37
|
+
}, ['status', 'executionResults'])).shift();
|
|
38
|
+
if (task === undefined) {
|
|
39
|
+
throw new factory.errors.NotFound(factory.taskName.CheckMovieTicket);
|
|
40
|
+
}
|
|
41
|
+
const errorByTask = task.executionResults.shift()?.error;
|
|
42
|
+
let defaultActionError;
|
|
43
|
+
if (typeof errorByTask === 'string') {
|
|
44
|
+
defaultActionError = { message: errorByTask };
|
|
45
|
+
}
|
|
46
|
+
else if (typeof errorByTask?.message === 'string') {
|
|
47
|
+
defaultActionError = { message: errorByTask.message, name: errorByTask.name };
|
|
48
|
+
}
|
|
49
|
+
let action = {
|
|
50
|
+
actionStatus: factory.actionStatusType.PotentialActionStatus,
|
|
51
|
+
...(defaultActionError !== undefined) ? { error: defaultActionError } : undefined
|
|
52
|
+
};
|
|
53
|
+
switch (task.status) {
|
|
54
|
+
case factory.taskStatus.Ready:
|
|
55
|
+
break;
|
|
56
|
+
default:
|
|
57
|
+
// タスクがReadyでなければアクション検索
|
|
58
|
+
const authorizeAction = (await repos.action.searchBySameAs({
|
|
59
|
+
sameAs: { id: { $eq: task.id } },
|
|
60
|
+
typeOf: { $eq: factory.actionType.CheckAction }
|
|
61
|
+
// purpose: { id: { $eq: String(params.purpose.id) } }
|
|
62
|
+
})).shift();
|
|
63
|
+
if (authorizeAction !== undefined) {
|
|
64
|
+
// purpose検証
|
|
65
|
+
if (authorizeAction.purpose?.id !== params.purpose.id) {
|
|
66
|
+
throw new factory.errors.NotFound('Action');
|
|
67
|
+
}
|
|
68
|
+
// result from recipe(2024-06-10~)
|
|
69
|
+
const purchaseNumberAuthResult = await repos.action.findIMinimizedPurchaseNumberAuthResultByCheckMovieTicketRecipe({
|
|
70
|
+
project: { id: params.project.id },
|
|
71
|
+
recipeFor: { id: authorizeAction.id }
|
|
72
|
+
});
|
|
73
|
+
action = {
|
|
74
|
+
id: authorizeAction.id,
|
|
75
|
+
actionStatus: authorizeAction.actionStatus,
|
|
76
|
+
...(authorizeAction.error !== undefined)
|
|
77
|
+
? {
|
|
78
|
+
error: (Array.isArray(authorizeAction.error))
|
|
79
|
+
? authorizeAction.error[0]
|
|
80
|
+
: authorizeAction.error
|
|
81
|
+
}
|
|
82
|
+
: undefined,
|
|
83
|
+
...(purchaseNumberAuthResult !== undefined) ? { result: { purchaseNumberAuthResult } } : undefined
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return action;
|
|
88
|
+
};
|
|
89
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as factory from '../../../factory';
|
|
2
|
+
import type { AccountingReportRepo } from '../../../repo/accountingReport';
|
|
3
|
+
import type { ActionRepo } from '../../../repo/action';
|
|
4
|
+
import type { AssetTransactionRepo } from '../../../repo/assetTransaction';
|
|
5
|
+
import type { PaymentServiceRepo } from '../../../repo/paymentService';
|
|
6
|
+
import type { PaymentServiceProviderRepo } from '../../../repo/paymentServiceProvider';
|
|
7
|
+
import type { SellerPaymentAcceptedRepo } from '../../../repo/sellerPaymentAccepted';
|
|
8
|
+
import type { TaskRepo } from '../../../repo/task';
|
|
9
|
+
import type { PlaceOrderRepo } from '../../../repo/transaction/placeOrder';
|
|
10
|
+
interface IInvalidatePaymentUrlRepos {
|
|
11
|
+
accountingReport: AccountingReportRepo;
|
|
12
|
+
action: ActionRepo;
|
|
13
|
+
assetTransaction: AssetTransactionRepo;
|
|
14
|
+
paymentAccepted: SellerPaymentAcceptedRepo;
|
|
15
|
+
paymentService: PaymentServiceRepo;
|
|
16
|
+
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
17
|
+
task: TaskRepo;
|
|
18
|
+
placeOrder: PlaceOrderRepo;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 決済承認中止タスクから決済URLを無効化する
|
|
22
|
+
*/
|
|
23
|
+
declare function invalidatePaymentUrl(params: factory.task.IData<factory.taskName.VoidPayTransaction> & {
|
|
24
|
+
sameAs?: {
|
|
25
|
+
id: string;
|
|
26
|
+
};
|
|
27
|
+
}): (repos: IInvalidatePaymentUrlRepos) => Promise<void>;
|
|
28
|
+
export { IInvalidatePaymentUrlRepos, invalidatePaymentUrl, };
|