@cinerino/sdk 3.144.0-alpha.1 → 3.144.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/playground/public/lib/bundle.js +29 -18
- package/example/src/transaction/processPlaceOrderByPaymentCard.ts +1 -8
- package/example/src/transaction/searchEventOffers.ts +66 -0
- package/lib/bundle.js +0 -1
- package/package.json +2 -2
- package/example/src/searchEventOffers.ts +0 -44
- package/example/src/transaction/processPlaceOrderByAnonymousCreditCard.ts +0 -401
|
@@ -3318,7 +3318,6 @@ var TaskName;
|
|
|
3318
3318
|
TaskName["AggregateScreeningEvent"] = "aggregateScreeningEvent";
|
|
3319
3319
|
TaskName["AggregateUseActionsOnEvent"] = "aggregateUseActionsOnEvent";
|
|
3320
3320
|
TaskName["DeleteAssetTransaction"] = "deleteAssetTransaction";
|
|
3321
|
-
TaskName["DeleteAuthorization"] = "deleteAuthorization";
|
|
3322
3321
|
TaskName["DeleteOrder"] = "deleteOrder";
|
|
3323
3322
|
TaskName["DeleteTransaction"] = "deleteTransaction";
|
|
3324
3323
|
TaskName["ImportEventCapacitiesFromCOA"] = "importEventCapacitiesFromCOA";
|
|
@@ -8729,8 +8728,11 @@ var OfferCatalogService = /** @class */ (function (_super) {
|
|
|
8729
8728
|
};
|
|
8730
8729
|
/**
|
|
8731
8730
|
* オファーカタログ検索
|
|
8731
|
+
* レスポンス最適化(2023-02-28~)
|
|
8732
8732
|
*/
|
|
8733
|
-
OfferCatalogService.prototype.search = function (params
|
|
8733
|
+
OfferCatalogService.prototype.search = function (params
|
|
8734
|
+
// ): Promise<ISearchResult<factory.offerCatalog.IOfferCatalog[]>> {
|
|
8735
|
+
) {
|
|
8734
8736
|
return __awaiter(this, void 0, void 0, function () {
|
|
8735
8737
|
var _this = this;
|
|
8736
8738
|
return __generator(this, function (_a) {
|
|
@@ -8755,21 +8757,6 @@ var OfferCatalogService = /** @class */ (function (_super) {
|
|
|
8755
8757
|
});
|
|
8756
8758
|
});
|
|
8757
8759
|
};
|
|
8758
|
-
OfferCatalogService.prototype.findById = function (params) {
|
|
8759
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
8760
|
-
var _this = this;
|
|
8761
|
-
return __generator(this, function (_a) {
|
|
8762
|
-
return [2 /*return*/, this.fetch({
|
|
8763
|
-
uri: "/offerCatalogs/" + encodeURIComponent(String(params.id)),
|
|
8764
|
-
method: 'GET',
|
|
8765
|
-
expectedStatusCodes: [http_status_1.OK]
|
|
8766
|
-
})
|
|
8767
|
-
.then(function (response) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
8768
|
-
return [2 /*return*/, response.json()];
|
|
8769
|
-
}); }); })];
|
|
8770
|
-
});
|
|
8771
|
-
});
|
|
8772
|
-
};
|
|
8773
8760
|
/**
|
|
8774
8761
|
* オファーカタログ更新
|
|
8775
8762
|
*/
|
|
@@ -8829,6 +8816,31 @@ var OfferCatalogService = /** @class */ (function (_super) {
|
|
|
8829
8816
|
});
|
|
8830
8817
|
});
|
|
8831
8818
|
};
|
|
8819
|
+
OfferCatalogService.prototype.searchItemListElement = function (params) {
|
|
8820
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
8821
|
+
var _this = this;
|
|
8822
|
+
return __generator(this, function (_a) {
|
|
8823
|
+
return [2 /*return*/, this.fetch({
|
|
8824
|
+
uri: "/offerCatalogs/" + encodeURIComponent(String(params.id)) + "/itemListElement",
|
|
8825
|
+
method: 'GET',
|
|
8826
|
+
qs: params,
|
|
8827
|
+
expectedStatusCodes: [http_status_1.OK]
|
|
8828
|
+
})
|
|
8829
|
+
.then(function (response) { return __awaiter(_this, void 0, void 0, function () {
|
|
8830
|
+
var _a;
|
|
8831
|
+
return __generator(this, function (_b) {
|
|
8832
|
+
switch (_b.label) {
|
|
8833
|
+
case 0:
|
|
8834
|
+
_a = {};
|
|
8835
|
+
return [4 /*yield*/, response.json()];
|
|
8836
|
+
case 1: return [2 /*return*/, (_a.data = _b.sent(),
|
|
8837
|
+
_a)];
|
|
8838
|
+
}
|
|
8839
|
+
});
|
|
8840
|
+
}); })];
|
|
8841
|
+
});
|
|
8842
|
+
});
|
|
8843
|
+
};
|
|
8832
8844
|
return OfferCatalogService;
|
|
8833
8845
|
}(service_1.Service));
|
|
8834
8846
|
exports.OfferCatalogService = OfferCatalogService;
|
|
@@ -16222,7 +16234,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
16222
16234
|
exports.ProductService = void 0;
|
|
16223
16235
|
var http_status_1 = require("http-status");
|
|
16224
16236
|
var service_1 = require("../service");
|
|
16225
|
-
// export type IProduct = factory.product.IProduct | factory.service.paymentService.IService;
|
|
16226
16237
|
/**
|
|
16227
16238
|
* プロダクトサービス
|
|
16228
16239
|
*/
|
|
@@ -334,13 +334,6 @@ function authorizeSeatReservationByEvent(params: {
|
|
|
334
334
|
const selectedSeatOffers = availableSeatOffers.slice(0, 3);
|
|
335
335
|
console.log(selectedSeatOffers.length, 'seats selected');
|
|
336
336
|
|
|
337
|
-
// アドオン選択
|
|
338
|
-
let acceptedAddOns: { id: string }[] = [];
|
|
339
|
-
if (Array.isArray(selectedTicketOffer.addOn) && selectedTicketOffer.addOn.length > 0) {
|
|
340
|
-
acceptedAddOns = [{ id: String(selectedTicketOffer.addOn[0].id) }];
|
|
341
|
-
}
|
|
342
|
-
console.log('addOn selected.', acceptedAddOns);
|
|
343
|
-
|
|
344
337
|
await wait(5000);
|
|
345
338
|
console.log('authorizing seat reservation...');
|
|
346
339
|
const seatReservationAuth = <IAuthorizeReservationAction>await placeOrderService.authorizeSeatReservation({
|
|
@@ -349,7 +342,7 @@ function authorizeSeatReservationByEvent(params: {
|
|
|
349
342
|
acceptedOffer: selectedSeatOffers.map((o) => {
|
|
350
343
|
return {
|
|
351
344
|
id: String(selectedTicketOffer.id),
|
|
352
|
-
addOn:
|
|
345
|
+
addOn: [],
|
|
353
346
|
itemOffered: {
|
|
354
347
|
serviceOutput: {
|
|
355
348
|
typeOf: client.factory.reservationType.EventReservation,
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// tslint:disable:no-console no-implicit-dependencies no-magic-numbers
|
|
2
|
+
import * as client from '../../../lib/index';
|
|
3
|
+
import { auth } from '../auth/clientCredentials';
|
|
4
|
+
|
|
5
|
+
const project = { id: process.env.PROJECT_ID };
|
|
6
|
+
const EVENT_ID = String(process.env.EVENT_ID);
|
|
7
|
+
const SELLER_ID = String(process.env.SELLER_ID);
|
|
8
|
+
|
|
9
|
+
const eventService = new client.service.Event({
|
|
10
|
+
endpoint: <string>process.env.API_ENDPOINT,
|
|
11
|
+
auth,
|
|
12
|
+
project
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const productService = new client.service.Product({
|
|
16
|
+
endpoint: <string>process.env.API_ENDPOINT,
|
|
17
|
+
auth,
|
|
18
|
+
project
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// tslint:disable-next-line:max-func-body-length
|
|
22
|
+
async function main() {
|
|
23
|
+
// 興行オファー検索
|
|
24
|
+
const eventOffers = await eventService.searchTicketOffers({
|
|
25
|
+
limit: 100,
|
|
26
|
+
page: 1,
|
|
27
|
+
event: { id: EVENT_ID }
|
|
28
|
+
});
|
|
29
|
+
console.log(eventOffers.map((o) => {
|
|
30
|
+
return `${(<client.factory.multilingualString>o.name).ja} ${o.addOn?.length}`;
|
|
31
|
+
})
|
|
32
|
+
.join('\n'));
|
|
33
|
+
|
|
34
|
+
console.log(eventOffers.length, '件の興行オファー');
|
|
35
|
+
|
|
36
|
+
const offerWithAddOn = eventOffers.find((offer) => Array.isArray(offer.addOn) && offer.addOn.length > 0);
|
|
37
|
+
if (offerWithAddOn === undefined) {
|
|
38
|
+
console.log('no offerWithAddOn');
|
|
39
|
+
} else {
|
|
40
|
+
const addOns = <client.factory.product.ITicketAddOn[] | client.factory.product.IMinimizedTicketAddOn[]>offerWithAddOn.addOn;
|
|
41
|
+
const addOnIds: string[] = [...new Set(
|
|
42
|
+
addOns.map((
|
|
43
|
+
a: client.factory.product.ITicketAddOn | client.factory.product.IMinimizedTicketAddOn) => String(a.itemOffered.id)
|
|
44
|
+
)
|
|
45
|
+
)];
|
|
46
|
+
console.log(addOnIds.length, '件のアドオンプロダクト');
|
|
47
|
+
|
|
48
|
+
for (const addOnId of addOnIds) {
|
|
49
|
+
// アドオンオファー検索
|
|
50
|
+
const addOnOffers = await productService.searchOffers({
|
|
51
|
+
limit: 100,
|
|
52
|
+
page: 1,
|
|
53
|
+
itemOffered: { id: addOnId },
|
|
54
|
+
seller: { id: SELLER_ID }
|
|
55
|
+
});
|
|
56
|
+
console.log(addOnOffers.map((offer) => `${offer.name.ja}`));
|
|
57
|
+
console.log('アドオン', addOnId, 'に', addOnOffers.length, '件のオファー');
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
main()
|
|
63
|
+
.then(() => {
|
|
64
|
+
console.log('success!');
|
|
65
|
+
})
|
|
66
|
+
.catch(console.error);
|
package/lib/bundle.js
CHANGED
|
@@ -16234,7 +16234,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
16234
16234
|
exports.ProductService = void 0;
|
|
16235
16235
|
var http_status_1 = require("http-status");
|
|
16236
16236
|
var service_1 = require("../service");
|
|
16237
|
-
// export type IProduct = factory.product.IProduct | factory.service.paymentService.IService;
|
|
16238
16237
|
/**
|
|
16239
16238
|
* プロダクトサービス
|
|
16240
16239
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cinerino/sdk",
|
|
3
|
-
"version": "3.144.0
|
|
3
|
+
"version": "3.144.0",
|
|
4
4
|
"description": "Cinerino SDK",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"browser": {
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"watchify": "^3.11.1"
|
|
98
98
|
},
|
|
99
99
|
"dependencies": {
|
|
100
|
-
"@cinerino/api-abstract-client": "3.144.0
|
|
100
|
+
"@cinerino/api-abstract-client": "3.144.0",
|
|
101
101
|
"debug": "^3.2.6",
|
|
102
102
|
"http-status": "^1.4.2",
|
|
103
103
|
"idtoken-verifier": "^2.0.3",
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-implicit-dependencies no-console
|
|
2
|
-
import * as client from '../../lib/index';
|
|
3
|
-
// import * as auth from './auth';
|
|
4
|
-
|
|
5
|
-
async function main() {
|
|
6
|
-
const authClient = new client.auth.ClientCredentials({
|
|
7
|
-
domain: <string>process.env.TEST_AUTHORIZE_SERVER_DOMAIN,
|
|
8
|
-
clientId: <string>process.env.TEST_CLIENT_ID,
|
|
9
|
-
clientSecret: <string>process.env.TEST_CLIENT_SECRET,
|
|
10
|
-
scopes: [],
|
|
11
|
-
state: ''
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
const eventService = new client.service.Event({
|
|
15
|
-
endpoint: <string>process.env.API_ENDPOINT,
|
|
16
|
-
auth: authClient,
|
|
17
|
-
project: { id: '' }
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
// const offers = await eventService.searchOffers({
|
|
21
|
-
// event: {
|
|
22
|
-
// id: '12116221020200121901710'
|
|
23
|
-
// }
|
|
24
|
-
// });
|
|
25
|
-
// console.log(offers);
|
|
26
|
-
// console.log(offers[0].containsPlace);
|
|
27
|
-
// console.log(offers.length, 'offers returned');
|
|
28
|
-
|
|
29
|
-
const offers = await eventService.searchTicketOffers4COA({
|
|
30
|
-
event: {
|
|
31
|
-
id: '12116221020200121901710'
|
|
32
|
-
},
|
|
33
|
-
seller: { id: '59d20831e53ebc2b4e774467', typeOf: client.factory.organizationType.Corporation }
|
|
34
|
-
});
|
|
35
|
-
console.log(offers);
|
|
36
|
-
console.log(offers.length, 'offers returned');
|
|
37
|
-
// fs.writeFileSync(`${__dirname}/offers.json`, JSON.stringify(offers, null, ' '));
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
main()
|
|
41
|
-
.then(() => {
|
|
42
|
-
console.log('success!');
|
|
43
|
-
})
|
|
44
|
-
.catch(console.error);
|
|
@@ -1,401 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console no-implicit-dependencies no-magic-numbers
|
|
2
|
-
import * as moment from 'moment';
|
|
3
|
-
import * as client from '../../../lib/index';
|
|
4
|
-
import { auth } from '../auth/clientCredentials';
|
|
5
|
-
// import * as auth from '../authAsAdmin';
|
|
6
|
-
|
|
7
|
-
const project = { id: 'cinerino' };
|
|
8
|
-
|
|
9
|
-
const profile = {
|
|
10
|
-
email: <string>process.env.TEST_PROFILE_EMAIL,
|
|
11
|
-
givenName: 'Taro',
|
|
12
|
-
familyName: 'SDK',
|
|
13
|
-
name: 'Taro ☆ SDK',
|
|
14
|
-
telephone: '+819012345678'
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const eventService = new client.service.Event({
|
|
18
|
-
endpoint: <string>process.env.API_ENDPOINT,
|
|
19
|
-
auth,
|
|
20
|
-
project
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
const sellerService = new client.service.Seller({
|
|
24
|
-
endpoint: <string>process.env.API_ENDPOINT,
|
|
25
|
-
auth,
|
|
26
|
-
project
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
const placeOrderService = new client.service.txn.PlaceOrder({
|
|
30
|
-
endpoint: <string>process.env.API_ENDPOINT,
|
|
31
|
-
auth,
|
|
32
|
-
project
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
const paymentService = new client.service.Payment({
|
|
36
|
-
endpoint: <string>process.env.API_ENDPOINT,
|
|
37
|
-
auth,
|
|
38
|
-
project
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
// tslint:disable-next-line:max-func-body-length
|
|
42
|
-
async function main() {
|
|
43
|
-
// 取引に使用するクレジットカードを決定する
|
|
44
|
-
const creditCard = {
|
|
45
|
-
cardNo: '4111111111111111',
|
|
46
|
-
expire: '2412',
|
|
47
|
-
holderName: 'AA BB'
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
// 販売劇場検索
|
|
51
|
-
const searchSellersResult = await sellerService.search({});
|
|
52
|
-
// tslint:disable-next-line:insecure-random
|
|
53
|
-
const seller = searchSellersResult.data[Math.floor(searchSellersResult.data.length * Math.random())];
|
|
54
|
-
if (seller === undefined) {
|
|
55
|
-
throw new Error('No seller');
|
|
56
|
-
}
|
|
57
|
-
console.log('ordering from seller...', (<client.factory.multilingualString>seller.name).ja);
|
|
58
|
-
|
|
59
|
-
// イベント検索
|
|
60
|
-
const searchScreeningEventsResult = await eventService.search<client.factory.eventType.ScreeningEvent>({
|
|
61
|
-
typeOf: client.factory.eventType.ScreeningEvent,
|
|
62
|
-
// superEventLocationIdentifiers: [seller.identifier],
|
|
63
|
-
inSessionFrom: moment()
|
|
64
|
-
.toDate(),
|
|
65
|
-
inSessionThrough: moment()
|
|
66
|
-
.add(1, 'week')
|
|
67
|
-
.toDate()
|
|
68
|
-
// superEvent: { locationBranchCodes: [seller.location.branchCode] }
|
|
69
|
-
});
|
|
70
|
-
console.log(searchScreeningEventsResult.totalCount, 'events found');
|
|
71
|
-
|
|
72
|
-
const availableEvents = searchScreeningEventsResult.data;
|
|
73
|
-
// const availableEvents = screeningEvents.filter(
|
|
74
|
-
// (event) => (event.offer.availability !== 0)
|
|
75
|
-
// );
|
|
76
|
-
if (availableEvents.length === 0) {
|
|
77
|
-
throw new Error('No available events');
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// WAITER許可証
|
|
81
|
-
// const passportToken = await request.post(
|
|
82
|
-
// `${process.env.WAITER_ENDPOINT}/passports`,
|
|
83
|
-
// {
|
|
84
|
-
// body: {
|
|
85
|
-
// scope: `Transaction:PlaceOrder:${seller.id}`
|
|
86
|
-
// },
|
|
87
|
-
// json: true
|
|
88
|
-
// }
|
|
89
|
-
// ).then((body) => body.token).catch((err) => {
|
|
90
|
-
// throw new Error(err.message);
|
|
91
|
-
// });
|
|
92
|
-
// console.log('passportToken published', passportToken);
|
|
93
|
-
|
|
94
|
-
// tslint:disable-next-line:prefer-array-literal
|
|
95
|
-
const identifier = [...Array(10)].map((_, i) => {
|
|
96
|
-
return {
|
|
97
|
-
name: `SampleName-${i}`,
|
|
98
|
-
value: `SampleValue-${i}`
|
|
99
|
-
};
|
|
100
|
-
});
|
|
101
|
-
console.log('starting transaction...', identifier);
|
|
102
|
-
const transaction = await placeOrderService.start({
|
|
103
|
-
expires: moment()
|
|
104
|
-
.add(10, 'minutes')
|
|
105
|
-
.toDate(),
|
|
106
|
-
agent: {
|
|
107
|
-
identifier: identifier
|
|
108
|
-
},
|
|
109
|
-
seller: {
|
|
110
|
-
typeOf: seller.typeOf,
|
|
111
|
-
id: String(seller.id)
|
|
112
|
-
},
|
|
113
|
-
object: {
|
|
114
|
-
// passport: { token: passportToken }
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
console.log('transaction started', transaction.id);
|
|
118
|
-
|
|
119
|
-
// 購入者情報入力時間
|
|
120
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
121
|
-
await wait(5000);
|
|
122
|
-
|
|
123
|
-
console.log('setting customer profile...');
|
|
124
|
-
await placeOrderService.setProfile({
|
|
125
|
-
id: transaction.id,
|
|
126
|
-
agent: profile
|
|
127
|
-
});
|
|
128
|
-
console.log('customer profile set');
|
|
129
|
-
|
|
130
|
-
const numEvents = 1;
|
|
131
|
-
let amount = 0;
|
|
132
|
-
// tslint:disable-next-line:max-line-length
|
|
133
|
-
const authorizeSeatReservationResults: client.factory.action.authorize.offer.seatReservation.IResult<client.factory.service.webAPI.Identifier.Chevre>[] = [];
|
|
134
|
-
|
|
135
|
-
// tslint:disable-next-line:no-increment-decrement
|
|
136
|
-
for (let i = 0; i < numEvents; i++) {
|
|
137
|
-
// イベント決定
|
|
138
|
-
// tslint:disable-next-line:insecure-random
|
|
139
|
-
const screeningEvent = availableEvents[Math.floor(availableEvents.length * Math.random())];
|
|
140
|
-
const authorizeSeatReservationResult = await authorizeSeatReservationByEvent({
|
|
141
|
-
event: screeningEvent,
|
|
142
|
-
seller: seller,
|
|
143
|
-
transaction: transaction
|
|
144
|
-
});
|
|
145
|
-
amount += authorizeSeatReservationResult.price;
|
|
146
|
-
authorizeSeatReservationResults.push(authorizeSeatReservationResult);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// クレジットカードオーソリアクション
|
|
150
|
-
console.log('authorizing credit card payment...');
|
|
151
|
-
let creditCardPaymentAuth = await paymentService.authorizeCreditCard({
|
|
152
|
-
object: {
|
|
153
|
-
typeOf: client.factory.action.authorize.paymentMethod.any.ResultType.Payment,
|
|
154
|
-
amount: amount,
|
|
155
|
-
paymentMethod: 'CreditCard',
|
|
156
|
-
method: '1',
|
|
157
|
-
creditCard: creditCard,
|
|
158
|
-
issuedThrough: { id: 'xxx' }
|
|
159
|
-
},
|
|
160
|
-
purpose: transaction
|
|
161
|
-
});
|
|
162
|
-
console.log('credit card payment authorized', creditCardPaymentAuth.id);
|
|
163
|
-
|
|
164
|
-
await wait(5000);
|
|
165
|
-
|
|
166
|
-
console.log('voiding credit card auth...');
|
|
167
|
-
await paymentService.voidTransaction({
|
|
168
|
-
id: creditCardPaymentAuth.id,
|
|
169
|
-
object: { typeOf: client.factory.service.paymentService.PaymentServiceType.CreditCard },
|
|
170
|
-
purpose: { typeOf: transaction.typeOf, id: transaction.id }
|
|
171
|
-
});
|
|
172
|
-
console.log('credit card auth voided');
|
|
173
|
-
|
|
174
|
-
console.log('authorizing credit card payment...');
|
|
175
|
-
creditCardPaymentAuth = await paymentService.authorizeCreditCard({
|
|
176
|
-
object: {
|
|
177
|
-
typeOf: client.factory.action.authorize.paymentMethod.any.ResultType.Payment,
|
|
178
|
-
amount: amount,
|
|
179
|
-
paymentMethod: 'CreditCard',
|
|
180
|
-
method: '1',
|
|
181
|
-
creditCard: creditCard,
|
|
182
|
-
issuedThrough: { id: 'xxx' }
|
|
183
|
-
},
|
|
184
|
-
purpose: transaction
|
|
185
|
-
});
|
|
186
|
-
console.log('credit card payment authorized', creditCardPaymentAuth.id);
|
|
187
|
-
|
|
188
|
-
// 購入情報確認時間
|
|
189
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
190
|
-
await wait(5000);
|
|
191
|
-
|
|
192
|
-
// 取引を中止する場合はコチラ↓
|
|
193
|
-
// console.log('取引を中止します...');
|
|
194
|
-
// await placeOrderService.cancel({ transactionId: transaction.id });
|
|
195
|
-
// console.log('取引を中止しました。');
|
|
196
|
-
|
|
197
|
-
console.log('confirming transaction...');
|
|
198
|
-
const email = {
|
|
199
|
-
sender: {
|
|
200
|
-
name: `♥ ${(<client.factory.multilingualString>seller.name).ja} ♥`
|
|
201
|
-
// email?: string;
|
|
202
|
-
},
|
|
203
|
-
// toRecipient: {
|
|
204
|
-
// name: 'Another recipient',
|
|
205
|
-
// email: ''
|
|
206
|
-
// },
|
|
207
|
-
about: `♥♥♥ ${profile.name}さんへご注文商品が届いております ♥♥♥`,
|
|
208
|
-
template: `
|
|
209
|
-
| Order from samples
|
|
210
|
-
|
|
|
211
|
-
| [注文番号]
|
|
212
|
-
| #{order.orderNumber}
|
|
213
|
-
|
|
|
214
|
-
| [合計]
|
|
215
|
-
| ¥#{order.price}
|
|
216
|
-
`
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
let confirmResult = await placeOrderService.confirm({
|
|
220
|
-
id: transaction.id,
|
|
221
|
-
potentialActions: {
|
|
222
|
-
order: {
|
|
223
|
-
potentialActions: {
|
|
224
|
-
sendOrder: {
|
|
225
|
-
potentialActions: {
|
|
226
|
-
sendEmailMessage: [
|
|
227
|
-
{
|
|
228
|
-
object: email
|
|
229
|
-
}
|
|
230
|
-
]
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
},
|
|
236
|
-
result: {
|
|
237
|
-
order: {
|
|
238
|
-
identifier: [
|
|
239
|
-
{ name: 'sampleOrderIdentifierName1', value: 'sampleOrderIdentifiervalue1' },
|
|
240
|
-
{ name: 'sampleOrderIdentifierName2', value: 'sampleOrderIdentifiervalue2' }
|
|
241
|
-
],
|
|
242
|
-
url: 'https://example.com'
|
|
243
|
-
}
|
|
244
|
-
},
|
|
245
|
-
sendEmailMessage: true,
|
|
246
|
-
email: email
|
|
247
|
-
});
|
|
248
|
-
console.log('transaction confirmed', confirmResult.order.orderNumber);
|
|
249
|
-
|
|
250
|
-
// 何度確定をコールしても冪等
|
|
251
|
-
console.log('confirming transaction...');
|
|
252
|
-
confirmResult = await placeOrderService.confirm({
|
|
253
|
-
id: transaction.id,
|
|
254
|
-
sendEmailMessage: true
|
|
255
|
-
});
|
|
256
|
-
console.log('transaction confirmed', confirmResult.order.orderNumber);
|
|
257
|
-
// 何度確定をコールしても冪等
|
|
258
|
-
console.log('confirming transaction...');
|
|
259
|
-
confirmResult = await placeOrderService.confirm({
|
|
260
|
-
id: transaction.id,
|
|
261
|
-
sendEmailMessage: true
|
|
262
|
-
});
|
|
263
|
-
console.log('transaction confirmed', confirmResult.order.orderNumber);
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
export type IAuthorizeReservationAction
|
|
267
|
-
= client.factory.action.authorize.offer.seatReservation.IAction<client.factory.service.webAPI.Identifier.Chevre>;
|
|
268
|
-
|
|
269
|
-
// tslint:disable-next-line:max-func-body-length
|
|
270
|
-
async function authorizeSeatReservationByEvent(params: {
|
|
271
|
-
event: client.factory.event.screeningEvent.IEvent;
|
|
272
|
-
seller: client.factory.seller.ISeller;
|
|
273
|
-
transaction: client.factory.transaction.placeOrder.ITransaction;
|
|
274
|
-
}): Promise<client.factory.action.authorize.offer.seatReservation.IResult<client.factory.service.webAPI.Identifier.Chevre>> {
|
|
275
|
-
const screeningEvent = params.event;
|
|
276
|
-
const transaction = params.transaction;
|
|
277
|
-
|
|
278
|
-
// 券種検索
|
|
279
|
-
let ticketOffers = await eventService.searchTicketOffers({
|
|
280
|
-
event: { id: screeningEvent.id }
|
|
281
|
-
});
|
|
282
|
-
console.log('チケットオファーは以下の通りです');
|
|
283
|
-
console.log(ticketOffers.map((o) => {
|
|
284
|
-
const unitPriceSpecification = o.priceSpecification.priceComponent
|
|
285
|
-
.filter((s) => s.typeOf === client.factory.priceSpecificationType.UnitPriceSpecification)
|
|
286
|
-
.map((s) => `単価:${s.price}/${(<client.factory.priceSpecification.IPriceSpecification<client.factory.priceSpecificationType.UnitPriceSpecification>>s).referenceQuantity.value}`)
|
|
287
|
-
.join(' ');
|
|
288
|
-
const categoryCodeCharge = o.priceSpecification.priceComponent
|
|
289
|
-
.filter((s) => s.typeOf === client.factory.priceSpecificationType.CategoryCodeChargeSpecification)
|
|
290
|
-
.map((s) => `+${(<client.factory.priceSpecification.IPriceSpecification<client.factory.priceSpecificationType.CategoryCodeChargeSpecification>>s).appliesToCategoryCode[0].codeValue}チャージ:${s.price} ${s.priceCurrency}`)
|
|
291
|
-
.join(' ');
|
|
292
|
-
|
|
293
|
-
return `${o.id} ${(<client.factory.multilingualString>o.name).ja} ${unitPriceSpecification} ${o.priceCurrency} ${categoryCodeCharge}`;
|
|
294
|
-
})
|
|
295
|
-
.join('\n'));
|
|
296
|
-
|
|
297
|
-
// 空席検索
|
|
298
|
-
const searchSeatsResult = await eventService.searchSeats({ event: screeningEvent });
|
|
299
|
-
console.log(searchSeatsResult.data.length, 'seats found');
|
|
300
|
-
const seatOffers = searchSeatsResult.data;
|
|
301
|
-
console.log(seatOffers.length, 'seatOffers found');
|
|
302
|
-
const availableSeatOffers = seatOffers.filter(
|
|
303
|
-
(o) => o.offers?.shift()?.availability === client.factory.itemAvailability.InStock
|
|
304
|
-
);
|
|
305
|
-
console.log(availableSeatOffers.length, 'availableSeatOffers found');
|
|
306
|
-
if (availableSeatOffers.length <= 0) {
|
|
307
|
-
throw new Error('No available seats');
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
// ムビチケ以外のオファーを選択
|
|
311
|
-
ticketOffers = ticketOffers.filter((offer) => {
|
|
312
|
-
const movieTicketTypeChargeSpecification = offer.priceSpecification.priceComponent.find(
|
|
313
|
-
(component) => component.typeOf === client.factory.priceSpecificationType.MovieTicketTypeChargeSpecification
|
|
314
|
-
);
|
|
315
|
-
|
|
316
|
-
return movieTicketTypeChargeSpecification === undefined;
|
|
317
|
-
});
|
|
318
|
-
|
|
319
|
-
const selectedTicketOffer = ticketOffers.shift();
|
|
320
|
-
// const selectedTicketOffer = ticketOffers.find((o) => o.identifier === '1001');
|
|
321
|
-
if (selectedTicketOffer === undefined) {
|
|
322
|
-
throw new Error('selectedTicketOffer undefined');
|
|
323
|
-
}
|
|
324
|
-
console.log('ticket offer selected', selectedTicketOffer);
|
|
325
|
-
|
|
326
|
-
// 座席をランダムに選択
|
|
327
|
-
const selectedScreeningRoomSection = String(seatOffers[0].containedInPlace?.branchCode);
|
|
328
|
-
console.log('screening room section selected', selectedScreeningRoomSection);
|
|
329
|
-
console.log(selectedScreeningRoomSection);
|
|
330
|
-
// const selectedSeatOffer = availableSeatOffers[Math.floor(availableSeatOffers.length * Math.random())];
|
|
331
|
-
const selectedSeatOffers = availableSeatOffers.slice(0, 3);
|
|
332
|
-
console.log(selectedSeatOffers.length, 'seats selected');
|
|
333
|
-
|
|
334
|
-
// アドオン選択
|
|
335
|
-
let acceptedAddOns: { id: string }[] = [];
|
|
336
|
-
if (Array.isArray(selectedTicketOffer.addOn) && selectedTicketOffer.addOn.length > 0) {
|
|
337
|
-
acceptedAddOns = [{ id: String(selectedTicketOffer.addOn[0].id) }];
|
|
338
|
-
}
|
|
339
|
-
console.log('addOn selected.', acceptedAddOns);
|
|
340
|
-
|
|
341
|
-
await wait(5000);
|
|
342
|
-
console.log('authorizing seat reservation...');
|
|
343
|
-
const seatReservationAuth = <IAuthorizeReservationAction>await placeOrderService.authorizeSeatReservation({
|
|
344
|
-
object: {
|
|
345
|
-
reservationFor: { id: screeningEvent.id },
|
|
346
|
-
acceptedOffer: selectedSeatOffers.map((o) => {
|
|
347
|
-
return {
|
|
348
|
-
id: String(selectedTicketOffer.id),
|
|
349
|
-
addOn: acceptedAddOns,
|
|
350
|
-
itemOffered: {
|
|
351
|
-
serviceOutput: {
|
|
352
|
-
typeOf: client.factory.reservationType.EventReservation,
|
|
353
|
-
additionalTicketText: 'test from samples',
|
|
354
|
-
reservedTicket: {
|
|
355
|
-
typeOf: 'Ticket',
|
|
356
|
-
ticketedSeat: {
|
|
357
|
-
typeOf: client.factory.placeType.Seat,
|
|
358
|
-
seatNumber: o.branchCode,
|
|
359
|
-
seatSection: selectedScreeningRoomSection,
|
|
360
|
-
seatRow: ''
|
|
361
|
-
}
|
|
362
|
-
},
|
|
363
|
-
additionalProperty: [{ name: 'sampleName', value: 'sampleValue' }]
|
|
364
|
-
},
|
|
365
|
-
pointAward: {
|
|
366
|
-
typeOf: client.factory.actionType.MoneyTransfer,
|
|
367
|
-
toLocation: { identifier: '139151625010963', issuedThrough: { id: 'xxx' } }
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
};
|
|
371
|
-
})
|
|
372
|
-
},
|
|
373
|
-
purpose: transaction
|
|
374
|
-
});
|
|
375
|
-
console.log('seat reservation authorized', seatReservationAuth.id);
|
|
376
|
-
|
|
377
|
-
// await wait(5000);
|
|
378
|
-
// console.log('voiding seat reservation auth...');
|
|
379
|
-
// await placeOrderService.voidSeatReservation({ transactionId: transaction.id, actionId: seatReservationAuth.id });
|
|
380
|
-
// console.log('seat reservation auth voided');
|
|
381
|
-
|
|
382
|
-
// 金額計算
|
|
383
|
-
if (seatReservationAuth.result === undefined) {
|
|
384
|
-
throw new Error('座席予約承認結果は必ず存在します');
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
const amount = seatReservationAuth.result.price;
|
|
388
|
-
console.log('金額は', amount);
|
|
389
|
-
|
|
390
|
-
return seatReservationAuth.result;
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
async function wait(waitInMilliseconds: number) {
|
|
394
|
-
return new Promise((resolve) => setTimeout(resolve, waitInMilliseconds));
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
main()
|
|
398
|
-
.then(() => {
|
|
399
|
-
console.log('success!');
|
|
400
|
-
})
|
|
401
|
-
.catch(console.error);
|