@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
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.processAlterTranResult2refundRecipe = exports.processAlterTranResult2payRecipe = void 0;
|
|
4
|
+
const factory = require("../../../factory");
|
|
5
|
+
function processAlterTranResult2payRecipe(params) {
|
|
6
|
+
const { processAlterTranResults, project, action } = params;
|
|
7
|
+
return {
|
|
8
|
+
project: { id: project.id, typeOf: factory.organizationType.Project },
|
|
9
|
+
typeOf: 'Recipe',
|
|
10
|
+
recipeCategory: factory.recipe.RecipeCategory.payCreditCard,
|
|
11
|
+
recipeFor: { id: action.id, typeOf: action.typeOf },
|
|
12
|
+
step: processAlterTranResults.map(({ searchTradeArgs, searchTradeResult, alterTranArgs, alterTranResult }) => {
|
|
13
|
+
return {
|
|
14
|
+
typeOf: 'HowToSection',
|
|
15
|
+
itemListElement: [
|
|
16
|
+
{
|
|
17
|
+
typeOf: 'HowToStep',
|
|
18
|
+
identifier: factory.recipe.StepIdentifier.searchTrade,
|
|
19
|
+
itemListElement: [Object.assign(Object.assign({ typeOf: 'HowToDirection' }, (searchTradeArgs !== undefined) ? { beforeMedia: searchTradeArgs } : undefined), (searchTradeResult !== undefined) ? { afterMedia: searchTradeResult } : undefined)]
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
typeOf: 'HowToStep',
|
|
23
|
+
identifier: factory.recipe.StepIdentifier.alterTran,
|
|
24
|
+
itemListElement: [Object.assign(Object.assign({ typeOf: 'HowToDirection' }, (alterTranArgs !== undefined) ? { beforeMedia: alterTranArgs } : undefined), (alterTranResult !== undefined) ? { afterMedia: alterTranResult } : undefined)]
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
};
|
|
28
|
+
})
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
exports.processAlterTranResult2payRecipe = processAlterTranResult2payRecipe;
|
|
32
|
+
function processAlterTranResult2refundRecipe(params) {
|
|
33
|
+
const { processAlterTranResult, project, action } = params;
|
|
34
|
+
const { searchTradeArgs, searchTradeResult, alterTranResult, alterTranArgs } = processAlterTranResult;
|
|
35
|
+
return {
|
|
36
|
+
project: { id: project.id, typeOf: factory.organizationType.Project },
|
|
37
|
+
typeOf: 'Recipe',
|
|
38
|
+
recipeCategory: factory.recipe.RecipeCategory.refundCreditCard,
|
|
39
|
+
recipeFor: { id: action.id, typeOf: action.typeOf },
|
|
40
|
+
step: [{
|
|
41
|
+
typeOf: 'HowToSection',
|
|
42
|
+
itemListElement: [
|
|
43
|
+
{
|
|
44
|
+
typeOf: 'HowToStep',
|
|
45
|
+
identifier: factory.recipe.StepIdentifier.searchTrade,
|
|
46
|
+
itemListElement: [Object.assign(Object.assign({ typeOf: 'HowToDirection' }, (searchTradeArgs !== undefined) ? { beforeMedia: searchTradeArgs } : undefined), (searchTradeResult !== undefined) ? { afterMedia: searchTradeResult } : undefined)]
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
typeOf: 'HowToStep',
|
|
50
|
+
identifier: factory.recipe.StepIdentifier.alterTran,
|
|
51
|
+
itemListElement: [Object.assign(Object.assign({ typeOf: 'HowToDirection' }, (alterTranArgs !== undefined) ? { beforeMedia: alterTranArgs } : undefined), (alterTranResult !== undefined) ? { afterMedia: alterTranResult } : undefined)]
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
}]
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
exports.processAlterTranResult2refundRecipe = processAlterTranResult2refundRecipe;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as factory from '../../../factory';
|
|
2
|
+
import type { MongoRepository as PaymentServiceProviderRepo } from '../../../repo/paymentServiceProvider';
|
|
3
|
+
import type { MongoRepository as PaymentAcceptedRepo } from '../../../repo/sellerPaymentAccepted';
|
|
4
|
+
interface IGMOInfo {
|
|
5
|
+
shopId: string;
|
|
6
|
+
shopPass: string;
|
|
7
|
+
returnUrls3ds: string[];
|
|
8
|
+
callbackType3ds?: factory.service.paymentService.ICallbackType3ds;
|
|
9
|
+
}
|
|
10
|
+
declare function getGMOInfoFromSeller(params: {
|
|
11
|
+
paymentMethodType: string;
|
|
12
|
+
seller: {
|
|
13
|
+
id: string;
|
|
14
|
+
};
|
|
15
|
+
paymentServiceId: string;
|
|
16
|
+
}): (repos: {
|
|
17
|
+
paymentAccepted: PaymentAcceptedRepo;
|
|
18
|
+
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
19
|
+
}) => Promise<IGMOInfo>;
|
|
20
|
+
export { getGMOInfoFromSeller };
|
|
@@ -0,0 +1,47 @@
|
|
|
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.getGMOInfoFromSeller = void 0;
|
|
13
|
+
const factory = require("../../../factory");
|
|
14
|
+
function getGMOInfoFromSeller(params) {
|
|
15
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
var _a, _b, _c, _d;
|
|
17
|
+
const paymentAccepted = yield repos.paymentAccepted.isAcceptedBySeller({
|
|
18
|
+
seller: { id: params.seller.id },
|
|
19
|
+
codeValue: params.paymentMethodType
|
|
20
|
+
});
|
|
21
|
+
if (paymentAccepted !== true) {
|
|
22
|
+
throw new factory.errors.Argument('transaction', `payment not accepted [${params.paymentMethodType}]`);
|
|
23
|
+
}
|
|
24
|
+
// 決済サービスからcredentialsを取得する
|
|
25
|
+
const paymentServices = yield repos.paymentServiceProvider.search({
|
|
26
|
+
limit: 1,
|
|
27
|
+
page: 1,
|
|
28
|
+
provider: { id: { $eq: params.seller.id } },
|
|
29
|
+
id: { $eq: params.paymentServiceId }
|
|
30
|
+
});
|
|
31
|
+
const paymentService = paymentServices.shift();
|
|
32
|
+
if (paymentService === undefined) {
|
|
33
|
+
throw new factory.errors.NotFound('PaymentService');
|
|
34
|
+
}
|
|
35
|
+
const provider = paymentService.provider;
|
|
36
|
+
const shopId = (_a = provider.credentials) === null || _a === void 0 ? void 0 : _a.shopId;
|
|
37
|
+
const shopPass = (_b = provider.credentials) === null || _b === void 0 ? void 0 : _b.shopPass;
|
|
38
|
+
if (typeof shopId !== 'string' || typeof shopPass !== 'string') {
|
|
39
|
+
throw new factory.errors.Argument('transaction', 'Provider credentials not enough');
|
|
40
|
+
}
|
|
41
|
+
const returnUrls3dsSetting = (_c = provider.credentials) === null || _c === void 0 ? void 0 : _c.returnUrls3ds;
|
|
42
|
+
const returnUrls3ds = (Array.isArray(returnUrls3dsSetting)) ? returnUrls3dsSetting : [];
|
|
43
|
+
const callbackType3ds = (_d = provider.credentials) === null || _d === void 0 ? void 0 : _d.callbackType3ds;
|
|
44
|
+
return { shopId, shopPass, returnUrls3ds, callbackType3ds };
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
exports.getGMOInfoFromSeller = getGMOInfoFromSeller;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
declare enum GMOErrorInfo {
|
|
2
|
+
TransactionNotFound = "E01110002"
|
|
3
|
+
}
|
|
4
|
+
interface IGMOError {
|
|
5
|
+
/**
|
|
6
|
+
* エラー番号
|
|
7
|
+
*/
|
|
8
|
+
errorNumber: string;
|
|
9
|
+
/**
|
|
10
|
+
* コード
|
|
11
|
+
*/
|
|
12
|
+
code: string;
|
|
13
|
+
/**
|
|
14
|
+
* 詳細コード
|
|
15
|
+
*/
|
|
16
|
+
info: GMOErrorInfo | string;
|
|
17
|
+
/**
|
|
18
|
+
* 状態
|
|
19
|
+
*/
|
|
20
|
+
state: string;
|
|
21
|
+
/**
|
|
22
|
+
* 課金対象
|
|
23
|
+
*/
|
|
24
|
+
billing: string;
|
|
25
|
+
/**
|
|
26
|
+
* エラー内容と加盟店側の対処の方法
|
|
27
|
+
*/
|
|
28
|
+
content: string;
|
|
29
|
+
/**
|
|
30
|
+
* ユーザへ表示するメッセージ例
|
|
31
|
+
*/
|
|
32
|
+
userMessage: string;
|
|
33
|
+
}
|
|
34
|
+
export { GMOErrorInfo, IGMOError };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GMOErrorInfo = void 0;
|
|
4
|
+
var GMOErrorInfo;
|
|
5
|
+
(function (GMOErrorInfo) {
|
|
6
|
+
GMOErrorInfo["TransactionNotFound"] = "E01110002";
|
|
7
|
+
})(GMOErrorInfo || (GMOErrorInfo = {}));
|
|
8
|
+
exports.GMOErrorInfo = GMOErrorInfo;
|
|
@@ -0,0 +1,20 @@
|
|
|
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 PaymentServiceProviderRepo } from '../../../repo/paymentServiceProvider';
|
|
5
|
+
import type { MongoRepository as PaymentAcceptedRepo } from '../../../repo/sellerPaymentAccepted';
|
|
6
|
+
import type { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
7
|
+
import * as factory from '../../../factory';
|
|
8
|
+
type IPayAction = factory.action.trade.pay.IAction;
|
|
9
|
+
/**
|
|
10
|
+
* クレジットカード決済
|
|
11
|
+
*/
|
|
12
|
+
declare function payCreditCard(params: factory.action.trade.pay.IAttributes): (repos: {
|
|
13
|
+
action: ActionRepo;
|
|
14
|
+
accountingReport: AccountingReportRepo;
|
|
15
|
+
paymentAccepted: PaymentAcceptedRepo;
|
|
16
|
+
paymentService: PaymentServiceRepo;
|
|
17
|
+
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
18
|
+
task: TaskRepo;
|
|
19
|
+
}) => Promise<IPayAction>;
|
|
20
|
+
export { payCreditCard };
|
|
@@ -0,0 +1,151 @@
|
|
|
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.payCreditCard = void 0;
|
|
13
|
+
const GMO = require("@motionpicture/gmo-service");
|
|
14
|
+
const credentials_1 = require("../../../credentials");
|
|
15
|
+
const factory = require("../../../factory");
|
|
16
|
+
const onPaid_1 = require("../any/onPaid");
|
|
17
|
+
const factory_1 = require("./factory");
|
|
18
|
+
const getGMOInfoFromSeller_1 = require("./getGMOInfoFromSeller");
|
|
19
|
+
/**
|
|
20
|
+
* クレジットカード決済
|
|
21
|
+
*/
|
|
22
|
+
function payCreditCard(params) {
|
|
23
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
var _a;
|
|
25
|
+
const payObject = params.object;
|
|
26
|
+
// CreditCard系統の決済方法タイプは動的
|
|
27
|
+
const paymentMethodType = payObject[0].paymentMethod.typeOf;
|
|
28
|
+
if (typeof paymentMethodType !== 'string') {
|
|
29
|
+
throw new factory.errors.ArgumentNull('object.paymentMethod.typeOf');
|
|
30
|
+
}
|
|
31
|
+
const paymentServiceId = payObject[0].id;
|
|
32
|
+
const availableChannel = yield repos.paymentService.findAvailableChannel({
|
|
33
|
+
project: params.project,
|
|
34
|
+
typeOf: factory.service.paymentService.PaymentServiceType.CreditCard,
|
|
35
|
+
id: paymentServiceId
|
|
36
|
+
});
|
|
37
|
+
const sellerId = (_a = params.recipient) === null || _a === void 0 ? void 0 : _a.id;
|
|
38
|
+
if (typeof sellerId !== 'string') {
|
|
39
|
+
throw new factory.errors.ArgumentNull('recipient.id');
|
|
40
|
+
}
|
|
41
|
+
const { shopId, shopPass } = yield (0, getGMOInfoFromSeller_1.getGMOInfoFromSeller)({ paymentMethodType, seller: { id: sellerId }, paymentServiceId })(repos);
|
|
42
|
+
// アクション開始
|
|
43
|
+
let action = yield repos.action.start(params);
|
|
44
|
+
const alterTranResults = [];
|
|
45
|
+
const processAlterTranResults = [];
|
|
46
|
+
try {
|
|
47
|
+
const creditService = new GMO.service.Credit({
|
|
48
|
+
endpoint: String(availableChannel.serviceUrl),
|
|
49
|
+
useFetch: credentials_1.credentials.gmo.useFetch
|
|
50
|
+
}, { timeout: credentials_1.credentials.gmo.timeout });
|
|
51
|
+
yield Promise.all(payObject.map((paymentMethod) => __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
const processAlterTranResult = yield processAlterTran({
|
|
53
|
+
shopId, shopPass, availableChannel, paymentMethod
|
|
54
|
+
})({ creditService });
|
|
55
|
+
processAlterTranResults.push(processAlterTranResult);
|
|
56
|
+
if (processAlterTranResult.processAlterTranError === undefined) {
|
|
57
|
+
if (processAlterTranResult.alterTranResult !== undefined) {
|
|
58
|
+
alterTranResults.push(processAlterTranResult.alterTranResult);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
// 代行決済連携中にエラーがあればそのままthrow
|
|
63
|
+
throw processAlterTranResult.processAlterTranError;
|
|
64
|
+
}
|
|
65
|
+
})));
|
|
66
|
+
// add recipe(2024-06-03~)
|
|
67
|
+
yield repos.action.saveOneRecipe((0, factory_1.processAlterTranResult2payRecipe)({
|
|
68
|
+
processAlterTranResults,
|
|
69
|
+
project: { id: params.project.id },
|
|
70
|
+
action: { id: action.id, typeOf: action.typeOf }
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
try {
|
|
75
|
+
yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error });
|
|
76
|
+
}
|
|
77
|
+
catch (__) {
|
|
78
|
+
// 失敗したら仕方ない
|
|
79
|
+
}
|
|
80
|
+
throw error;
|
|
81
|
+
}
|
|
82
|
+
const actionResult = { creditCardSales: alterTranResults };
|
|
83
|
+
action = (yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult }));
|
|
84
|
+
yield (0, onPaid_1.onPaid)(action)(repos);
|
|
85
|
+
return action;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
exports.payCreditCard = payCreditCard;
|
|
89
|
+
function processAlterTran(params) {
|
|
90
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
92
|
+
let searchTradeArgs;
|
|
93
|
+
let searchTradeResult;
|
|
94
|
+
let alterTranArgs;
|
|
95
|
+
let alterTranResult;
|
|
96
|
+
let processAlterTranError;
|
|
97
|
+
try {
|
|
98
|
+
const { shopId, shopPass } = params;
|
|
99
|
+
const paymentMethod = params.paymentMethod;
|
|
100
|
+
const orderId = paymentMethod.paymentMethod.paymentMethodId;
|
|
101
|
+
// 取引状態参照
|
|
102
|
+
searchTradeArgs = {
|
|
103
|
+
shopId, shopPass, orderId,
|
|
104
|
+
siteId: (_a = params.availableChannel.credentials) === null || _a === void 0 ? void 0 : _a.siteId,
|
|
105
|
+
sitePass: (_b = params.availableChannel.credentials) === null || _b === void 0 ? void 0 : _b.sitePass
|
|
106
|
+
};
|
|
107
|
+
searchTradeResult = yield repos.creditService.searchTrade(searchTradeArgs);
|
|
108
|
+
const { accessId, accessPass, forward, approve, tranId, jobCd } = searchTradeResult;
|
|
109
|
+
const amount = (_c = paymentMethod.paymentMethod.totalPaymentDue) === null || _c === void 0 ? void 0 : _c.value;
|
|
110
|
+
if (typeof amount !== 'number') {
|
|
111
|
+
throw new factory.errors.ArgumentNull('object.paymentMethod.totalPaymentDue?.value');
|
|
112
|
+
}
|
|
113
|
+
switch (jobCd) {
|
|
114
|
+
case GMO.utils.util.JobCd.Capture:
|
|
115
|
+
case GMO.utils.util.JobCd.Sales:
|
|
116
|
+
// すでに即時売上済み
|
|
117
|
+
alterTranResult = { accessId, accessPass, forward, approve, tranId, tranDate: '' };
|
|
118
|
+
break;
|
|
119
|
+
case GMO.utils.util.JobCd.Void:
|
|
120
|
+
// 返品手数料決済の場合を追加(状態が取消であれば即時売上)
|
|
121
|
+
alterTranArgs = {
|
|
122
|
+
shopId, shopPass, accessId, accessPass,
|
|
123
|
+
jobCd: GMO.utils.util.JobCd.Capture,
|
|
124
|
+
amount,
|
|
125
|
+
siteId: (_d = params.availableChannel.credentials) === null || _d === void 0 ? void 0 : _d.siteId,
|
|
126
|
+
sitePass: (_e = params.availableChannel.credentials) === null || _e === void 0 ? void 0 : _e.sitePass,
|
|
127
|
+
method: GMO.utils.util.Method.Lump // 再オーソリの場合、支払方法指定は必須
|
|
128
|
+
};
|
|
129
|
+
alterTranResult = yield repos.creditService.alterTran(alterTranArgs);
|
|
130
|
+
break;
|
|
131
|
+
case GMO.utils.util.JobCd.Auth:
|
|
132
|
+
alterTranArgs = {
|
|
133
|
+
shopId, shopPass,
|
|
134
|
+
accessId, accessPass,
|
|
135
|
+
jobCd: GMO.utils.util.JobCd.Sales,
|
|
136
|
+
amount: amount,
|
|
137
|
+
siteId: (_f = params.availableChannel.credentials) === null || _f === void 0 ? void 0 : _f.siteId,
|
|
138
|
+
sitePass: (_g = params.availableChannel.credentials) === null || _g === void 0 ? void 0 : _g.sitePass
|
|
139
|
+
};
|
|
140
|
+
alterTranResult = yield repos.creditService.alterTran(alterTranArgs);
|
|
141
|
+
break;
|
|
142
|
+
default:
|
|
143
|
+
throw new factory.errors.NotImplemented(`jobCd '${jobCd}' not implemented`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
processAlterTranError = error;
|
|
148
|
+
}
|
|
149
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (searchTradeArgs !== undefined) ? { searchTradeArgs } : undefined), (searchTradeResult !== undefined) ? { searchTradeResult } : undefined), (alterTranArgs !== undefined) ? { alterTranArgs } : undefined), (alterTranResult !== undefined) ? { alterTranResult } : undefined), (processAlterTranError !== undefined) ? { processAlterTranError } : undefined);
|
|
150
|
+
});
|
|
151
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
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 PaymentServiceProviderRepo } from '../../../repo/paymentServiceProvider';
|
|
5
|
+
import type { MongoRepository as PaymentAcceptedRepo } from '../../../repo/sellerPaymentAccepted';
|
|
6
|
+
import type { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
7
|
+
import * as factory from '../../../factory';
|
|
8
|
+
type IRefundAction = factory.action.trade.refund.IAction;
|
|
9
|
+
/**
|
|
10
|
+
* クレジットカード返金
|
|
11
|
+
*/
|
|
12
|
+
declare function refundCreditCard(params: Omit<factory.task.refund.IData, 'sameAs'> & {
|
|
13
|
+
sameAs?: {
|
|
14
|
+
id: string;
|
|
15
|
+
};
|
|
16
|
+
}, options: {
|
|
17
|
+
requirePayAction: boolean;
|
|
18
|
+
}): (repos: {
|
|
19
|
+
action: ActionRepo;
|
|
20
|
+
accountingReport: AccountingReportRepo;
|
|
21
|
+
paymentAccepted: PaymentAcceptedRepo;
|
|
22
|
+
paymentService: PaymentServiceRepo;
|
|
23
|
+
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
24
|
+
task: TaskRepo;
|
|
25
|
+
}) => Promise<IRefundAction>;
|
|
26
|
+
export { refundCreditCard };
|
|
@@ -0,0 +1,196 @@
|
|
|
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
|
+
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
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.refundCreditCard = void 0;
|
|
24
|
+
const GMO = require("@motionpicture/gmo-service");
|
|
25
|
+
const credentials_1 = require("../../../credentials");
|
|
26
|
+
const factory = require("../../../factory");
|
|
27
|
+
const onRefund_1 = require("../any/onRefund");
|
|
28
|
+
const factory_1 = require("./factory");
|
|
29
|
+
const getGMOInfoFromSeller_1 = require("./getGMOInfoFromSeller");
|
|
30
|
+
/**
|
|
31
|
+
* クレジットカード返金
|
|
32
|
+
*/
|
|
33
|
+
function refundCreditCard(params, options) {
|
|
34
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
36
|
+
const paymentMethodType = (_a = params.object[0]) === null || _a === void 0 ? void 0 : _a.paymentMethod.typeOf;
|
|
37
|
+
const paymentMethodId = (_b = params.object[0]) === null || _b === void 0 ? void 0 : _b.paymentMethod.paymentMethodId;
|
|
38
|
+
const paymentServiceId = (_c = params.object[0]) === null || _c === void 0 ? void 0 : _c.id;
|
|
39
|
+
// 本アクションに対応するPayActionを取り出す(Cinerino側で決済していた時期に関してはpayActionが存在しないので注意)
|
|
40
|
+
let payAction;
|
|
41
|
+
if (options.requirePayAction) {
|
|
42
|
+
payAction = yield repos.action.findPayAction({ project: { id: params.project.id }, paymentMethodId });
|
|
43
|
+
if (payAction === undefined) {
|
|
44
|
+
throw new factory.errors.NotFound('PayAction');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
let alterTranResultByPayAction;
|
|
48
|
+
if (payAction !== undefined) {
|
|
49
|
+
const payRecipe = yield repos.action.findRecipeByAction({
|
|
50
|
+
project: { id: params.project.id },
|
|
51
|
+
recipeFor: { id: payAction.id }
|
|
52
|
+
});
|
|
53
|
+
alterTranResultByPayAction = (_f = (_e = (_d = payRecipe === null || payRecipe === void 0 ? void 0 : payRecipe.step[0]) === null || _d === void 0 ? void 0 : _d.itemListElement[1]) === null || _e === void 0 ? void 0 : _e.itemListElement[0]) === null || _f === void 0 ? void 0 : _f.afterMedia;
|
|
54
|
+
}
|
|
55
|
+
const sellerId = (_g = params.agent) === null || _g === void 0 ? void 0 : _g.id;
|
|
56
|
+
if (typeof sellerId !== 'string') {
|
|
57
|
+
throw new factory.errors.ArgumentNull('agent.id');
|
|
58
|
+
}
|
|
59
|
+
const { shopId, shopPass } = yield (0, getGMOInfoFromSeller_1.getGMOInfoFromSeller)({ paymentMethodType, seller: { id: sellerId }, paymentServiceId })(repos);
|
|
60
|
+
const availableChannel = yield repos.paymentService.findAvailableChannel({
|
|
61
|
+
project: params.project,
|
|
62
|
+
typeOf: factory.service.paymentService.PaymentServiceType.CreditCard,
|
|
63
|
+
id: paymentServiceId
|
|
64
|
+
});
|
|
65
|
+
const { sameAs } = params, startingActionParams = __rest(params, ["sameAs"]);
|
|
66
|
+
let action = yield repos.action.start(Object.assign(Object.assign({}, startingActionParams), (typeof ((_h = params.sameAs) === null || _h === void 0 ? void 0 : _h.id) === 'string') ? { sameAs: { id: params.sameAs.id, typeOf: 'Task' } } : undefined));
|
|
67
|
+
const alterTranResult = [];
|
|
68
|
+
let processAlterTranResult;
|
|
69
|
+
try {
|
|
70
|
+
const creditService = new GMO.service.Credit({
|
|
71
|
+
endpoint: String(availableChannel.serviceUrl),
|
|
72
|
+
useFetch: credentials_1.credentials.gmo.useFetch
|
|
73
|
+
}, { timeout: credentials_1.credentials.gmo.timeout });
|
|
74
|
+
processAlterTranResult = yield processAlterTran({
|
|
75
|
+
availableChannel,
|
|
76
|
+
// alterTranResultByPayAction: payAction?.result?.creditCardSales?.[0],
|
|
77
|
+
alterTranResultByPayAction,
|
|
78
|
+
paymentMethodId: paymentMethodId,
|
|
79
|
+
shopId: shopId,
|
|
80
|
+
shopPass: shopPass,
|
|
81
|
+
refundFee: (_j = params.object[0]) === null || _j === void 0 ? void 0 : _j.refundFee
|
|
82
|
+
})({ creditService });
|
|
83
|
+
if (processAlterTranResult.processAlterTranError === undefined) {
|
|
84
|
+
if (processAlterTranResult.alterTranResult !== undefined) {
|
|
85
|
+
alterTranResult.push(processAlterTranResult.alterTranResult);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
// 代行決済連携中にエラーがあればそのままthrow
|
|
90
|
+
throw processAlterTranResult.processAlterTranError;
|
|
91
|
+
}
|
|
92
|
+
// add recipe(2024-06-04~)
|
|
93
|
+
yield repos.action.saveOneRecipe((0, factory_1.processAlterTranResult2refundRecipe)({
|
|
94
|
+
processAlterTranResult,
|
|
95
|
+
project: { id: params.project.id },
|
|
96
|
+
action: { id: action.id, typeOf: action.typeOf }
|
|
97
|
+
}));
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
try {
|
|
101
|
+
yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error });
|
|
102
|
+
}
|
|
103
|
+
catch (__) {
|
|
104
|
+
// no op
|
|
105
|
+
}
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
108
|
+
const actionResult = { alterTranResult };
|
|
109
|
+
action = (yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult }));
|
|
110
|
+
yield (0, onRefund_1.onRefund)(action)(repos);
|
|
111
|
+
return action;
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
exports.refundCreditCard = refundCreditCard;
|
|
115
|
+
function processAlterTran(params) {
|
|
116
|
+
// tslint:disable-next-line:cyclomatic-complexity
|
|
117
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
118
|
+
var _a, _b, _c, _d;
|
|
119
|
+
let searchTradeArgs;
|
|
120
|
+
let searchTradeResult;
|
|
121
|
+
let alterTranArgs;
|
|
122
|
+
let alterTranResult;
|
|
123
|
+
let processAlterTranError;
|
|
124
|
+
try {
|
|
125
|
+
const { shopId, shopPass } = params;
|
|
126
|
+
// 取引状態参照
|
|
127
|
+
searchTradeArgs = {
|
|
128
|
+
shopId, shopPass,
|
|
129
|
+
orderId: params.paymentMethodId,
|
|
130
|
+
siteId: (_a = params.availableChannel.credentials) === null || _a === void 0 ? void 0 : _a.siteId,
|
|
131
|
+
sitePass: (_b = params.availableChannel.credentials) === null || _b === void 0 ? void 0 : _b.sitePass
|
|
132
|
+
};
|
|
133
|
+
searchTradeResult = yield repos.creditService.searchTrade(searchTradeArgs);
|
|
134
|
+
const { accessId, accessPass, tranId, forward, approve, status } = searchTradeResult;
|
|
135
|
+
// 冪等性の担保をいったん保留
|
|
136
|
+
let creditCardSalesBefore;
|
|
137
|
+
if (params.alterTranResultByPayAction !== undefined) {
|
|
138
|
+
creditCardSalesBefore = params.alterTranResultByPayAction;
|
|
139
|
+
}
|
|
140
|
+
let alreadyRefunded = false;
|
|
141
|
+
// 決済時のGMO取引を確認できれば、既に返金済かどうかを判定
|
|
142
|
+
if (typeof (creditCardSalesBefore === null || creditCardSalesBefore === void 0 ? void 0 : creditCardSalesBefore.tranId) === 'string') {
|
|
143
|
+
if (tranId !== creditCardSalesBefore.tranId) {
|
|
144
|
+
alreadyRefunded = true;
|
|
145
|
+
}
|
|
146
|
+
// tranIdが空文字のケース(SPSwrapperで発生)に対応(Voidに対してVoidを実行してしまうので)(2024-04-20~)
|
|
147
|
+
if (tranId === '' && creditCardSalesBefore.tranId === '') {
|
|
148
|
+
if (status === GMO.utils.util.Status.Void) {
|
|
149
|
+
alreadyRefunded = true;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
if (alreadyRefunded) {
|
|
154
|
+
alterTranResult = { accessId, accessPass, forward, approve, tranId, tranDate: '' };
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
let caughtAlterTranError;
|
|
158
|
+
try {
|
|
159
|
+
alterTranArgs = {
|
|
160
|
+
shopId, shopPass, accessId, accessPass,
|
|
161
|
+
jobCd: GMO.utils.util.JobCd.Void,
|
|
162
|
+
siteId: (_c = params.availableChannel.credentials) === null || _c === void 0 ? void 0 : _c.siteId,
|
|
163
|
+
sitePass: (_d = params.availableChannel.credentials) === null || _d === void 0 ? void 0 : _d.sitePass
|
|
164
|
+
};
|
|
165
|
+
alterTranResult = yield repos.creditService.alterTran(alterTranArgs);
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
let throwsError = true;
|
|
169
|
+
// 未決済(3D 登録済)->取消をトライするとE01050004エラーとなるが、この場合何もする必要はない(2024-01-09~)
|
|
170
|
+
if (error.name === 'GMOServiceBadRequestError') {
|
|
171
|
+
if (Array.isArray(error.errors) && error.errors.length === 1 && error.errors[0].info === 'E01050004') {
|
|
172
|
+
if (status === GMO.utils.util.Status.Authenticated || status === GMO.utils.util.Status.Void) {
|
|
173
|
+
caughtAlterTranError = error;
|
|
174
|
+
throwsError = false;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
if (throwsError) {
|
|
179
|
+
throw error;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
if (alterTranResult === undefined && caughtAlterTranError !== undefined) {
|
|
183
|
+
alterTranResult = caughtAlterTranError;
|
|
184
|
+
}
|
|
185
|
+
if (alterTranResult === undefined) {
|
|
186
|
+
// impossible path
|
|
187
|
+
throw new factory.errors.NotImplemented('alterTranResult undefined not implemented');
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
processAlterTranError = error;
|
|
193
|
+
}
|
|
194
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (searchTradeArgs !== undefined) ? { searchTradeArgs } : undefined), (searchTradeResult !== undefined) ? { searchTradeResult } : undefined), (alterTranArgs !== undefined) ? { alterTranArgs } : undefined), (alterTranResult !== undefined) ? { alterTranResult } : undefined), (processAlterTranError !== undefined) ? { processAlterTranError } : undefined);
|
|
195
|
+
});
|
|
196
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as GMO from '@motionpicture/gmo-service';
|
|
2
|
+
import * as factory from '../../../factory';
|
|
3
|
+
/**
|
|
4
|
+
* 決済代行側の取引状態参照
|
|
5
|
+
* 存在しない場合NotFoundエラー
|
|
6
|
+
*/
|
|
7
|
+
declare function searchGMOTrade(params: {
|
|
8
|
+
availableChannel: factory.product.IAvailableChannel;
|
|
9
|
+
paymentMethodId: string;
|
|
10
|
+
shopId: string;
|
|
11
|
+
shopPass: string;
|
|
12
|
+
}): Promise<GMO.factory.credit.ISearchTradeResult>;
|
|
13
|
+
export { searchGMOTrade };
|
|
@@ -0,0 +1,62 @@
|
|
|
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.searchGMOTrade = void 0;
|
|
13
|
+
const GMO = require("@motionpicture/gmo-service");
|
|
14
|
+
const credentials_1 = require("../../../credentials");
|
|
15
|
+
const factory = require("../../../factory");
|
|
16
|
+
const gmoError_1 = require("./gmoError");
|
|
17
|
+
/**
|
|
18
|
+
* 決済代行側の取引状態参照
|
|
19
|
+
* 存在しない場合NotFoundエラー
|
|
20
|
+
*/
|
|
21
|
+
function searchGMOTrade(params) {
|
|
22
|
+
var _a, _b;
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const creditCardService = new GMO.service.Credit({
|
|
25
|
+
endpoint: String(params.availableChannel.serviceUrl),
|
|
26
|
+
useFetch: credentials_1.credentials.gmo.useFetch
|
|
27
|
+
}, { timeout: credentials_1.credentials.gmo.timeout });
|
|
28
|
+
// 取引状態参照
|
|
29
|
+
let searchTradeResult;
|
|
30
|
+
try {
|
|
31
|
+
searchTradeResult = yield creditCardService.searchTrade({
|
|
32
|
+
shopId: params.shopId,
|
|
33
|
+
shopPass: params.shopPass,
|
|
34
|
+
orderId: params.paymentMethodId,
|
|
35
|
+
siteId: (_a = params.availableChannel.credentials) === null || _a === void 0 ? void 0 : _a.siteId,
|
|
36
|
+
sitePass: (_b = params.availableChannel.credentials) === null || _b === void 0 ? void 0 : _b.sitePass
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
// searchTradeでのエラーをハンドリング(2024-04-08~)
|
|
41
|
+
let throwsError = true;
|
|
42
|
+
if (error.name === 'GMOServiceBadRequestError') {
|
|
43
|
+
if (Array.isArray(error.errors) && error.errors.length > 0) {
|
|
44
|
+
const gmoErrors = error.errors;
|
|
45
|
+
// 指定されたIDとパスワードの取引が存在しません。
|
|
46
|
+
const notFoundErrorExists = gmoErrors.some(({ info }) => info === gmoError_1.GMOErrorInfo.TransactionNotFound);
|
|
47
|
+
if (notFoundErrorExists) {
|
|
48
|
+
throwsError = false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (throwsError) {
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (searchTradeResult === undefined) {
|
|
57
|
+
throw new factory.errors.NotFound('searchTradeResult');
|
|
58
|
+
}
|
|
59
|
+
return searchTradeResult;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
exports.searchGMOTrade = searchGMOTrade;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as factory from '../../../factory';
|
|
2
|
+
import type { MongoRepository as PaymentServiceRepo } from '../../../repo/paymentService';
|
|
3
|
+
import type { MongoRepository as PaymentServiceProviderRepo } from '../../../repo/paymentServiceProvider';
|
|
4
|
+
import type { MongoRepository as PaymentAcceptedRepo } from '../../../repo/sellerPaymentAccepted';
|
|
5
|
+
/**
|
|
6
|
+
* クレジットカード決済中止
|
|
7
|
+
*/
|
|
8
|
+
declare function voidTransaction(params: factory.task.voidPayment.IData): (repos: {
|
|
9
|
+
paymentAccepted: PaymentAcceptedRepo;
|
|
10
|
+
paymentService: PaymentServiceRepo;
|
|
11
|
+
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
12
|
+
}) => Promise<void>;
|
|
13
|
+
export { voidTransaction };
|