@chevre/domain 21.33.0-alpha.19 → 21.33.0-alpha.20
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/lib/chevre/service/payment/creditCard.d.ts +2 -0
- package/lib/chevre/service/payment/creditCard.js +66 -12
- package/lib/chevre/service/payment.d.ts +2 -0
- package/lib/chevre/service/task/pay.js +2 -0
- package/lib/chevre/settings.d.ts +1 -0
- package/lib/chevre/settings.js +2 -1
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@ import * as GMO from '@motionpicture/gmo-service';
|
|
|
5
5
|
import * as factory from '../../factory';
|
|
6
6
|
import type { MongoRepository as AccountingReportRepo } from '../../repo/accountingReport';
|
|
7
7
|
import type { MongoRepository as ActionRepo } from '../../repo/action';
|
|
8
|
+
import type { ActionRecipeRepo } from '../../repo/actionRecipe';
|
|
8
9
|
import type { MongoRepository as PaymentServiceRepo } from '../../repo/paymentService';
|
|
9
10
|
import type { MongoRepository as PaymentServiceProviderRepo } from '../../repo/paymentServiceProvider';
|
|
10
11
|
import type { MongoRepository as PaymentAcceptedRepo } from '../../repo/sellerPaymentAccepted';
|
|
@@ -57,6 +58,7 @@ declare function voidTransaction(params: factory.task.voidPayment.IData): (repos
|
|
|
57
58
|
*/
|
|
58
59
|
declare function payCreditCard(params: factory.task.pay.IPayActionData): (repos: {
|
|
59
60
|
action: ActionRepo;
|
|
61
|
+
actionRecipe?: ActionRecipeRepo;
|
|
60
62
|
accountingReport: AccountingReportRepo;
|
|
61
63
|
paymentAccepted: PaymentAcceptedRepo;
|
|
62
64
|
paymentService: PaymentServiceRepo;
|
|
@@ -18,6 +18,7 @@ const createDebug = require("debug");
|
|
|
18
18
|
const http_status_1 = require("http-status");
|
|
19
19
|
const credentials_1 = require("../../credentials");
|
|
20
20
|
const factory = require("../../factory");
|
|
21
|
+
const settings_1 = require("../../settings");
|
|
21
22
|
const onPaid_1 = require("./any/onPaid");
|
|
22
23
|
const onRefund_1 = require("./any/onRefund");
|
|
23
24
|
const debug = createDebug('chevre-domain:service:payment');
|
|
@@ -300,7 +301,7 @@ exports.voidTransaction = voidTransaction;
|
|
|
300
301
|
*/
|
|
301
302
|
function payCreditCard(params) {
|
|
302
303
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
303
|
-
var _a;
|
|
304
|
+
var _a, _b;
|
|
304
305
|
const payObject = params.object;
|
|
305
306
|
// CreditCard系統の決済方法タイプは動的
|
|
306
307
|
const paymentMethodType = payObject[0].paymentMethod.typeOf;
|
|
@@ -326,9 +327,22 @@ function payCreditCard(params) {
|
|
|
326
327
|
endpoint: String(availableChannel.serviceUrl),
|
|
327
328
|
useFetch: credentials_1.credentials.gmo.useFetch
|
|
328
329
|
}, { timeout: credentials_1.credentials.gmo.timeout });
|
|
330
|
+
const processAlterTranResults = [];
|
|
329
331
|
yield Promise.all(payObject.map((paymentMethod) => __awaiter(this, void 0, void 0, function* () {
|
|
330
|
-
|
|
332
|
+
const processAlterTranResult = yield processAlterTran({
|
|
333
|
+
shopId, shopPass, availableChannel, paymentMethod
|
|
334
|
+
})({ creditCardService });
|
|
335
|
+
alterTranResults.push(processAlterTranResult.alterTranResult);
|
|
336
|
+
processAlterTranResults.push(processAlterTranResult);
|
|
331
337
|
})));
|
|
338
|
+
// add recipe(2024-06-03~)
|
|
339
|
+
if (settings_1.USE_EXPERIMENTAL_FEATURE) {
|
|
340
|
+
yield ((_b = repos.actionRecipe) === null || _b === void 0 ? void 0 : _b.saveOne(processAlterTranResult2recipe({
|
|
341
|
+
processAlterTranResults,
|
|
342
|
+
project: { id: params.project.id },
|
|
343
|
+
action: { id: action.id, typeOf: action.typeOf }
|
|
344
|
+
})));
|
|
345
|
+
}
|
|
332
346
|
}
|
|
333
347
|
catch (error) {
|
|
334
348
|
try {
|
|
@@ -352,17 +366,19 @@ exports.payCreditCard = payCreditCard;
|
|
|
352
366
|
function processAlterTran(params) {
|
|
353
367
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
354
368
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
355
|
-
|
|
369
|
+
let alterTranArgs;
|
|
370
|
+
let alterTranResult;
|
|
356
371
|
const paymentMethod = params.paymentMethod;
|
|
357
372
|
const orderId = paymentMethod.paymentMethod.paymentMethodId;
|
|
358
373
|
// 取引状態参照
|
|
359
|
-
const
|
|
374
|
+
const searchTradeArgs = {
|
|
360
375
|
shopId: params.shopId,
|
|
361
376
|
shopPass: params.shopPass,
|
|
362
377
|
orderId: orderId,
|
|
363
378
|
siteId: (_a = params.availableChannel.credentials) === null || _a === void 0 ? void 0 : _a.siteId,
|
|
364
379
|
sitePass: (_b = params.availableChannel.credentials) === null || _b === void 0 ? void 0 : _b.sitePass
|
|
365
|
-
}
|
|
380
|
+
};
|
|
381
|
+
const searchTradeResult = yield repos.creditCardService.searchTrade(searchTradeArgs);
|
|
366
382
|
const amount = (_c = paymentMethod.paymentMethod.totalPaymentDue) === null || _c === void 0 ? void 0 : _c.value;
|
|
367
383
|
if (typeof amount !== 'number') {
|
|
368
384
|
throw new factory.errors.ArgumentNull('object.paymentMethod.totalPaymentDue?.value');
|
|
@@ -372,19 +388,19 @@ function processAlterTran(params) {
|
|
|
372
388
|
case GMO.utils.util.JobCd.Sales:
|
|
373
389
|
debug('already in SALES');
|
|
374
390
|
// すでに即時売上済み
|
|
375
|
-
|
|
391
|
+
alterTranResult = {
|
|
376
392
|
accessId: searchTradeResult.accessId,
|
|
377
393
|
accessPass: searchTradeResult.accessPass,
|
|
378
394
|
forward: searchTradeResult.forward,
|
|
379
395
|
approve: searchTradeResult.approve,
|
|
380
396
|
tranId: searchTradeResult.tranId,
|
|
381
397
|
tranDate: ''
|
|
382
|
-
}
|
|
398
|
+
};
|
|
383
399
|
break;
|
|
384
400
|
case GMO.utils.util.JobCd.Void:
|
|
385
401
|
// 返品手数料決済の場合を追加(状態が取消であれば即時売上)
|
|
386
402
|
debug('calling alterTran...');
|
|
387
|
-
|
|
403
|
+
alterTranArgs = {
|
|
388
404
|
shopId: params.shopId,
|
|
389
405
|
shopPass: params.shopPass,
|
|
390
406
|
accessId: searchTradeResult.accessId,
|
|
@@ -394,12 +410,13 @@ function processAlterTran(params) {
|
|
|
394
410
|
siteId: (_d = params.availableChannel.credentials) === null || _d === void 0 ? void 0 : _d.siteId,
|
|
395
411
|
sitePass: (_e = params.availableChannel.credentials) === null || _e === void 0 ? void 0 : _e.sitePass,
|
|
396
412
|
method: GMO.utils.util.Method.Lump // 再オーソリの場合、支払方法指定は必須
|
|
397
|
-
}
|
|
413
|
+
};
|
|
414
|
+
alterTranResult = yield repos.creditCardService.alterTran(alterTranArgs);
|
|
398
415
|
debug('alterTran processed.');
|
|
399
416
|
break;
|
|
400
417
|
case GMO.utils.util.JobCd.Auth:
|
|
401
418
|
debug('calling alterTran...');
|
|
402
|
-
|
|
419
|
+
alterTranArgs = {
|
|
403
420
|
shopId: params.shopId,
|
|
404
421
|
shopPass: params.shopPass,
|
|
405
422
|
accessId: searchTradeResult.accessId,
|
|
@@ -408,7 +425,8 @@ function processAlterTran(params) {
|
|
|
408
425
|
amount: amount,
|
|
409
426
|
siteId: (_f = params.availableChannel.credentials) === null || _f === void 0 ? void 0 : _f.siteId,
|
|
410
427
|
sitePass: (_g = params.availableChannel.credentials) === null || _g === void 0 ? void 0 : _g.sitePass
|
|
411
|
-
}
|
|
428
|
+
};
|
|
429
|
+
alterTranResult = yield repos.creditCardService.alterTran(alterTranArgs);
|
|
412
430
|
// 失敗したら取引状態確認してどうこう、という処理も考えうるが、
|
|
413
431
|
// GMOはapiのコール制限が厳しく、下手にコールするとすぐにクライアントサイドにも影響をあたえてしまう
|
|
414
432
|
// リトライはタスクの仕組みに含まれているので失敗してもここでは何もしない
|
|
@@ -416,9 +434,45 @@ function processAlterTran(params) {
|
|
|
416
434
|
default:
|
|
417
435
|
throw new factory.errors.NotImplemented(`jobCd '${searchTradeResult.jobCd}' not implemented`);
|
|
418
436
|
}
|
|
419
|
-
return
|
|
437
|
+
return { searchTradeArgs, searchTradeResult, alterTranArgs, alterTranResult };
|
|
420
438
|
});
|
|
421
439
|
}
|
|
440
|
+
function processAlterTranResult2recipe(params) {
|
|
441
|
+
const { processAlterTranResults, project, action } = params;
|
|
442
|
+
return {
|
|
443
|
+
project: { id: project.id, typeOf: factory.organizationType.Project },
|
|
444
|
+
typeOf: 'Recipe',
|
|
445
|
+
recipeCategory: 'payCreditCard',
|
|
446
|
+
recipeFor: { id: action.id, typeOf: action.typeOf },
|
|
447
|
+
step: processAlterTranResults.map(({ searchTradeArgs, searchTradeResult, alterTranArgs, alterTranResult }) => {
|
|
448
|
+
return {
|
|
449
|
+
typeOf: 'HowToSection',
|
|
450
|
+
itemListElement: [
|
|
451
|
+
{
|
|
452
|
+
typeOf: 'HowToStep',
|
|
453
|
+
identifier: 'searchTrade',
|
|
454
|
+
itemListElement: [{
|
|
455
|
+
typeOf: 'HowToDirection',
|
|
456
|
+
beforeMedia: searchTradeArgs,
|
|
457
|
+
afterMedia: searchTradeResult
|
|
458
|
+
// text: 'entryTran'
|
|
459
|
+
}]
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
typeOf: 'HowToStep',
|
|
463
|
+
identifier: 'alterTran',
|
|
464
|
+
itemListElement: [{
|
|
465
|
+
typeOf: 'HowToDirection',
|
|
466
|
+
beforeMedia: alterTranArgs,
|
|
467
|
+
afterMedia: alterTranResult
|
|
468
|
+
// text: 'execTran'
|
|
469
|
+
}]
|
|
470
|
+
}
|
|
471
|
+
]
|
|
472
|
+
};
|
|
473
|
+
})
|
|
474
|
+
};
|
|
475
|
+
}
|
|
422
476
|
/**
|
|
423
477
|
* クレジットカード返金
|
|
424
478
|
*/
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import type { MongoRepository as AcceptedOfferRepo } from '../repo/acceptedOffer';
|
|
5
5
|
import type { MongoRepository as AccountingReportRepo } from '../repo/accountingReport';
|
|
6
6
|
import type { MongoRepository as ActionRepo } from '../repo/action';
|
|
7
|
+
import type { ActionRecipeRepo } from '../repo/actionRecipe';
|
|
7
8
|
import type { MongoRepository as AssetTransactionRepo } from '../repo/assetTransaction';
|
|
8
9
|
import type { MongoRepository as EventRepo } from '../repo/event';
|
|
9
10
|
import type { MongoRepository as OrderRepo } from '../repo/order';
|
|
@@ -21,6 +22,7 @@ import * as factory from '../factory';
|
|
|
21
22
|
export declare function pay(params: factory.task.pay.IData): (repos: {
|
|
22
23
|
acceptedOffer: AcceptedOfferRepo;
|
|
23
24
|
action: ActionRepo;
|
|
25
|
+
actionRecipe?: ActionRecipeRepo;
|
|
24
26
|
accountingReport: AccountingReportRepo;
|
|
25
27
|
assetTransaction: AssetTransactionRepo;
|
|
26
28
|
event: EventRepo;
|
|
@@ -13,6 +13,7 @@ exports.call = void 0;
|
|
|
13
13
|
const acceptedOffer_1 = require("../../repo/acceptedOffer");
|
|
14
14
|
const accountingReport_1 = require("../../repo/accountingReport");
|
|
15
15
|
const action_1 = require("../../repo/action");
|
|
16
|
+
const actionRecipe_1 = require("../../repo/actionRecipe");
|
|
16
17
|
const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
17
18
|
const event_1 = require("../../repo/event");
|
|
18
19
|
const order_1 = require("../../repo/order");
|
|
@@ -32,6 +33,7 @@ function call(data) {
|
|
|
32
33
|
acceptedOffer: new acceptedOffer_1.MongoRepository(settings.connection),
|
|
33
34
|
accountingReport: new accountingReport_1.MongoRepository(settings.connection),
|
|
34
35
|
action: new action_1.MongoRepository(settings.connection),
|
|
36
|
+
actionRecipe: new actionRecipe_1.ActionRecipeRepo(settings.connection),
|
|
35
37
|
assetTransaction: new assetTransaction_1.MongoRepository(settings.connection),
|
|
36
38
|
event: new event_1.MongoRepository(settings.connection),
|
|
37
39
|
order: new order_1.MongoRepository(settings.connection),
|
package/lib/chevre/settings.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export declare const USE_CHECK_RESOURCE_TASK: boolean;
|
|
|
40
40
|
export declare const USE_OPTIMIZE_RESERVATION_EXCEPTIONS: string[];
|
|
41
41
|
export declare const USE_OPTIMIZE_INFORM_EVENT: boolean;
|
|
42
42
|
export declare const USE_VALIDATE_MOVIE_TICKET_BY_TICKET_IDENTIFIER: boolean;
|
|
43
|
+
export declare const USE_EXPERIMENTAL_FEATURE: boolean;
|
|
43
44
|
export declare const MONGO_MAX_TIME_MS: number;
|
|
44
45
|
export declare const MONGO_READ_PREFERENCE: string;
|
|
45
46
|
export declare const MONGO_AUTO_INDEX: boolean;
|
package/lib/chevre/settings.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.settings = exports.DELIVER_ORDER_LIMIT = exports.MONGO_AUTO_INDEX = exports.MONGO_READ_PREFERENCE = exports.MONGO_MAX_TIME_MS = exports.USE_VALIDATE_MOVIE_TICKET_BY_TICKET_IDENTIFIER = exports.USE_OPTIMIZE_INFORM_EVENT = exports.USE_OPTIMIZE_RESERVATION_EXCEPTIONS = exports.USE_CHECK_RESOURCE_TASK = exports.USE_OWNERSHIP_INFO_BY_WEB_APPLICATION = exports.USE_SEND_EMAIL_MESSAGE_ON_ORDER_PROCESSING = exports.USE_FETCH_API = exports.USE_OPTIMIZE_TICKET_OFFER = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.MAX_NUM_CREDIT_CARD_PAYMENT_METHOD = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.MAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
|
|
3
|
+
exports.settings = exports.DELIVER_ORDER_LIMIT = exports.MONGO_AUTO_INDEX = exports.MONGO_READ_PREFERENCE = exports.MONGO_MAX_TIME_MS = exports.USE_EXPERIMENTAL_FEATURE = exports.USE_VALIDATE_MOVIE_TICKET_BY_TICKET_IDENTIFIER = exports.USE_OPTIMIZE_INFORM_EVENT = exports.USE_OPTIMIZE_RESERVATION_EXCEPTIONS = exports.USE_CHECK_RESOURCE_TASK = exports.USE_OWNERSHIP_INFO_BY_WEB_APPLICATION = exports.USE_SEND_EMAIL_MESSAGE_ON_ORDER_PROCESSING = exports.USE_FETCH_API = exports.USE_OPTIMIZE_TICKET_OFFER = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.MAX_NUM_CREDIT_CARD_PAYMENT_METHOD = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.MAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
|
|
4
4
|
const factory = require("./factory");
|
|
5
5
|
const transactionWebhookUrls = (typeof process.env.INFORM_TRANSACTION_URL === 'string')
|
|
6
6
|
? process.env.INFORM_TRANSACTION_URL.split(' ')
|
|
@@ -63,6 +63,7 @@ exports.USE_OPTIMIZE_RESERVATION_EXCEPTIONS = (typeof process.env.USE_OPTIMIZE_R
|
|
|
63
63
|
: [];
|
|
64
64
|
exports.USE_OPTIMIZE_INFORM_EVENT = process.env.USE_OPTIMIZE_INFORM_EVENT === '1';
|
|
65
65
|
exports.USE_VALIDATE_MOVIE_TICKET_BY_TICKET_IDENTIFIER = process.env.USE_VALIDATE_MOVIE_TICKET_BY_TICKET_IDENTIFIER === '1';
|
|
66
|
+
exports.USE_EXPERIMENTAL_FEATURE = process.env.USE_EXPERIMENTAL_FEATURE === '1';
|
|
66
67
|
exports.MONGO_MAX_TIME_MS = (typeof process.env.MONGO_MAX_TIME_MS === 'string')
|
|
67
68
|
? Number(process.env.MONGO_MAX_TIME_MS)
|
|
68
69
|
// tslint:disable-next-line:no-magic-numbers
|
package/package.json
CHANGED