@chevre/domain 21.29.0 → 21.30.0-alpha.0
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/migrateDeleteTransactionTasks.ts +35 -21
- package/example/src/chevre/optimizeDeleteTransactionTasks.ts +119 -0
- package/example/src/chevre/transaction/processPlaceOrder.ts +4 -1
- package/lib/chevre/repo/transactionProcess.d.ts +24 -0
- package/lib/chevre/repo/transactionProcess.js +55 -0
- package/lib/chevre/repository.d.ts +5 -0
- package/lib/chevre/repository.js +14 -1
- package/lib/chevre/service/payment/any.d.ts +3 -0
- package/lib/chevre/service/payment/any.js +6 -2
- package/lib/chevre/service/payment/creditCard.js +6 -0
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@ import * as mongoose from 'mongoose';
|
|
|
5
5
|
import { chevre } from '../../../lib/index';
|
|
6
6
|
|
|
7
7
|
// const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
+
const STORAGE_PERIOD_IN_DAYS = 30;
|
|
8
9
|
|
|
9
10
|
// tslint:disable-next-line:max-func-body-length
|
|
10
11
|
async function main() {
|
|
@@ -16,18 +17,18 @@ async function main() {
|
|
|
16
17
|
const cursor = taskRepo.getCursor(
|
|
17
18
|
{
|
|
18
19
|
name: { $eq: chevre.factory.taskName.DeleteTransaction },
|
|
19
|
-
status: { $eq: chevre.factory.taskStatus.Ready }
|
|
20
|
-
runsAt: {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
// _id: { $eq: '
|
|
20
|
+
status: { $eq: chevre.factory.taskStatus.Ready }
|
|
21
|
+
// runsAt: {
|
|
22
|
+
// $gte: moment()
|
|
23
|
+
// // tslint:disable-next-line:no-magic-numbers
|
|
24
|
+
// .add(29, 'days')
|
|
25
|
+
// .toDate(),
|
|
26
|
+
// $lte: moment()
|
|
27
|
+
// // tslint:disable-next-line:no-magic-numbers
|
|
28
|
+
// .add(365, 'days')
|
|
29
|
+
// .toDate()
|
|
30
|
+
// },
|
|
31
|
+
// _id: { $eq: '6440d8cf9e4983c32ade65de' }
|
|
31
32
|
},
|
|
32
33
|
{
|
|
33
34
|
_id: 1,
|
|
@@ -51,7 +52,10 @@ async function main() {
|
|
|
51
52
|
|
|
52
53
|
let placeOrderTransactionId: string | undefined;
|
|
53
54
|
if (deleteTransactionTask.data.object.typeOf === chevre.factory.transactionType.PlaceOrder) {
|
|
54
|
-
if (
|
|
55
|
+
if (
|
|
56
|
+
(typeof deleteTransactionTask.data.object.specifyingMethod !== 'string')
|
|
57
|
+
|| (deleteTransactionTask.data.object.specifyingMethod === chevre.factory.task.deleteTransaction.SpecifyingMethod.Id)
|
|
58
|
+
) {
|
|
55
59
|
placeOrderTransactionId = deleteTransactionTask.data.object.id;
|
|
56
60
|
}
|
|
57
61
|
}
|
|
@@ -59,17 +63,26 @@ async function main() {
|
|
|
59
63
|
let alreadyMigrated = true;
|
|
60
64
|
let runsAtExpected: moment.Moment | undefined;
|
|
61
65
|
if (typeof placeOrderTransactionId === 'string') {
|
|
62
|
-
|
|
66
|
+
console.log(
|
|
67
|
+
'checking transaction...',
|
|
68
|
+
deleteTransactionTask.project.id, deleteTransactionTask.name, deleteTransactionTask.id, deleteTransactionTask.runsAt,
|
|
69
|
+
placeOrderTransactionId
|
|
70
|
+
);
|
|
71
|
+
const placeOrderTransaction = (await transactionRepo.search({
|
|
72
|
+
limit: 1,
|
|
73
|
+
page: 1,
|
|
63
74
|
typeOf: chevre.factory.transactionType.PlaceOrder,
|
|
64
|
-
|
|
75
|
+
ids: [placeOrderTransactionId],
|
|
65
76
|
inclusion: ['endDate', 'status'],
|
|
66
77
|
exclusion: []
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
78
|
+
})).shift();
|
|
79
|
+
if (placeOrderTransaction !== undefined) {
|
|
80
|
+
const { endDate, status } = placeOrderTransaction;
|
|
81
|
+
runsAtExpected = moment(endDate)
|
|
82
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
83
|
+
.add(STORAGE_PERIOD_IN_DAYS, 'days');
|
|
71
84
|
|
|
72
|
-
|
|
85
|
+
// if (status !== chevre.factory.transactionStatusType.Confirmed) {
|
|
73
86
|
const taskRunsTooLate = moment(deleteTransactionTask.runsAt)
|
|
74
87
|
.isAfter(runsAtExpected);
|
|
75
88
|
const diff = moment(deleteTransactionTask.runsAt)
|
|
@@ -78,12 +91,13 @@ async function main() {
|
|
|
78
91
|
if (taskRunsTooLate) {
|
|
79
92
|
alreadyMigrated = false;
|
|
80
93
|
}
|
|
94
|
+
// }
|
|
81
95
|
}
|
|
82
96
|
}
|
|
83
97
|
|
|
84
98
|
if (alreadyMigrated) {
|
|
85
99
|
console.log(
|
|
86
|
-
'already
|
|
100
|
+
'already migrated.',
|
|
87
101
|
deleteTransactionTask.project.id, deleteTransactionTask.name, deleteTransactionTask.id, deleteTransactionTask.runsAt,
|
|
88
102
|
i, updateCount);
|
|
89
103
|
} else {
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
|
|
8
|
+
// tslint:disable-next-line:max-func-body-length
|
|
9
|
+
async function main() {
|
|
10
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
11
|
+
|
|
12
|
+
const taskRepo = await chevre.repository.Task.createInstance(mongoose.connection);
|
|
13
|
+
|
|
14
|
+
const cursor = taskRepo.getCursor(
|
|
15
|
+
{
|
|
16
|
+
name: { $eq: chevre.factory.taskName.DeleteTransaction },
|
|
17
|
+
status: { $eq: chevre.factory.taskStatus.Ready }
|
|
18
|
+
// runsAt: {
|
|
19
|
+
// $gte: moment()
|
|
20
|
+
// // tslint:disable-next-line:no-magic-numbers
|
|
21
|
+
// .add(29, 'days')
|
|
22
|
+
// .toDate(),
|
|
23
|
+
// $lte: moment()
|
|
24
|
+
// // tslint:disable-next-line:no-magic-numbers
|
|
25
|
+
// .add(365, 'days')
|
|
26
|
+
// .toDate()
|
|
27
|
+
// },
|
|
28
|
+
// _id: { $eq: '6441bcf04014af2c7d39f6aa' }
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
_id: 1,
|
|
32
|
+
project: 1,
|
|
33
|
+
data: 1,
|
|
34
|
+
status: 1,
|
|
35
|
+
name: 1,
|
|
36
|
+
runsAt: 1
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
console.log('tasks found');
|
|
40
|
+
|
|
41
|
+
let i = 0;
|
|
42
|
+
let updateCount = 0;
|
|
43
|
+
await cursor.eachAsync(async (doc) => {
|
|
44
|
+
i += 1;
|
|
45
|
+
const deleteTransactionTask: Pick<
|
|
46
|
+
chevre.factory.task.deleteTransaction.ITask,
|
|
47
|
+
'id' | 'project' | 'data' | 'status' | 'name' | 'runsAt'
|
|
48
|
+
> = doc.toObject();
|
|
49
|
+
|
|
50
|
+
let dataObject: chevre.factory.task.deleteTransaction.IObjectAsPlaceOrder | undefined;
|
|
51
|
+
if (deleteTransactionTask.data.object.typeOf === chevre.factory.transactionType.PlaceOrder) {
|
|
52
|
+
if (
|
|
53
|
+
(typeof deleteTransactionTask.data.object.specifyingMethod !== 'string')
|
|
54
|
+
|| (deleteTransactionTask.data.object.specifyingMethod === chevre.factory.task.deleteTransaction.SpecifyingMethod.Id)
|
|
55
|
+
) {
|
|
56
|
+
const existingDataObject = deleteTransactionTask.data.object;
|
|
57
|
+
if ((<any>existingDataObject).agent !== undefined) {
|
|
58
|
+
dataObject = {
|
|
59
|
+
specifyingMethod: chevre.factory.task.deleteTransaction.SpecifyingMethod.Id,
|
|
60
|
+
id: existingDataObject.id,
|
|
61
|
+
object: {
|
|
62
|
+
...(typeof existingDataObject.object.confirmationNumber === 'string')
|
|
63
|
+
? { confirmationNumber: existingDataObject.object.confirmationNumber }
|
|
64
|
+
: undefined,
|
|
65
|
+
...(typeof existingDataObject.object.orderNumber === 'string')
|
|
66
|
+
? { orderNumber: existingDataObject.object.orderNumber }
|
|
67
|
+
: undefined
|
|
68
|
+
},
|
|
69
|
+
project: existingDataObject.project,
|
|
70
|
+
startDate: existingDataObject.startDate,
|
|
71
|
+
typeOf: existingDataObject.typeOf,
|
|
72
|
+
...(existingDataObject.endDate !== undefined) ? { endDate: existingDataObject.endDate } : undefined
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
let alreadyMigrated = true;
|
|
79
|
+
if (typeof dataObject?.id === 'string') {
|
|
80
|
+
alreadyMigrated = false;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (alreadyMigrated) {
|
|
84
|
+
console.log(
|
|
85
|
+
'already migrated.',
|
|
86
|
+
deleteTransactionTask.project.id, deleteTransactionTask.name, deleteTransactionTask.id, deleteTransactionTask.runsAt,
|
|
87
|
+
i, updateCount);
|
|
88
|
+
} else {
|
|
89
|
+
console.log(
|
|
90
|
+
'updating...',
|
|
91
|
+
deleteTransactionTask.project.id, deleteTransactionTask.name, deleteTransactionTask.id, deleteTransactionTask.runsAt,
|
|
92
|
+
i, updateCount, dataObject);
|
|
93
|
+
if (dataObject !== undefined) {
|
|
94
|
+
await taskRepo.taskModel.findByIdAndUpdate(
|
|
95
|
+
deleteTransactionTask.id,
|
|
96
|
+
{
|
|
97
|
+
$set: {
|
|
98
|
+
'data.object': dataObject
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
{ timestamps: false }
|
|
102
|
+
)
|
|
103
|
+
.exec();
|
|
104
|
+
}
|
|
105
|
+
updateCount += 1;
|
|
106
|
+
console.log(
|
|
107
|
+
'updated.',
|
|
108
|
+
deleteTransactionTask.project.id, deleteTransactionTask.name, deleteTransactionTask.id, deleteTransactionTask.runsAt,
|
|
109
|
+
i, updateCount);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
console.log(i, 'tasks checked');
|
|
114
|
+
console.log(updateCount, 'tasks updated');
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
main()
|
|
118
|
+
.then()
|
|
119
|
+
.catch(console.error);
|
|
@@ -115,7 +115,8 @@ async function main() {
|
|
|
115
115
|
options: {
|
|
116
116
|
useCancelPayTransactionOnFailed: false,
|
|
117
117
|
useCheckMovieTicketBeforePay: false,
|
|
118
|
-
useCheckByIdentifierIfNotYet: false
|
|
118
|
+
useCheckByIdentifierIfNotYet: false,
|
|
119
|
+
useUnlockTransactionProcess: false
|
|
119
120
|
}
|
|
120
121
|
})({
|
|
121
122
|
accountingReport: await chevre.repository.AccountingReport.createInstance(mongoose.connection),
|
|
@@ -128,6 +129,8 @@ async function main() {
|
|
|
128
129
|
product: await chevre.repository.Product.createInstance(mongoose.connection),
|
|
129
130
|
task: await chevre.repository.Task.createInstance(mongoose.connection),
|
|
130
131
|
transactionNumber: await chevre.repository.TransactionNumber.createInstance(client),
|
|
132
|
+
transactionProcess:
|
|
133
|
+
await chevre.repository.TransactionProcess.createInstance(client, { lockExpiresInSeconds: 120 }),
|
|
131
134
|
transaction: await chevre.repository.Transaction.createInstance(mongoose.connection)
|
|
132
135
|
});
|
|
133
136
|
console.log('payment authorized.', authorizeResult.id);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { RedisClientType } from 'redis';
|
|
2
|
+
import * as factory from '../factory';
|
|
3
|
+
interface IProcessKey {
|
|
4
|
+
typeOf: factory.transactionType;
|
|
5
|
+
/**
|
|
6
|
+
* 取引ID
|
|
7
|
+
*/
|
|
8
|
+
id: string;
|
|
9
|
+
}
|
|
10
|
+
interface IOptions {
|
|
11
|
+
lockExpiresInSeconds: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* 取引プロセスリポジトリ
|
|
15
|
+
*/
|
|
16
|
+
export declare class TransactionProcessRepository {
|
|
17
|
+
private readonly options;
|
|
18
|
+
private readonly redisClient;
|
|
19
|
+
constructor(redisClient: RedisClientType, options: IOptions);
|
|
20
|
+
static CREATE_REDIS_KEY(params: IProcessKey): string;
|
|
21
|
+
lock(params: IProcessKey): Promise<boolean>;
|
|
22
|
+
unlock(params: IProcessKey): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.TransactionProcessRepository = void 0;
|
|
13
|
+
const createDebug = require("debug");
|
|
14
|
+
const factory = require("../factory");
|
|
15
|
+
const debug = createDebug('chevre-domain:repo:transactionProcess');
|
|
16
|
+
const DEFAULT_LOCK_EXPIRES = 120;
|
|
17
|
+
/**
|
|
18
|
+
* 取引プロセスリポジトリ
|
|
19
|
+
*/
|
|
20
|
+
class TransactionProcessRepository {
|
|
21
|
+
constructor(redisClient, options) {
|
|
22
|
+
this.redisClient = redisClient;
|
|
23
|
+
this.options = options;
|
|
24
|
+
}
|
|
25
|
+
static CREATE_REDIS_KEY(params) {
|
|
26
|
+
// 最適化(2024-03-21~)
|
|
27
|
+
// return `chevre-api:${params.project.id}:transactionProcess:${params.typeOf}:${params.id}`;
|
|
28
|
+
return `chvrapi:lockTxn:${params.id}`;
|
|
29
|
+
}
|
|
30
|
+
lock(params) {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
const key = TransactionProcessRepository.CREATE_REDIS_KEY(params);
|
|
33
|
+
// const ttl = TRANSACTION_RROCESS_LOCK_EXPIRES;
|
|
34
|
+
const ttl = (typeof this.options.lockExpiresInSeconds === 'number') ? this.options.lockExpiresInSeconds : DEFAULT_LOCK_EXPIRES;
|
|
35
|
+
const results = yield this.redisClient.multi()
|
|
36
|
+
.setNX(key, '1')
|
|
37
|
+
.expire(key, ttl)
|
|
38
|
+
.exec();
|
|
39
|
+
debug('locked,', params.id, results);
|
|
40
|
+
if (Array.isArray(results) && (results[0] === 1 || results[0] === true)) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
throw new factory.errors.AlreadyInUse(params.typeOf, [], 'Another transaction process in progress');
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
unlock(params) {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
const key = TransactionProcessRepository.CREATE_REDIS_KEY(params);
|
|
51
|
+
yield this.redisClient.del([key]);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.TransactionProcessRepository = TransactionProcessRepository;
|
|
@@ -57,6 +57,7 @@ import type { MongoRepository as TaskRepo } from './repo/task';
|
|
|
57
57
|
import type { MongoRepository as TelemetryRepo } from './repo/telemetry';
|
|
58
58
|
import type { MongoRepository as TransactionRepo } from './repo/transaction';
|
|
59
59
|
import type { RedisRepository as TransactionNumberRepo } from './repo/transactionNumber';
|
|
60
|
+
import type { TransactionProcessRepository } from './repo/transactionProcess';
|
|
60
61
|
import type { MongoRepository as TripRepo } from './repo/trip';
|
|
61
62
|
import type { RedisRepository as ConfirmationNumberRepo } from './repo/confirmationNumber';
|
|
62
63
|
import type { RedisRepository as OrderNumberRepo } from './repo/orderNumber';
|
|
@@ -323,6 +324,10 @@ export type TransactionNumber = TransactionNumberRepo;
|
|
|
323
324
|
export declare namespace TransactionNumber {
|
|
324
325
|
function createInstance(...params: ConstructorParameters<typeof TransactionNumberRepo>): Promise<TransactionNumberRepo>;
|
|
325
326
|
}
|
|
327
|
+
export type TransactionProcess = TransactionProcessRepository;
|
|
328
|
+
export declare namespace TransactionProcess {
|
|
329
|
+
function createInstance(...params: ConstructorParameters<typeof TransactionProcessRepository>): Promise<TransactionProcessRepository>;
|
|
330
|
+
}
|
|
326
331
|
export type Trip = TripRepo;
|
|
327
332
|
export declare namespace Trip {
|
|
328
333
|
function createInstance(...params: ConstructorParameters<typeof TripRepo>): Promise<TripRepo>;
|
package/lib/chevre/repository.js
CHANGED
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.StockHolder = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.SellerPaymentAccepted = exports.Seller = exports.Role = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductOffer = exports.ProductModel = exports.Product = exports.PriceSpecification = exports.place = exports.Permit = exports.Person = exports.paymentMethod = exports.PaymentServiceProvider = exports.PaymentService = exports.OwnershipInfo = exports.OrderNumber = exports.OrderInTransaction = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.Note = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.CustomerType = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Code = exports.CategoryCode = exports.AssetTransaction = exports.Aggregation = exports.AggregateReservation = exports.AggregateOffer = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = exports.AcceptedOffer = void 0;
|
|
13
|
-
exports.rateLimit = exports.Trip = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = void 0;
|
|
13
|
+
exports.rateLimit = exports.Trip = exports.TransactionProcess = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = void 0;
|
|
14
14
|
var AcceptedOffer;
|
|
15
15
|
(function (AcceptedOffer) {
|
|
16
16
|
let repo;
|
|
@@ -802,6 +802,19 @@ var TransactionNumber;
|
|
|
802
802
|
}
|
|
803
803
|
TransactionNumber.createInstance = createInstance;
|
|
804
804
|
})(TransactionNumber = exports.TransactionNumber || (exports.TransactionNumber = {}));
|
|
805
|
+
var TransactionProcess;
|
|
806
|
+
(function (TransactionProcess) {
|
|
807
|
+
let repo;
|
|
808
|
+
function createInstance(...params) {
|
|
809
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
810
|
+
if (repo === undefined) {
|
|
811
|
+
repo = (yield Promise.resolve().then(() => require('./repo/transactionProcess'))).TransactionProcessRepository;
|
|
812
|
+
}
|
|
813
|
+
return new repo(...params);
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
TransactionProcess.createInstance = createInstance;
|
|
817
|
+
})(TransactionProcess = exports.TransactionProcess || (exports.TransactionProcess = {}));
|
|
805
818
|
var Trip;
|
|
806
819
|
(function (Trip) {
|
|
807
820
|
let repo;
|
|
@@ -13,6 +13,7 @@ import type { MongoRepository as PaymentAcceptedRepo } from '../../repo/sellerPa
|
|
|
13
13
|
import type { MongoRepository as TaskRepo } from '../../repo/task';
|
|
14
14
|
import type { MongoRepository as TransactionRepo } from '../../repo/transaction';
|
|
15
15
|
import type { RedisRepository as TransactionNumberRepo } from '../../repo/transactionNumber';
|
|
16
|
+
import type { TransactionProcessRepository } from '../../repo/transactionProcess';
|
|
16
17
|
import * as PayTransactionService from '../assetTransaction/pay';
|
|
17
18
|
import { onPaymentStatusChanged } from './any/onPaymentStatusChanged';
|
|
18
19
|
import { person2username } from './any/person2username';
|
|
@@ -63,6 +64,7 @@ interface IAuthorizeRepos {
|
|
|
63
64
|
task: TaskRepo;
|
|
64
65
|
transaction: TransactionRepo;
|
|
65
66
|
transactionNumber: TransactionNumberRepo;
|
|
67
|
+
transactionProcess: TransactionProcessRepository;
|
|
66
68
|
}
|
|
67
69
|
type IAuthorizeOperation<T> = (repos: IAuthorizeRepos) => Promise<T>;
|
|
68
70
|
interface IPublishPaymentUrlRepos {
|
|
@@ -112,6 +114,7 @@ declare function authorize(params: {
|
|
|
112
114
|
useCancelPayTransactionOnFailed: boolean;
|
|
113
115
|
useCheckMovieTicketBeforePay: boolean;
|
|
114
116
|
useCheckByIdentifierIfNotYet: boolean;
|
|
117
|
+
useUnlockTransactionProcess: boolean;
|
|
115
118
|
};
|
|
116
119
|
}): IAuthorizeOperation<{
|
|
117
120
|
/**
|
|
@@ -278,7 +278,7 @@ exports.publishPaymentUrl = publishPaymentUrl;
|
|
|
278
278
|
* 決済承認
|
|
279
279
|
*/
|
|
280
280
|
function authorize(params) {
|
|
281
|
-
// tslint:disable-next-line:max-func-body-length
|
|
281
|
+
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
282
282
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
283
283
|
var _a, _b;
|
|
284
284
|
const transaction = yield repos.transaction.findInProgressById({ typeOf: params.purpose.typeOf, id: params.purpose.id });
|
|
@@ -406,12 +406,16 @@ function authorize(params) {
|
|
|
406
406
|
}
|
|
407
407
|
const result = (0, factory_1.createAuthorizeResult)({ payTransaction, object: authorizeObject });
|
|
408
408
|
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: result });
|
|
409
|
+
// 取引プロセスロック解除(2024-04-20~)
|
|
410
|
+
if (params.options.useUnlockTransactionProcess) {
|
|
411
|
+
yield repos.transactionProcess.unlock({ typeOf: transaction.typeOf, id: transaction.id });
|
|
412
|
+
}
|
|
409
413
|
return { id: action.id };
|
|
410
414
|
});
|
|
411
415
|
}
|
|
412
416
|
exports.authorize = authorize;
|
|
413
417
|
/**
|
|
414
|
-
*
|
|
418
|
+
* 注文取引に保管された決済情報を承認しようとしている決済の整合性を検証する
|
|
415
419
|
*/
|
|
416
420
|
function validatePaymentMethodByTransaction(params) {
|
|
417
421
|
var _a, _b;
|
|
@@ -499,6 +499,12 @@ function processChangeTransaction(params) {
|
|
|
499
499
|
if (searchTradeResult.tranId !== creditCardSalesBefore.tranId) {
|
|
500
500
|
alreadyRefunded = true;
|
|
501
501
|
}
|
|
502
|
+
// tranIdが空文字のケース(SPSwrapperで発生)に対応(Voidに対してVoidを実行してしまうので)(2024-04-20~)
|
|
503
|
+
if (searchTradeResult.tranId === '' && creditCardSalesBefore.tranId === '') {
|
|
504
|
+
if (searchTradeResult.status === GMO.utils.util.Status.Void) {
|
|
505
|
+
alreadyRefunded = true;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
502
508
|
}
|
|
503
509
|
if (alreadyRefunded) {
|
|
504
510
|
alterTranResult.push({
|
package/package.json
CHANGED