@chevre/domain 21.2.0-alpha.92 → 21.2.0-alpha.93
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/processPay.ts +2 -1
- package/example/src/chevre/searchActions.ts +26 -0
- package/lib/chevre/service/assetTransaction/pay.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/pay.js +6 -5
- package/lib/chevre/service/payment/any.d.ts +1 -0
- package/lib/chevre/service/payment/any.js +1 -1
- package/lib/chevre/service/payment/creditCard.d.ts +1 -1
- package/lib/chevre/service/payment/creditCard.js +21 -15
- package/lib/chevre/service/transaction/orderProgramMembership.js +2 -1
- package/package.json +1 -1
- package/example/src/chevre/searchSellers.ts +0 -33
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// tslint:disable:no-implicit-dependencies no-console
|
|
2
|
+
import { chevre } from '../../../lib/index';
|
|
3
|
+
|
|
4
|
+
import * as mongoose from 'mongoose';
|
|
5
|
+
|
|
6
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: true });
|
|
10
|
+
|
|
11
|
+
const actionRepo = new chevre.repository.Action(mongoose.connection);
|
|
12
|
+
const actions = await actionRepo.search(
|
|
13
|
+
{
|
|
14
|
+
object: { reservationNumber: { $eq: 'xxx' } }
|
|
15
|
+
},
|
|
16
|
+
['_id'],
|
|
17
|
+
[]
|
|
18
|
+
);
|
|
19
|
+
console.log('actions:', actions);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
main()
|
|
23
|
+
.then(() => {
|
|
24
|
+
console.log('success!');
|
|
25
|
+
})
|
|
26
|
+
.catch(console.error);
|
|
@@ -96,7 +96,7 @@ export declare function check(params: factory.action.check.paymentMethod.movieTi
|
|
|
96
96
|
/**
|
|
97
97
|
* 取引開始
|
|
98
98
|
*/
|
|
99
|
-
export declare function start(params: factory.assetTransaction.pay.IStartParamsWithoutDetail, useCheckMovieTicketBeforePay: boolean): IStartOperation<factory.assetTransaction.pay.ITransaction>;
|
|
99
|
+
export declare function start(params: factory.assetTransaction.pay.IStartParamsWithoutDetail, useCheckMovieTicketBeforePay: boolean, searchTrade4accountId: boolean): IStartOperation<factory.assetTransaction.pay.ITransaction>;
|
|
100
100
|
/**
|
|
101
101
|
* 取引確定
|
|
102
102
|
*/
|
|
@@ -42,7 +42,7 @@ function publishPaymentUrl(params) {
|
|
|
42
42
|
let result;
|
|
43
43
|
switch (paymentServiceType) {
|
|
44
44
|
case factory.service.paymentService.PaymentServiceType.CreditCard:
|
|
45
|
-
const authorizeResult = yield CreditCardPayment.authorize(params, paymentServiceId)(repos);
|
|
45
|
+
const authorizeResult = yield CreditCardPayment.authorize(params, paymentServiceId, false)(repos);
|
|
46
46
|
const acsUrl = authorizeResult.execTranResult.acsUrl;
|
|
47
47
|
if (typeof acsUrl !== 'string' || acsUrl.length === 0) {
|
|
48
48
|
throw new factory.errors.ServiceUnavailable('Payment URL unable to publish');
|
|
@@ -106,7 +106,7 @@ exports.check = check;
|
|
|
106
106
|
/**
|
|
107
107
|
* 取引開始
|
|
108
108
|
*/
|
|
109
|
-
function start(params, useCheckMovieTicketBeforePay) {
|
|
109
|
+
function start(params, useCheckMovieTicketBeforePay, searchTrade4accountId) {
|
|
110
110
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
111
111
|
var _a, _b;
|
|
112
112
|
// 金額をfix
|
|
@@ -137,7 +137,8 @@ function start(params, useCheckMovieTicketBeforePay) {
|
|
|
137
137
|
transaction = yield processAuthorizeAccount(params, transaction, String(paymentService === null || paymentService === void 0 ? void 0 : paymentService.id))(repos);
|
|
138
138
|
break;
|
|
139
139
|
case factory.service.paymentService.PaymentServiceType.CreditCard:
|
|
140
|
-
transaction =
|
|
140
|
+
transaction =
|
|
141
|
+
yield processAuthorizeCreditCard(params, transaction, String(paymentService === null || paymentService === void 0 ? void 0 : paymentService.id), searchTrade4accountId)(repos);
|
|
141
142
|
break;
|
|
142
143
|
case factory.service.paymentService.PaymentServiceType.MovieTicket:
|
|
143
144
|
transaction =
|
|
@@ -253,9 +254,9 @@ function processAuthorizeAccount(params, transaction, paymentServiceId) {
|
|
|
253
254
|
})(repos);
|
|
254
255
|
});
|
|
255
256
|
}
|
|
256
|
-
function processAuthorizeCreditCard(params, transaction, paymentServiceId) {
|
|
257
|
+
function processAuthorizeCreditCard(params, transaction, paymentServiceId, searchTrade4accountId) {
|
|
257
258
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
258
|
-
const authorizeResult = yield CreditCardPayment.authorize(params, paymentServiceId)(repos);
|
|
259
|
+
const authorizeResult = yield CreditCardPayment.authorize(params, paymentServiceId, searchTrade4accountId)(repos);
|
|
259
260
|
return saveAuthorizeResult({
|
|
260
261
|
id: transaction.id,
|
|
261
262
|
update: {
|
|
@@ -113,5 +113,6 @@ declare function authorize(params: {
|
|
|
113
113
|
*/
|
|
114
114
|
useCancelPayTransactionOnFailed: boolean;
|
|
115
115
|
useCheckMovieTicketBeforePay: boolean;
|
|
116
|
+
useSearchTrade4accountId: boolean;
|
|
116
117
|
}): IAuthorizeOperation<IAuthorizePaymentAction>;
|
|
117
118
|
export { onPaymentStatusChanged, authorize, invalidatePaymentUrl, voidPayTransaction, person2username, processVoidPayTransaction, publishPaymentUrl };
|
|
@@ -314,7 +314,7 @@ function authorize(params) {
|
|
|
314
314
|
transactionNumber: transactionNumber,
|
|
315
315
|
location: params.location
|
|
316
316
|
});
|
|
317
|
-
payTransaction = yield PayTransactionService.start(startParams, params.useCheckMovieTicketBeforePay)(repos);
|
|
317
|
+
payTransaction = yield PayTransactionService.start(startParams, params.useCheckMovieTicketBeforePay, params.useSearchTrade4accountId)(repos);
|
|
318
318
|
}
|
|
319
319
|
catch (error) {
|
|
320
320
|
try {
|
|
@@ -13,7 +13,7 @@ import { MongoRepository as TaskRepo } from '../../repo/task';
|
|
|
13
13
|
/**
|
|
14
14
|
* クレジットカード決済承認
|
|
15
15
|
*/
|
|
16
|
-
declare function authorize(params: factory.assetTransaction.pay.IStartParamsWithoutDetail, paymentServiceId: string): (repos: {
|
|
16
|
+
declare function authorize(params: factory.assetTransaction.pay.IStartParamsWithoutDetail, paymentServiceId: string, searchTrade4accountId: boolean): (repos: {
|
|
17
17
|
person: PersonRepo;
|
|
18
18
|
product: ProductRepo;
|
|
19
19
|
project: ProjectRepo;
|
|
@@ -21,11 +21,11 @@ const factory = require("../../factory");
|
|
|
21
21
|
const onPaid_1 = require("./any/onPaid");
|
|
22
22
|
const onRefund_1 = require("./any/onRefund");
|
|
23
23
|
const person2username_1 = require("./any/person2username");
|
|
24
|
-
const debug = createDebug('chevre-domain:service');
|
|
24
|
+
const debug = createDebug('chevre-domain:service:payment');
|
|
25
25
|
/**
|
|
26
26
|
* クレジットカード決済承認
|
|
27
27
|
*/
|
|
28
|
-
function authorize(params, paymentServiceId) {
|
|
28
|
+
function authorize(params, paymentServiceId, searchTrade4accountId) {
|
|
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({ id: params.project.id });
|
|
@@ -65,19 +65,25 @@ function authorize(params, paymentServiceId) {
|
|
|
65
65
|
catch (error) {
|
|
66
66
|
throw handleAuthorizeError(error);
|
|
67
67
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
68
|
+
if (searchTrade4accountId) {
|
|
69
|
+
try {
|
|
70
|
+
const creditCardService = new GMO.service.Credit({ endpoint: String(availableChannel.serviceUrl) }, { timeout: credentials_1.credentials.gmo.timeout });
|
|
71
|
+
// ベストエフォートでクレジットカード詳細情報を取得
|
|
72
|
+
const startSearchTradeDate = Date.now();
|
|
73
|
+
debug('searchTrade processing...orderId:', orderId, startSearchTradeDate);
|
|
74
|
+
searchTradeResult = yield creditCardService.searchTrade({
|
|
75
|
+
shopId: shopId,
|
|
76
|
+
shopPass: shopPass,
|
|
77
|
+
orderId: orderId,
|
|
78
|
+
siteId: (_c = availableChannel.credentials) === null || _c === void 0 ? void 0 : _c.siteId,
|
|
79
|
+
sitePass: (_d = availableChannel.credentials) === null || _d === void 0 ? void 0 : _d.sitePass
|
|
80
|
+
});
|
|
81
|
+
debug('searchTrade processed. orderId:', orderId, 'execution time:', (Date.now() - startSearchTradeDate), 'ms');
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
// no op
|
|
85
|
+
debug('searchTrade throwed an error. orderId:', orderId, error);
|
|
86
|
+
}
|
|
81
87
|
}
|
|
82
88
|
return {
|
|
83
89
|
accountId: (searchTradeResult !== undefined) ? searchTradeResult.cardNo : '',
|
|
@@ -339,7 +339,8 @@ function processAuthorizeCreditCard(params) {
|
|
|
339
339
|
purpose: params.purpose,
|
|
340
340
|
paymentServiceType: factory.service.paymentService.PaymentServiceType.CreditCard,
|
|
341
341
|
useCancelPayTransactionOnFailed: false,
|
|
342
|
-
useCheckMovieTicketBeforePay: false
|
|
342
|
+
useCheckMovieTicketBeforePay: false,
|
|
343
|
+
useSearchTrade4accountId: false
|
|
343
344
|
})(repos);
|
|
344
345
|
});
|
|
345
346
|
}
|
package/package.json
CHANGED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-implicit-dependencies no-console
|
|
2
|
-
import { chevre } from '../../../lib/index';
|
|
3
|
-
|
|
4
|
-
import * as mongoose from 'mongoose';
|
|
5
|
-
|
|
6
|
-
// const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
-
|
|
8
|
-
async function main() {
|
|
9
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
|
-
|
|
11
|
-
const sellerRepo = new chevre.repository.Seller(mongoose.connection);
|
|
12
|
-
const sellers = await sellerRepo.search({
|
|
13
|
-
hasMerchantReturnPolicy: { itemCondition: { id: { $eq: '646dc7848b3c1437d43dbfeb' } } }
|
|
14
|
-
});
|
|
15
|
-
console.log('sellers:', sellers);
|
|
16
|
-
|
|
17
|
-
const assetTransactionRepo = new chevre.repository.AssetTransaction(mongoose.connection);
|
|
18
|
-
const reserveTransactions = await assetTransactionRepo.search({
|
|
19
|
-
limit: 1,
|
|
20
|
-
typeOf: chevre.factory.assetTransactionType.Reserve,
|
|
21
|
-
object: {
|
|
22
|
-
reservationNumber: { $eq: 'xxx' }
|
|
23
|
-
// reservationFor: { id: { $eq: 'xxx' } }
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
console.log('reserveTransactions:', reserveTransactions);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
main()
|
|
30
|
-
.then(() => {
|
|
31
|
-
console.log('success!');
|
|
32
|
-
})
|
|
33
|
-
.catch(console.error);
|