@chevre/domain 21.20.0-alpha.1 → 21.20.0-alpha.3
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 +71 -62
- package/lib/chevre/service/assetTransaction/pay.js +16 -14
- package/lib/chevre/service/payment/any.js +26 -1
- package/lib/chevre/service/payment/creditCard.d.ts +2 -19
- package/lib/chevre/service/payment/creditCard.js +120 -76
- package/package.json +3 -3
|
@@ -1,11 +1,23 @@
|
|
|
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';
|
|
14
|
+
const AMOUNT: number = 1;
|
|
15
|
+
const creditCard: chevre.factory.paymentMethod.paymentCard.creditCard.IUncheckedCardRaw = {
|
|
16
|
+
cardNo: '4100000000000100',
|
|
17
|
+
expire: '2812',
|
|
18
|
+
cardPass: '123',
|
|
19
|
+
holderName: 'AA AA'
|
|
20
|
+
};
|
|
9
21
|
|
|
10
22
|
// tslint:disable-next-line:max-func-body-length
|
|
11
23
|
async function main() {
|
|
@@ -37,21 +49,14 @@ async function main() {
|
|
|
37
49
|
project: { id: project.id },
|
|
38
50
|
agent: { id: CLIENT_ID },
|
|
39
51
|
object: {
|
|
40
|
-
// accountId?: string;
|
|
41
|
-
// additionalProperty?: IPropertyValue<string>[];
|
|
42
|
-
amount: 1,
|
|
43
|
-
// description?: string;
|
|
44
|
-
// name?: string;
|
|
45
|
-
paymentMethod: 'PayPay',
|
|
46
|
-
// paymentMethodId?: string;
|
|
47
52
|
typeOf: chevre.factory.action.authorize.paymentMethod.any.ResultType.Payment,
|
|
48
|
-
|
|
53
|
+
amount: AMOUNT,
|
|
54
|
+
paymentMethod: paymentMethodType,
|
|
55
|
+
issuedThrough: { id: paymentServiceId },
|
|
49
56
|
method: '1',
|
|
50
57
|
creditCard: {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
cardPass: '123',
|
|
54
|
-
holderName: 'AA AA'
|
|
58
|
+
...creditCard,
|
|
59
|
+
retUrl: String(process.env.SECURE_TRAN_RET_URL)
|
|
55
60
|
}
|
|
56
61
|
},
|
|
57
62
|
purpose: { id: transaction.id, typeOf: transaction.typeOf },
|
|
@@ -60,9 +65,6 @@ async function main() {
|
|
|
60
65
|
typeOf: chevre.factory.creativeWorkType.WebApplication,
|
|
61
66
|
id: CLIENT_ID
|
|
62
67
|
}
|
|
63
|
-
// options: {
|
|
64
|
-
// use3DS: true
|
|
65
|
-
// }
|
|
66
68
|
})({
|
|
67
69
|
assetTransaction: await chevre.repository.AssetTransaction.createInstance(mongoose.connection),
|
|
68
70
|
paymentAccepted: await chevre.repository.SellerPaymentAccepted.createInstance(mongoose.connection),
|
|
@@ -75,55 +77,62 @@ async function main() {
|
|
|
75
77
|
});
|
|
76
78
|
console.log(publishPaymentUrlResult);
|
|
77
79
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
80
|
+
// wait callback...
|
|
81
|
+
await new Promise<void>((resolve, reject) => {
|
|
82
|
+
const rl = readline.createInterface({
|
|
83
|
+
input: process.stdin,
|
|
84
|
+
output: process.stdout
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
rl.question('callback received?:\n', async () => {
|
|
88
|
+
try {
|
|
89
|
+
const authorizeResult = await (await chevre.service.payment.any.createService()).authorize({
|
|
90
|
+
project: { id: project.id },
|
|
91
|
+
agent: { id: CLIENT_ID },
|
|
92
|
+
object: {
|
|
93
|
+
typeOf: chevre.factory.action.authorize.paymentMethod.any.ResultType.Payment,
|
|
94
|
+
amount: AMOUNT,
|
|
95
|
+
paymentMethodId: publishPaymentUrlResult.paymentMethodId,
|
|
96
|
+
paymentMethod: paymentMethodType,
|
|
97
|
+
issuedThrough: { id: paymentServiceId },
|
|
98
|
+
method: '1',
|
|
99
|
+
creditCard
|
|
100
|
+
},
|
|
101
|
+
purpose: { id: transaction.id, typeOf: transaction.typeOf },
|
|
102
|
+
paymentServiceType: chevre.factory.service.paymentService.PaymentServiceType.CreditCard,
|
|
103
|
+
location: {
|
|
104
|
+
typeOf: chevre.factory.creativeWorkType.WebApplication,
|
|
105
|
+
id: CLIENT_ID
|
|
106
|
+
},
|
|
107
|
+
options: {
|
|
108
|
+
useCancelPayTransactionOnFailed: false,
|
|
109
|
+
useCheckMovieTicketBeforePay: false,
|
|
110
|
+
useCheckByIdentifierIfNotYet: false,
|
|
111
|
+
useSearchTrade4accountId: false
|
|
112
|
+
}
|
|
113
|
+
})({
|
|
114
|
+
accountingReport: await chevre.repository.AccountingReport.createInstance(mongoose.connection),
|
|
115
|
+
action: await chevre.repository.Action.createInstance(mongoose.connection),
|
|
116
|
+
assetTransaction: await chevre.repository.AssetTransaction.createInstance(mongoose.connection),
|
|
117
|
+
event: await chevre.repository.Event.createInstance(mongoose.connection),
|
|
118
|
+
paymentAccepted: await chevre.repository.SellerPaymentAccepted.createInstance(mongoose.connection),
|
|
119
|
+
paymentService: await chevre.repository.PaymentService.createInstance(mongoose.connection),
|
|
120
|
+
paymentServiceProvider: await chevre.repository.PaymentServiceProvider.createInstance(mongoose.connection),
|
|
121
|
+
person: await chevre.repository.Person.createInstance({ userPoolId: '' }),
|
|
122
|
+
product: await chevre.repository.Product.createInstance(mongoose.connection),
|
|
123
|
+
project: await chevre.repository.Project.createInstance(mongoose.connection),
|
|
124
|
+
task: await chevre.repository.Task.createInstance(mongoose.connection),
|
|
125
|
+
transactionNumber: await chevre.repository.TransactionNumber.createInstance(client),
|
|
126
|
+
transaction: await chevre.repository.Transaction.createInstance(mongoose.connection)
|
|
127
|
+
});
|
|
128
|
+
console.log('payment authorized.', authorizeResult.result);
|
|
129
|
+
|
|
130
|
+
resolve();
|
|
131
|
+
} catch (error) {
|
|
132
|
+
reject(error);
|
|
97
133
|
}
|
|
98
|
-
}
|
|
99
|
-
purpose: { id: transaction.id, typeOf: transaction.typeOf },
|
|
100
|
-
paymentServiceType: chevre.factory.service.paymentService.PaymentServiceType.CreditCard,
|
|
101
|
-
location: {
|
|
102
|
-
typeOf: chevre.factory.creativeWorkType.WebApplication,
|
|
103
|
-
id: CLIENT_ID
|
|
104
|
-
},
|
|
105
|
-
options: {
|
|
106
|
-
useCancelPayTransactionOnFailed: false,
|
|
107
|
-
useCheckMovieTicketBeforePay: false,
|
|
108
|
-
useCheckByIdentifierIfNotYet: false,
|
|
109
|
-
useSearchTrade4accountId: false
|
|
110
|
-
}
|
|
111
|
-
})({
|
|
112
|
-
accountingReport: await chevre.repository.AccountingReport.createInstance(mongoose.connection),
|
|
113
|
-
action: await chevre.repository.Action.createInstance(mongoose.connection),
|
|
114
|
-
assetTransaction: await chevre.repository.AssetTransaction.createInstance(mongoose.connection),
|
|
115
|
-
event: await chevre.repository.Event.createInstance(mongoose.connection),
|
|
116
|
-
paymentAccepted: await chevre.repository.SellerPaymentAccepted.createInstance(mongoose.connection),
|
|
117
|
-
paymentService: await chevre.repository.PaymentService.createInstance(mongoose.connection),
|
|
118
|
-
paymentServiceProvider: await chevre.repository.PaymentServiceProvider.createInstance(mongoose.connection),
|
|
119
|
-
person: await chevre.repository.Person.createInstance({ userPoolId: '' }),
|
|
120
|
-
product: await chevre.repository.Product.createInstance(mongoose.connection),
|
|
121
|
-
project: await chevre.repository.Project.createInstance(mongoose.connection),
|
|
122
|
-
task: await chevre.repository.Task.createInstance(mongoose.connection),
|
|
123
|
-
transactionNumber: await chevre.repository.TransactionNumber.createInstance(client),
|
|
124
|
-
transaction: await chevre.repository.Transaction.createInstance(mongoose.connection)
|
|
134
|
+
});
|
|
125
135
|
});
|
|
126
|
-
console.log(authorizeResult);
|
|
127
136
|
}
|
|
128
137
|
|
|
129
138
|
main()
|
|
@@ -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;
|
|
@@ -41,13 +41,21 @@ function publishPaymentUrl(params) {
|
|
|
41
41
|
switch (paymentServiceType) {
|
|
42
42
|
case factory.service.paymentService.PaymentServiceType.CreditCard:
|
|
43
43
|
const authorizeResult = yield CreditCardPayment.authorize(params, paymentServiceId, { searchTrade4accountId: false })(repos);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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,
|
|
@@ -301,15 +309,9 @@ function processAuthorizeCreditCard(params, transaction, paymentServiceId, optio
|
|
|
301
309
|
: undefined))(repos);
|
|
302
310
|
return saveAuthorizeResult({
|
|
303
311
|
id: transaction.id,
|
|
304
|
-
update: {
|
|
305
|
-
'object.
|
|
306
|
-
|
|
307
|
-
'object.paymentMethod.paymentMethodId': authorizeResult.paymentMethodId,
|
|
308
|
-
'object.entryTranArgs': authorizeResult.entryTranArgs,
|
|
309
|
-
'object.entryTranResult': authorizeResult.entryTranResult,
|
|
310
|
-
'object.execTranArgs': authorizeResult.execTranArgs,
|
|
311
|
-
'object.execTranResult': authorizeResult.execTranResult
|
|
312
|
-
}
|
|
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)
|
|
313
315
|
})(repos);
|
|
314
316
|
});
|
|
315
317
|
}
|
|
@@ -237,7 +237,8 @@ function publishPaymentUrl(params) {
|
|
|
237
237
|
entryTranArgs: result.entryTranArgs,
|
|
238
238
|
entryTranResult: result.entryTranResult,
|
|
239
239
|
execTranArgs: result.execTranArgs,
|
|
240
|
-
execTranResult: result.execTranResult
|
|
240
|
+
execTranResult: result.execTranResult,
|
|
241
|
+
paymentMethod: startParams.object.paymentMethod // 拡張(2024-01-04~)
|
|
241
242
|
};
|
|
242
243
|
yield repos.transaction.findByIdAndUpdateInProgress({
|
|
243
244
|
id: transaction.id,
|
|
@@ -266,6 +267,11 @@ function authorize(params) {
|
|
|
266
267
|
if (typeof params.object.paymentMethodId === 'string' && params.object.paymentMethodId.length > 0) {
|
|
267
268
|
const paymentMethodByTransaction = transaction.object.paymentMethods;
|
|
268
269
|
if (params.object.paymentMethodId === (paymentMethodByTransaction === null || paymentMethodByTransaction === void 0 ? void 0 : paymentMethodByTransaction.paymentMethodId)) {
|
|
270
|
+
// 検証強化(2024-01-04~)
|
|
271
|
+
validatePaymentMethodByTransaction({
|
|
272
|
+
object: params.object,
|
|
273
|
+
paymentMethodByTransaction
|
|
274
|
+
});
|
|
269
275
|
transactionNumber = params.object.paymentMethodId;
|
|
270
276
|
const { entryTranArgs, entryTranResult, execTranArgs, execTranResult } = paymentMethodByTransaction;
|
|
271
277
|
if (entryTranArgs !== undefined && entryTranResult !== undefined
|
|
@@ -368,6 +374,25 @@ function authorize(params) {
|
|
|
368
374
|
});
|
|
369
375
|
}
|
|
370
376
|
exports.authorize = authorize;
|
|
377
|
+
function validatePaymentMethodByTransaction(params) {
|
|
378
|
+
var _a;
|
|
379
|
+
const paymentServiceIdByObject = params.object.issuedThrough.id;
|
|
380
|
+
const amountByObject = params.object.amount;
|
|
381
|
+
const paymentServiceIdByTransaction = params.paymentMethodByTransaction.issuedThrough.id;
|
|
382
|
+
const amountByTransaction = (_a = params.paymentMethodByTransaction.entryTranArgs) === null || _a === void 0 ? void 0 : _a.amount;
|
|
383
|
+
// 決済サービスID検証
|
|
384
|
+
if (paymentServiceIdByObject !== paymentServiceIdByTransaction) {
|
|
385
|
+
throw new factory.errors.Argument('object.issuedThrough.id', 'issuedThrough.id must match the target of the paymentUrl');
|
|
386
|
+
}
|
|
387
|
+
// 金額検証
|
|
388
|
+
if (amountByObject !== amountByTransaction) {
|
|
389
|
+
throw new factory.errors.Argument('object.amount', 'amount must match the target of the paymentUrl');
|
|
390
|
+
}
|
|
391
|
+
if (params.paymentMethodByTransaction.paymentMethod !== undefined) {
|
|
392
|
+
// tslint:disable-next-line:no-suspicious-comment
|
|
393
|
+
// TODO params.objectを上書きするか?
|
|
394
|
+
}
|
|
395
|
+
}
|
|
371
396
|
function validateFromLocation(params) {
|
|
372
397
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
373
398
|
var _a, _b;
|
|
@@ -7,26 +7,14 @@ import type { MongoRepository as AccountingReportRepo } from '../../repo/account
|
|
|
7
7
|
import type { MongoRepository as ActionRepo } from '../../repo/action';
|
|
8
8
|
import type { MongoRepository as PaymentServiceRepo } from '../../repo/paymentService';
|
|
9
9
|
import type { MongoRepository as PaymentServiceProviderRepo } from '../../repo/paymentServiceProvider';
|
|
10
|
-
import type { CognitoRepository as PersonRepo } from '../../repo/person';
|
|
11
|
-
import type { MongoRepository as ProjectRepo } from '../../repo/project';
|
|
12
10
|
import type { MongoRepository as PaymentAcceptedRepo } from '../../repo/sellerPaymentAccepted';
|
|
13
11
|
import type { MongoRepository as TaskRepo } from '../../repo/task';
|
|
14
|
-
export interface IExecTran3dsResult {
|
|
15
|
-
/**
|
|
16
|
-
* ACS呼出判定
|
|
17
|
-
*/
|
|
18
|
-
acs: string;
|
|
19
|
-
/**
|
|
20
|
-
* 3DSサーバーへのリダイレクトURL
|
|
21
|
-
* 3DS2.0認証初期化へのURL
|
|
22
|
-
*/
|
|
23
|
-
redirectUrl?: string;
|
|
24
|
-
}
|
|
25
12
|
interface IPaymentAgencyTransaction {
|
|
26
13
|
entryTranArgs: GMO.factory.credit.IEntryTranArgs;
|
|
27
14
|
entryTranResult: GMO.factory.credit.IEntryTranResult;
|
|
28
15
|
execTranArgs: GMO.factory.credit.IExecTranArgs;
|
|
29
|
-
execTranResult: GMO.factory.credit.IExecTranResult | IExecTran3dsResult;
|
|
16
|
+
execTranResult: GMO.factory.credit.IExecTranResult | GMO.factory.credit.IExecTran3dsResult;
|
|
17
|
+
secureTran2Result?: GMO.factory.credit.ISecureTran2Result;
|
|
30
18
|
}
|
|
31
19
|
type IAuthorizeResult = IPaymentAgencyTransaction & {
|
|
32
20
|
accountId: string;
|
|
@@ -42,8 +30,6 @@ declare function authorize(params: factory.assetTransaction.pay.IStartParamsWith
|
|
|
42
30
|
paymentAccepted: PaymentAcceptedRepo;
|
|
43
31
|
paymentService: PaymentServiceRepo;
|
|
44
32
|
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
45
|
-
person: PersonRepo;
|
|
46
|
-
project: ProjectRepo;
|
|
47
33
|
}) => Promise<IAuthorizeResult>;
|
|
48
34
|
/**
|
|
49
35
|
* クレジットカード決済中止
|
|
@@ -52,7 +38,6 @@ declare function voidTransaction(params: factory.task.voidPayment.IData): (repos
|
|
|
52
38
|
paymentAccepted: PaymentAcceptedRepo;
|
|
53
39
|
paymentService: PaymentServiceRepo;
|
|
54
40
|
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
55
|
-
project: ProjectRepo;
|
|
56
41
|
}) => Promise<void>;
|
|
57
42
|
/**
|
|
58
43
|
* クレジットカード決済
|
|
@@ -63,7 +48,6 @@ declare function payCreditCard(params: factory.task.pay.IData): (repos: {
|
|
|
63
48
|
paymentAccepted: PaymentAcceptedRepo;
|
|
64
49
|
paymentService: PaymentServiceRepo;
|
|
65
50
|
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
66
|
-
project: ProjectRepo;
|
|
67
51
|
task: TaskRepo;
|
|
68
52
|
}) => Promise<import("@chevre/factory/lib/action/trade/pay").IAction>;
|
|
69
53
|
/**
|
|
@@ -75,7 +59,6 @@ declare function refundCreditCard(params: factory.task.refund.IData, requirePayA
|
|
|
75
59
|
paymentAccepted: PaymentAcceptedRepo;
|
|
76
60
|
paymentService: PaymentServiceRepo;
|
|
77
61
|
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
78
|
-
project: ProjectRepo;
|
|
79
62
|
task: TaskRepo;
|
|
80
63
|
}) => Promise<import("@chevre/factory/lib/action/trade/refund").IAction>;
|
|
81
64
|
interface IGMOInfo {
|
|
@@ -20,19 +20,20 @@ const credentials_1 = require("../../credentials");
|
|
|
20
20
|
const factory = require("../../factory");
|
|
21
21
|
const onPaid_1 = require("./any/onPaid");
|
|
22
22
|
const onRefund_1 = require("./any/onRefund");
|
|
23
|
-
|
|
23
|
+
// import { person2username } from './any/person2username';
|
|
24
24
|
const debug = createDebug('chevre-domain:service:payment');
|
|
25
25
|
/**
|
|
26
26
|
* クレジットカード決済承認
|
|
27
27
|
*/
|
|
28
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
// const project = <Pick<factory.project.IProject, 'settings'>>await repos.project.findById({
|
|
32
|
+
// id: params.project.id,
|
|
33
|
+
// inclusion: ['settings'],
|
|
34
|
+
// exclusion: []
|
|
35
|
+
// });
|
|
36
|
+
var _a, _b, _c, _d, _e;
|
|
36
37
|
// CreditCard系統の決済方法タイプは動的
|
|
37
38
|
const paymentMethodType = (_a = params.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.identifier;
|
|
38
39
|
if (typeof paymentMethodType !== 'string') {
|
|
@@ -57,9 +58,25 @@ function authorize(params, paymentServiceId, options) {
|
|
|
57
58
|
let authorizeResult;
|
|
58
59
|
let searchTradeResult;
|
|
59
60
|
try {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
+
})();
|
|
79
|
+
}
|
|
63
80
|
}
|
|
64
81
|
catch (error) {
|
|
65
82
|
throw handleAuthorizeError(error);
|
|
@@ -75,8 +92,8 @@ function authorize(params, paymentServiceId, options) {
|
|
|
75
92
|
shopId: shopId,
|
|
76
93
|
shopPass: shopPass,
|
|
77
94
|
orderId: orderId,
|
|
78
|
-
siteId: (
|
|
79
|
-
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
|
|
80
97
|
});
|
|
81
98
|
debug('searchTrade processed. orderId:', orderId, 'execution time:', (Date.now() - startSearchTradeDate), 'ms');
|
|
82
99
|
}
|
|
@@ -85,19 +102,13 @@ function authorize(params, paymentServiceId, options) {
|
|
|
85
102
|
debug('searchTrade throwed an error. orderId:', orderId, error);
|
|
86
103
|
}
|
|
87
104
|
}
|
|
88
|
-
return {
|
|
89
|
-
accountId: (searchTradeResult !== undefined) ? searchTradeResult.cardNo : '',
|
|
90
|
-
paymentMethodId: orderId,
|
|
91
|
-
entryTranArgs: authorizeResult.entryTranArgs,
|
|
92
|
-
entryTranResult: authorizeResult.entryTranResult,
|
|
93
|
-
execTranArgs: authorizeResult.execTranArgs,
|
|
94
|
-
execTranResult: authorizeResult.execTranResult
|
|
95
|
-
};
|
|
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);
|
|
96
106
|
});
|
|
97
107
|
}
|
|
98
108
|
exports.authorize = authorize;
|
|
99
109
|
function processAuthorizeCreditCard(params) {
|
|
100
|
-
|
|
110
|
+
// tslint:disable-next-line:max-func-body-length
|
|
111
|
+
return () => __awaiter(this, void 0, void 0, function* () {
|
|
101
112
|
var _a, _b, _c, _d, _e, _f;
|
|
102
113
|
// GMOオーソリ取得
|
|
103
114
|
let entryTranArgs;
|
|
@@ -105,67 +116,100 @@ function processAuthorizeCreditCard(params) {
|
|
|
105
116
|
let execTranArgs;
|
|
106
117
|
let execTranResult;
|
|
107
118
|
const creditCardService = new GMO.service.Credit({ endpoint: String(params.availableChannel.serviceUrl) }, { timeout: credentials_1.credentials.gmo.timeout });
|
|
108
|
-
const pendingPaymentAgencyTransaction = params.pendingPaymentAgencyTransaction;
|
|
109
|
-
if (pendingPaymentAgencyTransaction !== undefined) {
|
|
110
|
-
const redirectUrl = (_a = pendingPaymentAgencyTransaction === null || pendingPaymentAgencyTransaction === void 0 ? void 0 : pendingPaymentAgencyTransaction.execTranResult) === null || _a === void 0 ? void 0 : _a.redirectUrl;
|
|
111
|
-
if (typeof redirectUrl === 'string' && redirectUrl.length > 0) {
|
|
112
|
-
throw new factory.errors.NotImplemented('secureTran2 not implemented');
|
|
113
|
-
// return {
|
|
114
|
-
// ...pendingPaymentAgencyTransaction
|
|
115
|
-
// };
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
entryTranArgs = {
|
|
119
|
-
shopId: params.shopId,
|
|
120
|
-
shopPass: params.shopPass,
|
|
121
|
-
orderId: params.orderId,
|
|
122
|
-
jobCd: GMO.utils.util.JobCd.Auth,
|
|
123
|
-
amount: (typeof params.object.amount === 'number')
|
|
124
|
-
? params.object.amount
|
|
125
|
-
: params.object.amount.value,
|
|
126
|
-
siteId: (_b = params.availableChannel.credentials) === null || _b === void 0 ? void 0 : _b.siteId,
|
|
127
|
-
sitePass: (_c = params.availableChannel.credentials) === null || _c === void 0 ? void 0 : _c.sitePass
|
|
128
|
-
};
|
|
129
|
-
entryTranResult = yield creditCardService.entryTran(entryTranArgs);
|
|
130
119
|
const creditCard = params.object.creditCard;
|
|
131
|
-
|
|
120
|
+
const memberId = creditCard.memberId;
|
|
132
121
|
const cardSeq = creditCard.cardSeq;
|
|
133
122
|
if (typeof memberId === 'string' && memberId.length > 0 && typeof cardSeq === 'number') {
|
|
123
|
+
// 決済承認時のuseUsernameAsGMOMemberId判定を廃止(2024-01-04~)
|
|
134
124
|
// 特殊なプロジェクトのみユーザーネームに自動変換(新旧会員互換性維持対応)
|
|
135
125
|
// memberIdはPersonIDが指定されてくる想定
|
|
136
|
-
const useUsernameAsGMOMemberId =
|
|
137
|
-
if (useUsernameAsGMOMemberId) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
126
|
+
// const useUsernameAsGMOMemberId = params.projectSettings?.useUsernameAsGMOMemberId === true;
|
|
127
|
+
// if (useUsernameAsGMOMemberId) {
|
|
128
|
+
// try {
|
|
129
|
+
// const customer = await repos.person.findById({ userId: memberId });
|
|
130
|
+
// memberId = await person2username(customer);
|
|
131
|
+
// } catch (error) {
|
|
132
|
+
// throw error;
|
|
133
|
+
// }
|
|
134
|
+
// }
|
|
146
135
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
entryTranArgs
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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: (_a = params.availableChannel.credentials) === null || _a === void 0 ? void 0 : _a.siteId,
|
|
160
|
+
sitePass: (_b = params.availableChannel.credentials) === null || _b === void 0 ? void 0 : _b.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: (_c = params.availableChannel.credentials) === null || _c === void 0 ? void 0 : _c.siteId,
|
|
183
|
+
sitePass: (_d = params.availableChannel.credentials) === null || _d === void 0 ? void 0 : _d.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: (_e = params.availableChannel.credentials) === null || _e === void 0 ? void 0 : _e.siteId,
|
|
192
|
+
sitePass: (_f = params.availableChannel.credentials) === null || _f === void 0 ? void 0 : _f.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 };
|
|
169
213
|
});
|
|
170
214
|
}
|
|
171
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.3",
|
|
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.3"
|
|
119
119
|
}
|