@chevre/domain 21.20.0-alpha.0 → 21.20.0-alpha.2
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/transaction/processPlaceOrder.ts +72 -8
- package/lib/chevre/service/assetTransaction/pay.d.ts +3 -1
- package/lib/chevre/service/assetTransaction/pay.js +24 -18
- package/lib/chevre/service/payment/any.js +11 -9
- package/lib/chevre/service/payment/creditCard.d.ts +17 -16
- package/lib/chevre/service/payment/creditCard.js +105 -55
- package/package.json +3 -3
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
// tslint:disable:no-console
|
|
2
2
|
import * as mongoose from 'mongoose';
|
|
3
|
+
import * as readline from 'readline';
|
|
3
4
|
import * as redis from 'redis';
|
|
4
5
|
|
|
5
6
|
import { chevre } from '../../../../lib/index';
|
|
6
7
|
|
|
7
8
|
const project = { id: String(process.env.PROJECT_ID) };
|
|
8
9
|
const CLIENT_ID = '51qbjcfr72h62m06vtv5kkhgje';
|
|
10
|
+
const paymentMethodType = 'CreditCard';
|
|
11
|
+
const paymentServiceId = '5f9a4fed4f3709000abe6415';
|
|
12
|
+
// const paymentMethodType = 'PayPay';
|
|
13
|
+
// const paymentServiceId = '60e9560176a391000b23e20b';
|
|
9
14
|
|
|
15
|
+
// tslint:disable-next-line:max-func-body-length
|
|
10
16
|
async function main() {
|
|
11
17
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
18
|
const client = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
|
|
@@ -36,17 +42,13 @@ async function main() {
|
|
|
36
42
|
project: { id: project.id },
|
|
37
43
|
agent: { id: CLIENT_ID },
|
|
38
44
|
object: {
|
|
39
|
-
// accountId?: string;
|
|
40
|
-
// additionalProperty?: IPropertyValue<string>[];
|
|
41
|
-
amount: 1,
|
|
42
|
-
// description?: string;
|
|
43
|
-
// name?: string;
|
|
44
|
-
paymentMethod: 'PayPay',
|
|
45
|
-
// paymentMethodId?: string;
|
|
46
45
|
typeOf: chevre.factory.action.authorize.paymentMethod.any.ResultType.Payment,
|
|
47
|
-
|
|
46
|
+
amount: 1,
|
|
47
|
+
paymentMethod: paymentMethodType,
|
|
48
|
+
issuedThrough: { id: paymentServiceId },
|
|
48
49
|
method: '1',
|
|
49
50
|
creditCard: {
|
|
51
|
+
retUrl: String(process.env.SECURE_TRAN_RET_URL),
|
|
50
52
|
cardNo: '4100000000000100',
|
|
51
53
|
expire: '2812',
|
|
52
54
|
cardPass: '123',
|
|
@@ -73,6 +75,68 @@ async function main() {
|
|
|
73
75
|
transaction: await chevre.repository.Transaction.createInstance(mongoose.connection)
|
|
74
76
|
});
|
|
75
77
|
console.log(publishPaymentUrlResult);
|
|
78
|
+
|
|
79
|
+
// wait callback...
|
|
80
|
+
await new Promise<void>((resolve, reject) => {
|
|
81
|
+
const rl = readline.createInterface({
|
|
82
|
+
input: process.stdin,
|
|
83
|
+
output: process.stdout
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
rl.question('callback received?:\n', async () => {
|
|
87
|
+
try {
|
|
88
|
+
const authorizeResult = await (await chevre.service.payment.any.createService()).authorize({
|
|
89
|
+
project: { id: project.id },
|
|
90
|
+
agent: { id: CLIENT_ID },
|
|
91
|
+
object: {
|
|
92
|
+
typeOf: chevre.factory.action.authorize.paymentMethod.any.ResultType.Payment,
|
|
93
|
+
amount: 1,
|
|
94
|
+
paymentMethodId: publishPaymentUrlResult.paymentMethodId,
|
|
95
|
+
paymentMethod: paymentMethodType,
|
|
96
|
+
issuedThrough: { id: paymentServiceId },
|
|
97
|
+
method: '1',
|
|
98
|
+
creditCard: {
|
|
99
|
+
cardNo: '4100000000000100',
|
|
100
|
+
expire: '2812',
|
|
101
|
+
cardPass: '123',
|
|
102
|
+
holderName: 'AA AA'
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
purpose: { id: transaction.id, typeOf: transaction.typeOf },
|
|
106
|
+
paymentServiceType: chevre.factory.service.paymentService.PaymentServiceType.CreditCard,
|
|
107
|
+
location: {
|
|
108
|
+
typeOf: chevre.factory.creativeWorkType.WebApplication,
|
|
109
|
+
id: CLIENT_ID
|
|
110
|
+
},
|
|
111
|
+
options: {
|
|
112
|
+
useCancelPayTransactionOnFailed: false,
|
|
113
|
+
useCheckMovieTicketBeforePay: false,
|
|
114
|
+
useCheckByIdentifierIfNotYet: false,
|
|
115
|
+
useSearchTrade4accountId: false
|
|
116
|
+
}
|
|
117
|
+
})({
|
|
118
|
+
accountingReport: await chevre.repository.AccountingReport.createInstance(mongoose.connection),
|
|
119
|
+
action: await chevre.repository.Action.createInstance(mongoose.connection),
|
|
120
|
+
assetTransaction: await chevre.repository.AssetTransaction.createInstance(mongoose.connection),
|
|
121
|
+
event: await chevre.repository.Event.createInstance(mongoose.connection),
|
|
122
|
+
paymentAccepted: await chevre.repository.SellerPaymentAccepted.createInstance(mongoose.connection),
|
|
123
|
+
paymentService: await chevre.repository.PaymentService.createInstance(mongoose.connection),
|
|
124
|
+
paymentServiceProvider: await chevre.repository.PaymentServiceProvider.createInstance(mongoose.connection),
|
|
125
|
+
person: await chevre.repository.Person.createInstance({ userPoolId: '' }),
|
|
126
|
+
product: await chevre.repository.Product.createInstance(mongoose.connection),
|
|
127
|
+
project: await chevre.repository.Project.createInstance(mongoose.connection),
|
|
128
|
+
task: await chevre.repository.Task.createInstance(mongoose.connection),
|
|
129
|
+
transactionNumber: await chevre.repository.TransactionNumber.createInstance(client),
|
|
130
|
+
transaction: await chevre.repository.Transaction.createInstance(mongoose.connection)
|
|
131
|
+
});
|
|
132
|
+
console.log(authorizeResult);
|
|
133
|
+
|
|
134
|
+
resolve();
|
|
135
|
+
} catch (error) {
|
|
136
|
+
reject(error);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
});
|
|
76
140
|
}
|
|
77
141
|
|
|
78
142
|
main()
|
|
@@ -80,7 +80,7 @@ export type IInvalidatePaymentUrlOperation<T> = (repos: {
|
|
|
80
80
|
task: TaskRepo;
|
|
81
81
|
assetTransaction: AssetTransactionRepo;
|
|
82
82
|
}) => Promise<T>;
|
|
83
|
-
export type IPublishPaymentUrlResult = CreditCardPayment.
|
|
83
|
+
export type IPublishPaymentUrlResult = CreditCardPayment.IPaymentAgencyTransaction & {
|
|
84
84
|
paymentMethodId: string;
|
|
85
85
|
paymentUrl: string;
|
|
86
86
|
};
|
|
@@ -99,6 +99,7 @@ export declare function invalidatePaymentUrl(params: factory.task.refund.IData):
|
|
|
99
99
|
export declare function check(params: factory.action.check.paymentMethod.movieTicket.IAttributes): ICheckOperation<{
|
|
100
100
|
result: MovieTicketPayment.ICheckResult;
|
|
101
101
|
}>;
|
|
102
|
+
export import IPaymentAgencyTransaction = CreditCardPayment.IPaymentAgencyTransaction;
|
|
102
103
|
/**
|
|
103
104
|
* 取引開始
|
|
104
105
|
*/
|
|
@@ -106,6 +107,7 @@ export declare function start(params: factory.assetTransaction.pay.IStartParamsW
|
|
|
106
107
|
useCheckMovieTicketBeforePay: boolean;
|
|
107
108
|
useCheckByIdentifierIfNotYet: boolean;
|
|
108
109
|
searchTrade4accountId: boolean;
|
|
110
|
+
pendingPaymentAgencyTransaction?: CreditCardPayment.IPaymentAgencyTransaction;
|
|
109
111
|
}): IStartOperation<factory.assetTransaction.pay.ITransaction>;
|
|
110
112
|
/**
|
|
111
113
|
* 取引確定
|
|
@@ -23,7 +23,7 @@ const potentialActions_1 = require("./pay/potentialActions");
|
|
|
23
23
|
*/
|
|
24
24
|
function publishPaymentUrl(params) {
|
|
25
25
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
var _a, _b;
|
|
26
|
+
var _a, _b, _c;
|
|
27
27
|
const paymentServiceType = (_a = params.object) === null || _a === void 0 ? void 0 : _a.typeOf;
|
|
28
28
|
// 金額をfix
|
|
29
29
|
const amount = (_b = params.object.paymentMethod) === null || _b === void 0 ? void 0 : _b.amount;
|
|
@@ -40,14 +40,22 @@ function publishPaymentUrl(params) {
|
|
|
40
40
|
let result;
|
|
41
41
|
switch (paymentServiceType) {
|
|
42
42
|
case factory.service.paymentService.PaymentServiceType.CreditCard:
|
|
43
|
-
const authorizeResult = yield CreditCardPayment.authorize(params, paymentServiceId, false)(repos);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
const authorizeResult = yield CreditCardPayment.authorize(params, paymentServiceId, { searchTrade4accountId: false })(repos);
|
|
44
|
+
let paymentUrl;
|
|
45
|
+
// 3DS拡張(2024-01-02~)
|
|
46
|
+
const retUrl = (_c = params.object.paymentMethod.creditCard) === null || _c === void 0 ? void 0 : _c.retUrl;
|
|
47
|
+
if (typeof retUrl === 'string' && retUrl.length > 0) {
|
|
48
|
+
paymentUrl = authorizeResult.execTranResult.redirectUrl;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
paymentUrl = authorizeResult.execTranResult.acsUrl;
|
|
52
|
+
}
|
|
53
|
+
if (typeof paymentUrl !== 'string' || paymentUrl.length === 0) {
|
|
54
|
+
throw new factory.errors.ServiceUnavailable(`Payment URL unable to publish. [retUrl: ${retUrl}]`);
|
|
47
55
|
}
|
|
48
56
|
result = {
|
|
49
57
|
paymentMethodId: transactionNumber,
|
|
50
|
-
paymentUrl
|
|
58
|
+
paymentUrl,
|
|
51
59
|
entryTranArgs: authorizeResult.entryTranArgs,
|
|
52
60
|
entryTranResult: authorizeResult.entryTranResult,
|
|
53
61
|
execTranArgs: authorizeResult.execTranArgs,
|
|
@@ -138,7 +146,9 @@ function start(params, options) {
|
|
|
138
146
|
break;
|
|
139
147
|
case factory.service.paymentService.PaymentServiceType.CreditCard:
|
|
140
148
|
transaction =
|
|
141
|
-
yield processAuthorizeCreditCard(params, transaction, String(paymentService === null || paymentService === void 0 ? void 0 : paymentService.id), options.searchTrade4accountId
|
|
149
|
+
yield processAuthorizeCreditCard(params, transaction, String(paymentService === null || paymentService === void 0 ? void 0 : paymentService.id), Object.assign({ searchTrade4accountId: options.searchTrade4accountId }, (options.pendingPaymentAgencyTransaction !== undefined)
|
|
150
|
+
? { pendingPaymentAgencyTransaction: options.pendingPaymentAgencyTransaction }
|
|
151
|
+
: undefined))(repos);
|
|
142
152
|
break;
|
|
143
153
|
case factory.service.paymentService.PaymentServiceType.MovieTicket:
|
|
144
154
|
transaction =
|
|
@@ -292,20 +302,16 @@ function processAuthorizeAccount(params, transaction, paymentServiceId) {
|
|
|
292
302
|
})(repos);
|
|
293
303
|
});
|
|
294
304
|
}
|
|
295
|
-
function processAuthorizeCreditCard(params, transaction, paymentServiceId,
|
|
305
|
+
function processAuthorizeCreditCard(params, transaction, paymentServiceId, options) {
|
|
296
306
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
297
|
-
const authorizeResult = yield CreditCardPayment.authorize(params, paymentServiceId, searchTrade4accountId
|
|
307
|
+
const authorizeResult = yield CreditCardPayment.authorize(params, paymentServiceId, Object.assign({ searchTrade4accountId: options.searchTrade4accountId }, (options.pendingPaymentAgencyTransaction !== undefined)
|
|
308
|
+
? { pendingPaymentAgencyTransaction: options.pendingPaymentAgencyTransaction }
|
|
309
|
+
: undefined))(repos);
|
|
298
310
|
return saveAuthorizeResult({
|
|
299
311
|
id: transaction.id,
|
|
300
|
-
update: {
|
|
301
|
-
'object.
|
|
302
|
-
|
|
303
|
-
'object.paymentMethod.paymentMethodId': authorizeResult.paymentMethodId,
|
|
304
|
-
'object.entryTranArgs': authorizeResult.entryTranArgs,
|
|
305
|
-
'object.entryTranResult': authorizeResult.entryTranResult,
|
|
306
|
-
'object.execTranArgs': authorizeResult.execTranArgs,
|
|
307
|
-
'object.execTranResult': authorizeResult.execTranResult
|
|
308
|
-
}
|
|
312
|
+
update: Object.assign({ 'object.accountId': authorizeResult.accountId, 'object.paymentMethod.accountId': authorizeResult.accountId, 'object.paymentMethod.paymentMethodId': authorizeResult.paymentMethodId, 'object.entryTranArgs': authorizeResult.entryTranArgs, 'object.entryTranResult': authorizeResult.entryTranResult, 'object.execTranArgs': authorizeResult.execTranArgs, 'object.execTranResult': authorizeResult.execTranResult }, (authorizeResult.secureTran2Result !== undefined)
|
|
313
|
+
? { 'object.secureTran2Result': authorizeResult.secureTran2Result }
|
|
314
|
+
: undefined)
|
|
309
315
|
})(repos);
|
|
310
316
|
});
|
|
311
317
|
}
|
|
@@ -256,16 +256,22 @@ exports.publishPaymentUrl = publishPaymentUrl;
|
|
|
256
256
|
function authorize(params) {
|
|
257
257
|
// tslint:disable-next-line:max-func-body-length
|
|
258
258
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
259
|
-
var _a
|
|
259
|
+
var _a;
|
|
260
260
|
const transaction = yield repos.transaction.findInProgressById({ typeOf: params.purpose.typeOf, id: params.purpose.id });
|
|
261
261
|
const paymentServiceType = params.paymentServiceType;
|
|
262
262
|
// 取引番号生成
|
|
263
263
|
let transactionNumber;
|
|
264
|
+
let pendingPaymentAgencyTransaction;
|
|
264
265
|
// リクエストでpaymentMethodIdを指定された場合、取引に保管されたpaymentMethodIdに一致すればそちらを適用(外部サイト決済対応)
|
|
265
266
|
if (typeof params.object.paymentMethodId === 'string' && params.object.paymentMethodId.length > 0) {
|
|
266
|
-
const
|
|
267
|
-
if (params.object.paymentMethodId ===
|
|
267
|
+
const paymentMethodByTransaction = transaction.object.paymentMethods;
|
|
268
|
+
if (params.object.paymentMethodId === (paymentMethodByTransaction === null || paymentMethodByTransaction === void 0 ? void 0 : paymentMethodByTransaction.paymentMethodId)) {
|
|
268
269
|
transactionNumber = params.object.paymentMethodId;
|
|
270
|
+
const { entryTranArgs, entryTranResult, execTranArgs, execTranResult } = paymentMethodByTransaction;
|
|
271
|
+
if (entryTranArgs !== undefined && entryTranResult !== undefined
|
|
272
|
+
&& execTranArgs !== undefined && execTranResult !== undefined) {
|
|
273
|
+
pendingPaymentAgencyTransaction = { entryTranArgs, entryTranResult, execTranArgs, execTranResult };
|
|
274
|
+
}
|
|
269
275
|
// 既に承認済であれば何もしない(2023-05-15~)
|
|
270
276
|
const existingCompletedAuthorizeActions = yield repos.action.searchByPurpose({
|
|
271
277
|
typeOf: factory.actionType.AuthorizeAction,
|
|
@@ -309,7 +315,7 @@ function authorize(params) {
|
|
|
309
315
|
id: transaction.seller.id,
|
|
310
316
|
name: (typeof transaction.seller.name === 'string')
|
|
311
317
|
? transaction.seller.name
|
|
312
|
-
: String((
|
|
318
|
+
: String((_a = transaction.seller.name) === null || _a === void 0 ? void 0 : _a.ja)
|
|
313
319
|
},
|
|
314
320
|
purpose: { typeOf: transaction.typeOf, id: transaction.id }
|
|
315
321
|
};
|
|
@@ -328,11 +334,7 @@ function authorize(params) {
|
|
|
328
334
|
transactionNumber: transactionNumber,
|
|
329
335
|
location: params.location
|
|
330
336
|
});
|
|
331
|
-
payTransaction = yield PayTransactionService.start(startParams, {
|
|
332
|
-
useCheckMovieTicketBeforePay: params.options.useCheckMovieTicketBeforePay,
|
|
333
|
-
useCheckByIdentifierIfNotYet: params.options.useCheckByIdentifierIfNotYet,
|
|
334
|
-
searchTrade4accountId: params.options.useSearchTrade4accountId
|
|
335
|
-
})(repos);
|
|
337
|
+
payTransaction = yield PayTransactionService.start(startParams, Object.assign({ useCheckMovieTicketBeforePay: params.options.useCheckMovieTicketBeforePay, useCheckByIdentifierIfNotYet: params.options.useCheckByIdentifierIfNotYet, searchTrade4accountId: params.options.useSearchTrade4accountId }, (pendingPaymentAgencyTransaction !== undefined) ? { pendingPaymentAgencyTransaction } : undefined))(repos);
|
|
336
338
|
}
|
|
337
339
|
catch (error) {
|
|
338
340
|
try {
|
|
@@ -11,29 +11,30 @@ import type { CognitoRepository as PersonRepo } from '../../repo/person';
|
|
|
11
11
|
import type { MongoRepository as ProjectRepo } from '../../repo/project';
|
|
12
12
|
import type { MongoRepository as PaymentAcceptedRepo } from '../../repo/sellerPaymentAccepted';
|
|
13
13
|
import type { MongoRepository as TaskRepo } from '../../repo/task';
|
|
14
|
+
interface IPaymentAgencyTransaction {
|
|
15
|
+
entryTranArgs: GMO.factory.credit.IEntryTranArgs;
|
|
16
|
+
entryTranResult: GMO.factory.credit.IEntryTranResult;
|
|
17
|
+
execTranArgs: GMO.factory.credit.IExecTranArgs;
|
|
18
|
+
execTranResult: GMO.factory.credit.IExecTranResult | GMO.factory.credit.IExecTran3dsResult;
|
|
19
|
+
secureTran2Result?: GMO.factory.credit.ISecureTran2Result;
|
|
20
|
+
}
|
|
21
|
+
type IAuthorizeResult = IPaymentAgencyTransaction & {
|
|
22
|
+
accountId: string;
|
|
23
|
+
paymentMethodId: string;
|
|
24
|
+
};
|
|
14
25
|
/**
|
|
15
26
|
* クレジットカード決済承認
|
|
16
27
|
*/
|
|
17
|
-
declare function authorize(params: factory.assetTransaction.pay.IStartParamsWithoutDetail, paymentServiceId: string,
|
|
28
|
+
declare function authorize(params: factory.assetTransaction.pay.IStartParamsWithoutDetail, paymentServiceId: string, options: {
|
|
29
|
+
searchTrade4accountId: boolean;
|
|
30
|
+
pendingPaymentAgencyTransaction?: IPaymentAgencyTransaction;
|
|
31
|
+
}): (repos: {
|
|
18
32
|
paymentAccepted: PaymentAcceptedRepo;
|
|
19
33
|
paymentService: PaymentServiceRepo;
|
|
20
34
|
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
21
35
|
person: PersonRepo;
|
|
22
36
|
project: ProjectRepo;
|
|
23
|
-
}) => Promise<
|
|
24
|
-
accountId: string;
|
|
25
|
-
paymentMethodId: string;
|
|
26
|
-
entryTranArgs: GMO.factory.credit.IEntryTranArgs;
|
|
27
|
-
entryTranResult: GMO.factory.credit.IEntryTranResult;
|
|
28
|
-
execTranArgs: GMO.factory.credit.IExecTranArgs;
|
|
29
|
-
execTranResult: GMO.factory.credit.IExecTranResult;
|
|
30
|
-
}>;
|
|
31
|
-
interface IAuthorizeResult {
|
|
32
|
-
entryTranArgs: GMO.factory.credit.IEntryTranArgs;
|
|
33
|
-
entryTranResult: GMO.factory.credit.IEntryTranResult;
|
|
34
|
-
execTranArgs: GMO.factory.credit.IExecTranArgs;
|
|
35
|
-
execTranResult: GMO.factory.credit.IExecTranResult;
|
|
36
|
-
}
|
|
37
|
+
}) => Promise<IAuthorizeResult>;
|
|
37
38
|
/**
|
|
38
39
|
* クレジットカード決済中止
|
|
39
40
|
*/
|
|
@@ -87,4 +88,4 @@ declare function searchGMOTrade(params: {
|
|
|
87
88
|
shopId: string;
|
|
88
89
|
shopPass: string;
|
|
89
90
|
}): Promise<GMO.factory.credit.ISearchTradeResult>;
|
|
90
|
-
export { IAuthorizeResult, getGMOInfoFromSeller, authorize, payCreditCard, refundCreditCard, searchGMOTrade, voidTransaction };
|
|
91
|
+
export { IAuthorizeResult, IPaymentAgencyTransaction, getGMOInfoFromSeller, authorize, payCreditCard, refundCreditCard, searchGMOTrade, voidTransaction };
|
|
@@ -25,9 +25,10 @@ const debug = createDebug('chevre-domain:service:payment');
|
|
|
25
25
|
/**
|
|
26
26
|
* クレジットカード決済承認
|
|
27
27
|
*/
|
|
28
|
-
function authorize(params, paymentServiceId,
|
|
28
|
+
function authorize(params, paymentServiceId, options) {
|
|
29
|
+
// tslint:disable-next-line:max-func-body-length
|
|
29
30
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
30
|
-
var _a, _b, _c, _d;
|
|
31
|
+
var _a, _b, _c, _d, _e;
|
|
31
32
|
const project = yield repos.project.findById({
|
|
32
33
|
id: params.project.id,
|
|
33
34
|
inclusion: ['settings'],
|
|
@@ -57,18 +58,30 @@ function authorize(params, paymentServiceId, searchTrade4accountId) {
|
|
|
57
58
|
let authorizeResult;
|
|
58
59
|
let searchTradeResult;
|
|
59
60
|
try {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
61
|
+
const pendingPaymentAgencyTransaction = options.pendingPaymentAgencyTransaction;
|
|
62
|
+
const redirectUrl = (_c = pendingPaymentAgencyTransaction === null || pendingPaymentAgencyTransaction === void 0 ? void 0 : pendingPaymentAgencyTransaction.execTranResult) === null || _c === void 0 ? void 0 : _c.redirectUrl;
|
|
63
|
+
if (pendingPaymentAgencyTransaction !== undefined
|
|
64
|
+
&& typeof redirectUrl === 'string' && redirectUrl.length > 0) {
|
|
65
|
+
authorizeResult = yield processAuthorizeCreditCard3ds({
|
|
66
|
+
availableChannel,
|
|
67
|
+
pendingPaymentAgencyTransaction
|
|
68
|
+
})();
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
authorizeResult = yield processAuthorizeCreditCard({
|
|
72
|
+
projectSettings: project.settings,
|
|
73
|
+
shopId: shopId,
|
|
74
|
+
shopPass: shopPass,
|
|
75
|
+
orderId: orderId,
|
|
76
|
+
availableChannel: availableChannel,
|
|
77
|
+
object: params.object.paymentMethod
|
|
78
|
+
})(repos);
|
|
79
|
+
}
|
|
68
80
|
}
|
|
69
81
|
catch (error) {
|
|
70
82
|
throw handleAuthorizeError(error);
|
|
71
83
|
}
|
|
84
|
+
const searchTrade4accountId = (options === null || options === void 0 ? void 0 : options.searchTrade4accountId) === true;
|
|
72
85
|
if (searchTrade4accountId) {
|
|
73
86
|
try {
|
|
74
87
|
const creditCardService = new GMO.service.Credit({ endpoint: String(availableChannel.serviceUrl) }, { timeout: credentials_1.credentials.gmo.timeout });
|
|
@@ -79,8 +92,8 @@ function authorize(params, paymentServiceId, searchTrade4accountId) {
|
|
|
79
92
|
shopId: shopId,
|
|
80
93
|
shopPass: shopPass,
|
|
81
94
|
orderId: orderId,
|
|
82
|
-
siteId: (
|
|
83
|
-
sitePass: (
|
|
95
|
+
siteId: (_d = availableChannel.credentials) === null || _d === void 0 ? void 0 : _d.siteId,
|
|
96
|
+
sitePass: (_e = availableChannel.credentials) === null || _e === void 0 ? void 0 : _e.sitePass
|
|
84
97
|
});
|
|
85
98
|
debug('searchTrade processed. orderId:', orderId, 'execution time:', (Date.now() - startSearchTradeDate), 'ms');
|
|
86
99
|
}
|
|
@@ -89,18 +102,12 @@ function authorize(params, paymentServiceId, searchTrade4accountId) {
|
|
|
89
102
|
debug('searchTrade throwed an error. orderId:', orderId, error);
|
|
90
103
|
}
|
|
91
104
|
}
|
|
92
|
-
return {
|
|
93
|
-
accountId: (searchTradeResult !== undefined) ? searchTradeResult.cardNo : '',
|
|
94
|
-
paymentMethodId: orderId,
|
|
95
|
-
entryTranArgs: authorizeResult.entryTranArgs,
|
|
96
|
-
entryTranResult: authorizeResult.entryTranResult,
|
|
97
|
-
execTranArgs: authorizeResult.execTranArgs,
|
|
98
|
-
execTranResult: authorizeResult.execTranResult
|
|
99
|
-
};
|
|
105
|
+
return Object.assign({ accountId: (searchTradeResult !== undefined) ? searchTradeResult.cardNo : '', paymentMethodId: orderId, entryTranArgs: authorizeResult.entryTranArgs, entryTranResult: authorizeResult.entryTranResult, execTranArgs: authorizeResult.execTranArgs, execTranResult: authorizeResult.execTranResult }, (authorizeResult.secureTran2Result !== undefined) ? { secureTran2Result: authorizeResult.secureTran2Result } : undefined);
|
|
100
106
|
});
|
|
101
107
|
}
|
|
102
108
|
exports.authorize = authorize;
|
|
103
109
|
function processAuthorizeCreditCard(params) {
|
|
110
|
+
// tslint:disable-next-line:max-func-body-length
|
|
104
111
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
105
112
|
var _a, _b, _c, _d, _e;
|
|
106
113
|
// GMOオーソリ取得
|
|
@@ -109,25 +116,13 @@ function processAuthorizeCreditCard(params) {
|
|
|
109
116
|
let execTranArgs;
|
|
110
117
|
let execTranResult;
|
|
111
118
|
const creditCardService = new GMO.service.Credit({ endpoint: String(params.availableChannel.serviceUrl) }, { timeout: credentials_1.credentials.gmo.timeout });
|
|
112
|
-
entryTranArgs = {
|
|
113
|
-
shopId: params.shopId,
|
|
114
|
-
shopPass: params.shopPass,
|
|
115
|
-
orderId: params.orderId,
|
|
116
|
-
jobCd: GMO.utils.util.JobCd.Auth,
|
|
117
|
-
amount: (typeof params.object.amount === 'number')
|
|
118
|
-
? params.object.amount
|
|
119
|
-
: params.object.amount.value,
|
|
120
|
-
siteId: (_a = params.availableChannel.credentials) === null || _a === void 0 ? void 0 : _a.siteId,
|
|
121
|
-
sitePass: (_b = params.availableChannel.credentials) === null || _b === void 0 ? void 0 : _b.sitePass
|
|
122
|
-
};
|
|
123
|
-
entryTranResult = yield creditCardService.entryTran(entryTranArgs);
|
|
124
119
|
const creditCard = params.object.creditCard;
|
|
125
120
|
let memberId = creditCard.memberId;
|
|
126
121
|
const cardSeq = creditCard.cardSeq;
|
|
127
122
|
if (typeof memberId === 'string' && memberId.length > 0 && typeof cardSeq === 'number') {
|
|
128
123
|
// 特殊なプロジェクトのみユーザーネームに自動変換(新旧会員互換性維持対応)
|
|
129
124
|
// memberIdはPersonIDが指定されてくる想定
|
|
130
|
-
const useUsernameAsGMOMemberId = ((
|
|
125
|
+
const useUsernameAsGMOMemberId = ((_a = params.projectSettings) === null || _a === void 0 ? void 0 : _a.useUsernameAsGMOMemberId) === true;
|
|
131
126
|
if (useUsernameAsGMOMemberId) {
|
|
132
127
|
try {
|
|
133
128
|
const customer = yield repos.person.findById({ userId: memberId });
|
|
@@ -138,28 +133,83 @@ function processAuthorizeCreditCard(params) {
|
|
|
138
133
|
}
|
|
139
134
|
}
|
|
140
135
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
entryTranArgs
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
136
|
+
const retUrl = creditCard === null || creditCard === void 0 ? void 0 : creditCard.retUrl;
|
|
137
|
+
// 3DS拡張(2024-01-02~)
|
|
138
|
+
if (typeof retUrl === 'string' && retUrl.length > 0) {
|
|
139
|
+
entryTranArgs = {
|
|
140
|
+
shopId: params.shopId,
|
|
141
|
+
shopPass: params.shopPass,
|
|
142
|
+
orderId: params.orderId,
|
|
143
|
+
jobCd: GMO.utils.util.JobCd.Auth,
|
|
144
|
+
amount: (typeof params.object.amount === 'number')
|
|
145
|
+
? params.object.amount
|
|
146
|
+
: params.object.amount.value,
|
|
147
|
+
// siteId: params.availableChannel.credentials?.siteId,
|
|
148
|
+
// sitePass: params.availableChannel.credentials?.sitePass,
|
|
149
|
+
tdFlag: GMO.utils.util.TdFlag.Version2,
|
|
150
|
+
// tdTenantName: '',
|
|
151
|
+
tds2Type: GMO.utils.util.Tds2Type.Error
|
|
152
|
+
};
|
|
153
|
+
entryTranResult = yield creditCardService.entryTran(entryTranArgs);
|
|
154
|
+
execTranArgs = {
|
|
155
|
+
accessId: entryTranResult.accessId,
|
|
156
|
+
accessPass: entryTranResult.accessPass,
|
|
157
|
+
orderId: params.orderId,
|
|
158
|
+
method: params.object.method,
|
|
159
|
+
// siteId: params.availableChannel.credentials?.siteId,
|
|
160
|
+
// sitePass: params.availableChannel.credentials?.sitePass,
|
|
161
|
+
cardNo: creditCard.cardNo,
|
|
162
|
+
cardPass: creditCard.cardPass,
|
|
163
|
+
expire: creditCard.expire,
|
|
164
|
+
token: creditCard.token,
|
|
165
|
+
memberId: memberId,
|
|
166
|
+
cardSeq: cardSeq,
|
|
167
|
+
seqMode: GMO.utils.util.SeqMode.Physics,
|
|
168
|
+
retUrl,
|
|
169
|
+
callbackType: GMO.utils.util.CallbackType.Get
|
|
170
|
+
};
|
|
171
|
+
execTranResult = yield creditCardService.execTran3ds(execTranArgs);
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
entryTranArgs = {
|
|
175
|
+
shopId: params.shopId,
|
|
176
|
+
shopPass: params.shopPass,
|
|
177
|
+
orderId: params.orderId,
|
|
178
|
+
jobCd: GMO.utils.util.JobCd.Auth,
|
|
179
|
+
amount: (typeof params.object.amount === 'number')
|
|
180
|
+
? params.object.amount
|
|
181
|
+
: params.object.amount.value,
|
|
182
|
+
siteId: (_b = params.availableChannel.credentials) === null || _b === void 0 ? void 0 : _b.siteId,
|
|
183
|
+
sitePass: (_c = params.availableChannel.credentials) === null || _c === void 0 ? void 0 : _c.sitePass
|
|
184
|
+
};
|
|
185
|
+
entryTranResult = yield creditCardService.entryTran(entryTranArgs);
|
|
186
|
+
execTranArgs = {
|
|
187
|
+
accessId: entryTranResult.accessId,
|
|
188
|
+
accessPass: entryTranResult.accessPass,
|
|
189
|
+
orderId: params.orderId,
|
|
190
|
+
method: params.object.method,
|
|
191
|
+
siteId: (_d = params.availableChannel.credentials) === null || _d === void 0 ? void 0 : _d.siteId,
|
|
192
|
+
sitePass: (_e = params.availableChannel.credentials) === null || _e === void 0 ? void 0 : _e.sitePass,
|
|
193
|
+
cardNo: creditCard.cardNo,
|
|
194
|
+
cardPass: creditCard.cardPass,
|
|
195
|
+
expire: creditCard.expire,
|
|
196
|
+
token: creditCard.token,
|
|
197
|
+
memberId: memberId,
|
|
198
|
+
cardSeq: cardSeq,
|
|
199
|
+
seqMode: GMO.utils.util.SeqMode.Physics
|
|
200
|
+
};
|
|
201
|
+
execTranResult = yield creditCardService.execTran(execTranArgs);
|
|
202
|
+
}
|
|
203
|
+
return { entryTranArgs, entryTranResult, execTranArgs, execTranResult };
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
function processAuthorizeCreditCard3ds(params) {
|
|
207
|
+
return () => __awaiter(this, void 0, void 0, function* () {
|
|
208
|
+
const creditCardService = new GMO.service.Credit({ endpoint: String(params.availableChannel.serviceUrl) }, { timeout: credentials_1.credentials.gmo.timeout });
|
|
209
|
+
const { entryTranArgs, entryTranResult, execTranArgs, execTranResult } = params.pendingPaymentAgencyTransaction;
|
|
210
|
+
const { accessId, accessPass } = entryTranResult;
|
|
211
|
+
const secureTran2Result = yield creditCardService.secureTran2({ accessId, accessPass });
|
|
212
|
+
return { entryTranArgs, entryTranResult, execTranArgs, execTranResult, secureTran2Result };
|
|
163
213
|
});
|
|
164
214
|
}
|
|
165
215
|
function handleAuthorizeError(error) {
|
package/package.json
CHANGED
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/credential-providers": "3.433.0",
|
|
13
|
-
"@chevre/factory": "4.351.0-alpha.
|
|
13
|
+
"@chevre/factory": "4.351.0-alpha.2",
|
|
14
14
|
"@cinerino/sdk": "5.6.0",
|
|
15
15
|
"@motionpicture/coa-service": "9.2.0",
|
|
16
|
-
"@motionpicture/gmo-service": "5.
|
|
16
|
+
"@motionpicture/gmo-service": "5.3.0-alpha.0",
|
|
17
17
|
"@sendgrid/mail": "6.4.0",
|
|
18
18
|
"@surfrock/sdk": "1.2.0",
|
|
19
19
|
"@waiter/domain": "6.4.0-alpha.4",
|
|
@@ -115,5 +115,5 @@
|
|
|
115
115
|
"postversion": "git push origin --tags",
|
|
116
116
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
117
117
|
},
|
|
118
|
-
"version": "21.20.0-alpha.
|
|
118
|
+
"version": "21.20.0-alpha.2"
|
|
119
119
|
}
|