@chevre/domain 21.33.0-alpha.9 → 21.33.0
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/findTransactionById.ts +8 -5
- package/example/src/chevre/migratePayCreditCardRecipes.ts +104 -0
- package/example/src/chevre/migratePayMovieTicketRecipes.ts +100 -0
- package/example/src/chevre/migrateTransactionObjectPaymentMethods.ts +147 -0
- package/example/src/chevre/reexportTasksByExportAction.ts +37 -0
- package/example/src/chevre/searchActionsBySameAs.ts +2 -1
- package/example/src/chevre/searchCheckMovieTicketResultYkknInfo.ts +26 -6
- package/example/src/chevre/searchTransactions.ts +1 -1
- package/example/src/chevre/unsetUnnecessaryFields.ts +3 -18
- package/lib/chevre/repo/action.d.ts +51 -0
- package/lib/chevre/repo/action.js +122 -2
- package/lib/chevre/repo/assetTransaction.d.ts +9 -2
- package/lib/chevre/repo/assetTransaction.js +48 -3
- package/lib/chevre/repo/mongoose/schemas/actionRecipe.d.ts +5 -0
- package/lib/chevre/repo/mongoose/schemas/actionRecipe.js +89 -0
- package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +23 -25
- package/lib/chevre/repo/mongoose/schemas/transaction.js +5 -52
- package/lib/chevre/repo/transaction.d.ts +26 -11
- package/lib/chevre/repo/transaction.js +89 -17
- package/lib/chevre/service/assetTransaction/pay.d.ts +6 -2
- package/lib/chevre/service/assetTransaction/pay.js +49 -5
- package/lib/chevre/service/offer/event/voidTransaction.js +4 -6
- package/lib/chevre/service/offer/eventServiceByCOA/findAcceptAction.js +2 -1
- package/lib/chevre/service/offer/product.js +1 -1
- package/lib/chevre/service/payment/any/handlePrePublishedPaymentMethodIdOnAuthorizing.d.ts +23 -0
- package/lib/chevre/service/payment/any/handlePrePublishedPaymentMethodIdOnAuthorizing.js +155 -0
- package/lib/chevre/service/payment/any.d.ts +10 -2
- package/lib/chevre/service/payment/any.js +83 -114
- package/lib/chevre/service/payment/creditCard/authorize.d.ts +41 -0
- package/lib/chevre/service/payment/creditCard/authorize.js +216 -0
- package/lib/chevre/service/payment/creditCard/factory.d.ts +35 -0
- package/lib/chevre/service/payment/creditCard/factory.js +57 -0
- package/lib/chevre/service/payment/creditCard/getGMOInfoFromSeller.d.ts +20 -0
- package/lib/chevre/service/payment/creditCard/getGMOInfoFromSeller.js +47 -0
- package/lib/chevre/service/payment/creditCard/gmoError.d.ts +34 -0
- package/lib/chevre/service/payment/creditCard/gmoError.js +8 -0
- package/lib/chevre/service/payment/creditCard/payCreditCard.d.ts +20 -0
- package/lib/chevre/service/payment/creditCard/payCreditCard.js +151 -0
- package/lib/chevre/service/payment/creditCard/refundCreditCard.d.ts +26 -0
- package/lib/chevre/service/payment/creditCard/refundCreditCard.js +196 -0
- package/lib/chevre/service/payment/creditCard/searchGMOTrade.d.ts +13 -0
- package/lib/chevre/service/payment/creditCard/searchGMOTrade.js +62 -0
- package/lib/chevre/service/payment/creditCard/voidTransaction.d.ts +13 -0
- package/lib/chevre/service/payment/creditCard/voidTransaction.js +90 -0
- package/lib/chevre/service/payment/creditCard.d.ts +7 -106
- package/lib/chevre/service/payment/creditCard.js +12 -638
- package/lib/chevre/service/payment/faceToFace.d.ts +1 -1
- package/lib/chevre/service/payment/movieTicket/authorize.d.ts +38 -0
- package/lib/chevre/service/payment/movieTicket/authorize.js +71 -0
- package/lib/chevre/service/payment/movieTicket/checkMovieTicket.d.ts +22 -0
- package/lib/chevre/service/payment/movieTicket/checkMovieTicket.js +109 -0
- package/lib/chevre/service/payment/movieTicket/factory.d.ts +52 -1
- package/lib/chevre/service/payment/movieTicket/factory.js +114 -1
- package/lib/chevre/service/payment/movieTicket/payMovieTicket.d.ts +24 -0
- package/lib/chevre/service/payment/movieTicket/payMovieTicket.js +157 -0
- package/lib/chevre/service/payment/movieTicket/{checkByIdentifier.d.ts → processPurchaseNumberAuth.d.ts} +5 -6
- package/lib/chevre/service/payment/movieTicket/{checkByIdentifier.js → processPurchaseNumberAuth.js} +4 -8
- package/lib/chevre/service/payment/movieTicket/refundMovieTicket.d.ts +21 -0
- package/lib/chevre/service/payment/movieTicket/refundMovieTicket.js +248 -0
- package/lib/chevre/service/payment/movieTicket/validation.js +3 -3
- package/lib/chevre/service/payment/movieTicket/voidTransaction.d.ts +12 -0
- package/lib/chevre/service/payment/movieTicket/voidTransaction.js +74 -0
- package/lib/chevre/service/payment/movieTicket.d.ts +7 -75
- package/lib/chevre/service/payment/movieTicket.js +11 -567
- package/lib/chevre/service/payment/paymentCard.d.ts +1 -1
- package/lib/chevre/service/payment.d.ts +9 -1
- package/lib/chevre/service/payment.js +2 -1
- package/lib/chevre/service/task/acceptCOAOffer.js +2 -1
- package/lib/chevre/service/task/authorizePayment.js +2 -1
- package/lib/chevre/service/task/checkMovieTicket.js +1 -1
- package/lib/chevre/service/task/pay.d.ts +2 -2
- package/lib/chevre/service/task/pay.js +3 -2
- package/lib/chevre/service/task/publishPaymentUrl.js +2 -1
- package/lib/chevre/service/task/voidPayTransaction.d.ts +2 -2
- package/lib/chevre/service/task/voidPayTransaction.js +2 -4
- package/lib/chevre/service/task/voidPayment.js +0 -1
- package/lib/chevre/service/task.js +2 -0
- package/lib/chevre/service/transaction/moneyTransfer/exportTasks/factory.d.ts +1 -1
- package/lib/chevre/service/transaction/moneyTransfer/potentialActions.d.ts +1 -1
- package/lib/chevre/service/transaction/moneyTransfer.js +2 -2
- package/lib/chevre/service/transaction/placeOrder.js +2 -3
- package/lib/chevre/service/transaction/placeOrderInProgress/confirm.js +3 -2
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.d.ts +0 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/result.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +4 -3
- package/lib/chevre/service/transaction/returnOrder/exportTasks/factory.d.ts +1 -1
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.d.ts +1 -1
- package/lib/chevre/service/transaction/returnOrder/potentialActions.d.ts +1 -1
- package/lib/chevre/service/transaction/returnOrder.js +2 -2
- package/lib/chevre/settings.d.ts +1 -0
- package/lib/chevre/settings.js +2 -1
- package/package.json +3 -3
- package/example/src/chevre/migrateOwnershipInfos2newUserPool.ts +0 -152
- package/example/src/chevre/migratePayTransactionReservedTicketIdentifier.ts +0 -95
package/lib/chevre/service/payment/movieTicket/{checkByIdentifier.js → processPurchaseNumberAuth.js}
RENAMED
|
@@ -9,17 +9,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.processPurchaseNumberAuth = void 0;
|
|
13
13
|
const surfrock = require("@surfrock/sdk");
|
|
14
14
|
const moment = require("moment-timezone");
|
|
15
15
|
// import type { MongoRepository as ProjectRepo } from '../../../repo/project';
|
|
16
16
|
const credentials_1 = require("../../../credentials");
|
|
17
17
|
const factory = require("../../../factory");
|
|
18
18
|
const getCredentials_1 = require("./getCredentials");
|
|
19
|
-
|
|
20
|
-
* MovieTicket認証
|
|
21
|
-
*/
|
|
22
|
-
function checkByIdentifier(params) {
|
|
19
|
+
function processPurchaseNumberAuth(params) {
|
|
23
20
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
24
21
|
var _a, _b, _c;
|
|
25
22
|
let purchaseNumberAuthIn;
|
|
@@ -63,8 +60,7 @@ function checkByIdentifier(params) {
|
|
|
63
60
|
skhnCd = `${eventCOAInfo.titleCode}${`00${eventCOAInfo.titleBranchNum}`.slice(DIGITS)}`;
|
|
64
61
|
}
|
|
65
62
|
const sellerCredentials = yield (0, getCredentials_1.getCredentials)({
|
|
66
|
-
|
|
67
|
-
seller: { id: String(params.seller.id), project: { id: params.seller.project.id } },
|
|
63
|
+
seller: { id: String(params.seller.id), project: { id: params.screeningEvent.project.id } },
|
|
68
64
|
paymentServiceId: params.paymentServiceId
|
|
69
65
|
})(repos);
|
|
70
66
|
purchaseNumberAuthIn = {
|
|
@@ -92,4 +88,4 @@ function checkByIdentifier(params) {
|
|
|
92
88
|
return { purchaseNumberAuthIn, purchaseNumberAuthResult };
|
|
93
89
|
});
|
|
94
90
|
}
|
|
95
|
-
exports.
|
|
91
|
+
exports.processPurchaseNumberAuth = processPurchaseNumberAuth;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { MongoRepository as AccountingReportRepo } from '../../../repo/accountingReport';
|
|
2
|
+
import type { MongoRepository as ActionRepo } from '../../../repo/action';
|
|
3
|
+
import type { MongoRepository as PaymentServiceRepo } from '../../../repo/paymentService';
|
|
4
|
+
import type { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
5
|
+
import * as factory from '../../../factory';
|
|
6
|
+
interface IRefundOperationRepos {
|
|
7
|
+
action: ActionRepo;
|
|
8
|
+
accountingReport: AccountingReportRepo;
|
|
9
|
+
paymentService: PaymentServiceRepo;
|
|
10
|
+
task: TaskRepo;
|
|
11
|
+
}
|
|
12
|
+
type IRefundOperation<T> = (repos: IRefundOperationRepos) => Promise<T>;
|
|
13
|
+
/**
|
|
14
|
+
* 決済カード返金
|
|
15
|
+
*/
|
|
16
|
+
declare function refundMovieTicket(params: factory.task.refund.IData & {
|
|
17
|
+
sameAs?: {
|
|
18
|
+
id: string;
|
|
19
|
+
};
|
|
20
|
+
}): IRefundOperation<void>;
|
|
21
|
+
export { refundMovieTicket };
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.refundMovieTicket = void 0;
|
|
13
|
+
const surfrock = require("@surfrock/sdk");
|
|
14
|
+
const http_status_1 = require("http-status");
|
|
15
|
+
const credentials_1 = require("../../../credentials");
|
|
16
|
+
const errorHandler_1 = require("../../../errorHandler");
|
|
17
|
+
const factory = require("../../../factory");
|
|
18
|
+
const onRefund_1 = require("../any/onRefund");
|
|
19
|
+
const factory_1 = require("./factory");
|
|
20
|
+
/**
|
|
21
|
+
* 決済カード返金
|
|
22
|
+
*/
|
|
23
|
+
function refundMovieTicket(params) {
|
|
24
|
+
// tslint:disable-next-line:max-func-body-length
|
|
25
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
27
|
+
const paymentMethodId = (_a = params.object[0]) === null || _a === void 0 ? void 0 : _a.paymentMethod.paymentMethodId;
|
|
28
|
+
const paymentServiceId = (_b = params.object[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
29
|
+
const availableChannel = yield repos.paymentService.findAvailableChannel({
|
|
30
|
+
project: params.project,
|
|
31
|
+
typeOf: factory.service.paymentService.PaymentServiceType.MovieTicket,
|
|
32
|
+
id: paymentServiceId
|
|
33
|
+
});
|
|
34
|
+
const mvtkReserveAuthClient = new surfrock.auth.ClientCredentials({
|
|
35
|
+
domain: String((_c = availableChannel.credentials) === null || _c === void 0 ? void 0 : _c.authorizeServerDomain),
|
|
36
|
+
clientId: String((_d = availableChannel.credentials) === null || _d === void 0 ? void 0 : _d.clientId),
|
|
37
|
+
clientSecret: String((_e = availableChannel.credentials) === null || _e === void 0 ? void 0 : _e.clientSecret),
|
|
38
|
+
scopes: [],
|
|
39
|
+
state: ''
|
|
40
|
+
});
|
|
41
|
+
const seatService = new surfrock.service.seat.SeatService({ endpoint: String(availableChannel.serviceUrl), auth: mvtkReserveAuthClient }, { timeout: credentials_1.credentials.movieticketReserve.timeout });
|
|
42
|
+
let seatInfoSyncCancelIn;
|
|
43
|
+
let seatInfoSyncIn;
|
|
44
|
+
const useSeatInfoSyncCancel = ((_f = availableChannel.credentials) === null || _f === void 0 ? void 0 : _f.useSeatInfoSyncCancel) === true;
|
|
45
|
+
if (useSeatInfoSyncCancel) {
|
|
46
|
+
seatInfoSyncCancelIn = yield createSeatInfoSyncCancelInOnRefund({
|
|
47
|
+
project: { id: params.project.id },
|
|
48
|
+
paymentMethodId
|
|
49
|
+
})({ action: repos.action });
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
seatInfoSyncIn = yield createSeatInfoSyncInOnRefund({
|
|
53
|
+
project: { id: params.project.id },
|
|
54
|
+
paymentMethodId
|
|
55
|
+
})({ action: repos.action });
|
|
56
|
+
}
|
|
57
|
+
const instrument = Object.assign(Object.assign({ typeOf: factory.service.paymentService.PaymentServiceType.MovieTicket }, (seatInfoSyncIn !== undefined) ? { seatInfoSyncIn } : undefined), (seatInfoSyncCancelIn !== undefined) ? { seatInfoSyncCancelIn } : undefined);
|
|
58
|
+
let action = yield repos.action.start(Object.assign(Object.assign(Object.assign({}, params), (typeof ((_g = params.sameAs) === null || _g === void 0 ? void 0 : _g.id) === 'string') ? { sameAs: { id: params.sameAs.id, typeOf: 'Task' } } : undefined), { instrument // instrumentをセット(2024-04-30~)
|
|
59
|
+
}));
|
|
60
|
+
let processSeatInfoSyncCancelResult;
|
|
61
|
+
let processSeatInfoSyncResult;
|
|
62
|
+
try {
|
|
63
|
+
if (useSeatInfoSyncCancel) {
|
|
64
|
+
if (seatInfoSyncCancelIn === undefined) {
|
|
65
|
+
throw new factory.errors.ServiceUnavailable('seatInfoSyncCancelIn must be set');
|
|
66
|
+
}
|
|
67
|
+
processSeatInfoSyncCancelResult = yield processSeatInfoSyncCancel({ seatInfoSyncCancelIn })({ seatService });
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
if (seatInfoSyncIn === undefined) {
|
|
71
|
+
throw new factory.errors.ServiceUnavailable('seatInfoSyncIn must be set');
|
|
72
|
+
}
|
|
73
|
+
processSeatInfoSyncResult = yield processSeatInfoSync({
|
|
74
|
+
seatInfoSyncIn, paymentMethodId, purpose: params.purpose
|
|
75
|
+
})({ seatService });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
let message = String(error.message);
|
|
80
|
+
message += `決済ID:${paymentMethodId}`; // エラー通知先で情報を読み取りやすくするために、messageに情報付加
|
|
81
|
+
try {
|
|
82
|
+
const actionError = Object.assign(Object.assign({}, error), { message: message, name: error.name });
|
|
83
|
+
yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error: actionError });
|
|
84
|
+
}
|
|
85
|
+
catch (__) {
|
|
86
|
+
// 失敗したら仕方ない
|
|
87
|
+
}
|
|
88
|
+
error = (0, errorHandler_1.handleMvtkReserveError)(Object.assign(Object.assign({}, error), { message: message }));
|
|
89
|
+
throw error;
|
|
90
|
+
}
|
|
91
|
+
// アクションとしてはFailedだが後続処理を実行するケースに対応(2024-03-21~)
|
|
92
|
+
const seatInfoSyncResultAsError = processSeatInfoSyncResult === null || processSeatInfoSyncResult === void 0 ? void 0 : processSeatInfoSyncResult.seatInfoSyncResultAsError;
|
|
93
|
+
if (seatInfoSyncResultAsError !== undefined) {
|
|
94
|
+
action = (yield repos.action.giveUpWithObject({ typeOf: action.typeOf, id: action.id, error: seatInfoSyncResultAsError }));
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
// add recipe(2024-06-04~)
|
|
98
|
+
yield repos.action.saveOneRecipe((0, factory_1.processSeatInfoSyncResult2refundRecipe)(Object.assign(Object.assign({ project: { id: params.project.id }, action: { id: action.id, typeOf: action.typeOf } }, (processSeatInfoSyncResult !== undefined) ? { processSeatInfoSyncResult } : undefined), (processSeatInfoSyncCancelResult !== undefined) ? { processSeatInfoSyncCancelResult } : undefined)));
|
|
99
|
+
const actionResult = Object.assign(Object.assign({}, ((processSeatInfoSyncResult === null || processSeatInfoSyncResult === void 0 ? void 0 : processSeatInfoSyncResult.seatInfoSyncResult) !== undefined)
|
|
100
|
+
? { seatInfoSyncResult: processSeatInfoSyncResult.seatInfoSyncResult }
|
|
101
|
+
: undefined), ((processSeatInfoSyncCancelResult === null || processSeatInfoSyncCancelResult === void 0 ? void 0 : processSeatInfoSyncCancelResult.seatInfoSyncCancelResult) !== undefined)
|
|
102
|
+
? { seatInfoSyncCancelResult: processSeatInfoSyncCancelResult.seatInfoSyncCancelResult }
|
|
103
|
+
: undefined);
|
|
104
|
+
action = (yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult }));
|
|
105
|
+
}
|
|
106
|
+
yield (0, onRefund_1.onRefund)(action)(repos);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
exports.refundMovieTicket = refundMovieTicket;
|
|
110
|
+
function createSeatInfoSyncInOnRefund(params) {
|
|
111
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
112
|
+
var _a;
|
|
113
|
+
// 本アクションに対応するPayActionを取り出す
|
|
114
|
+
// 例えばtimeoutが原因でCompletedActionStatusでない場合、外部サービス側では着券済の可能性もあるので、そこを考慮する
|
|
115
|
+
const payAction = yield repos.action.findPayAction({
|
|
116
|
+
project: { id: params.project.id },
|
|
117
|
+
paymentMethodId: params.paymentMethodId,
|
|
118
|
+
actionStatus: {
|
|
119
|
+
$in: [
|
|
120
|
+
factory.actionStatusType.ActiveActionStatus,
|
|
121
|
+
factory.actionStatusType.CompletedActionStatus,
|
|
122
|
+
factory.actionStatusType.FailedActionStatus
|
|
123
|
+
]
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
if (payAction === undefined) {
|
|
127
|
+
throw new factory.errors.NotFound('PayAction');
|
|
128
|
+
}
|
|
129
|
+
const seatInfoSyncInOnPay = (_a = payAction.instrument) === null || _a === void 0 ? void 0 : _a.seatInfoSyncIn;
|
|
130
|
+
if (seatInfoSyncInOnPay === undefined) {
|
|
131
|
+
throw new factory.errors.NotFound('PayAction.instrument?.seatInfoSyncIn');
|
|
132
|
+
}
|
|
133
|
+
let seatInfoSyncIn;
|
|
134
|
+
// 着券時のseatInfoSyncInに対してtrkshFlgだけ変更してリクエストする
|
|
135
|
+
seatInfoSyncIn = Object.assign(Object.assign({}, seatInfoSyncInOnPay), { trkshFlg: surfrock.factory.service.seat.seatInfoSync.DeleteFlag.True // 取消フラグ
|
|
136
|
+
});
|
|
137
|
+
return seatInfoSyncIn;
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
function createSeatInfoSyncCancelInOnRefund(params) {
|
|
141
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
142
|
+
var _a;
|
|
143
|
+
// 本アクションに対応するPayActionを取り出す
|
|
144
|
+
// 例えばtimeoutが原因でCompletedActionStatusでない場合、外部サービス側では着券済の可能性もあるので、そこを考慮する
|
|
145
|
+
const payAction = yield repos.action.findPayAction({
|
|
146
|
+
project: { id: params.project.id },
|
|
147
|
+
paymentMethodId: params.paymentMethodId,
|
|
148
|
+
actionStatus: {
|
|
149
|
+
$in: [
|
|
150
|
+
factory.actionStatusType.ActiveActionStatus,
|
|
151
|
+
factory.actionStatusType.CompletedActionStatus,
|
|
152
|
+
factory.actionStatusType.FailedActionStatus
|
|
153
|
+
]
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
if (payAction === undefined) {
|
|
157
|
+
throw new factory.errors.NotFound('PayAction');
|
|
158
|
+
}
|
|
159
|
+
const seatInfoSyncInOnPay = (_a = payAction.instrument) === null || _a === void 0 ? void 0 : _a.seatInfoSyncIn;
|
|
160
|
+
if (seatInfoSyncInOnPay === undefined) {
|
|
161
|
+
throw new factory.errors.NotFound('PayAction.instrument?.seatInfoSyncIn');
|
|
162
|
+
}
|
|
163
|
+
let seatInfoSyncCancelIn;
|
|
164
|
+
seatInfoSyncCancelIn = {
|
|
165
|
+
kgygishCd: seatInfoSyncInOnPay.kgygishCd,
|
|
166
|
+
kgysystmzskyykNo: seatInfoSyncInOnPay.kgygishSstmZskyykNo,
|
|
167
|
+
kgysystmzskyykNoIkktsCnclFlg: '1',
|
|
168
|
+
jyuTyp: surfrock.service.seat.factory.seatInfoSyncCancel.JyuTyp.JyuTyp05,
|
|
169
|
+
jyuTypRmk: ''
|
|
170
|
+
// knyknrNoInfoIn: [],
|
|
171
|
+
};
|
|
172
|
+
return seatInfoSyncCancelIn;
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
function processSeatInfoSyncCancel(params) {
|
|
176
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
177
|
+
var _a;
|
|
178
|
+
let seatInfoSyncCancelResult;
|
|
179
|
+
const { seatInfoSyncCancelIn } = params;
|
|
180
|
+
try {
|
|
181
|
+
seatInfoSyncCancelResult = yield repos.seatService.seatInfoSyncCancel(seatInfoSyncCancelIn);
|
|
182
|
+
}
|
|
183
|
+
catch (error) {
|
|
184
|
+
let throwsError = true;
|
|
185
|
+
if (error.name === errorHandler_1.MOVIE_TICKET_RESERVE_REQUEST_ERROR_NAME) {
|
|
186
|
+
if (error.code === http_status_1.BAD_REQUEST) {
|
|
187
|
+
if (Array.isArray(error.errors) && error.errors.length > 0) {
|
|
188
|
+
const mvtkReserveServiceError = error.errors[0];
|
|
189
|
+
// 興行会社システム座席予約番号存在無の場合、取消済なのでok
|
|
190
|
+
if (mvtkReserveServiceError.status === surfrock.factory.ResultStatus.Success) {
|
|
191
|
+
const cnclResult = (_a = mvtkReserveServiceError.rawResult) === null || _a === void 0 ? void 0 : _a.cnclResult;
|
|
192
|
+
if (cnclResult === surfrock.service.seat.factory.seatInfoSyncCancel.CancelResult.CancelResult02) {
|
|
193
|
+
seatInfoSyncCancelResult = error;
|
|
194
|
+
throwsError = false;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (throwsError) {
|
|
201
|
+
throw error;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return { seatInfoSyncCancelIn, seatInfoSyncCancelResult };
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
function processSeatInfoSync(params) {
|
|
208
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
209
|
+
let seatInfoSyncResult;
|
|
210
|
+
let seatInfoSyncResultAsError;
|
|
211
|
+
const { seatInfoSyncIn, paymentMethodId, purpose } = params;
|
|
212
|
+
try {
|
|
213
|
+
seatInfoSyncResult = yield repos.seatService.seatInfoSync(seatInfoSyncIn);
|
|
214
|
+
}
|
|
215
|
+
catch (error) {
|
|
216
|
+
let throwsError = true;
|
|
217
|
+
// 「存在しない興行会社システム座席予約番号が入力されました」の場合、取消済なのでok
|
|
218
|
+
if (error.name === errorHandler_1.MOVIE_TICKET_RESERVE_REQUEST_ERROR_NAME) {
|
|
219
|
+
if (error.code === http_status_1.BAD_REQUEST && error.message === factory_1.MovieticketReserveRequestErrorMessage.NotFound) {
|
|
220
|
+
seatInfoSyncResult = error;
|
|
221
|
+
throwsError = false;
|
|
222
|
+
}
|
|
223
|
+
// ReservationResult 19の内容が不明だがリトライする意味はおそらくないパターン
|
|
224
|
+
if (error.code === http_status_1.BAD_REQUEST && error.message === factory_1.MovieticketReserveRequestErrorMessage.ReservationResult19) {
|
|
225
|
+
seatInfoSyncResult = error;
|
|
226
|
+
throwsError = false;
|
|
227
|
+
}
|
|
228
|
+
// surfrock: bookingNoが存在しないケースをハンドル(2024-03-13~)
|
|
229
|
+
const expectedMessage4surfrockNotFound = JSON.stringify({ message: `bookingNo:"${paymentMethodId}" が見つかりません。` });
|
|
230
|
+
if (error.code === http_status_1.BAD_REQUEST && error.message === expectedMessage4surfrockNotFound) {
|
|
231
|
+
seatInfoSyncResult = error;
|
|
232
|
+
throwsError = false;
|
|
233
|
+
}
|
|
234
|
+
// 着券取消可能期間超過を認識した上でのあえての返金の場合(注文からしばらく経って返品など)(2024-03-19~)
|
|
235
|
+
if (error.code === http_status_1.BAD_REQUEST && error.message === factory_1.MovieticketReserveRequestErrorMessage.CancellationPeriodPassed) {
|
|
236
|
+
if (purpose.typeOf === factory.actionType.ReturnAction) {
|
|
237
|
+
seatInfoSyncResultAsError = error;
|
|
238
|
+
throwsError = false;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
if (throwsError) {
|
|
243
|
+
throw error;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return { seatInfoSyncIn, seatInfoSyncResult, seatInfoSyncResultAsError };
|
|
247
|
+
});
|
|
248
|
+
}
|
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.validateMovieTicket = void 0;
|
|
13
13
|
const createDebug = require("debug");
|
|
14
14
|
const factory = require("../../../factory");
|
|
15
|
-
const
|
|
15
|
+
const processPurchaseNumberAuth_1 = require("./processPurchaseNumberAuth");
|
|
16
16
|
const debug = createDebug('chevre-domain:service:payment');
|
|
17
17
|
function validateMovieTicket(params, paymentServiceId, useCheckMovieTicketBeforePay, useCheckByIdentifierIfNotYet) {
|
|
18
18
|
// tslint:disable-next-line:max-func-body-length
|
|
@@ -80,7 +80,7 @@ function validateMovieTicket(params, paymentServiceId, useCheckMovieTicketBefore
|
|
|
80
80
|
const checkResult = yield checkByIdentifierIfNotYet({
|
|
81
81
|
movieTicketIdentifier,
|
|
82
82
|
movieTickets: movieTickets,
|
|
83
|
-
seller: { id: sellerId
|
|
83
|
+
seller: { id: sellerId },
|
|
84
84
|
screeningEvent: screeningEvent,
|
|
85
85
|
paymentServiceId,
|
|
86
86
|
useCheckByIdentifierIfNotYet
|
|
@@ -141,7 +141,7 @@ function checkByIdentifierIfNotYet(params) {
|
|
|
141
141
|
}
|
|
142
142
|
if (checkResult === undefined) {
|
|
143
143
|
debug('checkByIdentifier processing because movieTickets not checked yet...', checkResult);
|
|
144
|
-
checkResult = yield (0,
|
|
144
|
+
checkResult = yield (0, processPurchaseNumberAuth_1.processPurchaseNumberAuth)(params)(repos);
|
|
145
145
|
}
|
|
146
146
|
return checkResult;
|
|
147
147
|
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { MongoRepository as AccountingReportRepo } from '../../../repo/accountingReport';
|
|
2
|
+
import type { MongoRepository as ActionRepo } from '../../../repo/action';
|
|
3
|
+
import type { MongoRepository as PaymentServiceRepo } from '../../../repo/paymentService';
|
|
4
|
+
import type { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
5
|
+
import * as factory from '../../../factory';
|
|
6
|
+
declare function voidTransaction(params: factory.task.voidPayment.IData): (repos: {
|
|
7
|
+
action: ActionRepo;
|
|
8
|
+
accountingReport: AccountingReportRepo;
|
|
9
|
+
paymentService: PaymentServiceRepo;
|
|
10
|
+
task: TaskRepo;
|
|
11
|
+
}) => Promise<void>;
|
|
12
|
+
export { voidTransaction };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.voidTransaction = void 0;
|
|
13
|
+
const factory = require("../../../factory");
|
|
14
|
+
const refundMovieTicket_1 = require("./refundMovieTicket");
|
|
15
|
+
function voidTransaction(params) {
|
|
16
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
var _a, _b, _c;
|
|
18
|
+
const transaction = params.object;
|
|
19
|
+
const paymentMethodType = (_a = transaction.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.identifier;
|
|
20
|
+
if (typeof paymentMethodType !== 'string') {
|
|
21
|
+
throw new factory.errors.ArgumentNull('object.paymentMethod.identifier');
|
|
22
|
+
}
|
|
23
|
+
// const paymentMethodId = transaction.object.paymentMethod?.paymentMethodId;
|
|
24
|
+
const paymentMethodId = transaction.object.paymentMethodId;
|
|
25
|
+
if (typeof paymentMethodId !== 'string') {
|
|
26
|
+
throw new factory.errors.ArgumentNull('object.paymentMethodId');
|
|
27
|
+
}
|
|
28
|
+
// 決済開始時に着券していれば、取消
|
|
29
|
+
// 例えばtimeoutが原因でCompletedActionStatusでない場合、外部サービス側では着券済の可能性もあるので、そこを考慮する
|
|
30
|
+
const payAction = yield repos.action.findPayAction({
|
|
31
|
+
project: { id: transaction.project.id },
|
|
32
|
+
paymentMethodId,
|
|
33
|
+
actionStatus: {
|
|
34
|
+
$in: [
|
|
35
|
+
factory.actionStatusType.ActiveActionStatus,
|
|
36
|
+
factory.actionStatusType.CompletedActionStatus,
|
|
37
|
+
factory.actionStatusType.FailedActionStatus
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
if (payAction !== undefined) {
|
|
42
|
+
let refundAction;
|
|
43
|
+
const seller = transaction.recipient;
|
|
44
|
+
if (typeof (seller === null || seller === void 0 ? void 0 : seller.id) !== 'string') {
|
|
45
|
+
throw new factory.errors.NotFound('payTransaction.recipient');
|
|
46
|
+
}
|
|
47
|
+
refundAction = {
|
|
48
|
+
project: transaction.project,
|
|
49
|
+
typeOf: factory.actionType.RefundAction,
|
|
50
|
+
object: [{
|
|
51
|
+
typeOf: transaction.object.typeOf,
|
|
52
|
+
id: (typeof transaction.object.id === 'string') ? transaction.object.id : '',
|
|
53
|
+
paymentMethod: {
|
|
54
|
+
paymentMethodId: paymentMethodId,
|
|
55
|
+
typeOf: paymentMethodType,
|
|
56
|
+
name: (typeof ((_b = transaction.object.paymentMethod) === null || _b === void 0 ? void 0 : _b.name) === 'string')
|
|
57
|
+
? transaction.object.paymentMethod.name
|
|
58
|
+
: paymentMethodType,
|
|
59
|
+
additionalProperty: []
|
|
60
|
+
}
|
|
61
|
+
}],
|
|
62
|
+
agent: {
|
|
63
|
+
id: seller.id,
|
|
64
|
+
name: (typeof seller.name === 'string') ? seller.name : String((_c = seller.name) === null || _c === void 0 ? void 0 : _c.ja),
|
|
65
|
+
typeOf: seller.typeOf
|
|
66
|
+
},
|
|
67
|
+
recipient: transaction.recipient,
|
|
68
|
+
purpose: payAction.purpose
|
|
69
|
+
};
|
|
70
|
+
yield (0, refundMovieTicket_1.refundMovieTicket)(refundAction)(repos);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
exports.voidTransaction = voidTransaction;
|
|
@@ -1,78 +1,10 @@
|
|
|
1
|
-
import type { MongoRepository as AccountingReportRepo } from '../../repo/accountingReport';
|
|
2
|
-
import type { MongoRepository as ActionRepo } from '../../repo/action';
|
|
3
|
-
import type { MongoRepository as EventRepo } from '../../repo/event';
|
|
4
|
-
import type { MongoRepository as PaymentServiceRepo } from '../../repo/paymentService';
|
|
5
|
-
import type { MongoRepository as PaymentServiceProviderRepo } from '../../repo/paymentServiceProvider';
|
|
6
|
-
import type { MongoRepository as PaymentAcceptedRepo } from '../../repo/sellerPaymentAccepted';
|
|
7
|
-
import type { MongoRepository as TaskRepo } from '../../repo/task';
|
|
8
|
-
import * as factory from '../../factory';
|
|
9
|
-
import { ICheckResult } from './movieTicket/checkByIdentifier';
|
|
10
|
-
interface ICheckOperationRepos {
|
|
11
|
-
action: ActionRepo;
|
|
12
|
-
event: EventRepo;
|
|
13
|
-
paymentAccepted: PaymentAcceptedRepo;
|
|
14
|
-
paymentService: PaymentServiceRepo;
|
|
15
|
-
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
16
|
-
}
|
|
17
|
-
type ICheckOperation<T> = (repos: ICheckOperationRepos) => Promise<T>;
|
|
18
|
-
interface IPayOperationRepos {
|
|
19
|
-
action: ActionRepo;
|
|
20
|
-
accountingReport: AccountingReportRepo;
|
|
21
|
-
event: EventRepo;
|
|
22
|
-
paymentAccepted: PaymentAcceptedRepo;
|
|
23
|
-
paymentService: PaymentServiceRepo;
|
|
24
|
-
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
25
|
-
task: TaskRepo;
|
|
26
|
-
}
|
|
27
|
-
type IPayOperation<T> = (repos: IPayOperationRepos) => Promise<T>;
|
|
28
|
-
interface IRefundOperationRepos {
|
|
29
|
-
action: ActionRepo;
|
|
30
|
-
accountingReport: AccountingReportRepo;
|
|
31
|
-
paymentService: PaymentServiceRepo;
|
|
32
|
-
task: TaskRepo;
|
|
33
|
-
}
|
|
34
|
-
type IRefundOperation<T> = (repos: IRefundOperationRepos) => Promise<T>;
|
|
35
1
|
/**
|
|
36
|
-
*
|
|
2
|
+
* 決済カード決済サービス
|
|
37
3
|
*/
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
payAction: factory.action.trade.pay.IAction;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* MovieTicket承認
|
|
48
|
-
* オーソリサービスが存在するわけではないので、実質着券する
|
|
49
|
-
*/
|
|
50
|
-
declare function authorize(params: factory.assetTransaction.pay.IStartParamsWithoutDetail, transaction: factory.assetTransaction.pay.ITransaction, paymentServiceId: string, useCheckMovieTicketBeforePay: boolean, useCheckByIdentifierIfNotYet: boolean): (repos: {
|
|
51
|
-
action: ActionRepo;
|
|
52
|
-
accountingReport: AccountingReportRepo;
|
|
53
|
-
event: EventRepo;
|
|
54
|
-
paymentAccepted: PaymentAcceptedRepo;
|
|
55
|
-
paymentService: PaymentServiceRepo;
|
|
56
|
-
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
57
|
-
task: TaskRepo;
|
|
58
|
-
}) => Promise<IAuthorizeResult>;
|
|
59
|
-
declare function voidTransaction(params: factory.task.voidPayment.IData): (repos: {
|
|
60
|
-
action: ActionRepo;
|
|
61
|
-
accountingReport: AccountingReportRepo;
|
|
62
|
-
paymentService: PaymentServiceRepo;
|
|
63
|
-
task: TaskRepo;
|
|
64
|
-
}) => Promise<void>;
|
|
65
|
-
type IPayAction = factory.action.trade.pay.IAction;
|
|
66
|
-
/**
|
|
67
|
-
* MovieTicket着券
|
|
68
|
-
*/
|
|
69
|
-
declare function payMovieTicket(params: factory.task.pay.IPayActionData): IPayOperation<IPayAction>;
|
|
70
|
-
/**
|
|
71
|
-
* MovieTicket着券取消
|
|
72
|
-
*/
|
|
73
|
-
declare function refundMovieTicket(params: factory.task.refund.IData & {
|
|
74
|
-
sameAs?: {
|
|
75
|
-
id: string;
|
|
76
|
-
};
|
|
77
|
-
}): IRefundOperation<void>;
|
|
4
|
+
import { authorize } from './movieTicket/authorize';
|
|
5
|
+
import { checkMovieTicket } from './movieTicket/checkMovieTicket';
|
|
6
|
+
import { payMovieTicket } from './movieTicket/payMovieTicket';
|
|
7
|
+
import { ICheckResult } from './movieTicket/processPurchaseNumberAuth';
|
|
8
|
+
import { refundMovieTicket } from './movieTicket/refundMovieTicket';
|
|
9
|
+
import { voidTransaction } from './movieTicket/voidTransaction';
|
|
78
10
|
export { ICheckResult, authorize, checkMovieTicket, payMovieTicket, refundMovieTicket, voidTransaction };
|