@chevre/domain 21.19.0 → 21.20.0-alpha.1
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 +131 -0
- package/lib/chevre/service/assetTransaction/pay.d.ts +5 -2
- package/lib/chevre/service/assetTransaction/pay.js +13 -5
- package/lib/chevre/service/payment/any.d.ts +1 -1
- package/lib/chevre/service/payment/any.js +21 -11
- package/lib/chevre/service/payment/creditCard.d.ts +27 -10
- package/lib/chevre/service/payment/creditCard.js +21 -15
- package/package.json +2 -2
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
import * as redis from 'redis';
|
|
4
|
+
|
|
5
|
+
import { chevre } from '../../../../lib/index';
|
|
6
|
+
|
|
7
|
+
const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
+
const CLIENT_ID = '51qbjcfr72h62m06vtv5kkhgje';
|
|
9
|
+
|
|
10
|
+
// tslint:disable-next-line:max-func-body-length
|
|
11
|
+
async function main() {
|
|
12
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
|
+
const client = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
|
|
14
|
+
socket: {
|
|
15
|
+
port: Number(<string>process.env.REDIS_PORT),
|
|
16
|
+
host: <string>process.env.REDIS_HOST
|
|
17
|
+
},
|
|
18
|
+
password: <string>process.env.REDIS_KEY
|
|
19
|
+
});
|
|
20
|
+
await client.connect();
|
|
21
|
+
|
|
22
|
+
const transaction = await (await chevre.service.transaction.createService()).placeOrderInProgress.start({
|
|
23
|
+
project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
24
|
+
agent: { id: CLIENT_ID, typeOf: chevre.factory.creativeWorkType.WebApplication },
|
|
25
|
+
object: {
|
|
26
|
+
clientUser: <any>{ client_id: CLIENT_ID }
|
|
27
|
+
},
|
|
28
|
+
seller: { id: '59d20831e53ebc2b4e774466' },
|
|
29
|
+
validateEligibleCustomerType: false
|
|
30
|
+
})({
|
|
31
|
+
seller: await chevre.repository.Seller.createInstance(mongoose.connection),
|
|
32
|
+
transaction: await chevre.repository.Transaction.createInstance(mongoose.connection)
|
|
33
|
+
});
|
|
34
|
+
console.log('transaction started', transaction);
|
|
35
|
+
|
|
36
|
+
const publishPaymentUrlResult = await (await chevre.service.payment.any.createService()).publishPaymentUrl({
|
|
37
|
+
project: { id: project.id },
|
|
38
|
+
agent: { id: CLIENT_ID },
|
|
39
|
+
object: {
|
|
40
|
+
// accountId?: string;
|
|
41
|
+
// additionalProperty?: IPropertyValue<string>[];
|
|
42
|
+
amount: 1,
|
|
43
|
+
// description?: string;
|
|
44
|
+
// name?: string;
|
|
45
|
+
paymentMethod: 'PayPay',
|
|
46
|
+
// paymentMethodId?: string;
|
|
47
|
+
typeOf: chevre.factory.action.authorize.paymentMethod.any.ResultType.Payment,
|
|
48
|
+
issuedThrough: { id: '60e9560176a391000b23e20b' },
|
|
49
|
+
method: '1',
|
|
50
|
+
creditCard: {
|
|
51
|
+
cardNo: '4100000000000100',
|
|
52
|
+
expire: '2812',
|
|
53
|
+
cardPass: '123',
|
|
54
|
+
holderName: 'AA AA'
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
purpose: { id: transaction.id, typeOf: transaction.typeOf },
|
|
58
|
+
paymentServiceType: chevre.factory.service.paymentService.PaymentServiceType.CreditCard,
|
|
59
|
+
location: {
|
|
60
|
+
typeOf: chevre.factory.creativeWorkType.WebApplication,
|
|
61
|
+
id: CLIENT_ID
|
|
62
|
+
}
|
|
63
|
+
// options: {
|
|
64
|
+
// use3DS: true
|
|
65
|
+
// }
|
|
66
|
+
})({
|
|
67
|
+
assetTransaction: await chevre.repository.AssetTransaction.createInstance(mongoose.connection),
|
|
68
|
+
paymentAccepted: await chevre.repository.SellerPaymentAccepted.createInstance(mongoose.connection),
|
|
69
|
+
paymentService: await chevre.repository.PaymentService.createInstance(mongoose.connection),
|
|
70
|
+
paymentServiceProvider: await chevre.repository.PaymentServiceProvider.createInstance(mongoose.connection),
|
|
71
|
+
person: await chevre.repository.Person.createInstance({ userPoolId: '' }),
|
|
72
|
+
project: await chevre.repository.Project.createInstance(mongoose.connection),
|
|
73
|
+
transactionNumber: await chevre.repository.TransactionNumber.createInstance(client),
|
|
74
|
+
transaction: await chevre.repository.Transaction.createInstance(mongoose.connection)
|
|
75
|
+
});
|
|
76
|
+
console.log(publishPaymentUrlResult);
|
|
77
|
+
|
|
78
|
+
const authorizeResult = await (await chevre.service.payment.any.createService()).authorize({
|
|
79
|
+
project: { id: project.id },
|
|
80
|
+
agent: { id: CLIENT_ID },
|
|
81
|
+
object: {
|
|
82
|
+
// accountId?: string;
|
|
83
|
+
// additionalProperty?: IPropertyValue<string>[];
|
|
84
|
+
amount: 1,
|
|
85
|
+
// description?: string;
|
|
86
|
+
// name?: string;
|
|
87
|
+
paymentMethod: 'PayPay',
|
|
88
|
+
paymentMethodId: publishPaymentUrlResult.paymentMethodId,
|
|
89
|
+
typeOf: chevre.factory.action.authorize.paymentMethod.any.ResultType.Payment,
|
|
90
|
+
issuedThrough: { id: '60e9560176a391000b23e20b' },
|
|
91
|
+
method: '1',
|
|
92
|
+
creditCard: {
|
|
93
|
+
cardNo: '4100000000000100',
|
|
94
|
+
expire: '2812',
|
|
95
|
+
cardPass: '123',
|
|
96
|
+
holderName: 'AA AA'
|
|
97
|
+
}
|
|
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)
|
|
125
|
+
});
|
|
126
|
+
console.log(authorizeResult);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
main()
|
|
130
|
+
.then(console.log)
|
|
131
|
+
.catch(console.error);
|
|
@@ -16,6 +16,7 @@ import type { MongoRepository as ProductRepo } from '../../repo/product';
|
|
|
16
16
|
import type { MongoRepository as ProjectRepo } from '../../repo/project';
|
|
17
17
|
import type { MongoRepository as PaymentAcceptedRepo } from '../../repo/sellerPaymentAccepted';
|
|
18
18
|
import type { MongoRepository as TaskRepo } from '../../repo/task';
|
|
19
|
+
import * as CreditCardPayment from '../payment/creditCard';
|
|
19
20
|
import * as MovieTicketPayment from '../payment/movieTicket';
|
|
20
21
|
export interface IStartOperationRepos {
|
|
21
22
|
accountingReport: AccountingReportRepo;
|
|
@@ -79,10 +80,10 @@ export type IInvalidatePaymentUrlOperation<T> = (repos: {
|
|
|
79
80
|
task: TaskRepo;
|
|
80
81
|
assetTransaction: AssetTransactionRepo;
|
|
81
82
|
}) => Promise<T>;
|
|
82
|
-
export
|
|
83
|
+
export type IPublishPaymentUrlResult = CreditCardPayment.IPaymentAgencyTransaction & {
|
|
83
84
|
paymentMethodId: string;
|
|
84
85
|
paymentUrl: string;
|
|
85
|
-
}
|
|
86
|
+
};
|
|
86
87
|
/**
|
|
87
88
|
* 外部決済ロケーション発行
|
|
88
89
|
*/
|
|
@@ -98,6 +99,7 @@ export declare function invalidatePaymentUrl(params: factory.task.refund.IData):
|
|
|
98
99
|
export declare function check(params: factory.action.check.paymentMethod.movieTicket.IAttributes): ICheckOperation<{
|
|
99
100
|
result: MovieTicketPayment.ICheckResult;
|
|
100
101
|
}>;
|
|
102
|
+
export import IPaymentAgencyTransaction = CreditCardPayment.IPaymentAgencyTransaction;
|
|
101
103
|
/**
|
|
102
104
|
* 取引開始
|
|
103
105
|
*/
|
|
@@ -105,6 +107,7 @@ export declare function start(params: factory.assetTransaction.pay.IStartParamsW
|
|
|
105
107
|
useCheckMovieTicketBeforePay: boolean;
|
|
106
108
|
useCheckByIdentifierIfNotYet: boolean;
|
|
107
109
|
searchTrade4accountId: boolean;
|
|
110
|
+
pendingPaymentAgencyTransaction?: CreditCardPayment.IPaymentAgencyTransaction;
|
|
108
111
|
}): IStartOperation<factory.assetTransaction.pay.ITransaction>;
|
|
109
112
|
/**
|
|
110
113
|
* 取引確定
|
|
@@ -40,14 +40,18 @@ 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);
|
|
43
|
+
const authorizeResult = yield CreditCardPayment.authorize(params, paymentServiceId, { searchTrade4accountId: false })(repos);
|
|
44
44
|
const acsUrl = authorizeResult.execTranResult.acsUrl;
|
|
45
45
|
if (typeof acsUrl !== 'string' || acsUrl.length === 0) {
|
|
46
46
|
throw new factory.errors.ServiceUnavailable('Payment URL unable to publish');
|
|
47
47
|
}
|
|
48
48
|
result = {
|
|
49
49
|
paymentMethodId: transactionNumber,
|
|
50
|
-
paymentUrl: acsUrl
|
|
50
|
+
paymentUrl: acsUrl,
|
|
51
|
+
entryTranArgs: authorizeResult.entryTranArgs,
|
|
52
|
+
entryTranResult: authorizeResult.entryTranResult,
|
|
53
|
+
execTranArgs: authorizeResult.execTranArgs,
|
|
54
|
+
execTranResult: authorizeResult.execTranResult
|
|
51
55
|
};
|
|
52
56
|
break;
|
|
53
57
|
default:
|
|
@@ -134,7 +138,9 @@ function start(params, options) {
|
|
|
134
138
|
break;
|
|
135
139
|
case factory.service.paymentService.PaymentServiceType.CreditCard:
|
|
136
140
|
transaction =
|
|
137
|
-
yield processAuthorizeCreditCard(params, transaction, String(paymentService === null || paymentService === void 0 ? void 0 : paymentService.id), options.searchTrade4accountId
|
|
141
|
+
yield processAuthorizeCreditCard(params, transaction, String(paymentService === null || paymentService === void 0 ? void 0 : paymentService.id), Object.assign({ searchTrade4accountId: options.searchTrade4accountId }, (options.pendingPaymentAgencyTransaction !== undefined)
|
|
142
|
+
? { pendingPaymentAgencyTransaction: options.pendingPaymentAgencyTransaction }
|
|
143
|
+
: undefined))(repos);
|
|
138
144
|
break;
|
|
139
145
|
case factory.service.paymentService.PaymentServiceType.MovieTicket:
|
|
140
146
|
transaction =
|
|
@@ -288,9 +294,11 @@ function processAuthorizeAccount(params, transaction, paymentServiceId) {
|
|
|
288
294
|
})(repos);
|
|
289
295
|
});
|
|
290
296
|
}
|
|
291
|
-
function processAuthorizeCreditCard(params, transaction, paymentServiceId,
|
|
297
|
+
function processAuthorizeCreditCard(params, transaction, paymentServiceId, options) {
|
|
292
298
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
293
|
-
const authorizeResult = yield CreditCardPayment.authorize(params, paymentServiceId, searchTrade4accountId
|
|
299
|
+
const authorizeResult = yield CreditCardPayment.authorize(params, paymentServiceId, Object.assign({ searchTrade4accountId: options.searchTrade4accountId }, (options.pendingPaymentAgencyTransaction !== undefined)
|
|
300
|
+
? { pendingPaymentAgencyTransaction: options.pendingPaymentAgencyTransaction }
|
|
301
|
+
: undefined))(repos);
|
|
294
302
|
return saveAuthorizeResult({
|
|
295
303
|
id: transaction.id,
|
|
296
304
|
update: {
|
|
@@ -98,7 +98,7 @@ declare function publishPaymentUrl(params: {
|
|
|
98
98
|
purpose: factory.action.authorize.paymentMethod.any.IPurpose;
|
|
99
99
|
paymentServiceType: factory.service.paymentService.PaymentServiceType;
|
|
100
100
|
location: factory.action.trade.pay.ILocation;
|
|
101
|
-
}): IPublishPaymentUrlOperation<PayTransactionService.IPublishPaymentUrlResult
|
|
101
|
+
}): IPublishPaymentUrlOperation<Pick<PayTransactionService.IPublishPaymentUrlResult, 'paymentMethodId' | 'paymentUrl'>>;
|
|
102
102
|
/**
|
|
103
103
|
* 決済承認
|
|
104
104
|
*/
|
|
@@ -232,13 +232,21 @@ function publishPaymentUrl(params) {
|
|
|
232
232
|
typeOf: params.object.paymentMethod,
|
|
233
233
|
paymentMethodId: result.paymentMethodId,
|
|
234
234
|
paymentUrl: result.paymentUrl,
|
|
235
|
-
issuedThrough: { id: (typeof startParams.object.id === 'string') ? startParams.object.id : '' }
|
|
235
|
+
issuedThrough: { id: (typeof startParams.object.id === 'string') ? startParams.object.id : '' },
|
|
236
|
+
// GMO IFを保管(2024-01-01~)
|
|
237
|
+
entryTranArgs: result.entryTranArgs,
|
|
238
|
+
entryTranResult: result.entryTranResult,
|
|
239
|
+
execTranArgs: result.execTranArgs,
|
|
240
|
+
execTranResult: result.execTranResult
|
|
236
241
|
};
|
|
237
242
|
yield repos.transaction.findByIdAndUpdateInProgress({
|
|
238
243
|
id: transaction.id,
|
|
239
244
|
update: { $set: { 'object.paymentMethods': paymentMethodByPaymentUrl } }
|
|
240
245
|
});
|
|
241
|
-
return
|
|
246
|
+
return {
|
|
247
|
+
paymentMethodId: result.paymentMethodId,
|
|
248
|
+
paymentUrl: result.paymentUrl
|
|
249
|
+
};
|
|
242
250
|
});
|
|
243
251
|
}
|
|
244
252
|
exports.publishPaymentUrl = publishPaymentUrl;
|
|
@@ -248,16 +256,22 @@ exports.publishPaymentUrl = publishPaymentUrl;
|
|
|
248
256
|
function authorize(params) {
|
|
249
257
|
// tslint:disable-next-line:max-func-body-length
|
|
250
258
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
251
|
-
var _a
|
|
259
|
+
var _a;
|
|
252
260
|
const transaction = yield repos.transaction.findInProgressById({ typeOf: params.purpose.typeOf, id: params.purpose.id });
|
|
253
261
|
const paymentServiceType = params.paymentServiceType;
|
|
254
262
|
// 取引番号生成
|
|
255
263
|
let transactionNumber;
|
|
264
|
+
let pendingPaymentAgencyTransaction;
|
|
256
265
|
// リクエストでpaymentMethodIdを指定された場合、取引に保管されたpaymentMethodIdに一致すればそちらを適用(外部サイト決済対応)
|
|
257
266
|
if (typeof params.object.paymentMethodId === 'string' && params.object.paymentMethodId.length > 0) {
|
|
258
|
-
const
|
|
259
|
-
if (params.object.paymentMethodId ===
|
|
267
|
+
const paymentMethodByTransaction = transaction.object.paymentMethods;
|
|
268
|
+
if (params.object.paymentMethodId === (paymentMethodByTransaction === null || paymentMethodByTransaction === void 0 ? void 0 : paymentMethodByTransaction.paymentMethodId)) {
|
|
260
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
|
+
}
|
|
261
275
|
// 既に承認済であれば何もしない(2023-05-15~)
|
|
262
276
|
const existingCompletedAuthorizeActions = yield repos.action.searchByPurpose({
|
|
263
277
|
typeOf: factory.actionType.AuthorizeAction,
|
|
@@ -301,7 +315,7 @@ function authorize(params) {
|
|
|
301
315
|
id: transaction.seller.id,
|
|
302
316
|
name: (typeof transaction.seller.name === 'string')
|
|
303
317
|
? transaction.seller.name
|
|
304
|
-
: String((
|
|
318
|
+
: String((_a = transaction.seller.name) === null || _a === void 0 ? void 0 : _a.ja)
|
|
305
319
|
},
|
|
306
320
|
purpose: { typeOf: transaction.typeOf, id: transaction.id }
|
|
307
321
|
};
|
|
@@ -320,11 +334,7 @@ function authorize(params) {
|
|
|
320
334
|
transactionNumber: transactionNumber,
|
|
321
335
|
location: params.location
|
|
322
336
|
});
|
|
323
|
-
payTransaction = yield PayTransactionService.start(startParams, {
|
|
324
|
-
useCheckMovieTicketBeforePay: params.options.useCheckMovieTicketBeforePay,
|
|
325
|
-
useCheckByIdentifierIfNotYet: params.options.useCheckByIdentifierIfNotYet,
|
|
326
|
-
searchTrade4accountId: params.options.useSearchTrade4accountId
|
|
327
|
-
})(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);
|
|
328
338
|
}
|
|
329
339
|
catch (error) {
|
|
330
340
|
try {
|
|
@@ -11,23 +11,40 @@ 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
|
+
export interface IExecTran3dsResult {
|
|
15
|
+
/**
|
|
16
|
+
* ACS呼出判定
|
|
17
|
+
*/
|
|
18
|
+
acs: string;
|
|
19
|
+
/**
|
|
20
|
+
* 3DSサーバーへのリダイレクトURL
|
|
21
|
+
* 3DS2.0認証初期化へのURL
|
|
22
|
+
*/
|
|
23
|
+
redirectUrl?: string;
|
|
24
|
+
}
|
|
25
|
+
interface IPaymentAgencyTransaction {
|
|
26
|
+
entryTranArgs: GMO.factory.credit.IEntryTranArgs;
|
|
27
|
+
entryTranResult: GMO.factory.credit.IEntryTranResult;
|
|
28
|
+
execTranArgs: GMO.factory.credit.IExecTranArgs;
|
|
29
|
+
execTranResult: GMO.factory.credit.IExecTranResult | IExecTran3dsResult;
|
|
30
|
+
}
|
|
31
|
+
type IAuthorizeResult = IPaymentAgencyTransaction & {
|
|
32
|
+
accountId: string;
|
|
33
|
+
paymentMethodId: string;
|
|
34
|
+
};
|
|
14
35
|
/**
|
|
15
36
|
* クレジットカード決済承認
|
|
16
37
|
*/
|
|
17
|
-
declare function authorize(params: factory.assetTransaction.pay.IStartParamsWithoutDetail, paymentServiceId: string,
|
|
38
|
+
declare function authorize(params: factory.assetTransaction.pay.IStartParamsWithoutDetail, paymentServiceId: string, options: {
|
|
39
|
+
searchTrade4accountId: boolean;
|
|
40
|
+
pendingPaymentAgencyTransaction?: IPaymentAgencyTransaction;
|
|
41
|
+
}): (repos: {
|
|
18
42
|
paymentAccepted: PaymentAcceptedRepo;
|
|
19
43
|
paymentService: PaymentServiceRepo;
|
|
20
44
|
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
21
45
|
person: PersonRepo;
|
|
22
46
|
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
|
-
}>;
|
|
47
|
+
}) => Promise<IAuthorizeResult>;
|
|
31
48
|
/**
|
|
32
49
|
* クレジットカード決済中止
|
|
33
50
|
*/
|
|
@@ -81,4 +98,4 @@ declare function searchGMOTrade(params: {
|
|
|
81
98
|
shopId: string;
|
|
82
99
|
shopPass: string;
|
|
83
100
|
}): Promise<GMO.factory.credit.ISearchTradeResult>;
|
|
84
|
-
export { getGMOInfoFromSeller, authorize, payCreditCard, refundCreditCard, searchGMOTrade, voidTransaction };
|
|
101
|
+
export { IAuthorizeResult, IPaymentAgencyTransaction, getGMOInfoFromSeller, authorize, payCreditCard, refundCreditCard, searchGMOTrade, voidTransaction };
|
|
@@ -25,7 +25,7 @@ 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
29
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
30
30
|
var _a, _b, _c, _d;
|
|
31
31
|
const project = yield repos.project.findById({
|
|
@@ -57,18 +57,14 @@ function authorize(params, paymentServiceId, searchTrade4accountId) {
|
|
|
57
57
|
let authorizeResult;
|
|
58
58
|
let searchTradeResult;
|
|
59
59
|
try {
|
|
60
|
-
authorizeResult = yield processAuthorizeCreditCard({
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
shopPass: shopPass,
|
|
64
|
-
orderId: orderId,
|
|
65
|
-
availableChannel: availableChannel,
|
|
66
|
-
object: params.object.paymentMethod
|
|
67
|
-
})(repos);
|
|
60
|
+
authorizeResult = yield processAuthorizeCreditCard(Object.assign({ projectSettings: project.settings, shopId: shopId, shopPass: shopPass, orderId: orderId, availableChannel: availableChannel, object: params.object.paymentMethod }, (options.pendingPaymentAgencyTransaction !== undefined)
|
|
61
|
+
? { pendingPaymentAgencyTransaction: options.pendingPaymentAgencyTransaction }
|
|
62
|
+
: undefined))(repos);
|
|
68
63
|
}
|
|
69
64
|
catch (error) {
|
|
70
65
|
throw handleAuthorizeError(error);
|
|
71
66
|
}
|
|
67
|
+
const searchTrade4accountId = (options === null || options === void 0 ? void 0 : options.searchTrade4accountId) === true;
|
|
72
68
|
if (searchTrade4accountId) {
|
|
73
69
|
try {
|
|
74
70
|
const creditCardService = new GMO.service.Credit({ endpoint: String(availableChannel.serviceUrl) }, { timeout: credentials_1.credentials.gmo.timeout });
|
|
@@ -102,13 +98,23 @@ function authorize(params, paymentServiceId, searchTrade4accountId) {
|
|
|
102
98
|
exports.authorize = authorize;
|
|
103
99
|
function processAuthorizeCreditCard(params) {
|
|
104
100
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
105
|
-
var _a, _b, _c, _d, _e;
|
|
101
|
+
var _a, _b, _c, _d, _e, _f;
|
|
106
102
|
// GMOオーソリ取得
|
|
107
103
|
let entryTranArgs;
|
|
108
104
|
let entryTranResult;
|
|
109
105
|
let execTranArgs;
|
|
110
106
|
let execTranResult;
|
|
111
107
|
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
|
+
}
|
|
112
118
|
entryTranArgs = {
|
|
113
119
|
shopId: params.shopId,
|
|
114
120
|
shopPass: params.shopPass,
|
|
@@ -117,8 +123,8 @@ function processAuthorizeCreditCard(params) {
|
|
|
117
123
|
amount: (typeof params.object.amount === 'number')
|
|
118
124
|
? params.object.amount
|
|
119
125
|
: params.object.amount.value,
|
|
120
|
-
siteId: (
|
|
121
|
-
sitePass: (
|
|
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
|
|
122
128
|
};
|
|
123
129
|
entryTranResult = yield creditCardService.entryTran(entryTranArgs);
|
|
124
130
|
const creditCard = params.object.creditCard;
|
|
@@ -127,7 +133,7 @@ function processAuthorizeCreditCard(params) {
|
|
|
127
133
|
if (typeof memberId === 'string' && memberId.length > 0 && typeof cardSeq === 'number') {
|
|
128
134
|
// 特殊なプロジェクトのみユーザーネームに自動変換(新旧会員互換性維持対応)
|
|
129
135
|
// memberIdはPersonIDが指定されてくる想定
|
|
130
|
-
const useUsernameAsGMOMemberId = ((
|
|
136
|
+
const useUsernameAsGMOMemberId = ((_d = params.projectSettings) === null || _d === void 0 ? void 0 : _d.useUsernameAsGMOMemberId) === true;
|
|
131
137
|
if (useUsernameAsGMOMemberId) {
|
|
132
138
|
try {
|
|
133
139
|
const customer = yield repos.person.findById({ userId: memberId });
|
|
@@ -143,8 +149,8 @@ function processAuthorizeCreditCard(params) {
|
|
|
143
149
|
accessPass: entryTranResult.accessPass,
|
|
144
150
|
orderId: params.orderId,
|
|
145
151
|
method: params.object.method,
|
|
146
|
-
siteId: (
|
|
147
|
-
sitePass: (
|
|
152
|
+
siteId: (_e = params.availableChannel.credentials) === null || _e === void 0 ? void 0 : _e.siteId,
|
|
153
|
+
sitePass: (_f = params.availableChannel.credentials) === null || _f === void 0 ? void 0 : _f.sitePass,
|
|
148
154
|
cardNo: creditCard.cardNo,
|
|
149
155
|
cardPass: creditCard.cardPass,
|
|
150
156
|
expire: creditCard.expire,
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/credential-providers": "3.433.0",
|
|
13
|
-
"@chevre/factory": "4.
|
|
13
|
+
"@chevre/factory": "4.351.0-alpha.1",
|
|
14
14
|
"@cinerino/sdk": "5.6.0",
|
|
15
15
|
"@motionpicture/coa-service": "9.2.0",
|
|
16
16
|
"@motionpicture/gmo-service": "5.2.0",
|
|
@@ -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.
|
|
118
|
+
"version": "21.20.0-alpha.1"
|
|
119
119
|
}
|