@chevre/domain 23.1.0-alpha.25 → 23.1.0-alpha.27
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/{eventOffer/adminEventOffers.ts → acceptedPaymentMethodOffer/adminAcceptedPaymentMethodOffers.ts} +12 -11
- package/lib/chevre/repo/acceptedPaymentMethodOffer.d.ts +41 -0
- package/lib/chevre/repo/acceptedPaymentMethodOffer.js +180 -0
- package/lib/chevre/repo/mongoose/schemas/acceptedPaymentMethodOffer.d.ts +10 -0
- package/lib/chevre/repo/mongoose/schemas/acceptedPaymentMethodOffer.js +97 -0
- package/lib/chevre/repository.d.ts +5 -0
- package/lib/chevre/repository.js +15 -2
- package/lib/chevre/service/assetTransaction/pay/validateAcceptedPaymentMethodIfNeeded.d.ts +15 -0
- package/lib/chevre/service/assetTransaction/pay/validateAcceptedPaymentMethodIfNeeded.js +64 -0
- package/lib/chevre/service/assetTransaction/pay.d.ts +4 -0
- package/lib/chevre/service/assetTransaction/pay.js +5 -0
- package/lib/chevre/service/payment/any.d.ts +4 -0
- package/lib/chevre/service/task/authorizePayment.js +2 -0
- package/lib/chevre/service/task/publishPaymentUrl.js +4 -0
- package/package.json +2 -2
- package/example/src/chevre/eventOffer/publishEventOfferToken.ts +0 -98
|
@@ -9,22 +9,23 @@ const project = { id: String(process.env.PROJECT_ID) };
|
|
|
9
9
|
async function main() {
|
|
10
10
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const acceptedPaymentMethodOfferRepo = await chevre.repository.AcceptedPaymentMethodOffer.createInstance(mongoose.connection);
|
|
13
13
|
|
|
14
14
|
const validFrom = moment()
|
|
15
15
|
.toDate();
|
|
16
16
|
const validThrough = moment(validFrom)
|
|
17
17
|
.add(1, 'hour')
|
|
18
18
|
.toDate();
|
|
19
|
-
const
|
|
19
|
+
const settingOffer: Omit<chevre.factory.acceptedPaymentMethodOffer.IAcceptedPaymentMethodOffer, 'id'> = {
|
|
20
20
|
typeOf: chevre.factory.offerType.Offer,
|
|
21
|
-
identifier: '
|
|
21
|
+
identifier: '20251202acceptedPaymentMethodOffer',
|
|
22
22
|
itemOffered: {
|
|
23
|
-
id: '
|
|
24
|
-
typeOf: chevre.factory.eventType.
|
|
23
|
+
id: '7k9ayl8hc',
|
|
24
|
+
typeOf: chevre.factory.eventType.ScreeningEventSeries
|
|
25
25
|
},
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
acceptedPaymentMethod: {
|
|
27
|
+
id: '5f9a52994f3709000abe6417',
|
|
28
|
+
typeOf: chevre.factory.service.paymentService.PaymentServiceType.MovieTicket
|
|
28
29
|
},
|
|
29
30
|
validFrom,
|
|
30
31
|
validThrough,
|
|
@@ -35,10 +36,10 @@ async function main() {
|
|
|
35
36
|
project: { id: project.id, typeOf: chevre.factory.organizationType.Project }
|
|
36
37
|
};
|
|
37
38
|
|
|
38
|
-
let result = await
|
|
39
|
+
let result = await acceptedPaymentMethodOfferRepo.upsertAcceptedPaymentMethodOffersByIdentifier(
|
|
39
40
|
[
|
|
40
41
|
{
|
|
41
|
-
$set:
|
|
42
|
+
$set: settingOffer,
|
|
42
43
|
$unset: {}
|
|
43
44
|
}
|
|
44
45
|
],
|
|
@@ -48,10 +49,10 @@ async function main() {
|
|
|
48
49
|
);
|
|
49
50
|
console.log(result);
|
|
50
51
|
|
|
51
|
-
result = await
|
|
52
|
+
result = await acceptedPaymentMethodOfferRepo.upsertAcceptedPaymentMethodOffersByIdentifier(
|
|
52
53
|
[
|
|
53
54
|
{
|
|
54
|
-
$set:
|
|
55
|
+
$set: settingOffer,
|
|
55
56
|
$unset: {}
|
|
56
57
|
}
|
|
57
58
|
],
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { BulkWriteResult } from 'mongodb';
|
|
2
|
+
import { Connection, FilterQuery } from 'mongoose';
|
|
3
|
+
import * as factory from '../factory';
|
|
4
|
+
import { IDocType } from './mongoose/schemas/acceptedPaymentMethodOffer';
|
|
5
|
+
type IUnset = {
|
|
6
|
+
[key in keyof IDocType]?: 1;
|
|
7
|
+
};
|
|
8
|
+
type IDocWithId = IDocType & {
|
|
9
|
+
id: string;
|
|
10
|
+
};
|
|
11
|
+
type IKeyOfProjection = keyof IDocType;
|
|
12
|
+
/**
|
|
13
|
+
* 対応決済方法オファーリポジトリ
|
|
14
|
+
*/
|
|
15
|
+
export declare class AcceptedPaymentMethodOfferRepo {
|
|
16
|
+
private readonly acceptedPaymentMethodOfferModel;
|
|
17
|
+
constructor(connection: Connection);
|
|
18
|
+
static CREATE_MONGO_CONDITIONS(params: factory.acceptedPaymentMethodOffer.ISearchConditions): FilterQuery<IDocType>[];
|
|
19
|
+
findAcceptedPaymentMethodOffers(params: factory.acceptedPaymentMethodOffer.ISearchConditions, inclusion: IKeyOfProjection[]): Promise<IDocWithId[]>;
|
|
20
|
+
/**
|
|
21
|
+
* オファーコードと提供リソースIDをキーにして冪等置換
|
|
22
|
+
*/
|
|
23
|
+
upsertAcceptedPaymentMethodOffersByIdentifier(params: {
|
|
24
|
+
$set: Pick<IDocType, 'identifier' | 'itemOffered' | 'acceptedPaymentMethod' | 'seller' | 'project' | 'typeOf' | 'validFrom' | 'validThrough'> & {
|
|
25
|
+
id?: never;
|
|
26
|
+
};
|
|
27
|
+
$unset: IUnset;
|
|
28
|
+
}[], options: {
|
|
29
|
+
/**
|
|
30
|
+
* falseの場合setOnInsertのみ
|
|
31
|
+
* trueの場合setのみ
|
|
32
|
+
*/
|
|
33
|
+
update: boolean;
|
|
34
|
+
}): Promise<{
|
|
35
|
+
bulkWriteResult: BulkWriteResult;
|
|
36
|
+
modifiedProductOffers: {
|
|
37
|
+
id: string;
|
|
38
|
+
}[];
|
|
39
|
+
} | void>;
|
|
40
|
+
}
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,180 @@
|
|
|
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.AcceptedPaymentMethodOfferRepo = void 0;
|
|
13
|
+
const factory = require("../factory");
|
|
14
|
+
const settings_1 = require("../settings");
|
|
15
|
+
const acceptedPaymentMethodOffer_1 = require("./mongoose/schemas/acceptedPaymentMethodOffer");
|
|
16
|
+
const AVAILABLE_PROJECT_FIELDS = [
|
|
17
|
+
'identifier',
|
|
18
|
+
'project',
|
|
19
|
+
'itemOffered',
|
|
20
|
+
'acceptedPaymentMethod',
|
|
21
|
+
'typeOf',
|
|
22
|
+
'validFrom',
|
|
23
|
+
'validThrough',
|
|
24
|
+
'seller'
|
|
25
|
+
];
|
|
26
|
+
/**
|
|
27
|
+
* 対応決済方法オファーリポジトリ
|
|
28
|
+
*/
|
|
29
|
+
class AcceptedPaymentMethodOfferRepo {
|
|
30
|
+
constructor(connection) {
|
|
31
|
+
this.acceptedPaymentMethodOfferModel = connection.model(acceptedPaymentMethodOffer_1.modelName, (0, acceptedPaymentMethodOffer_1.createSchema)());
|
|
32
|
+
}
|
|
33
|
+
static CREATE_MONGO_CONDITIONS(params) {
|
|
34
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
35
|
+
const andConditions = [];
|
|
36
|
+
const idEq = (_a = params.id) === null || _a === void 0 ? void 0 : _a.$eq;
|
|
37
|
+
if (typeof idEq === 'string') {
|
|
38
|
+
andConditions.push({ _id: { $eq: idEq } });
|
|
39
|
+
}
|
|
40
|
+
const projectIdEq = (_c = (_b = params.project) === null || _b === void 0 ? void 0 : _b.id) === null || _c === void 0 ? void 0 : _c.$eq;
|
|
41
|
+
if (typeof projectIdEq === 'string') {
|
|
42
|
+
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
43
|
+
}
|
|
44
|
+
const identifierEq = (_d = params.identifier) === null || _d === void 0 ? void 0 : _d.$eq;
|
|
45
|
+
if (typeof identifierEq === 'string') {
|
|
46
|
+
andConditions.push({ identifier: { $eq: identifierEq } });
|
|
47
|
+
}
|
|
48
|
+
const identifierIn = (_e = params.identifier) === null || _e === void 0 ? void 0 : _e.$in;
|
|
49
|
+
if (Array.isArray(identifierIn)) {
|
|
50
|
+
andConditions.push({ identifier: { $in: identifierIn } });
|
|
51
|
+
}
|
|
52
|
+
const itemOfferedIdEq = (_g = (_f = params.itemOffered) === null || _f === void 0 ? void 0 : _f.id) === null || _g === void 0 ? void 0 : _g.$eq;
|
|
53
|
+
if (typeof itemOfferedIdEq === 'string') {
|
|
54
|
+
andConditions.push({ 'itemOffered.id': { $eq: itemOfferedIdEq } });
|
|
55
|
+
}
|
|
56
|
+
const itemOfferedIdIn = (_j = (_h = params.itemOffered) === null || _h === void 0 ? void 0 : _h.id) === null || _j === void 0 ? void 0 : _j.$in;
|
|
57
|
+
if (Array.isArray(itemOfferedIdIn)) {
|
|
58
|
+
andConditions.push({ 'itemOffered.id': { $in: itemOfferedIdIn } });
|
|
59
|
+
}
|
|
60
|
+
const acceptedPaymentMethodIdEq = (_l = (_k = params.acceptedPaymentMethod) === null || _k === void 0 ? void 0 : _k.id) === null || _l === void 0 ? void 0 : _l.$eq;
|
|
61
|
+
if (typeof acceptedPaymentMethodIdEq === 'string') {
|
|
62
|
+
andConditions.push({ 'acceptedPaymentMethod.id': { $eq: acceptedPaymentMethodIdEq } });
|
|
63
|
+
}
|
|
64
|
+
const sellerByIdEq = (_o = (_m = params.seller) === null || _m === void 0 ? void 0 : _m.id) === null || _o === void 0 ? void 0 : _o.$eq;
|
|
65
|
+
if (typeof sellerByIdEq === 'string') {
|
|
66
|
+
andConditions.push({ 'seller.id': { $eq: sellerByIdEq } });
|
|
67
|
+
}
|
|
68
|
+
const validFromLte = (_p = params.validFrom) === null || _p === void 0 ? void 0 : _p.$lte;
|
|
69
|
+
if (validFromLte instanceof Date) {
|
|
70
|
+
andConditions.push({ validFrom: { $lte: validFromLte } });
|
|
71
|
+
}
|
|
72
|
+
const validThroughGte = (_q = params.validThrough) === null || _q === void 0 ? void 0 : _q.$gte;
|
|
73
|
+
if (validThroughGte instanceof Date) {
|
|
74
|
+
andConditions.push({ validThrough: { $gte: validThroughGte } });
|
|
75
|
+
}
|
|
76
|
+
return andConditions;
|
|
77
|
+
}
|
|
78
|
+
findAcceptedPaymentMethodOffers(params, inclusion) {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
var _a;
|
|
81
|
+
const conditions = AcceptedPaymentMethodOfferRepo.CREATE_MONGO_CONDITIONS(params);
|
|
82
|
+
let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
|
|
83
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
84
|
+
positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
|
|
88
|
+
}
|
|
89
|
+
const projection = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1]))));
|
|
90
|
+
const query = this.acceptedPaymentMethodOfferModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
|
|
91
|
+
if (typeof ((_a = params.sort) === null || _a === void 0 ? void 0 : _a.validFrom) === 'number') {
|
|
92
|
+
query.sort({ validFrom: params.sort.validFrom });
|
|
93
|
+
}
|
|
94
|
+
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
95
|
+
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
96
|
+
query.limit(params.limit)
|
|
97
|
+
.skip(params.limit * (page - 1));
|
|
98
|
+
}
|
|
99
|
+
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
100
|
+
.lean()
|
|
101
|
+
.exec();
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* オファーコードと提供リソースIDをキーにして冪等置換
|
|
106
|
+
*/
|
|
107
|
+
upsertAcceptedPaymentMethodOffersByIdentifier(params, options) {
|
|
108
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
109
|
+
const { update } = options;
|
|
110
|
+
const bulkWriteOps = [];
|
|
111
|
+
const queryFilters = [];
|
|
112
|
+
if (Array.isArray(params)) {
|
|
113
|
+
params.forEach(({ $set, $unset }) => {
|
|
114
|
+
const { identifier, itemOffered, acceptedPaymentMethod, seller, project, validFrom, validThrough } = $set;
|
|
115
|
+
if (typeof identifier !== 'string' || identifier === '') {
|
|
116
|
+
throw new factory.errors.ArgumentNull('identifier');
|
|
117
|
+
}
|
|
118
|
+
if (typeof itemOffered.id !== 'string' || itemOffered.id === '') {
|
|
119
|
+
throw new factory.errors.ArgumentNull('itemOffered.id');
|
|
120
|
+
}
|
|
121
|
+
// リソースのユニークネスを保証するfilter
|
|
122
|
+
const filter = {
|
|
123
|
+
'project.id': { $eq: project.id },
|
|
124
|
+
'itemOffered.id': { $eq: itemOffered.id },
|
|
125
|
+
identifier: { $eq: identifier }
|
|
126
|
+
};
|
|
127
|
+
queryFilters.push({
|
|
128
|
+
'project.id': { $eq: project.id },
|
|
129
|
+
'itemOffered.id': { $eq: itemOffered.id },
|
|
130
|
+
identifier: { $eq: identifier }
|
|
131
|
+
});
|
|
132
|
+
if (update === true) {
|
|
133
|
+
const setFields = {
|
|
134
|
+
validFrom,
|
|
135
|
+
validThrough,
|
|
136
|
+
acceptedPaymentMethod
|
|
137
|
+
};
|
|
138
|
+
const updateFilter = Object.assign({ $set: setFields }, ($unset !== undefined) ? { $unset } : undefined);
|
|
139
|
+
const updateOne = {
|
|
140
|
+
filter,
|
|
141
|
+
update: updateFilter,
|
|
142
|
+
upsert: false
|
|
143
|
+
};
|
|
144
|
+
bulkWriteOps.push({ updateOne });
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
const setOnInsert = {
|
|
148
|
+
itemOffered, identifier, project, seller,
|
|
149
|
+
typeOf: factory.offerType.Offer,
|
|
150
|
+
validFrom,
|
|
151
|
+
validThrough,
|
|
152
|
+
acceptedPaymentMethod
|
|
153
|
+
};
|
|
154
|
+
const updateFilter = {
|
|
155
|
+
$setOnInsert: setOnInsert
|
|
156
|
+
};
|
|
157
|
+
const updateOne = {
|
|
158
|
+
filter,
|
|
159
|
+
update: updateFilter,
|
|
160
|
+
upsert: true
|
|
161
|
+
};
|
|
162
|
+
bulkWriteOps.push({ updateOne });
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
if (bulkWriteOps.length > 0) {
|
|
167
|
+
const bulkWriteResult = yield this.acceptedPaymentMethodOfferModel.bulkWrite(bulkWriteOps, { ordered: false });
|
|
168
|
+
// modifiedの場合upsertedIdsに含まれないので、idを検索する
|
|
169
|
+
const modifiedProductOffers = yield this.acceptedPaymentMethodOfferModel.find({ $or: queryFilters }, {
|
|
170
|
+
_id: 0,
|
|
171
|
+
id: { $toString: '$_id' }
|
|
172
|
+
})
|
|
173
|
+
.lean()
|
|
174
|
+
.exec();
|
|
175
|
+
return { bulkWriteResult, modifiedProductOffers };
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
exports.AcceptedPaymentMethodOfferRepo = AcceptedPaymentMethodOfferRepo;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
|
|
2
|
+
import * as factory from '../../../factory';
|
|
3
|
+
type IDocType = factory.acceptedPaymentMethodOffer.IAcceptedPaymentMethodOffer;
|
|
4
|
+
type IModel = Model<IDocType>;
|
|
5
|
+
type ISchemaDefinition = SchemaDefinition<IDocType>;
|
|
6
|
+
type ISchema = Schema<IDocType, IModel, {}, {}, {}, {}, ISchemaDefinition, IDocType>;
|
|
7
|
+
declare const modelName = "AcceptedPaymentMethodOffer";
|
|
8
|
+
declare const indexes: [d: IndexDefinition, o: IndexOptions][];
|
|
9
|
+
declare function createSchema(): ISchema;
|
|
10
|
+
export { createSchema, IDocType, IModel, indexes, modelName };
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.modelName = exports.indexes = void 0;
|
|
4
|
+
exports.createSchema = createSchema;
|
|
5
|
+
const mongoose_1 = require("mongoose");
|
|
6
|
+
const settings_1 = require("../../../settings");
|
|
7
|
+
const writeConcern_1 = require("../writeConcern");
|
|
8
|
+
const modelName = 'AcceptedPaymentMethodOffer';
|
|
9
|
+
exports.modelName = modelName;
|
|
10
|
+
const schemaDefinition = {
|
|
11
|
+
project: { type: mongoose_1.SchemaTypes.Mixed, required: true },
|
|
12
|
+
seller: { type: mongoose_1.SchemaTypes.Mixed, required: true },
|
|
13
|
+
typeOf: { type: String, required: true },
|
|
14
|
+
identifier: { type: String, required: true },
|
|
15
|
+
itemOffered: { type: mongoose_1.SchemaTypes.Mixed, required: true },
|
|
16
|
+
validFrom: { type: Date, required: true },
|
|
17
|
+
validThrough: { type: Date, required: true },
|
|
18
|
+
acceptedPaymentMethod: { type: mongoose_1.SchemaTypes.Mixed, required: true }
|
|
19
|
+
// offeredBy: { type: SchemaTypes.Mixed, required: false }
|
|
20
|
+
};
|
|
21
|
+
const schemaOptions = {
|
|
22
|
+
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
23
|
+
autoCreate: false,
|
|
24
|
+
collection: 'acceptedPaymentMethodOffers',
|
|
25
|
+
id: true,
|
|
26
|
+
read: settings_1.MONGO_READ_PREFERENCE,
|
|
27
|
+
writeConcern: writeConcern_1.writeConcern,
|
|
28
|
+
strict: true,
|
|
29
|
+
strictQuery: false,
|
|
30
|
+
timestamps: false,
|
|
31
|
+
versionKey: false,
|
|
32
|
+
toJSON: {
|
|
33
|
+
getters: false,
|
|
34
|
+
virtuals: false,
|
|
35
|
+
minimize: false,
|
|
36
|
+
versionKey: false
|
|
37
|
+
},
|
|
38
|
+
toObject: {
|
|
39
|
+
getters: false,
|
|
40
|
+
virtuals: true,
|
|
41
|
+
minimize: false,
|
|
42
|
+
versionKey: false
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const indexes = [
|
|
46
|
+
[
|
|
47
|
+
{ validFrom: 1 },
|
|
48
|
+
{ name: 'validFrom' }
|
|
49
|
+
],
|
|
50
|
+
[
|
|
51
|
+
{ validThrough: 1, validFrom: 1 },
|
|
52
|
+
{ name: 'validThrough' }
|
|
53
|
+
],
|
|
54
|
+
[
|
|
55
|
+
{
|
|
56
|
+
'project.id': 1,
|
|
57
|
+
'itemOffered.id': 1,
|
|
58
|
+
identifier: 1
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: 'uniqueByItemOfferedAndIdentifier',
|
|
62
|
+
unique: true
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
[
|
|
66
|
+
{ 'project.id': 1, validFrom: 1 },
|
|
67
|
+
{ name: 'projectId' }
|
|
68
|
+
],
|
|
69
|
+
[
|
|
70
|
+
{ 'seller.id': 1, validFrom: 1 },
|
|
71
|
+
{ name: 'sellerId' }
|
|
72
|
+
],
|
|
73
|
+
[
|
|
74
|
+
{ identifier: 1, validFrom: 1 },
|
|
75
|
+
{ name: 'identifier' }
|
|
76
|
+
],
|
|
77
|
+
[
|
|
78
|
+
{ 'itemOffered.id': 1, validFrom: 1 },
|
|
79
|
+
{ name: 'itemOfferedId' }
|
|
80
|
+
]
|
|
81
|
+
];
|
|
82
|
+
exports.indexes = indexes;
|
|
83
|
+
/**
|
|
84
|
+
* 対応決済方法オファースキーマ
|
|
85
|
+
*/
|
|
86
|
+
let schema;
|
|
87
|
+
function createSchema() {
|
|
88
|
+
if (schema === undefined) {
|
|
89
|
+
schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
|
|
90
|
+
if (settings_1.MONGO_AUTO_INDEX) {
|
|
91
|
+
indexes.forEach((indexParams) => {
|
|
92
|
+
schema === null || schema === void 0 ? void 0 : schema.index(...indexParams);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return schema;
|
|
97
|
+
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* リポジトリ
|
|
3
3
|
*/
|
|
4
4
|
import type { AcceptedOfferRepo } from './repo/acceptedOffer';
|
|
5
|
+
import type { AcceptedPaymentMethodOfferRepo } from './repo/acceptedPaymentMethodOffer';
|
|
5
6
|
import type { AccountRepo } from './repo/account';
|
|
6
7
|
import type { AccountingReportRepo } from './repo/accountingReport';
|
|
7
8
|
import type { AccountTitleRepo } from './repo/accountTitle';
|
|
@@ -94,6 +95,10 @@ export type AcceptedOffer = AcceptedOfferRepo;
|
|
|
94
95
|
export declare namespace AcceptedOffer {
|
|
95
96
|
function createInstance(...params: ConstructorParameters<typeof AcceptedOfferRepo>): Promise<AcceptedOfferRepo>;
|
|
96
97
|
}
|
|
98
|
+
export type AcceptedPaymentMethodOffer = AcceptedPaymentMethodOfferRepo;
|
|
99
|
+
export declare namespace AcceptedPaymentMethodOffer {
|
|
100
|
+
function createInstance(...params: ConstructorParameters<typeof AcceptedPaymentMethodOfferRepo>): Promise<AcceptedPaymentMethodOfferRepo>;
|
|
101
|
+
}
|
|
97
102
|
export type Account = AccountRepo;
|
|
98
103
|
export declare namespace Account {
|
|
99
104
|
function createInstance(...params: ConstructorParameters<typeof AccountRepo>): Promise<AccountRepo>;
|
package/lib/chevre/repository.js
CHANGED
|
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
13
|
-
exports.WebSite = exports.rateLimit = exports.Trip = exports.TransactionProcess = exports.TransactionNumber = exports.Transaction = exports.Ticket = exports.Telemetry = exports.Task = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.ServiceAvailableHour = exports.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.SellerMakesOffer = exports.Seller = exports.Schedule = exports.Role = exports.ReserveInterface = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductOffer = exports.ProductModel = exports.ProductHasOfferCatalog = exports.Product = exports.PriceSpecification = exports.PotentialAction = exports.place = exports.Permit = exports.Person = void 0;
|
|
12
|
+
exports.PendingReservation = exports.PaymentServiceProvider = exports.PaymentServiceChannel = exports.PaymentService = exports.Passport = exports.OwnershipInfo = exports.OrderNumber = exports.OrderInTransaction = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.NoteAboutOrder = exports.Note = exports.MovieTicketType = exports.Message = exports.MerchantReturnPolicy = exports.MemberProgram = exports.Member = exports.Issuer = exports.IdentityProvider = exports.Identity = exports.EventSeries = exports.EventSellerMakesOffer = exports.EventOffer = exports.Event = exports.EmailMessage = exports.CustomerType = exports.Customer = exports.Credentials = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Authorization = exports.CategoryCode = exports.AssetTransaction = exports.Aggregation = exports.AggregateReservation = exports.AggregateOrder = exports.AggregateOffer = exports.AdvanceBookingRequirement = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = exports.AcceptedPaymentMethodOffer = exports.AcceptedOffer = void 0;
|
|
13
|
+
exports.WebSite = exports.rateLimit = exports.Trip = exports.TransactionProcess = exports.TransactionNumber = exports.Transaction = exports.Ticket = exports.Telemetry = exports.Task = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.ServiceAvailableHour = exports.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.SellerMakesOffer = exports.Seller = exports.Schedule = exports.Role = exports.ReserveInterface = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductOffer = exports.ProductModel = exports.ProductHasOfferCatalog = exports.Product = exports.PriceSpecification = exports.PotentialAction = exports.place = exports.Permit = exports.Person = exports.paymentMethod = void 0;
|
|
14
14
|
var AcceptedOffer;
|
|
15
15
|
(function (AcceptedOffer) {
|
|
16
16
|
let repo;
|
|
@@ -24,6 +24,19 @@ var AcceptedOffer;
|
|
|
24
24
|
}
|
|
25
25
|
AcceptedOffer.createInstance = createInstance;
|
|
26
26
|
})(AcceptedOffer || (exports.AcceptedOffer = AcceptedOffer = {}));
|
|
27
|
+
var AcceptedPaymentMethodOffer;
|
|
28
|
+
(function (AcceptedPaymentMethodOffer) {
|
|
29
|
+
let repo;
|
|
30
|
+
function createInstance(...params) {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
if (repo === undefined) {
|
|
33
|
+
repo = (yield Promise.resolve().then(() => require('./repo/acceptedPaymentMethodOffer'))).AcceptedPaymentMethodOfferRepo;
|
|
34
|
+
}
|
|
35
|
+
return new repo(...params);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
AcceptedPaymentMethodOffer.createInstance = createInstance;
|
|
39
|
+
})(AcceptedPaymentMethodOffer || (exports.AcceptedPaymentMethodOffer = AcceptedPaymentMethodOffer = {}));
|
|
27
40
|
var Account;
|
|
28
41
|
(function (Account) {
|
|
29
42
|
let repo;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ペイメントカード決済取引バリデーション
|
|
3
|
+
*/
|
|
4
|
+
import type { EventRepo } from '../../../repo/event';
|
|
5
|
+
import type { EventSeriesRepo } from '../../../repo/eventSeries';
|
|
6
|
+
import * as factory from '../../../factory';
|
|
7
|
+
/**
|
|
8
|
+
* 必要あらば関連リソースの対応決済方法を検証する
|
|
9
|
+
*/
|
|
10
|
+
export declare function validateAcceptedPaymentMethodIfNeeded(params: Pick<factory.assetTransaction.pay.IStartParamsWithoutDetail, 'object'> | {
|
|
11
|
+
object: factory.action.accept.pay.IPayObject;
|
|
12
|
+
}): (repos: {
|
|
13
|
+
event: EventRepo;
|
|
14
|
+
eventSeries: EventSeriesRepo;
|
|
15
|
+
}) => Promise<void>;
|
|
@@ -0,0 +1,64 @@
|
|
|
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.validateAcceptedPaymentMethodIfNeeded = validateAcceptedPaymentMethodIfNeeded;
|
|
13
|
+
const factory = require("../../../factory");
|
|
14
|
+
/**
|
|
15
|
+
* 必要あらば関連リソースの対応決済方法を検証する
|
|
16
|
+
*/
|
|
17
|
+
function validateAcceptedPaymentMethodIfNeeded(params) {
|
|
18
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
var _a, _b;
|
|
20
|
+
const orderedItems = (_a = params.object.serviceOutput) === null || _a === void 0 ? void 0 : _a.referencesOrder.orderedItem;
|
|
21
|
+
if (Array.isArray(orderedItems)) {
|
|
22
|
+
const eventIds = orderedItems.map((orderedItem) => orderedItem.orderedItem.serviceOutput.reservationFor.id);
|
|
23
|
+
if (eventIds.length === 0) {
|
|
24
|
+
throw new factory.errors.ArgumentNull('object.serviceOutput.referencesOrder.orderedItem');
|
|
25
|
+
}
|
|
26
|
+
// 指定された全イベントについて、施設コンテンツの対応決済方法を検証する
|
|
27
|
+
const eventSeriesIds = (yield repos.event.projectEventFields({
|
|
28
|
+
limit: eventIds.length,
|
|
29
|
+
page: 1,
|
|
30
|
+
id: { $in: eventIds },
|
|
31
|
+
typeOf: factory.eventType.ScreeningEvent
|
|
32
|
+
}, ['superEvent'])).map((event) => event.superEvent.id);
|
|
33
|
+
if (eventSeriesIds.length !== eventIds.length) {
|
|
34
|
+
throw new factory.errors.NotFound(factory.eventType.ScreeningEvent);
|
|
35
|
+
}
|
|
36
|
+
const uniqueEventSeriesIds = [...new Set(eventSeriesIds)];
|
|
37
|
+
// tslint:disable-next-line:no-console
|
|
38
|
+
console.log('validateAcceptedPaymentMethodIfNeeded: eventSeries with AggregateOffer?', uniqueEventSeriesIds);
|
|
39
|
+
for (const eventSeriesId of uniqueEventSeriesIds) {
|
|
40
|
+
const eventSeries = (yield repos.eventSeries.projectEventSeriesFields({
|
|
41
|
+
limit: 1,
|
|
42
|
+
page: 1,
|
|
43
|
+
id: { $eq: eventSeriesId }
|
|
44
|
+
}, ['offers'])).shift();
|
|
45
|
+
if (eventSeries === undefined) {
|
|
46
|
+
throw new factory.errors.NotFound(factory.eventType.ScreeningEventSeries);
|
|
47
|
+
}
|
|
48
|
+
if (((_b = eventSeries.offers) === null || _b === void 0 ? void 0 : _b.typeOf) === factory.offerType.AggregateOffer) {
|
|
49
|
+
// 対応決済方法オファーIDの指定が必要
|
|
50
|
+
throw new factory.errors.ArgumentNull('acceptedPaymentMethodOfferId');
|
|
51
|
+
// if (paymentAccepted !== true) {
|
|
52
|
+
// throw new factory.errors.Argument('recipient', `payment not accepted [${paymentMethodType}]`);
|
|
53
|
+
// }
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
// 集約オファーでなければ検証の必要なし
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
// 関連注文の指定がなければ検証の必要なし
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
@@ -10,6 +10,7 @@ import type { ActionRepo } from '../../repo/action';
|
|
|
10
10
|
import type { AssetTransactionRepo } from '../../repo/assetTransaction';
|
|
11
11
|
import type { CredentialsRepo } from '../../repo/credentials';
|
|
12
12
|
import type { EventRepo } from '../../repo/event';
|
|
13
|
+
import type { EventSeriesRepo } from '../../repo/eventSeries';
|
|
13
14
|
import type { OrderRepo } from '../../repo/order';
|
|
14
15
|
import type { PaymentServiceRepo } from '../../repo/paymentService';
|
|
15
16
|
import type { PaymentServiceProviderRepo } from '../../repo/paymentServiceProvider';
|
|
@@ -24,6 +25,7 @@ export interface IStartOperationRepos {
|
|
|
24
25
|
action: ActionRepo;
|
|
25
26
|
credentials: CredentialsRepo;
|
|
26
27
|
event: EventRepo;
|
|
28
|
+
eventSeries: EventSeriesRepo;
|
|
27
29
|
paymentAccepted: SellerPaymentAcceptedRepo;
|
|
28
30
|
paymentService: PaymentServiceRepo;
|
|
29
31
|
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
@@ -61,6 +63,8 @@ export type ICheckOperation<T> = (repos: {
|
|
|
61
63
|
}, settings: Settings) => Promise<T>;
|
|
62
64
|
export type IPublishPaymentUrlOperation<T> = (repos: {
|
|
63
65
|
action: ActionRepo;
|
|
66
|
+
event: EventRepo;
|
|
67
|
+
eventSeries: EventSeriesRepo;
|
|
64
68
|
paymentAccepted: SellerPaymentAcceptedRepo;
|
|
65
69
|
paymentService: PaymentServiceRepo;
|
|
66
70
|
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
@@ -24,6 +24,7 @@ const PaymentCardPayment = require("../payment/paymentCard");
|
|
|
24
24
|
const fixInformAction_1 = require("./fixInformAction");
|
|
25
25
|
const validation_1 = require("./pay/account/validation");
|
|
26
26
|
const factory_1 = require("./pay/factory");
|
|
27
|
+
const validateAcceptedPaymentMethodIfNeeded_1 = require("./pay/validateAcceptedPaymentMethodIfNeeded");
|
|
27
28
|
function publishPaymentUrlResult2recipe(params) {
|
|
28
29
|
const { project, result } = params;
|
|
29
30
|
return {
|
|
@@ -76,6 +77,8 @@ function publishPaymentUrl(params, options) {
|
|
|
76
77
|
throw new factory.errors.ArgumentNull('transactionNumber');
|
|
77
78
|
}
|
|
78
79
|
yield validateSeller(params)(repos);
|
|
80
|
+
// リソースの対応決済方法検証(2025-12-02~)
|
|
81
|
+
yield (0, validateAcceptedPaymentMethodIfNeeded_1.validateAcceptedPaymentMethodIfNeeded)(params)(repos);
|
|
79
82
|
// 決済サービス確認
|
|
80
83
|
const paymentServiceId = getPaymentServiceId(params);
|
|
81
84
|
// 決済受入アクション生成(2024-03-28~)
|
|
@@ -186,6 +189,8 @@ function start(params, options) {
|
|
|
186
189
|
throw new factory.errors.ArgumentNull('transactionNumber');
|
|
187
190
|
}
|
|
188
191
|
yield validateSeller(params)(repos);
|
|
192
|
+
// リソースの対応決済方法検証(2025-12-02~)
|
|
193
|
+
yield (0, validateAcceptedPaymentMethodIfNeeded_1.validateAcceptedPaymentMethodIfNeeded)(params)(repos);
|
|
189
194
|
// 決済サービス確認
|
|
190
195
|
const paymentServiceType = (_b = params.object) === null || _b === void 0 ? void 0 : _b.typeOf;
|
|
191
196
|
const paymentService = yield fixPaymentService(params)(repos);
|
|
@@ -7,6 +7,7 @@ import type { AuthorizationRepo } from '../../repo/authorization';
|
|
|
7
7
|
import type { ConfirmationNumberRepo } from '../../repo/confirmationNumber';
|
|
8
8
|
import type { CredentialsRepo } from '../../repo/credentials';
|
|
9
9
|
import type { EventRepo } from '../../repo/event';
|
|
10
|
+
import type { EventSeriesRepo } from '../../repo/eventSeries';
|
|
10
11
|
import type { OrderNumberRepo } from '../../repo/orderNumber';
|
|
11
12
|
import type { PaymentServiceRepo } from '../../repo/paymentService';
|
|
12
13
|
import type { PaymentServiceProviderRepo } from '../../repo/paymentServiceProvider';
|
|
@@ -85,6 +86,7 @@ interface IAuthorizeRepos {
|
|
|
85
86
|
confirmationNumber: ConfirmationNumberRepo;
|
|
86
87
|
credentials: CredentialsRepo;
|
|
87
88
|
event: EventRepo;
|
|
89
|
+
eventSeries: EventSeriesRepo;
|
|
88
90
|
orderNumber: OrderNumberRepo;
|
|
89
91
|
paymentAccepted: SellerPaymentAcceptedRepo;
|
|
90
92
|
paymentService: PaymentServiceRepo;
|
|
@@ -102,6 +104,8 @@ interface IPublishPaymentUrlRepos {
|
|
|
102
104
|
action: ActionRepo;
|
|
103
105
|
assetTransaction: AssetTransactionRepo;
|
|
104
106
|
authorization: AuthorizationRepo;
|
|
107
|
+
event: EventRepo;
|
|
108
|
+
eventSeries: EventSeriesRepo;
|
|
105
109
|
orderNumber: OrderNumberRepo;
|
|
106
110
|
paymentAccepted: SellerPaymentAcceptedRepo;
|
|
107
111
|
paymentService: PaymentServiceRepo;
|
|
@@ -18,6 +18,7 @@ const authorization_1 = require("../../repo/authorization");
|
|
|
18
18
|
const confirmationNumber_1 = require("../../repo/confirmationNumber");
|
|
19
19
|
const credentials_1 = require("../../repo/credentials");
|
|
20
20
|
const event_1 = require("../../repo/event");
|
|
21
|
+
const eventSeries_1 = require("../../repo/eventSeries");
|
|
21
22
|
const orderNumber_1 = require("../../repo/orderNumber");
|
|
22
23
|
const paymentService_1 = require("../../repo/paymentService");
|
|
23
24
|
const paymentServiceProvider_1 = require("../../repo/paymentServiceProvider");
|
|
@@ -63,6 +64,7 @@ function call(params) {
|
|
|
63
64
|
expireInSeconds: (useCredentialsRepo) ? credentialsExpireInSeconds : 0
|
|
64
65
|
}),
|
|
65
66
|
event: new event_1.EventRepo(connection),
|
|
67
|
+
eventSeries: new eventSeries_1.EventSeriesRepo(connection),
|
|
66
68
|
orderNumber: new orderNumber_1.OrderNumberRepo({ connection }),
|
|
67
69
|
paymentAccepted: new sellerPaymentAccepted_1.SellerPaymentAcceptedRepo(connection),
|
|
68
70
|
paymentService: new paymentService_1.PaymentServiceRepo(connection),
|
|
@@ -14,6 +14,8 @@ const factory = require("../../factory");
|
|
|
14
14
|
const action_1 = require("../../repo/action");
|
|
15
15
|
const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
16
16
|
const authorization_1 = require("../../repo/authorization");
|
|
17
|
+
const event_1 = require("../../repo/event");
|
|
18
|
+
const eventSeries_1 = require("../../repo/eventSeries");
|
|
17
19
|
const orderNumber_1 = require("../../repo/orderNumber");
|
|
18
20
|
const paymentService_1 = require("../../repo/paymentService");
|
|
19
21
|
const paymentServiceProvider_1 = require("../../repo/paymentServiceProvider");
|
|
@@ -43,6 +45,8 @@ function call(params) {
|
|
|
43
45
|
action: actionRepo,
|
|
44
46
|
assetTransaction: new assetTransaction_1.AssetTransactionRepo(connection),
|
|
45
47
|
authorization: new authorization_1.AuthorizationRepo(connection),
|
|
48
|
+
event: new event_1.EventRepo(connection),
|
|
49
|
+
eventSeries: new eventSeries_1.EventSeriesRepo(connection),
|
|
46
50
|
orderNumber: new orderNumber_1.OrderNumberRepo({ connection }),
|
|
47
51
|
paymentAccepted: new sellerPaymentAccepted_1.SellerPaymentAcceptedRepo(connection),
|
|
48
52
|
paymentService: new paymentService_1.PaymentServiceRepo(connection),
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
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": "5.4.0-alpha.
|
|
14
|
+
"@chevre/factory": "5.4.0-alpha.3",
|
|
15
15
|
"@cinerino/sdk": "12.11.0",
|
|
16
16
|
"@motionpicture/coa-service": "9.6.0",
|
|
17
17
|
"@motionpicture/gmo-service": "5.4.0-alpha.1",
|
|
@@ -115,5 +115,5 @@
|
|
|
115
115
|
"postversion": "git push origin --tags",
|
|
116
116
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
117
117
|
},
|
|
118
|
-
"version": "23.1.0-alpha.
|
|
118
|
+
"version": "23.1.0-alpha.27"
|
|
119
119
|
}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import { sign } from 'jsonwebtoken';
|
|
3
|
-
import * as moment from 'moment';
|
|
4
|
-
import * as mongoose from 'mongoose';
|
|
5
|
-
|
|
6
|
-
import { chevre } from '../../../../lib/index';
|
|
7
|
-
|
|
8
|
-
const project = { id: String(process.env.PROJECT_ID) };
|
|
9
|
-
|
|
10
|
-
async function main() {
|
|
11
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
-
|
|
13
|
-
const eventOfferRepo = await chevre.repository.EventOffer.createInstance(mongoose.connection);
|
|
14
|
-
const issuerRepo = await chevre.repository.Issuer.createInstance(mongoose.connection);
|
|
15
|
-
|
|
16
|
-
const eventOffer = (await eventOfferRepo.findEventOffers(
|
|
17
|
-
{
|
|
18
|
-
limit: 1,
|
|
19
|
-
page: 1,
|
|
20
|
-
project: { id: { $eq: project.id } },
|
|
21
|
-
id: { $eq: '691e5bb3929e69df1ec6e9a6' }
|
|
22
|
-
},
|
|
23
|
-
['offeredBy', 'identifier', 'itemOffered']
|
|
24
|
-
)).shift();
|
|
25
|
-
if (eventOffer === undefined) {
|
|
26
|
-
throw new chevre.factory.errors.NotFound(chevre.factory.offerType.Offer);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const issuerIdentifier = eventOffer.offeredBy?.identifier;
|
|
30
|
-
if (typeof issuerIdentifier !== 'string') {
|
|
31
|
-
throw new chevre.factory.errors.NotFound('eventOffer.offeredBy?.identifier');
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// const tier = (await memberProgramRepo.projectMemberProgramTiers(
|
|
35
|
-
// {
|
|
36
|
-
// limit: 1,
|
|
37
|
-
// page: 1,
|
|
38
|
-
// project: { id: { $eq: project.id } },
|
|
39
|
-
// identifier: { $eq: tierIdentifier }
|
|
40
|
-
// }
|
|
41
|
-
// )).shift();
|
|
42
|
-
// if (tier === undefined) {
|
|
43
|
-
// throw new chevre.factory.errors.NotFound('MemberProgramTier');
|
|
44
|
-
// }
|
|
45
|
-
|
|
46
|
-
const { url, tokenSecret } = await issuerRepo.findByIdentifier({
|
|
47
|
-
identifier: issuerIdentifier,
|
|
48
|
-
project: { id: project.id }
|
|
49
|
-
});
|
|
50
|
-
if (typeof tokenSecret !== 'string') {
|
|
51
|
-
throw new chevre.factory.errors.NotFound('issuer.tokenSecret');
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const payload: chevre.factory.assetTransaction.reserve.IEventOfferTokenPayload = {
|
|
55
|
-
identifier: eventOffer.identifier,
|
|
56
|
-
validFrom: moment()
|
|
57
|
-
.format('YYYY-MM-DDTHH:mm:ssZ'),
|
|
58
|
-
validThrough: moment()
|
|
59
|
-
.add(1, 'hour')
|
|
60
|
-
.format('YYYY-MM-DDTHH:mm:ssZ'),
|
|
61
|
-
eligibleQuantity: {
|
|
62
|
-
maxValue: 1
|
|
63
|
-
},
|
|
64
|
-
itemOffered: {
|
|
65
|
-
id: 'xxx'
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const token = await new Promise<string>((resolve, reject) => {
|
|
70
|
-
// 所有権を暗号化する
|
|
71
|
-
sign(
|
|
72
|
-
payload,
|
|
73
|
-
tokenSecret,
|
|
74
|
-
{
|
|
75
|
-
// algorithm: jwtSetting.algorithm,
|
|
76
|
-
issuer: url,
|
|
77
|
-
expiresIn: 1800
|
|
78
|
-
// subject,
|
|
79
|
-
},
|
|
80
|
-
(err, encoded) => {
|
|
81
|
-
if (err instanceof Error) {
|
|
82
|
-
reject(err);
|
|
83
|
-
} else {
|
|
84
|
-
if (typeof encoded !== 'string') {
|
|
85
|
-
reject(new Error('cannot be signed unexpectedly'));
|
|
86
|
-
} else {
|
|
87
|
-
resolve(encoded);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
);
|
|
92
|
-
});
|
|
93
|
-
console.log(token);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
main()
|
|
97
|
-
.then()
|
|
98
|
-
.catch(console.error);
|