@chevre/domain 22.9.0-alpha.46 → 22.9.0-alpha.47
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/migratePaymentServiceChannelIds.ts +5 -5
- package/example/src/chevre/migratePaymentServiceChannelsCreditCard.ts +104 -0
- package/example/src/chevre/migratePaymentServiceChannelsMovieTicket.ts +112 -0
- package/example/src/chevre/migrateWebSites.ts +111 -0
- package/lib/chevre/repo/paymentService.d.ts +14 -0
- package/lib/chevre/repo/paymentService.js +49 -63
- package/lib/chevre/service/assetTransaction/pay.js +2 -1
- package/lib/chevre/service/assetTransaction/reserveCOA/cancel.d.ts +4 -2
- package/lib/chevre/service/assetTransaction/reserveCOA/cancel.js +1 -1
- package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4coa.d.ts +0 -1
- package/lib/chevre/service/offer/event/voidTransaction.js +1 -4
- package/lib/chevre/service/offer/event/voidTransactionByActionId.js +1 -4
- package/lib/chevre/service/payment/creditCard/authorize.js +4 -1
- package/lib/chevre/service/payment/creditCard/getGMOInfoFromSeller.d.ts +1 -0
- package/lib/chevre/service/payment/creditCard/getGMOInfoFromSeller.js +4 -2
- package/lib/chevre/service/payment/creditCard/payCreditCard.js +4 -1
- package/lib/chevre/service/payment/creditCard/refundCreditCard.js +7 -1
- package/lib/chevre/service/payment/creditCard/voidTransaction.js +5 -1
- package/lib/chevre/service/reserve/cancelReservation.d.ts +1 -1
- package/lib/chevre/service/reserveCOA/cancelReservation.d.ts +2 -11
- package/lib/chevre/service/reserveCOA/cancelReservation.js +42 -71
- package/lib/chevre/service/task/cancelPendingReservation.d.ts +2 -2
- package/lib/chevre/service/task/cancelPendingReservation.js +15 -54
- package/lib/chevre/service/task.js +0 -1
- package/package.json +3 -3
- package/lib/chevre/service/reserveCOA/factory.d.ts +0 -13
- package/lib/chevre/service/reserveCOA/factory.js +0 -23
|
@@ -83,11 +83,11 @@ async function main() {
|
|
|
83
83
|
} else {
|
|
84
84
|
if (paymentService.typeOf === chevre.factory.service.paymentService.PaymentServiceType.CreditCard
|
|
85
85
|
|| paymentService.typeOf === chevre.factory.service.paymentService.PaymentServiceType.MovieTicket) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
86
|
+
await paymentServiceRepo.migrateChannelId({
|
|
87
|
+
project: { id: paymentService.project.id },
|
|
88
|
+
id: paymentService.id,
|
|
89
|
+
typeOf: paymentService.typeOf
|
|
90
|
+
});
|
|
91
91
|
updateCount += 1;
|
|
92
92
|
console.log(
|
|
93
93
|
'updated.',
|
|
@@ -0,0 +1,104 @@
|
|
|
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
|
+
// const excludedProject = { id: String(process.env.EXCLUDED_PROJECT_ID) };
|
|
8
|
+
|
|
9
|
+
// tslint:disable-next-line:max-func-body-length
|
|
10
|
+
async function main() {
|
|
11
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
+
|
|
13
|
+
const paymentServiceRepo = await chevre.repository.PaymentService.createInstance(mongoose.connection);
|
|
14
|
+
|
|
15
|
+
const cursor = paymentServiceRepo.getCursor(
|
|
16
|
+
{
|
|
17
|
+
typeOf: { $eq: chevre.factory.service.paymentService.PaymentServiceType.CreditCard }
|
|
18
|
+
// _id: { $eq: 'cinerino' }
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
_id: 1,
|
|
22
|
+
availableChannel: 1,
|
|
23
|
+
productID: 1,
|
|
24
|
+
project: 1,
|
|
25
|
+
typeOf: 1
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
console.log('docs found');
|
|
29
|
+
|
|
30
|
+
let i = 0;
|
|
31
|
+
let updateCount = 0;
|
|
32
|
+
let serviceUrls: string[] = [];
|
|
33
|
+
const unexpectedProjectIds: string[] = [];
|
|
34
|
+
await cursor.eachAsync(async (doc) => {
|
|
35
|
+
i += 1;
|
|
36
|
+
const paymentService: Pick<
|
|
37
|
+
chevre.factory.service.paymentService.IService,
|
|
38
|
+
'availableChannel' | 'id' | 'productID' | 'project' | 'typeOf'
|
|
39
|
+
> = doc.toObject();
|
|
40
|
+
|
|
41
|
+
console.log(
|
|
42
|
+
'alreadyMigrated?', paymentService.project.id, i);
|
|
43
|
+
if (typeof paymentService.id !== 'string') {
|
|
44
|
+
throw new Error('id must be string');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
let alreadyMigrated = false;
|
|
48
|
+
try {
|
|
49
|
+
const existingChannel = await paymentServiceRepo.findAvailableChannelCreditCard({
|
|
50
|
+
project: { id: paymentService.project.id },
|
|
51
|
+
id: paymentService.id
|
|
52
|
+
});
|
|
53
|
+
if (typeof existingChannel.credentials?.siteId === 'string'
|
|
54
|
+
&& typeof existingChannel.credentials?.sitePass === 'string') {
|
|
55
|
+
alreadyMigrated = true;
|
|
56
|
+
}
|
|
57
|
+
} catch (error) {
|
|
58
|
+
// no op
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const serviceUrl = paymentService.availableChannel?.serviceUrl;
|
|
62
|
+
if (typeof serviceUrl === 'string') {
|
|
63
|
+
serviceUrls.push(serviceUrl);
|
|
64
|
+
} else {
|
|
65
|
+
throw new Error('serviceUrl must be string');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// docs(same serviceUrl and different siteId,sitePass ) exist?
|
|
69
|
+
// const credentials =
|
|
70
|
+
// <chevre.factory.serviceChannel.ICredentialsCreditCard | undefined>paymentService.availableChannel?.credentials;
|
|
71
|
+
// if (typeof credentials?.siteId !== 'string') {
|
|
72
|
+
// throw new Error('siteId must be string');
|
|
73
|
+
// }
|
|
74
|
+
// if (typeof credentials?.sitePass !== 'string') {
|
|
75
|
+
// throw new Error('sitePass must be string');
|
|
76
|
+
// }
|
|
77
|
+
|
|
78
|
+
if (alreadyMigrated) {
|
|
79
|
+
console.log(
|
|
80
|
+
'already migrated.', paymentService.project.id, i);
|
|
81
|
+
} else {
|
|
82
|
+
console.log(
|
|
83
|
+
'updating...',
|
|
84
|
+
paymentService.project.id, i);
|
|
85
|
+
// await paymentServiceRepo.saveChannelByServiceUrl(newChannel);
|
|
86
|
+
updateCount += 1;
|
|
87
|
+
console.log(
|
|
88
|
+
'updated.',
|
|
89
|
+
paymentService.project.id, i);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
serviceUrls = [...new Set(serviceUrls)];
|
|
94
|
+
console.log('unexpectedProjectIds:', unexpectedProjectIds);
|
|
95
|
+
// console.log(serviceUrls);
|
|
96
|
+
console.log(serviceUrls);
|
|
97
|
+
console.log(serviceUrls.length, 'serviceUrls found');
|
|
98
|
+
console.log(i, 'docs checked');
|
|
99
|
+
console.log(updateCount, 'docs updated');
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
main()
|
|
103
|
+
.then()
|
|
104
|
+
.catch(console.error);
|
|
@@ -0,0 +1,112 @@
|
|
|
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
|
+
// const excludedProject = { id: String(process.env.EXCLUDED_PROJECT_ID) };
|
|
8
|
+
|
|
9
|
+
// tslint:disable-next-line:max-func-body-length
|
|
10
|
+
async function main() {
|
|
11
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
+
|
|
13
|
+
const paymentServiceRepo = await chevre.repository.PaymentService.createInstance(mongoose.connection);
|
|
14
|
+
|
|
15
|
+
const cursor = paymentServiceRepo.getCursor(
|
|
16
|
+
{
|
|
17
|
+
typeOf: { $eq: chevre.factory.service.paymentService.PaymentServiceType.MovieTicket }
|
|
18
|
+
// _id: { $eq: 'cinerino' }
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
_id: 1,
|
|
22
|
+
availableChannel: 1,
|
|
23
|
+
productID: 1,
|
|
24
|
+
project: 1,
|
|
25
|
+
typeOf: 1
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
console.log('docs found');
|
|
29
|
+
|
|
30
|
+
let i = 0;
|
|
31
|
+
let updateCount = 0;
|
|
32
|
+
let serviceUrls: string[] = [];
|
|
33
|
+
const unexpectedProjectIds: string[] = [];
|
|
34
|
+
await cursor.eachAsync(async (doc) => {
|
|
35
|
+
i += 1;
|
|
36
|
+
const paymentService: Pick<
|
|
37
|
+
chevre.factory.service.paymentService.IService,
|
|
38
|
+
'availableChannel' | 'id' | 'productID' | 'project' | 'typeOf'
|
|
39
|
+
> = doc.toObject();
|
|
40
|
+
|
|
41
|
+
console.log(
|
|
42
|
+
'alreadyMigrated?', paymentService.project.id, i);
|
|
43
|
+
if (typeof paymentService.id !== 'string') {
|
|
44
|
+
throw new Error('id must be string');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
let alreadyMigrated = false;
|
|
48
|
+
try {
|
|
49
|
+
const existingChannel = await paymentServiceRepo.findAvailableChannelMovieTicket({
|
|
50
|
+
project: { id: paymentService.project.id },
|
|
51
|
+
id: paymentService.id
|
|
52
|
+
});
|
|
53
|
+
if (typeof existingChannel.credentials?.authorizeServerDomain === 'string') {
|
|
54
|
+
alreadyMigrated = true;
|
|
55
|
+
}
|
|
56
|
+
} catch (error) {
|
|
57
|
+
// no op
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const serviceUrl = paymentService.availableChannel?.serviceUrl;
|
|
61
|
+
if (typeof serviceUrl === 'string') {
|
|
62
|
+
serviceUrls.push(serviceUrl);
|
|
63
|
+
} else {
|
|
64
|
+
throw new Error('serviceUrl must be string');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (alreadyMigrated) {
|
|
68
|
+
console.log(
|
|
69
|
+
'already migrated.', paymentService.project.id, i);
|
|
70
|
+
} else {
|
|
71
|
+
const credentials =
|
|
72
|
+
<chevre.factory.serviceChannel.ICredentialsMovieTicket | undefined>paymentService.availableChannel?.credentials;
|
|
73
|
+
if (typeof credentials?.authorizeServerDomain !== 'string') {
|
|
74
|
+
throw new Error('authorizeServerDomain must be string');
|
|
75
|
+
}
|
|
76
|
+
if (typeof credentials?.clientId !== 'string') {
|
|
77
|
+
throw new Error('clientId must be string');
|
|
78
|
+
}
|
|
79
|
+
if (typeof credentials?.clientSecret !== 'string') {
|
|
80
|
+
throw new Error('clientSecret must be string');
|
|
81
|
+
}
|
|
82
|
+
const newChannel: chevre.factory.serviceChannel.IServiceChannelMovieTicket = {
|
|
83
|
+
credentials,
|
|
84
|
+
project: { id: '*', typeOf: chevre.factory.organizationType.Project },
|
|
85
|
+
providesService: {
|
|
86
|
+
typeOf: chevre.factory.service.paymentService.PaymentServiceType.MovieTicket
|
|
87
|
+
},
|
|
88
|
+
serviceUrl,
|
|
89
|
+
typeOf: 'ServiceChannel'
|
|
90
|
+
};
|
|
91
|
+
console.log(
|
|
92
|
+
'updating...',
|
|
93
|
+
paymentService.project.id, i, newChannel);
|
|
94
|
+
await paymentServiceRepo.saveChannelByServiceUrl(newChannel);
|
|
95
|
+
updateCount += 1;
|
|
96
|
+
console.log(
|
|
97
|
+
'updated.',
|
|
98
|
+
paymentService.project.id, i);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
serviceUrls = [...new Set(serviceUrls)];
|
|
103
|
+
console.log('unexpectedProjectIds:', unexpectedProjectIds);
|
|
104
|
+
console.log(serviceUrls);
|
|
105
|
+
console.log(serviceUrls.length, 'serviceUrls found');
|
|
106
|
+
console.log(i, 'docs checked');
|
|
107
|
+
console.log(updateCount, 'docs updated');
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
main()
|
|
111
|
+
.then()
|
|
112
|
+
.catch(console.error);
|
|
@@ -0,0 +1,111 @@
|
|
|
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
|
+
// const excludedProject = { id: String(process.env.EXCLUDED_PROJECT_ID) };
|
|
8
|
+
|
|
9
|
+
// tslint:disable-next-line:max-func-body-length
|
|
10
|
+
async function main() {
|
|
11
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
+
|
|
13
|
+
const paymentServiceRepo = await chevre.repository.PaymentService.createInstance(mongoose.connection);
|
|
14
|
+
// const potentialActionRepo = await chevre.repository.PotentialAction.createInstance(mongoose.connection);
|
|
15
|
+
// const identityProviderRepo = await chevre.repository.IdentityProvider.createInstance(mongoose.connection);
|
|
16
|
+
const webSiteRepo = await chevre.repository.WebSite.createInstance(mongoose.connection);
|
|
17
|
+
|
|
18
|
+
let webSiteIdentifiers: string[] = [];
|
|
19
|
+
|
|
20
|
+
const cursor = paymentServiceRepo.getCursor(
|
|
21
|
+
{
|
|
22
|
+
typeOf: { $eq: chevre.factory.service.paymentService.PaymentServiceType.CreditCard }
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
_id: 1,
|
|
26
|
+
availableChannel: 1,
|
|
27
|
+
productID: 1,
|
|
28
|
+
project: 1,
|
|
29
|
+
typeOf: 1
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
console.log('docs found');
|
|
33
|
+
|
|
34
|
+
let i = 0;
|
|
35
|
+
let updateCount = 0;
|
|
36
|
+
|
|
37
|
+
await cursor.eachAsync(async (doc) => {
|
|
38
|
+
i += 1;
|
|
39
|
+
|
|
40
|
+
const paymentService: Pick<
|
|
41
|
+
chevre.factory.service.paymentService.IService,
|
|
42
|
+
'availableChannel' | 'id' | 'productID' | 'project' | 'typeOf'
|
|
43
|
+
> = doc.toObject();
|
|
44
|
+
|
|
45
|
+
let webSiteIdentifier: string | undefined;
|
|
46
|
+
const serviceUrl = paymentService.availableChannel?.serviceUrl;
|
|
47
|
+
if (typeof serviceUrl === 'string') {
|
|
48
|
+
if (/appspot.com/.test(serviceUrl)) {
|
|
49
|
+
webSiteIdentifier = new URL(serviceUrl).hostname;
|
|
50
|
+
webSiteIdentifiers.push(webSiteIdentifier);
|
|
51
|
+
}
|
|
52
|
+
} else {
|
|
53
|
+
throw new Error('serviceUrl must be string');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (typeof webSiteIdentifier !== 'string') {
|
|
57
|
+
console.log(
|
|
58
|
+
'already migrated.', serviceUrl, webSiteIdentifier, i);
|
|
59
|
+
} else {
|
|
60
|
+
let alreadyMigrated = false;
|
|
61
|
+
const existingWebSites = await webSiteRepo.projectFields(
|
|
62
|
+
{
|
|
63
|
+
about: { identifier: { $eq: webSiteIdentifier } },
|
|
64
|
+
project: { id: { $eq: paymentService.project.id } }
|
|
65
|
+
},
|
|
66
|
+
['about']
|
|
67
|
+
);
|
|
68
|
+
alreadyMigrated = existingWebSites.length === 1;
|
|
69
|
+
|
|
70
|
+
if (alreadyMigrated) {
|
|
71
|
+
console.log(
|
|
72
|
+
'already migrated.', webSiteIdentifier, i);
|
|
73
|
+
} else {
|
|
74
|
+
const creatingWebSite: Pick<
|
|
75
|
+
chevre.factory.creativeWork.certification.webSite.ICertification,
|
|
76
|
+
'about' | 'certificationStatus' | 'project' | 'auditDate'
|
|
77
|
+
> = {
|
|
78
|
+
project: { id: paymentService.project.id, typeOf: chevre.factory.organizationType.Project },
|
|
79
|
+
about: { identifier: webSiteIdentifier, typeOf: chevre.factory.creativeWorkType.WebSite },
|
|
80
|
+
certificationStatus: chevre.factory.CertificationStatusEnumeration.CertificationInactive
|
|
81
|
+
};
|
|
82
|
+
console.log(
|
|
83
|
+
'updating...', i, creatingWebSite);
|
|
84
|
+
const { id } = await webSiteRepo.save({
|
|
85
|
+
attributes: creatingWebSite
|
|
86
|
+
});
|
|
87
|
+
await webSiteRepo.save({
|
|
88
|
+
id,
|
|
89
|
+
attributes: {
|
|
90
|
+
...creatingWebSite,
|
|
91
|
+
auditDate: new Date(),
|
|
92
|
+
certificationStatus: chevre.factory.CertificationStatusEnumeration.CertificationActive
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
updateCount += 1;
|
|
96
|
+
console.log(
|
|
97
|
+
'updated.', i);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
webSiteIdentifiers = [...new Set(webSiteIdentifiers)];
|
|
103
|
+
console.log(webSiteIdentifiers);
|
|
104
|
+
console.log(webSiteIdentifiers.length, 'webSiteIdentifiers found');
|
|
105
|
+
console.log(i, 'docs checked');
|
|
106
|
+
console.log(updateCount, 'docs updated');
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
main()
|
|
110
|
+
.then()
|
|
111
|
+
.catch(console.error);
|
|
@@ -69,6 +69,20 @@ export declare class PaymentServiceRepo {
|
|
|
69
69
|
id: string;
|
|
70
70
|
credentials: factory.serviceChannel.ICredentialsMovieTicket;
|
|
71
71
|
}>;
|
|
72
|
+
saveChannelByServiceUrl(params: Omit<factory.serviceChannel.IServiceChannel, 'id'>): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* for migrate(2025-02-20~)
|
|
75
|
+
*/
|
|
76
|
+
migrateChannelId(params: {
|
|
77
|
+
project: {
|
|
78
|
+
id: string;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* payment service ID
|
|
82
|
+
*/
|
|
83
|
+
id: string;
|
|
84
|
+
typeOf: factory.service.paymentService.PaymentServiceType.CreditCard | factory.service.paymentService.PaymentServiceType.MovieTicket;
|
|
85
|
+
}): Promise<void>;
|
|
72
86
|
unsetUnnecessaryFields(params: {
|
|
73
87
|
filter: any;
|
|
74
88
|
$unset: any;
|
|
@@ -317,13 +317,12 @@ class PaymentServiceRepo {
|
|
|
317
317
|
if (availableChannel === undefined) {
|
|
318
318
|
throw new factory.errors.NotFound('paymentService.availableChannel');
|
|
319
319
|
}
|
|
320
|
-
if (typeof availableChannel.
|
|
321
|
-
throw new factory.errors.NotFound('paymentService.availableChannel.
|
|
320
|
+
if (typeof availableChannel.serviceUrl !== 'string' || availableChannel.serviceUrl === '') {
|
|
321
|
+
throw new factory.errors.NotFound('paymentService.availableChannel.serviceUrl');
|
|
322
322
|
}
|
|
323
323
|
const serviceChannel = yield this.paymentServiceChannelModel.findOne({
|
|
324
324
|
'project.id': { $eq: params.project.id },
|
|
325
|
-
|
|
326
|
-
// serviceUrl: { $eq: availableChannel.serviceUrl },
|
|
325
|
+
serviceUrl: { $eq: availableChannel.serviceUrl },
|
|
327
326
|
'providesService.typeOf': { $eq: factory.service.paymentService.PaymentServiceType.CreditCard }
|
|
328
327
|
}, {
|
|
329
328
|
credentials: 1,
|
|
@@ -357,13 +356,12 @@ class PaymentServiceRepo {
|
|
|
357
356
|
if (availableChannel === undefined) {
|
|
358
357
|
throw new factory.errors.NotFound('paymentService.availableChannel');
|
|
359
358
|
}
|
|
360
|
-
if (typeof availableChannel.
|
|
361
|
-
throw new factory.errors.NotFound('paymentService.availableChannel.
|
|
359
|
+
if (typeof availableChannel.serviceUrl !== 'string' || availableChannel.serviceUrl === '') {
|
|
360
|
+
throw new factory.errors.NotFound('paymentService.availableChannel.serviceUrl');
|
|
362
361
|
}
|
|
363
362
|
const serviceChannel = yield this.paymentServiceChannelModel.findOne({
|
|
364
363
|
'project.id': { $eq: '*' },
|
|
365
|
-
|
|
366
|
-
// serviceUrl: { $eq: availableChannel.serviceUrl },
|
|
364
|
+
serviceUrl: { $eq: availableChannel.serviceUrl },
|
|
367
365
|
'providesService.typeOf': { $eq: factory.service.paymentService.PaymentServiceType.MovieTicket }
|
|
368
366
|
}, {
|
|
369
367
|
credentials: 1,
|
|
@@ -379,61 +377,49 @@ class PaymentServiceRepo {
|
|
|
379
377
|
return Object.assign(Object.assign({}, availableChannel), { id: serviceChannel.id, serviceUrl: serviceChannel.serviceUrl, credentials: serviceChannel.credentials });
|
|
380
378
|
});
|
|
381
379
|
}
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
// $set: {
|
|
426
|
-
// 'availableChannel.id': existingChannel.id
|
|
427
|
-
// }
|
|
428
|
-
// },
|
|
429
|
-
// { upsert: false, new: true, projection: { _id: 1, id: { $toString: '$_id' } } }
|
|
430
|
-
// )
|
|
431
|
-
// .lean<{ id: string }>()
|
|
432
|
-
// .exec();
|
|
433
|
-
// if (doc === null) {
|
|
434
|
-
// throw new factory.errors.NotFound(this.paymentServiceModel.modelName);
|
|
435
|
-
// }
|
|
436
|
-
// }
|
|
380
|
+
saveChannelByServiceUrl(params) {
|
|
381
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
382
|
+
yield this.paymentServiceChannelModel.findOneAndUpdate({
|
|
383
|
+
'project.id': { $eq: params.project.id },
|
|
384
|
+
serviceUrl: { $eq: params.serviceUrl }
|
|
385
|
+
}, {
|
|
386
|
+
$setOnInsert: params
|
|
387
|
+
}, { upsert: true })
|
|
388
|
+
.exec();
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* for migrate(2025-02-20~)
|
|
393
|
+
*/
|
|
394
|
+
migrateChannelId(params) {
|
|
395
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
396
|
+
let existingChannel;
|
|
397
|
+
if (params.typeOf === factory.service.paymentService.PaymentServiceType.CreditCard) {
|
|
398
|
+
existingChannel = yield this.findAvailableChannelCreditCard(params);
|
|
399
|
+
}
|
|
400
|
+
else if (params.typeOf === factory.service.paymentService.PaymentServiceType.MovieTicket) {
|
|
401
|
+
existingChannel = yield this.findAvailableChannelMovieTicket(params);
|
|
402
|
+
}
|
|
403
|
+
else {
|
|
404
|
+
throw new factory.errors.Argument('typeOf', `not implemented`);
|
|
405
|
+
}
|
|
406
|
+
if (typeof existingChannel.id !== 'string' || existingChannel.id === '') {
|
|
407
|
+
throw new factory.errors.NotFound('existingChannel.id');
|
|
408
|
+
}
|
|
409
|
+
// tslint:disable-next-line:no-console
|
|
410
|
+
console.log('updating paymentService...', existingChannel.id, existingChannel.serviceUrl, params.project.id, params.id);
|
|
411
|
+
const doc = yield this.paymentServiceModel.findOneAndUpdate({ _id: { $eq: params.id } }, {
|
|
412
|
+
$set: {
|
|
413
|
+
'availableChannel.id': existingChannel.id
|
|
414
|
+
}
|
|
415
|
+
}, { upsert: false, new: true, projection: { _id: 1, id: { $toString: '$_id' } } })
|
|
416
|
+
.lean()
|
|
417
|
+
.exec();
|
|
418
|
+
if (doc === null) {
|
|
419
|
+
throw new factory.errors.NotFound(this.paymentServiceModel.modelName);
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
}
|
|
437
423
|
unsetUnnecessaryFields(params) {
|
|
438
424
|
return __awaiter(this, void 0, void 0, function* () {
|
|
439
425
|
return this.paymentServiceModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
|
|
@@ -609,7 +609,8 @@ function searchGMOTrade(params) {
|
|
|
609
609
|
const { shopId, shopPass } = yield CreditCardPayment.getGMOInfoFromSeller({
|
|
610
610
|
paymentMethodType,
|
|
611
611
|
seller: { id: sellerId },
|
|
612
|
-
paymentServiceId
|
|
612
|
+
paymentServiceId,
|
|
613
|
+
requirePaymentAccepted: false
|
|
613
614
|
})(repos);
|
|
614
615
|
return CreditCardPayment.searchGMOTrade({
|
|
615
616
|
availableChannel,
|
|
@@ -2,7 +2,6 @@ import type * as COA from '@motionpicture/coa-service';
|
|
|
2
2
|
import * as factory from '../../../factory';
|
|
3
3
|
import { ActionRepo } from '../../../repo/action';
|
|
4
4
|
type ICancelOperation<T> = (repos: {
|
|
5
|
-
action: ActionRepo;
|
|
6
5
|
reserveService: COA.service.Reserve;
|
|
7
6
|
}) => Promise<T>;
|
|
8
7
|
declare function cancel(params: {
|
|
@@ -10,5 +9,8 @@ declare function cancel(params: {
|
|
|
10
9
|
}): ICancelOperation<void>;
|
|
11
10
|
declare function cancelByAcceptAction(params: {
|
|
12
11
|
action: factory.action.accept.coaOffer.IAction;
|
|
13
|
-
}):
|
|
12
|
+
}): (repos: {
|
|
13
|
+
action: ActionRepo;
|
|
14
|
+
reserveService: COA.service.Reserve;
|
|
15
|
+
}) => Promise<void>;
|
|
14
16
|
export { cancel, cancelByAcceptAction };
|
|
@@ -14,7 +14,7 @@ exports.cancelByAcceptAction = cancelByAcceptAction;
|
|
|
14
14
|
const cancelReservation_1 = require("../../reserveCOA/cancelReservation");
|
|
15
15
|
function cancel(params) {
|
|
16
16
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
17
|
-
yield (0, cancelReservation_1.
|
|
17
|
+
yield (0, cancelReservation_1.cancelPendingReservation)(params)(repos);
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
function cancelByAcceptAction(params) {
|
|
@@ -4,7 +4,6 @@ import { ActionRepo } from '../../../../repo/action';
|
|
|
4
4
|
declare function processVoidTransaction4coa(params: {
|
|
5
5
|
action: factory.action.authorize.offer.eventService.IAction;
|
|
6
6
|
}): (repos: {
|
|
7
|
-
action: ActionRepo;
|
|
8
7
|
reserveService: COA.service.Reserve;
|
|
9
8
|
}) => Promise<void>;
|
|
10
9
|
declare function processVoidTransactionByAcceptAction4coa(params: {
|
|
@@ -85,10 +85,7 @@ function voidTransaction(params) {
|
|
|
85
85
|
yield (0, processVoidTransaction4coa_1.processVoidTransaction4coa)({
|
|
86
86
|
// action: <factory.action.authorize.offer.eventService.IAction<WebAPIIdentifier.COA>>action
|
|
87
87
|
action
|
|
88
|
-
})({
|
|
89
|
-
action: repos.action,
|
|
90
|
-
reserveService
|
|
91
|
-
});
|
|
88
|
+
})({ reserveService });
|
|
92
89
|
break;
|
|
93
90
|
default:
|
|
94
91
|
yield (0, processVoidTransaction4chevre_1.processVoidTransaction4chevre)({
|
|
@@ -59,10 +59,7 @@ function voidTransactionByActionId(params) {
|
|
|
59
59
|
}
|
|
60
60
|
yield (0, processVoidTransaction4coa_1.processVoidTransaction4coa)({
|
|
61
61
|
action
|
|
62
|
-
})({
|
|
63
|
-
action: repos.action,
|
|
64
|
-
reserveService
|
|
65
|
-
});
|
|
62
|
+
})({ reserveService });
|
|
66
63
|
break;
|
|
67
64
|
default:
|
|
68
65
|
yield (0, processVoidTransaction4chevre_1.processVoidTransaction4chevre)({
|
|
@@ -42,7 +42,10 @@ payTransaction, paymentServiceId, options) {
|
|
|
42
42
|
if (typeof sellerId !== 'string') {
|
|
43
43
|
throw new factory.errors.ArgumentNull('recipient.id');
|
|
44
44
|
}
|
|
45
|
-
const { shopId, shopPass, returnUrls3ds, callbackType3ds } = yield (0, getGMOInfoFromSeller_1.getGMOInfoFromSeller)({
|
|
45
|
+
const { shopId, shopPass, returnUrls3ds, callbackType3ds } = yield (0, getGMOInfoFromSeller_1.getGMOInfoFromSeller)({
|
|
46
|
+
paymentMethodType, seller: { id: sellerId }, paymentServiceId,
|
|
47
|
+
requirePaymentAccepted: true
|
|
48
|
+
})(repos);
|
|
46
49
|
// GMOオーダーIDはカスタム指定可能
|
|
47
50
|
const orderId = payTransaction.transactionNumber;
|
|
48
51
|
if (typeof orderId !== 'string') {
|
|
@@ -18,8 +18,10 @@ function getGMOInfoFromSeller(params) {
|
|
|
18
18
|
seller: { id: params.seller.id },
|
|
19
19
|
codeValue: params.paymentMethodType
|
|
20
20
|
});
|
|
21
|
-
if (
|
|
22
|
-
|
|
21
|
+
if (params.requirePaymentAccepted) {
|
|
22
|
+
if (paymentAccepted !== true) {
|
|
23
|
+
throw new factory.errors.Argument('transaction', `payment not accepted [${params.paymentMethodType}]`);
|
|
24
|
+
}
|
|
23
25
|
}
|
|
24
26
|
// 決済サービスからcredentialsを取得する
|
|
25
27
|
const paymentServices = yield repos.paymentServiceProvider.search({
|
|
@@ -37,7 +37,10 @@ function payCreditCard(params) {
|
|
|
37
37
|
if (typeof sellerId !== 'string') {
|
|
38
38
|
throw new factory.errors.ArgumentNull('recipient.id');
|
|
39
39
|
}
|
|
40
|
-
const { shopId, shopPass } = yield (0, getGMOInfoFromSeller_1.getGMOInfoFromSeller)({
|
|
40
|
+
const { shopId, shopPass } = yield (0, getGMOInfoFromSeller_1.getGMOInfoFromSeller)({
|
|
41
|
+
paymentMethodType, seller: { id: sellerId }, paymentServiceId,
|
|
42
|
+
requirePaymentAccepted: true
|
|
43
|
+
})(repos);
|
|
41
44
|
const action = yield repos.action.start(params);
|
|
42
45
|
const alterTranResults = [];
|
|
43
46
|
const processAlterTranResults = [];
|
|
@@ -36,6 +36,7 @@ function refundCreditCard(params
|
|
|
36
36
|
// requirePayAction: boolean;
|
|
37
37
|
// }
|
|
38
38
|
) {
|
|
39
|
+
// tslint:disable-next-line:max-func-body-length
|
|
39
40
|
return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
|
|
40
41
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
41
42
|
const { purpose } = params;
|
|
@@ -43,8 +44,10 @@ function refundCreditCard(params
|
|
|
43
44
|
const paymentMethodId = (_b = params.object[0]) === null || _b === void 0 ? void 0 : _b.paymentMethod.paymentMethodId;
|
|
44
45
|
const paymentServiceId = (_c = params.object[0]) === null || _c === void 0 ? void 0 : _c.id;
|
|
45
46
|
let requirePayAction = false;
|
|
47
|
+
let requirePaymentAccepted = false;
|
|
46
48
|
if (purpose.typeOf === factory.actionType.ReturnAction) {
|
|
47
49
|
requirePayAction = true;
|
|
50
|
+
requirePaymentAccepted = true;
|
|
48
51
|
}
|
|
49
52
|
// 本アクションに対応するPayActionを取り出す(Cinerino側で決済していた時期に関してはpayActionが存在しないので注意)
|
|
50
53
|
let payAction;
|
|
@@ -61,7 +64,10 @@ function refundCreditCard(params
|
|
|
61
64
|
alterTranResultByPayAction = (_f = (_e = (_d = payRecipe === null || payRecipe === void 0 ? void 0 : payRecipe.step[0]) === null || _d === void 0 ? void 0 : _d.itemListElement[1]) === null || _e === void 0 ? void 0 : _e.itemListElement[0]) === null || _f === void 0 ? void 0 : _f.afterMedia;
|
|
62
65
|
}
|
|
63
66
|
const sellerId = params.agent.id;
|
|
64
|
-
const { shopId, shopPass } = yield (0, getGMOInfoFromSeller_1.getGMOInfoFromSeller)({
|
|
67
|
+
const { shopId, shopPass } = yield (0, getGMOInfoFromSeller_1.getGMOInfoFromSeller)({
|
|
68
|
+
paymentMethodType, seller: { id: sellerId }, paymentServiceId,
|
|
69
|
+
requirePaymentAccepted
|
|
70
|
+
})(repos);
|
|
65
71
|
const availableChannel = yield repos.paymentService.findAvailableChannelCreditCard({
|
|
66
72
|
project: params.project,
|
|
67
73
|
id: paymentServiceId
|
|
@@ -19,6 +19,7 @@ const gmoError_1 = require("./gmoError");
|
|
|
19
19
|
*/
|
|
20
20
|
// tslint:disable-next-line:max-func-body-length
|
|
21
21
|
function voidTransaction(params) {
|
|
22
|
+
// tslint:disable-next-line:max-func-body-length
|
|
22
23
|
return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
|
|
23
24
|
var _a, _b, _c, _d, _e, _f;
|
|
24
25
|
const transaction = params.object;
|
|
@@ -41,7 +42,10 @@ function voidTransaction(params) {
|
|
|
41
42
|
if (typeof sellerId !== 'string') {
|
|
42
43
|
throw new factory.errors.ArgumentNull('object.recipient.id');
|
|
43
44
|
}
|
|
44
|
-
const { shopId, shopPass } = yield (0, getGMOInfoFromSeller_1.getGMOInfoFromSeller)({
|
|
45
|
+
const { shopId, shopPass } = yield (0, getGMOInfoFromSeller_1.getGMOInfoFromSeller)({
|
|
46
|
+
paymentMethodType, seller: { id: sellerId }, paymentServiceId,
|
|
47
|
+
requirePaymentAccepted: false
|
|
48
|
+
})(repos);
|
|
45
49
|
// authorizeInvoiceActionが存在すれば取消(2024-06-13~)
|
|
46
50
|
const authorizeInvoiceAction = (yield repos.action.search({
|
|
47
51
|
limit: 1,
|
|
@@ -9,7 +9,7 @@ import type { TaskRepo } from '../../repo/task';
|
|
|
9
9
|
/**
|
|
10
10
|
* 保留予約取消
|
|
11
11
|
*/
|
|
12
|
-
declare function cancelPendingReservation(actionAttributes: factory.task.cancelPendingReservation.
|
|
12
|
+
declare function cancelPendingReservation(actionAttributes: factory.task.cancelPendingReservation.IData): (repos: {
|
|
13
13
|
action: ActionRepo;
|
|
14
14
|
assetTransaction: AssetTransactionRepo;
|
|
15
15
|
stockHolder: StockHolderRepo;
|
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
import type * as COA from '@motionpicture/coa-service';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
3
|
import { ActionRepo } from '../../repo/action';
|
|
4
|
-
declare function cancelPendingReservation(params:
|
|
5
|
-
project: {
|
|
6
|
-
id: string;
|
|
7
|
-
};
|
|
8
|
-
}): (repos: {
|
|
9
|
-
action: ActionRepo;
|
|
10
|
-
reserveService: COA.service.Reserve;
|
|
11
|
-
}) => Promise<void>;
|
|
12
|
-
declare function cancelPendingReservationByAuthorizeAction(params: {
|
|
4
|
+
declare function cancelPendingReservation(params: {
|
|
13
5
|
action: factory.action.authorize.offer.eventService.IAction;
|
|
14
6
|
}): (repos: {
|
|
15
|
-
action: ActionRepo;
|
|
16
7
|
reserveService: COA.service.Reserve;
|
|
17
8
|
}) => Promise<void>;
|
|
18
9
|
declare function cancelPendingReservationByAcceptAction(params: {
|
|
@@ -21,4 +12,4 @@ declare function cancelPendingReservationByAcceptAction(params: {
|
|
|
21
12
|
action: ActionRepo;
|
|
22
13
|
reserveService: COA.service.Reserve;
|
|
23
14
|
}) => Promise<void>;
|
|
24
|
-
export { cancelPendingReservation,
|
|
15
|
+
export { cancelPendingReservation, cancelPendingReservationByAcceptAction };
|
|
@@ -10,34 +10,28 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.cancelPendingReservation = cancelPendingReservation;
|
|
13
|
-
exports.cancelPendingReservationByAuthorizeAction = cancelPendingReservationByAuthorizeAction;
|
|
14
13
|
exports.cancelPendingReservationByAcceptAction = cancelPendingReservationByAcceptAction;
|
|
15
14
|
const http_status_1 = require("http-status");
|
|
16
|
-
const factory = require("../../factory");
|
|
17
|
-
const factory_1 = require("./factory");
|
|
18
|
-
function createCancelPendingReservationAction(params) {
|
|
19
|
-
const { object, instrument, project } = params;
|
|
20
|
-
return {
|
|
21
|
-
project: { id: project.id, typeOf: factory.organizationType.Project },
|
|
22
|
-
typeOf: factory.actionType.CancelAction,
|
|
23
|
-
agent: { id: project.id, typeOf: factory.organizationType.Project },
|
|
24
|
-
object,
|
|
25
|
-
instrument
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
15
|
function cancelPendingReservation(params) {
|
|
29
16
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
17
|
+
// object.pendingTransactionに連携内容情報が記録されているので、その情報を元に仮予約を取り消す
|
|
18
|
+
let delTmpReserveParams;
|
|
19
|
+
// objectに進行中取引情報があれば利用する(2023-09-11~)
|
|
20
|
+
const pendingTransaction = params.action.object.pendingTransaction;
|
|
21
|
+
if (typeof (pendingTransaction === null || pendingTransaction === void 0 ? void 0 : pendingTransaction.typeOf) === 'string') {
|
|
22
|
+
delTmpReserveParams = {
|
|
23
|
+
theaterCode: pendingTransaction.theaterCode,
|
|
24
|
+
dateJouei: pendingTransaction.dateJouei,
|
|
25
|
+
titleCode: pendingTransaction.titleCode,
|
|
26
|
+
titleBranchNum: pendingTransaction.titleBranchNum,
|
|
27
|
+
timeBegin: pendingTransaction.timeBegin,
|
|
28
|
+
tmpReserveNum: pendingTransaction.tmpReserveNum
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
if (delTmpReserveParams !== undefined) {
|
|
32
|
+
// COAで仮予約取消
|
|
39
33
|
try {
|
|
40
|
-
yield repos.reserveService.delTmpReserve(
|
|
34
|
+
yield repos.reserveService.delTmpReserve(delTmpReserveParams);
|
|
41
35
|
}
|
|
42
36
|
catch (error) {
|
|
43
37
|
let deleted = false;
|
|
@@ -49,13 +43,6 @@ function cancelPendingReservation(params) {
|
|
|
49
43
|
&& error.code < http_status_1.INTERNAL_SERVER_ERROR) {
|
|
50
44
|
// すでに取消済の場合こうなるので、okとする
|
|
51
45
|
if (error.message === '座席取消失敗') {
|
|
52
|
-
recipe = (0, factory_1.processCancelPendingCOAReserveResult2recipe)({
|
|
53
|
-
processCancelPendingCOAReserveResult: {
|
|
54
|
-
delTmpReserveArgs,
|
|
55
|
-
delTmpReserveResult: Object.assign(Object.assign({}, error), { message: error.message })
|
|
56
|
-
},
|
|
57
|
-
project: { id: params.project.id }
|
|
58
|
-
});
|
|
59
46
|
deleted = true;
|
|
60
47
|
}
|
|
61
48
|
}
|
|
@@ -65,42 +52,6 @@ function cancelPendingReservation(params) {
|
|
|
65
52
|
}
|
|
66
53
|
}
|
|
67
54
|
}
|
|
68
|
-
catch (error) {
|
|
69
|
-
try {
|
|
70
|
-
yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error });
|
|
71
|
-
}
|
|
72
|
-
catch (__) {
|
|
73
|
-
// 失敗したら仕方ない
|
|
74
|
-
}
|
|
75
|
-
throw error;
|
|
76
|
-
}
|
|
77
|
-
const actionResult = {};
|
|
78
|
-
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: actionResult, recipe });
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
function cancelPendingReservationByAuthorizeAction(params) {
|
|
82
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
83
|
-
// object.pendingTransactionに連携内容情報が記録されているので、その情報を元に仮予約を取り消す
|
|
84
|
-
let delTmpReserveParams;
|
|
85
|
-
// objectに進行中取引情報があれば利用する(2023-09-11~)
|
|
86
|
-
const pendingTransaction = params.action.object.pendingTransaction;
|
|
87
|
-
if (typeof (pendingTransaction === null || pendingTransaction === void 0 ? void 0 : pendingTransaction.typeOf) === 'string') {
|
|
88
|
-
delTmpReserveParams = {
|
|
89
|
-
theaterCode: pendingTransaction.theaterCode,
|
|
90
|
-
dateJouei: pendingTransaction.dateJouei,
|
|
91
|
-
titleCode: pendingTransaction.titleCode,
|
|
92
|
-
titleBranchNum: pendingTransaction.titleBranchNum,
|
|
93
|
-
timeBegin: pendingTransaction.timeBegin,
|
|
94
|
-
tmpReserveNum: pendingTransaction.tmpReserveNum
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
if (delTmpReserveParams !== undefined) {
|
|
98
|
-
yield cancelPendingReservation({
|
|
99
|
-
project: { id: params.action.project.id },
|
|
100
|
-
object: Object.assign(Object.assign({}, delTmpReserveParams), { reservationStatus: factory.reservationStatusType.ReservationPending, transactionNumber: delTmpReserveParams.tmpReserveNum, typeOf: factory.assetTransactionType.COAReserveTransaction }),
|
|
101
|
-
instrument: [params.action.purpose]
|
|
102
|
-
})(repos);
|
|
103
|
-
}
|
|
104
55
|
});
|
|
105
56
|
}
|
|
106
57
|
function cancelPendingReservationByAcceptAction(params) {
|
|
@@ -112,6 +63,9 @@ function cancelPendingReservationByAcceptAction(params) {
|
|
|
112
63
|
});
|
|
113
64
|
if (recipe !== null) {
|
|
114
65
|
let delTmpReserveParams;
|
|
66
|
+
// instrument,resultに連携内容情報が保管されているので、その情報を元に仮予約を取り消す
|
|
67
|
+
// const coaRequestBody = params.action.instrument?.requestBody;
|
|
68
|
+
// const coaResponseBody = params.action.result?.result?.responseBody;
|
|
115
69
|
// recipeから連携情報取得に変更(2024-06-11~)
|
|
116
70
|
const coaRequestBody = (_c = (_b = (_a = recipe.step[0]) === null || _a === void 0 ? void 0 : _a.itemListElement[0]) === null || _b === void 0 ? void 0 : _b.itemListElement[0]) === null || _c === void 0 ? void 0 : _c.beforeMedia;
|
|
117
71
|
const coaResponseBody = (_f = (_e = (_d = recipe.step[0]) === null || _d === void 0 ? void 0 : _d.itemListElement[0]) === null || _e === void 0 ? void 0 : _e.itemListElement[0]) === null || _f === void 0 ? void 0 : _f.afterMedia;
|
|
@@ -126,11 +80,28 @@ function cancelPendingReservationByAcceptAction(params) {
|
|
|
126
80
|
};
|
|
127
81
|
}
|
|
128
82
|
if (delTmpReserveParams !== undefined) {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
83
|
+
// COAで仮予約取消
|
|
84
|
+
try {
|
|
85
|
+
yield repos.reserveService.delTmpReserve(delTmpReserveParams);
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
let deleted = false;
|
|
89
|
+
// COAサービスエラーの場合ハンドリング
|
|
90
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
91
|
+
/* istanbul ignore if */
|
|
92
|
+
if (error.name === 'COAServiceError') {
|
|
93
|
+
if (typeof error.code === 'number'
|
|
94
|
+
&& error.code < http_status_1.INTERNAL_SERVER_ERROR) {
|
|
95
|
+
// すでに取消済の場合こうなるので、okとする
|
|
96
|
+
if (error.message === '座席取消失敗') {
|
|
97
|
+
deleted = true;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (!deleted) {
|
|
102
|
+
throw error;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
134
105
|
}
|
|
135
106
|
}
|
|
136
107
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as factory from '../../factory';
|
|
2
|
-
import type {
|
|
2
|
+
import type { IOperationExecute } from '../task';
|
|
3
3
|
/**
|
|
4
4
|
* タスク実行関数
|
|
5
5
|
*/
|
|
6
|
-
export declare function call(
|
|
6
|
+
export declare function call(data: factory.task.cancelPendingReservation.IData): IOperationExecute<void>;
|
|
@@ -10,76 +10,37 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.call = call;
|
|
13
|
-
// import * as COA from '@motionpicture/coa-service';
|
|
14
13
|
const factory = require("../../factory");
|
|
15
14
|
const action_1 = require("../../repo/action");
|
|
16
15
|
const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
17
16
|
const offer_1 = require("../../repo/rateLimit/offer");
|
|
18
17
|
const reservation_1 = require("../../repo/reservation");
|
|
19
|
-
// import { ReserveInterfaceRepo } from '../../repo/reserveInterface';
|
|
20
18
|
const setting_1 = require("../../repo/setting");
|
|
21
19
|
const stockHolder_1 = require("../../repo/stockHolder");
|
|
22
20
|
const task_1 = require("../../repo/task");
|
|
23
21
|
const cancelReservation_1 = require("../reserve/cancelReservation");
|
|
24
|
-
// import { cancelPendingReservation as cancelPendingCOAReserve } from '../reserveCOA/cancelReservation';
|
|
25
|
-
// let coaAuthClientCreated: boolean = false;
|
|
26
|
-
// let coaAuthClient: COA.auth.RefreshToken = new COA.auth.RefreshToken({
|
|
27
|
-
// endpoint: '', // 使用されないので空文字でok
|
|
28
|
-
// refreshToken: '', // 使用されないので空文字でok
|
|
29
|
-
// useFetch: true
|
|
30
|
-
// });
|
|
31
22
|
/**
|
|
32
23
|
* タスク実行関数
|
|
33
24
|
*/
|
|
34
|
-
function call(
|
|
25
|
+
function call(data) {
|
|
35
26
|
return (_a) => __awaiter(this, [_a], void 0, function* ({ connection, redisClient }) {
|
|
36
|
-
var _b, _c, _d, _e;
|
|
37
27
|
if (redisClient === undefined) {
|
|
38
28
|
throw new factory.errors.Argument('settings', 'redisClient required');
|
|
39
29
|
}
|
|
40
|
-
|
|
41
|
-
//
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
else if (((_c = data.object) === null || _c === void 0 ? void 0 : _c.typeOf) === factory.assetTransactionType.COAReserveTransaction) {
|
|
54
|
-
throw new factory.errors.NotImplemented(`object.typeOf ${(_d = data.object) === null || _d === void 0 ? void 0 : _d.typeOf} not implemented`);
|
|
55
|
-
// if (!coaAuthClientCreated) {
|
|
56
|
-
// const reserveInterfaceRepo = new ReserveInterfaceRepo(connection);
|
|
57
|
-
// const coaAPI = await reserveInterfaceRepo.findOne({ project: { id: { $eq: params.project.id } } });
|
|
58
|
-
// const credentials = coaAPI?.availableChannel?.credentials;
|
|
59
|
-
// if (typeof credentials?.refreshToken === 'string') {
|
|
60
|
-
// coaAuthClient = new COA.auth.RefreshToken(credentials);
|
|
61
|
-
// coaAuthClientCreated = true;
|
|
62
|
-
// }
|
|
63
|
-
// }
|
|
64
|
-
// const reserveService = new COA.service.Reserve(
|
|
65
|
-
// {
|
|
66
|
-
// endpoint: coaAuthClient.options.endpoint, // same as authClient(2024-07-17~)
|
|
67
|
-
// auth: coaAuthClient
|
|
68
|
-
// },
|
|
69
|
-
// { timeout: settings.coa.timeout }
|
|
70
|
-
// );
|
|
71
|
-
// const { object, instrument } = data;
|
|
72
|
-
// await cancelPendingCOAReserve({
|
|
73
|
-
// object,
|
|
74
|
-
// instrument,
|
|
75
|
-
// project: { id: params.project.id }
|
|
76
|
-
// })({
|
|
77
|
-
// action: new ActionRepo(connection),
|
|
78
|
-
// reserveService
|
|
79
|
-
// });
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
throw new factory.errors.NotImplemented(`purpose.typeOf ${(_e = data.purpose) === null || _e === void 0 ? void 0 : _e.typeOf} not implemented`);
|
|
30
|
+
// アクション数は予約番号単位で1しかありえないはず(2023-06-05~)
|
|
31
|
+
// if (data.actionAttributes.length !== 1) {
|
|
32
|
+
// throw new factory.errors.Argument('data.actionAttributes', 'data.actionAttributes.length must be 1');
|
|
33
|
+
// }
|
|
34
|
+
yield (0, cancelReservation_1.cancelPendingReservation)(data)({
|
|
35
|
+
action: new action_1.ActionRepo(connection),
|
|
36
|
+
assetTransaction: new assetTransaction_1.AssetTransactionRepo(connection),
|
|
37
|
+
stockHolder: new stockHolder_1.StockHolderRepo(redisClient, connection),
|
|
38
|
+
offerRateLimit: new offer_1.OfferRateLimitRepo(redisClient),
|
|
39
|
+
reservation: new reservation_1.ReservationRepo(connection),
|
|
40
|
+
setting: new setting_1.SettingRepo(connection),
|
|
41
|
+
task: new task_1.TaskRepo(connection)
|
|
83
42
|
}
|
|
43
|
+
// settings
|
|
44
|
+
);
|
|
84
45
|
});
|
|
85
46
|
}
|
|
@@ -101,7 +101,6 @@ function execute(task) {
|
|
|
101
101
|
case factory.taskName.AcceptCOAOffer:
|
|
102
102
|
case factory.taskName.AggregateOnSystem:
|
|
103
103
|
case factory.taskName.AuthorizePayment:
|
|
104
|
-
case factory.taskName.CancelPendingReservation:
|
|
105
104
|
case factory.taskName.CheckMovieTicket:
|
|
106
105
|
case factory.taskName.DeletePerson:
|
|
107
106
|
case factory.taskName.HandleNotification:
|
package/package.json
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/client-cognito-identity-provider": "3.600.0",
|
|
13
13
|
"@aws-sdk/credential-providers": "3.600.0",
|
|
14
|
-
"@chevre/factory": "4.393.0-alpha.
|
|
15
|
-
"@cinerino/sdk": "10.21.0-alpha.
|
|
14
|
+
"@chevre/factory": "4.393.0-alpha.33",
|
|
15
|
+
"@cinerino/sdk": "10.21.0-alpha.22",
|
|
16
16
|
"@motionpicture/coa-service": "9.6.0",
|
|
17
17
|
"@motionpicture/gmo-service": "5.3.0",
|
|
18
18
|
"@sendgrid/mail": "6.4.0",
|
|
@@ -112,5 +112,5 @@
|
|
|
112
112
|
"postversion": "git push origin --tags",
|
|
113
113
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
114
114
|
},
|
|
115
|
-
"version": "22.9.0-alpha.
|
|
115
|
+
"version": "22.9.0-alpha.47"
|
|
116
116
|
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type * as COA from '@motionpicture/coa-service';
|
|
2
|
-
import * as factory from '../../factory';
|
|
3
|
-
interface IProcessCancelPendingCOAReserveResult {
|
|
4
|
-
delTmpReserveArgs?: COA.factory.reserve.IDelTmpReserveArgs;
|
|
5
|
-
delTmpReserveResult?: factory.action.cancel.coaReserve.IDelTmpReserveResultAsError;
|
|
6
|
-
}
|
|
7
|
-
declare function processCancelPendingCOAReserveResult2recipe(params: {
|
|
8
|
-
processCancelPendingCOAReserveResult: IProcessCancelPendingCOAReserveResult;
|
|
9
|
-
project: {
|
|
10
|
-
id: string;
|
|
11
|
-
};
|
|
12
|
-
}): factory.action.cancel.coaReserve.ICancelPendingCOAReserveRecipe;
|
|
13
|
-
export { IProcessCancelPendingCOAReserveResult, processCancelPendingCOAReserveResult2recipe };
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.processCancelPendingCOAReserveResult2recipe = processCancelPendingCOAReserveResult2recipe;
|
|
4
|
-
const factory = require("../../factory");
|
|
5
|
-
function processCancelPendingCOAReserveResult2recipe(params) {
|
|
6
|
-
const { processCancelPendingCOAReserveResult, project } = params;
|
|
7
|
-
const { delTmpReserveArgs, delTmpReserveResult } = processCancelPendingCOAReserveResult;
|
|
8
|
-
return {
|
|
9
|
-
project: { id: project.id, typeOf: factory.organizationType.Project },
|
|
10
|
-
typeOf: 'Recipe',
|
|
11
|
-
recipeCategory: factory.recipe.RecipeCategory.cancelPendingCOAReserve,
|
|
12
|
-
step: [{
|
|
13
|
-
typeOf: 'HowToSection',
|
|
14
|
-
itemListElement: [
|
|
15
|
-
{
|
|
16
|
-
typeOf: 'HowToStep',
|
|
17
|
-
identifier: factory.recipe.StepIdentifier.delTmpReserve,
|
|
18
|
-
itemListElement: [Object.assign(Object.assign({ typeOf: 'HowToDirection' }, (delTmpReserveArgs !== undefined) ? { beforeMedia: delTmpReserveArgs } : undefined), (delTmpReserveResult !== undefined) ? { afterMedia: delTmpReserveResult } : undefined)]
|
|
19
|
-
}
|
|
20
|
-
]
|
|
21
|
-
}]
|
|
22
|
-
};
|
|
23
|
-
}
|