@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
|
@@ -1,644 +1,18 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.voidTransaction = exports.searchGMOTrade = exports.refundCreditCard = exports.payCreditCard = exports.authorize = exports.getGMOInfoFromSeller = void 0;
|
|
13
4
|
/**
|
|
14
5
|
* クレジットカード決済サービス
|
|
15
6
|
*/
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
var _a, _b, _c, _d, _e;
|
|
30
|
-
// CreditCard系統の決済方法タイプは動的
|
|
31
|
-
const paymentMethodType = (_a = params.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.identifier;
|
|
32
|
-
if (typeof paymentMethodType !== 'string') {
|
|
33
|
-
throw new factory.errors.ArgumentNull('object.paymentMethod.identifier');
|
|
34
|
-
}
|
|
35
|
-
const availableChannel = yield repos.paymentService.findAvailableChannel({
|
|
36
|
-
project: params.project,
|
|
37
|
-
typeOf: factory.service.paymentService.PaymentServiceType.CreditCard,
|
|
38
|
-
id: paymentServiceId
|
|
39
|
-
});
|
|
40
|
-
const sellerId = (_b = params.recipient) === null || _b === void 0 ? void 0 : _b.id;
|
|
41
|
-
if (typeof sellerId !== 'string') {
|
|
42
|
-
throw new factory.errors.ArgumentNull('recipient.id');
|
|
43
|
-
}
|
|
44
|
-
const { shopId, shopPass, returnUrls3ds, callbackType3ds } = yield getGMOInfoFromSeller({ paymentMethodType, seller: { id: sellerId }, paymentServiceId })(repos);
|
|
45
|
-
// GMOオーダーIDはカスタム指定可能
|
|
46
|
-
const orderId = params.transactionNumber;
|
|
47
|
-
if (typeof orderId !== 'string') {
|
|
48
|
-
throw new factory.errors.ArgumentNull('transactionNumber');
|
|
49
|
-
}
|
|
50
|
-
let authorizeResult;
|
|
51
|
-
try {
|
|
52
|
-
// タスクによって実行されているかどうか
|
|
53
|
-
const executedByTask = typeof ((_c = options.executor) === null || _c === void 0 ? void 0 : _c.id) === 'string' && options.executor.id !== '';
|
|
54
|
-
// 非同期承認時に長時間対応(2024-05-18~)
|
|
55
|
-
const timeout = (executedByTask && typeof credentials_1.credentials.gmo.timeoutBackground === 'number')
|
|
56
|
-
? credentials_1.credentials.gmo.timeoutBackground
|
|
57
|
-
: credentials_1.credentials.gmo.timeout;
|
|
58
|
-
debug('processAuthorizeCreditCard processing... executor:', (_d = options.executor) === null || _d === void 0 ? void 0 : _d.id, 'timeout:', timeout);
|
|
59
|
-
const creditCardService = new GMO.service.Credit({
|
|
60
|
-
endpoint: String(availableChannel.serviceUrl),
|
|
61
|
-
useFetch: credentials_1.credentials.gmo.useFetch
|
|
62
|
-
}, { timeout });
|
|
63
|
-
const pendingPaymentAgencyTransaction = options.pendingPaymentAgencyTransaction;
|
|
64
|
-
const redirectUrl = (_e = pendingPaymentAgencyTransaction === null || pendingPaymentAgencyTransaction === void 0 ? void 0 : pendingPaymentAgencyTransaction.execTranResult) === null || _e === void 0 ? void 0 : _e.redirectUrl;
|
|
65
|
-
if (pendingPaymentAgencyTransaction !== undefined
|
|
66
|
-
&& typeof redirectUrl === 'string' && redirectUrl.length > 0) {
|
|
67
|
-
authorizeResult = yield processAuthorizeCreditCard3ds({
|
|
68
|
-
availableChannel,
|
|
69
|
-
pendingPaymentAgencyTransaction
|
|
70
|
-
})({ creditCardService });
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
authorizeResult = yield processAuthorizeCreditCard({
|
|
74
|
-
shopId: shopId,
|
|
75
|
-
shopPass: shopPass,
|
|
76
|
-
returnUrls3ds,
|
|
77
|
-
callbackType3ds,
|
|
78
|
-
orderId: orderId,
|
|
79
|
-
availableChannel: availableChannel,
|
|
80
|
-
object: params.object.paymentMethod,
|
|
81
|
-
processPublishPaymentUrl: options.processPublishPaymentUrl
|
|
82
|
-
})({ creditCardService });
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
catch (error) {
|
|
86
|
-
// アクション保管用のエラーと両方throw(2024-03-27~)
|
|
87
|
-
throw [handleAuthorizeError(error), error];
|
|
88
|
-
// throw handleAuthorizeError(error);
|
|
89
|
-
}
|
|
90
|
-
// クレジットカード詳細情報取得廃止(2024-03-19~)
|
|
91
|
-
// const searchTrade4accountId = options?.searchTrade4accountId === true;
|
|
92
|
-
// if (searchTrade4accountId) {
|
|
93
|
-
// }
|
|
94
|
-
return Object.assign({ accountId: '', paymentMethodId: orderId, entryTranArgs: authorizeResult.entryTranArgs, entryTranResult: authorizeResult.entryTranResult, execTranArgs: authorizeResult.execTranArgs, execTranResult: authorizeResult.execTranResult }, (authorizeResult.secureTran2Result !== undefined) ? { secureTran2Result: authorizeResult.secureTran2Result } : undefined);
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
exports.authorize = authorize;
|
|
98
|
-
function processAuthorizeCreditCard(params) {
|
|
99
|
-
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
100
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
101
|
-
var _a, _b, _c, _d, _e, _f;
|
|
102
|
-
// GMOオーソリ取得
|
|
103
|
-
let entryTranArgs;
|
|
104
|
-
let entryTranResult;
|
|
105
|
-
let execTranArgs;
|
|
106
|
-
let execTranResult;
|
|
107
|
-
const creditCard = params.object.creditCard;
|
|
108
|
-
const { cardSeq, memberId } = creditCard;
|
|
109
|
-
if (typeof memberId === 'string' && memberId.length > 0 && typeof cardSeq === 'number') {
|
|
110
|
-
// 決済承認時のuseUsernameAsGMOMemberId判定を廃止(2024-01-04~)
|
|
111
|
-
}
|
|
112
|
-
const { cardNo, cardPass, expire } = creditCard;
|
|
113
|
-
const { token } = creditCard;
|
|
114
|
-
const retUrl = creditCard === null || creditCard === void 0 ? void 0 : creditCard.retUrl;
|
|
115
|
-
// 3DS拡張(2024-01-02~)
|
|
116
|
-
if (params.processPublishPaymentUrl === true && typeof retUrl === 'string' && retUrl.length > 0) {
|
|
117
|
-
let returnUrlObject;
|
|
118
|
-
try {
|
|
119
|
-
returnUrlObject = new URL(retUrl);
|
|
120
|
-
}
|
|
121
|
-
catch (error) {
|
|
122
|
-
throw new factory.errors.Argument('object.creditCard.retUrl', 'retUrl unparsable');
|
|
123
|
-
}
|
|
124
|
-
const returnUrlShouldBeIncluded = `${returnUrlObject.origin}${returnUrlObject.pathname}`;
|
|
125
|
-
if (!params.returnUrls3ds.includes(returnUrlShouldBeIncluded)) {
|
|
126
|
-
throw new factory.errors.Argument('object.creditCard.retUrl', 'invalid returnUrl');
|
|
127
|
-
}
|
|
128
|
-
entryTranArgs = {
|
|
129
|
-
shopId: params.shopId,
|
|
130
|
-
shopPass: params.shopPass,
|
|
131
|
-
orderId: params.orderId,
|
|
132
|
-
jobCd: GMO.utils.util.JobCd.Auth,
|
|
133
|
-
amount: (typeof params.object.amount === 'number')
|
|
134
|
-
? params.object.amount
|
|
135
|
-
: params.object.amount.value,
|
|
136
|
-
// siteId: params.availableChannel.credentials?.siteId,
|
|
137
|
-
// sitePass: params.availableChannel.credentials?.sitePass,
|
|
138
|
-
tdFlag: GMO.utils.util.TdFlag.Version2,
|
|
139
|
-
// tdTenantName: '',
|
|
140
|
-
tds2Type: GMO.utils.util.Tds2Type.Error
|
|
141
|
-
};
|
|
142
|
-
entryTranResult = yield repos.creditCardService.entryTran(entryTranArgs);
|
|
143
|
-
execTranArgs = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ accessId: entryTranResult.accessId, accessPass: entryTranResult.accessPass, orderId: params.orderId, method: params.object.method, siteId: (_a = params.availableChannel.credentials) === null || _a === void 0 ? void 0 : _a.siteId, sitePass: (_b = params.availableChannel.credentials) === null || _b === void 0 ? void 0 : _b.sitePass, seqMode: GMO.utils.util.SeqMode.Physics, retUrl, callbackType: (params.callbackType3ds === 'GET') ? GMO.utils.util.CallbackType.Get : GMO.utils.util.CallbackType.Post }, (typeof cardNo === 'string') ? { cardNo } : undefined), (typeof cardPass === 'string') ? { cardPass } : undefined), (typeof expire === 'string') ? { expire } : undefined), (typeof token === 'string') ? { token } : undefined), (typeof memberId === 'string') ? { memberId } : undefined), (typeof cardSeq === 'number') ? { cardSeq } : undefined);
|
|
144
|
-
execTranResult = yield repos.creditCardService.execTran3ds(execTranArgs);
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
entryTranArgs = {
|
|
148
|
-
shopId: params.shopId,
|
|
149
|
-
shopPass: params.shopPass,
|
|
150
|
-
orderId: params.orderId,
|
|
151
|
-
jobCd: GMO.utils.util.JobCd.Auth,
|
|
152
|
-
amount: (typeof params.object.amount === 'number')
|
|
153
|
-
? params.object.amount
|
|
154
|
-
: params.object.amount.value,
|
|
155
|
-
siteId: (_c = params.availableChannel.credentials) === null || _c === void 0 ? void 0 : _c.siteId,
|
|
156
|
-
sitePass: (_d = params.availableChannel.credentials) === null || _d === void 0 ? void 0 : _d.sitePass
|
|
157
|
-
};
|
|
158
|
-
entryTranResult = yield repos.creditCardService.entryTran(entryTranArgs);
|
|
159
|
-
execTranArgs = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ accessId: entryTranResult.accessId, accessPass: entryTranResult.accessPass, orderId: params.orderId, method: params.object.method, siteId: (_e = params.availableChannel.credentials) === null || _e === void 0 ? void 0 : _e.siteId, sitePass: (_f = params.availableChannel.credentials) === null || _f === void 0 ? void 0 : _f.sitePass, seqMode: GMO.utils.util.SeqMode.Physics }, (typeof cardNo === 'string') ? { cardNo } : undefined), (typeof cardPass === 'string') ? { cardPass } : undefined), (typeof expire === 'string') ? { expire } : undefined), (typeof token === 'string') ? { token } : undefined), (typeof memberId === 'string') ? { memberId } : undefined), (typeof cardSeq === 'number') ? { cardSeq } : undefined);
|
|
160
|
-
execTranResult = yield repos.creditCardService.execTran(execTranArgs);
|
|
161
|
-
}
|
|
162
|
-
return { entryTranArgs, entryTranResult, execTranArgs, execTranResult };
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
function processAuthorizeCreditCard3ds(params) {
|
|
166
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
167
|
-
const { entryTranArgs, entryTranResult, execTranArgs, execTranResult } = params.pendingPaymentAgencyTransaction;
|
|
168
|
-
const { accessId, accessPass } = entryTranResult;
|
|
169
|
-
const secureTran2Result = yield repos.creditCardService.secureTran2({ accessId, accessPass });
|
|
170
|
-
return { entryTranArgs, entryTranResult, execTranArgs, execTranResult, secureTran2Result };
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
var GMOErrorInfo;
|
|
174
|
-
(function (GMOErrorInfo) {
|
|
175
|
-
GMOErrorInfo["TransactionNotFound"] = "E01110002";
|
|
176
|
-
})(GMOErrorInfo || (GMOErrorInfo = {}));
|
|
177
|
-
function handleAuthorizeError(error) {
|
|
178
|
-
debug('handling creditCard authorizeError:', error);
|
|
179
|
-
let handledError = error;
|
|
180
|
-
if (error.name === 'GMOServiceBadRequestError') {
|
|
181
|
-
if (Array.isArray(error.errors) && error.errors.length > 0) {
|
|
182
|
-
const gmoErrors = error.errors;
|
|
183
|
-
// 流量制限オーバーエラーの場合
|
|
184
|
-
const serviceUnavailableError = gmoErrors.find((gmoError) => { var _a; return (_a = gmoError.info) === null || _a === void 0 ? void 0 : _a.match(/^E92000001|E92000002$/); });
|
|
185
|
-
// オーダーID重複エラーの場合
|
|
186
|
-
const duplicateError = gmoErrors.find((gmoError) => { var _a; return (_a = gmoError.info) === null || _a === void 0 ? void 0 : _a.match(/^E01040010$/); });
|
|
187
|
-
if (serviceUnavailableError !== undefined) {
|
|
188
|
-
handledError = new factory.errors.RateLimitExceeded(serviceUnavailableError.userMessage);
|
|
189
|
-
}
|
|
190
|
-
else if (duplicateError !== undefined) {
|
|
191
|
-
handledError = new factory.errors.AlreadyInUse('payment', ['orderId'], duplicateError.userMessage);
|
|
192
|
-
}
|
|
193
|
-
else {
|
|
194
|
-
const userMessages = gmoErrors.map((gmoError) => gmoError.userMessage)
|
|
195
|
-
.join(',');
|
|
196
|
-
handledError = new factory.errors.Argument('payment', userMessages);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
else {
|
|
200
|
-
// その他の場合、なんらかのクライアントエラー
|
|
201
|
-
handledError = new factory.errors.Argument('payment', 'unexpected bad request');
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
else if (error.name === 'RequestError') {
|
|
205
|
-
// タイムアウト設定によって中止されたリクエストの場合
|
|
206
|
-
// const uri: string | undefined = error.requestOptions?.uri;
|
|
207
|
-
handledError = new factory.errors.GatewayTimeout(`Gateway Timeout. name:${error.name} type:${error.type} message:${error.message}`);
|
|
208
|
-
}
|
|
209
|
-
else if (error.name === 'AbortError') {
|
|
210
|
-
// タイムアウト設定によって中止されたリクエストの場合
|
|
211
|
-
// AbortErrorハンドリング(2024-03-27~)
|
|
212
|
-
// {
|
|
213
|
-
// "type": "aborted",
|
|
214
|
-
// "message": "The user aborted a request.",
|
|
215
|
-
// "name": "AbortError"
|
|
216
|
-
// }
|
|
217
|
-
handledError = new factory.errors.GatewayTimeout(`Gateway Timeout. name:${error.name} type:${error.type} message:${error.message}`);
|
|
218
|
-
}
|
|
219
|
-
// 決済代行側が4xxを返却した場合
|
|
220
|
-
if (typeof error.code === 'number' && error.code < http_status_1.INTERNAL_SERVER_ERROR) {
|
|
221
|
-
handledError = new factory.errors.Argument('payment', `bad request code:${error.code} message:${error.message}`);
|
|
222
|
-
}
|
|
223
|
-
return handledError;
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* クレジットカード決済中止
|
|
227
|
-
*/
|
|
228
|
-
function voidTransaction(params) {
|
|
229
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
230
|
-
var _a, _b, _c, _d, _e, _f;
|
|
231
|
-
const transaction = params.object;
|
|
232
|
-
// CreditCard系統の決済方法タイプは動的
|
|
233
|
-
const paymentMethodType = (_a = transaction.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.identifier;
|
|
234
|
-
if (typeof paymentMethodType !== 'string') {
|
|
235
|
-
throw new factory.errors.ArgumentNull('object.paymentMethod.identifier');
|
|
236
|
-
}
|
|
237
|
-
const paymentMethodId = transaction.object.paymentMethodId;
|
|
238
|
-
if (typeof paymentMethodId !== 'string') {
|
|
239
|
-
throw new factory.errors.ArgumentNull('object.paymentMethodId');
|
|
240
|
-
}
|
|
241
|
-
const paymentServiceId = String(transaction.object.id);
|
|
242
|
-
const availableChannel = yield repos.paymentService.findAvailableChannel({
|
|
243
|
-
project: transaction.project,
|
|
244
|
-
typeOf: factory.service.paymentService.PaymentServiceType.CreditCard,
|
|
245
|
-
id: paymentServiceId
|
|
246
|
-
});
|
|
247
|
-
const sellerId = (_b = transaction.recipient) === null || _b === void 0 ? void 0 : _b.id;
|
|
248
|
-
if (typeof sellerId !== 'string') {
|
|
249
|
-
throw new factory.errors.ArgumentNull('object.recipient.id');
|
|
250
|
-
}
|
|
251
|
-
const { shopId, shopPass } = yield getGMOInfoFromSeller({ paymentMethodType, seller: { id: sellerId }, paymentServiceId })(repos);
|
|
252
|
-
const creditCardService = new GMO.service.Credit({
|
|
253
|
-
endpoint: String(availableChannel.serviceUrl),
|
|
254
|
-
useFetch: credentials_1.credentials.gmo.useFetch
|
|
255
|
-
}, { timeout: credentials_1.credentials.gmo.timeout });
|
|
256
|
-
let searchTradeResult;
|
|
257
|
-
try {
|
|
258
|
-
searchTradeResult = yield creditCardService.searchTrade({
|
|
259
|
-
shopId: shopId,
|
|
260
|
-
shopPass: shopPass,
|
|
261
|
-
orderId: paymentMethodId,
|
|
262
|
-
siteId: (_c = availableChannel.credentials) === null || _c === void 0 ? void 0 : _c.siteId,
|
|
263
|
-
sitePass: (_d = availableChannel.credentials) === null || _d === void 0 ? void 0 : _d.sitePass
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
catch (error) {
|
|
267
|
-
// searchTradeでのエラーをハンドリング(2024-01-27~)
|
|
268
|
-
let throwsError = true;
|
|
269
|
-
if (error.name === 'GMOServiceBadRequestError') {
|
|
270
|
-
if (Array.isArray(error.errors) && error.errors.length > 0) {
|
|
271
|
-
const gmoErrors = error.errors;
|
|
272
|
-
// 指定されたIDとパスワードの取引が存在しません。
|
|
273
|
-
const notFoundErrorExists = gmoErrors.some(({ info }) => info === GMOErrorInfo.TransactionNotFound);
|
|
274
|
-
if (notFoundErrorExists) {
|
|
275
|
-
throwsError = false;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
if (throwsError) {
|
|
280
|
-
throw error;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
// 仮売上であれば取消
|
|
284
|
-
if ((searchTradeResult === null || searchTradeResult === void 0 ? void 0 : searchTradeResult.status) === GMO.utils.util.JobCd.Auth) {
|
|
285
|
-
yield creditCardService.alterTran({
|
|
286
|
-
shopId: shopId,
|
|
287
|
-
shopPass: shopPass,
|
|
288
|
-
accessId: searchTradeResult.accessId,
|
|
289
|
-
accessPass: searchTradeResult.accessPass,
|
|
290
|
-
jobCd: GMO.utils.util.JobCd.Void,
|
|
291
|
-
siteId: (_e = availableChannel.credentials) === null || _e === void 0 ? void 0 : _e.siteId,
|
|
292
|
-
sitePass: (_f = availableChannel.credentials) === null || _f === void 0 ? void 0 : _f.sitePass
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
exports.voidTransaction = voidTransaction;
|
|
298
|
-
/**
|
|
299
|
-
* クレジットカード決済
|
|
300
|
-
*/
|
|
301
|
-
function payCreditCard(params) {
|
|
302
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
303
|
-
var _a;
|
|
304
|
-
const payObject = params.object;
|
|
305
|
-
// CreditCard系統の決済方法タイプは動的
|
|
306
|
-
const paymentMethodType = payObject[0].paymentMethod.typeOf;
|
|
307
|
-
if (typeof paymentMethodType !== 'string') {
|
|
308
|
-
throw new factory.errors.ArgumentNull('object.paymentMethod.typeOf');
|
|
309
|
-
}
|
|
310
|
-
const paymentServiceId = payObject[0].id;
|
|
311
|
-
const availableChannel = yield repos.paymentService.findAvailableChannel({
|
|
312
|
-
project: params.project,
|
|
313
|
-
typeOf: factory.service.paymentService.PaymentServiceType.CreditCard,
|
|
314
|
-
id: paymentServiceId
|
|
315
|
-
});
|
|
316
|
-
const sellerId = (_a = params.recipient) === null || _a === void 0 ? void 0 : _a.id;
|
|
317
|
-
if (typeof sellerId !== 'string') {
|
|
318
|
-
throw new factory.errors.ArgumentNull('recipient.id');
|
|
319
|
-
}
|
|
320
|
-
const { shopId, shopPass } = yield getGMOInfoFromSeller({ paymentMethodType, seller: { id: sellerId }, paymentServiceId })(repos);
|
|
321
|
-
// アクション開始
|
|
322
|
-
let action = yield repos.action.start(params);
|
|
323
|
-
const alterTranResults = [];
|
|
324
|
-
try {
|
|
325
|
-
const creditCardService = new GMO.service.Credit({
|
|
326
|
-
endpoint: String(availableChannel.serviceUrl),
|
|
327
|
-
useFetch: credentials_1.credentials.gmo.useFetch
|
|
328
|
-
}, { timeout: credentials_1.credentials.gmo.timeout });
|
|
329
|
-
yield Promise.all(payObject.map((paymentMethod) => __awaiter(this, void 0, void 0, function* () {
|
|
330
|
-
alterTranResults.push(...yield processAlterTran({ shopId, shopPass, availableChannel, paymentMethod })({ creditCardService }));
|
|
331
|
-
})));
|
|
332
|
-
}
|
|
333
|
-
catch (error) {
|
|
334
|
-
try {
|
|
335
|
-
yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error });
|
|
336
|
-
}
|
|
337
|
-
catch (__) {
|
|
338
|
-
// 失敗したら仕方ない
|
|
339
|
-
}
|
|
340
|
-
throw error;
|
|
341
|
-
}
|
|
342
|
-
// アクション完了
|
|
343
|
-
const actionResult = {
|
|
344
|
-
creditCardSales: alterTranResults
|
|
345
|
-
};
|
|
346
|
-
action = (yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult }));
|
|
347
|
-
yield (0, onPaid_1.onPaid)(action)(repos);
|
|
348
|
-
return action;
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
|
-
exports.payCreditCard = payCreditCard;
|
|
352
|
-
function processAlterTran(params) {
|
|
353
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
354
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
355
|
-
const alterTranResults = [];
|
|
356
|
-
const paymentMethod = params.paymentMethod;
|
|
357
|
-
const orderId = paymentMethod.paymentMethod.paymentMethodId;
|
|
358
|
-
// 取引状態参照
|
|
359
|
-
const searchTradeResult = yield repos.creditCardService.searchTrade({
|
|
360
|
-
shopId: params.shopId,
|
|
361
|
-
shopPass: params.shopPass,
|
|
362
|
-
orderId: orderId,
|
|
363
|
-
siteId: (_a = params.availableChannel.credentials) === null || _a === void 0 ? void 0 : _a.siteId,
|
|
364
|
-
sitePass: (_b = params.availableChannel.credentials) === null || _b === void 0 ? void 0 : _b.sitePass
|
|
365
|
-
});
|
|
366
|
-
const amount = (_c = paymentMethod.paymentMethod.totalPaymentDue) === null || _c === void 0 ? void 0 : _c.value;
|
|
367
|
-
if (typeof amount !== 'number') {
|
|
368
|
-
throw new factory.errors.ArgumentNull('object.paymentMethod.totalPaymentDue?.value');
|
|
369
|
-
}
|
|
370
|
-
switch (searchTradeResult.jobCd) {
|
|
371
|
-
case GMO.utils.util.JobCd.Capture:
|
|
372
|
-
case GMO.utils.util.JobCd.Sales:
|
|
373
|
-
debug('already in SALES');
|
|
374
|
-
// すでに即時売上済み
|
|
375
|
-
alterTranResults.push({
|
|
376
|
-
accessId: searchTradeResult.accessId,
|
|
377
|
-
accessPass: searchTradeResult.accessPass,
|
|
378
|
-
forward: searchTradeResult.forward,
|
|
379
|
-
approve: searchTradeResult.approve,
|
|
380
|
-
tranId: searchTradeResult.tranId,
|
|
381
|
-
tranDate: ''
|
|
382
|
-
});
|
|
383
|
-
break;
|
|
384
|
-
case GMO.utils.util.JobCd.Void:
|
|
385
|
-
// 返品手数料決済の場合を追加(状態が取消であれば即時売上)
|
|
386
|
-
debug('calling alterTran...');
|
|
387
|
-
alterTranResults.push(yield repos.creditCardService.alterTran({
|
|
388
|
-
shopId: params.shopId,
|
|
389
|
-
shopPass: params.shopPass,
|
|
390
|
-
accessId: searchTradeResult.accessId,
|
|
391
|
-
accessPass: searchTradeResult.accessPass,
|
|
392
|
-
jobCd: GMO.utils.util.JobCd.Capture,
|
|
393
|
-
amount: amount,
|
|
394
|
-
siteId: (_d = params.availableChannel.credentials) === null || _d === void 0 ? void 0 : _d.siteId,
|
|
395
|
-
sitePass: (_e = params.availableChannel.credentials) === null || _e === void 0 ? void 0 : _e.sitePass,
|
|
396
|
-
method: GMO.utils.util.Method.Lump // 再オーソリの場合、支払方法指定は必須
|
|
397
|
-
}));
|
|
398
|
-
debug('alterTran processed.');
|
|
399
|
-
break;
|
|
400
|
-
case GMO.utils.util.JobCd.Auth:
|
|
401
|
-
debug('calling alterTran...');
|
|
402
|
-
alterTranResults.push(yield repos.creditCardService.alterTran({
|
|
403
|
-
shopId: params.shopId,
|
|
404
|
-
shopPass: params.shopPass,
|
|
405
|
-
accessId: searchTradeResult.accessId,
|
|
406
|
-
accessPass: searchTradeResult.accessPass,
|
|
407
|
-
jobCd: GMO.utils.util.JobCd.Sales,
|
|
408
|
-
amount: amount,
|
|
409
|
-
siteId: (_f = params.availableChannel.credentials) === null || _f === void 0 ? void 0 : _f.siteId,
|
|
410
|
-
sitePass: (_g = params.availableChannel.credentials) === null || _g === void 0 ? void 0 : _g.sitePass
|
|
411
|
-
}));
|
|
412
|
-
// 失敗したら取引状態確認してどうこう、という処理も考えうるが、
|
|
413
|
-
// GMOはapiのコール制限が厳しく、下手にコールするとすぐにクライアントサイドにも影響をあたえてしまう
|
|
414
|
-
// リトライはタスクの仕組みに含まれているので失敗してもここでは何もしない
|
|
415
|
-
break;
|
|
416
|
-
default:
|
|
417
|
-
throw new factory.errors.NotImplemented(`jobCd '${searchTradeResult.jobCd}' not implemented`);
|
|
418
|
-
}
|
|
419
|
-
return alterTranResults;
|
|
420
|
-
});
|
|
421
|
-
}
|
|
422
|
-
/**
|
|
423
|
-
* クレジットカード返金
|
|
424
|
-
*/
|
|
425
|
-
function refundCreditCard(params, options) {
|
|
426
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
427
|
-
var _a, _b, _c, _d, _e, _f;
|
|
428
|
-
const paymentMethodType = (_a = params.object[0]) === null || _a === void 0 ? void 0 : _a.paymentMethod.typeOf;
|
|
429
|
-
const paymentMethodId = (_b = params.object[0]) === null || _b === void 0 ? void 0 : _b.paymentMethod.paymentMethodId;
|
|
430
|
-
const paymentServiceId = (_c = params.object[0]) === null || _c === void 0 ? void 0 : _c.id;
|
|
431
|
-
// 本アクションに対応するPayActionを取り出す(Cinerino側で決済していた時期に関してはpayActionが存在しないので注意)
|
|
432
|
-
let payAction;
|
|
433
|
-
if (options.requirePayAction) {
|
|
434
|
-
payAction = yield repos.action.findPayAction({ project: { id: params.project.id }, paymentMethodId });
|
|
435
|
-
if (payAction === undefined) {
|
|
436
|
-
throw new factory.errors.NotFound('PayAction');
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
const sellerId = (_d = params.agent) === null || _d === void 0 ? void 0 : _d.id;
|
|
440
|
-
if (typeof sellerId !== 'string') {
|
|
441
|
-
throw new factory.errors.ArgumentNull('agent.id');
|
|
442
|
-
}
|
|
443
|
-
const { shopId, shopPass } = yield getGMOInfoFromSeller({ paymentMethodType, seller: { id: sellerId }, paymentServiceId })(repos);
|
|
444
|
-
const availableChannel = yield repos.paymentService.findAvailableChannel({
|
|
445
|
-
project: params.project,
|
|
446
|
-
typeOf: factory.service.paymentService.PaymentServiceType.CreditCard,
|
|
447
|
-
id: paymentServiceId
|
|
448
|
-
});
|
|
449
|
-
let action = yield repos.action.start(Object.assign(Object.assign({}, params), (typeof ((_e = params.sameAs) === null || _e === void 0 ? void 0 : _e.id) === 'string')
|
|
450
|
-
? {
|
|
451
|
-
sameAs: {
|
|
452
|
-
id: params.sameAs.id,
|
|
453
|
-
typeOf: 'Task'
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
: undefined));
|
|
457
|
-
let alterTranResult = [];
|
|
458
|
-
try {
|
|
459
|
-
alterTranResult = yield processChangeTransaction({
|
|
460
|
-
availableChannel,
|
|
461
|
-
payAction: payAction,
|
|
462
|
-
paymentMethodId: paymentMethodId,
|
|
463
|
-
shopId: shopId,
|
|
464
|
-
shopPass: shopPass,
|
|
465
|
-
refundFee: (_f = params.object[0]) === null || _f === void 0 ? void 0 : _f.refundFee
|
|
466
|
-
});
|
|
467
|
-
}
|
|
468
|
-
catch (error) {
|
|
469
|
-
try {
|
|
470
|
-
yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error });
|
|
471
|
-
}
|
|
472
|
-
catch (__) {
|
|
473
|
-
// no op
|
|
474
|
-
}
|
|
475
|
-
throw error;
|
|
476
|
-
}
|
|
477
|
-
const actionResult = { alterTranResult };
|
|
478
|
-
action = (yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult }));
|
|
479
|
-
yield (0, onRefund_1.onRefund)(action)(repos);
|
|
480
|
-
return action;
|
|
481
|
-
});
|
|
482
|
-
}
|
|
483
|
-
exports.refundCreditCard = refundCreditCard;
|
|
484
|
-
function processChangeTransaction(params) {
|
|
485
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
486
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
487
|
-
const alterTranResult = [];
|
|
488
|
-
const creditCardService = new GMO.service.Credit({
|
|
489
|
-
endpoint: String(params.availableChannel.serviceUrl),
|
|
490
|
-
useFetch: credentials_1.credentials.gmo.useFetch
|
|
491
|
-
}, { timeout: credentials_1.credentials.gmo.timeout });
|
|
492
|
-
// 取引状態参照
|
|
493
|
-
const searchTradeResult = yield creditCardService.searchTrade({
|
|
494
|
-
shopId: params.shopId,
|
|
495
|
-
shopPass: params.shopPass,
|
|
496
|
-
orderId: params.paymentMethodId,
|
|
497
|
-
siteId: (_a = params.availableChannel.credentials) === null || _a === void 0 ? void 0 : _a.siteId,
|
|
498
|
-
sitePass: (_b = params.availableChannel.credentials) === null || _b === void 0 ? void 0 : _b.sitePass
|
|
499
|
-
});
|
|
500
|
-
// 冪等性の担保をいったん保留
|
|
501
|
-
let creditCardSalesBefore;
|
|
502
|
-
if (Array.isArray((_d = (_c = params.payAction) === null || _c === void 0 ? void 0 : _c.result) === null || _d === void 0 ? void 0 : _d.creditCardSales)) {
|
|
503
|
-
creditCardSalesBefore = (_f = (_e = params.payAction) === null || _e === void 0 ? void 0 : _e.result) === null || _f === void 0 ? void 0 : _f.creditCardSales[0];
|
|
504
|
-
}
|
|
505
|
-
let alreadyRefunded = false;
|
|
506
|
-
// 決済時のGMO取引を確認できれば、既に返金済かどうかを判定
|
|
507
|
-
if (typeof (creditCardSalesBefore === null || creditCardSalesBefore === void 0 ? void 0 : creditCardSalesBefore.tranId) === 'string') {
|
|
508
|
-
// GMO取引状態に変更がなければ金額変更
|
|
509
|
-
if (searchTradeResult.tranId !== creditCardSalesBefore.tranId) {
|
|
510
|
-
alreadyRefunded = true;
|
|
511
|
-
}
|
|
512
|
-
// tranIdが空文字のケース(SPSwrapperで発生)に対応(Voidに対してVoidを実行してしまうので)(2024-04-20~)
|
|
513
|
-
if (searchTradeResult.tranId === '' && creditCardSalesBefore.tranId === '') {
|
|
514
|
-
if (searchTradeResult.status === GMO.utils.util.Status.Void) {
|
|
515
|
-
alreadyRefunded = true;
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
if (alreadyRefunded) {
|
|
520
|
-
alterTranResult.push({
|
|
521
|
-
accessId: searchTradeResult.accessId,
|
|
522
|
-
accessPass: searchTradeResult.accessPass,
|
|
523
|
-
forward: searchTradeResult.forward,
|
|
524
|
-
approve: searchTradeResult.approve,
|
|
525
|
-
tranId: searchTradeResult.tranId,
|
|
526
|
-
tranDate: ''
|
|
527
|
-
});
|
|
528
|
-
}
|
|
529
|
-
else {
|
|
530
|
-
try {
|
|
531
|
-
// 手数料決済については、取消→即時売上の流れ
|
|
532
|
-
debug('alterTran processing... searchTradeResult:', searchTradeResult);
|
|
533
|
-
alterTranResult.push(yield creditCardService.alterTran({
|
|
534
|
-
shopId: params.shopId,
|
|
535
|
-
shopPass: params.shopPass,
|
|
536
|
-
accessId: searchTradeResult.accessId,
|
|
537
|
-
accessPass: searchTradeResult.accessPass,
|
|
538
|
-
jobCd: GMO.utils.util.JobCd.Void,
|
|
539
|
-
siteId: (_g = params.availableChannel.credentials) === null || _g === void 0 ? void 0 : _g.siteId,
|
|
540
|
-
sitePass: (_h = params.availableChannel.credentials) === null || _h === void 0 ? void 0 : _h.sitePass
|
|
541
|
-
}));
|
|
542
|
-
debug('alterTran processed.');
|
|
543
|
-
}
|
|
544
|
-
catch (error) {
|
|
545
|
-
let throwsError = true;
|
|
546
|
-
// 未決済(3D 登録済)->取消をトライするとE01050004エラーとなるが、この場合何もする必要はない(2024-01-09~)
|
|
547
|
-
if (error.name === 'GMOServiceBadRequestError') {
|
|
548
|
-
// 会員が存在しない場合このエラーになる
|
|
549
|
-
if (Array.isArray(error.errors) && error.errors.length === 1 && error.errors[0].info === 'E01050004') {
|
|
550
|
-
debug('creditCardService.alterTran:E01050004:', 'orderId:', searchTradeResult.orderId, 'status:', searchTradeResult.status);
|
|
551
|
-
if (searchTradeResult.status === GMO.utils.util.Status.Authenticated
|
|
552
|
-
|| searchTradeResult.status === GMO.utils.util.Status.Void) {
|
|
553
|
-
throwsError = false;
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
if (throwsError) {
|
|
558
|
-
throw error;
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
return alterTranResult;
|
|
563
|
-
});
|
|
564
|
-
}
|
|
565
|
-
function getGMOInfoFromSeller(params) {
|
|
566
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
567
|
-
var _a, _b, _c, _d;
|
|
568
|
-
const paymentAccepted = yield repos.paymentAccepted.isAcceptedBySeller({
|
|
569
|
-
seller: { id: params.seller.id },
|
|
570
|
-
codeValue: params.paymentMethodType
|
|
571
|
-
});
|
|
572
|
-
if (paymentAccepted !== true) {
|
|
573
|
-
throw new factory.errors.Argument('transaction', `payment not accepted [${params.paymentMethodType}]`);
|
|
574
|
-
}
|
|
575
|
-
// 決済サービスからcredentialsを取得する
|
|
576
|
-
const paymentServices = yield repos.paymentServiceProvider.search({
|
|
577
|
-
limit: 1,
|
|
578
|
-
page: 1,
|
|
579
|
-
provider: { id: { $eq: params.seller.id } },
|
|
580
|
-
id: { $eq: params.paymentServiceId }
|
|
581
|
-
});
|
|
582
|
-
const paymentService = paymentServices.shift();
|
|
583
|
-
if (paymentService === undefined) {
|
|
584
|
-
throw new factory.errors.NotFound('PaymentService');
|
|
585
|
-
}
|
|
586
|
-
const provider = paymentService.provider;
|
|
587
|
-
const shopId = (_a = provider.credentials) === null || _a === void 0 ? void 0 : _a.shopId;
|
|
588
|
-
const shopPass = (_b = provider.credentials) === null || _b === void 0 ? void 0 : _b.shopPass;
|
|
589
|
-
if (typeof shopId !== 'string' || typeof shopPass !== 'string') {
|
|
590
|
-
throw new factory.errors.Argument('transaction', 'Provider credentials not enough');
|
|
591
|
-
}
|
|
592
|
-
const returnUrls3dsSetting = (_c = provider.credentials) === null || _c === void 0 ? void 0 : _c.returnUrls3ds;
|
|
593
|
-
const returnUrls3ds = (Array.isArray(returnUrls3dsSetting)) ? returnUrls3dsSetting : [];
|
|
594
|
-
const callbackType3ds = (_d = provider.credentials) === null || _d === void 0 ? void 0 : _d.callbackType3ds;
|
|
595
|
-
return { shopId, shopPass, returnUrls3ds, callbackType3ds };
|
|
596
|
-
});
|
|
597
|
-
}
|
|
598
|
-
exports.getGMOInfoFromSeller = getGMOInfoFromSeller;
|
|
599
|
-
/**
|
|
600
|
-
* 決済代行側の取引状態参照
|
|
601
|
-
* 存在しない場合NotFoundエラー
|
|
602
|
-
*/
|
|
603
|
-
function searchGMOTrade(params) {
|
|
604
|
-
var _a, _b;
|
|
605
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
606
|
-
const creditCardService = new GMO.service.Credit({
|
|
607
|
-
endpoint: String(params.availableChannel.serviceUrl),
|
|
608
|
-
useFetch: credentials_1.credentials.gmo.useFetch
|
|
609
|
-
}, { timeout: credentials_1.credentials.gmo.timeout });
|
|
610
|
-
// 取引状態参照
|
|
611
|
-
let searchTradeResult;
|
|
612
|
-
try {
|
|
613
|
-
searchTradeResult = yield creditCardService.searchTrade({
|
|
614
|
-
shopId: params.shopId,
|
|
615
|
-
shopPass: params.shopPass,
|
|
616
|
-
orderId: params.paymentMethodId,
|
|
617
|
-
siteId: (_a = params.availableChannel.credentials) === null || _a === void 0 ? void 0 : _a.siteId,
|
|
618
|
-
sitePass: (_b = params.availableChannel.credentials) === null || _b === void 0 ? void 0 : _b.sitePass
|
|
619
|
-
});
|
|
620
|
-
}
|
|
621
|
-
catch (error) {
|
|
622
|
-
// searchTradeでのエラーをハンドリング(2024-04-08~)
|
|
623
|
-
let throwsError = true;
|
|
624
|
-
if (error.name === 'GMOServiceBadRequestError') {
|
|
625
|
-
if (Array.isArray(error.errors) && error.errors.length > 0) {
|
|
626
|
-
const gmoErrors = error.errors;
|
|
627
|
-
// 指定されたIDとパスワードの取引が存在しません。
|
|
628
|
-
const notFoundErrorExists = gmoErrors.some(({ info }) => info === GMOErrorInfo.TransactionNotFound);
|
|
629
|
-
if (notFoundErrorExists) {
|
|
630
|
-
throwsError = false;
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
if (throwsError) {
|
|
635
|
-
throw error;
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
if (searchTradeResult === undefined) {
|
|
639
|
-
throw new factory.errors.NotFound('searchTradeResult');
|
|
640
|
-
}
|
|
641
|
-
return searchTradeResult;
|
|
642
|
-
});
|
|
643
|
-
}
|
|
644
|
-
exports.searchGMOTrade = searchGMOTrade;
|
|
7
|
+
const authorize_1 = require("./creditCard/authorize");
|
|
8
|
+
Object.defineProperty(exports, "authorize", { enumerable: true, get: function () { return authorize_1.authorize; } });
|
|
9
|
+
const getGMOInfoFromSeller_1 = require("./creditCard/getGMOInfoFromSeller");
|
|
10
|
+
Object.defineProperty(exports, "getGMOInfoFromSeller", { enumerable: true, get: function () { return getGMOInfoFromSeller_1.getGMOInfoFromSeller; } });
|
|
11
|
+
const payCreditCard_1 = require("./creditCard/payCreditCard");
|
|
12
|
+
Object.defineProperty(exports, "payCreditCard", { enumerable: true, get: function () { return payCreditCard_1.payCreditCard; } });
|
|
13
|
+
const refundCreditCard_1 = require("./creditCard/refundCreditCard");
|
|
14
|
+
Object.defineProperty(exports, "refundCreditCard", { enumerable: true, get: function () { return refundCreditCard_1.refundCreditCard; } });
|
|
15
|
+
const searchGMOTrade_1 = require("./creditCard/searchGMOTrade");
|
|
16
|
+
Object.defineProperty(exports, "searchGMOTrade", { enumerable: true, get: function () { return searchGMOTrade_1.searchGMOTrade; } });
|
|
17
|
+
const voidTransaction_1 = require("./creditCard/voidTransaction");
|
|
18
|
+
Object.defineProperty(exports, "voidTransaction", { enumerable: true, get: function () { return voidTransaction_1.voidTransaction; } });
|
|
@@ -9,7 +9,7 @@ import type { MongoRepository as TaskRepo } from '../../repo/task';
|
|
|
9
9
|
declare function voidTransaction(__: factory.task.voidPayment.IData): (___: {
|
|
10
10
|
product: ProductRepo;
|
|
11
11
|
}) => Promise<void>;
|
|
12
|
-
declare function payFaceToFace(params: factory.
|
|
12
|
+
declare function payFaceToFace(params: factory.action.trade.pay.IAttributes): (repos: {
|
|
13
13
|
action: ActionRepo;
|
|
14
14
|
accountingReport: AccountingReportRepo;
|
|
15
15
|
product: ProductRepo;
|