@cinerino/sdk 12.13.0-alpha.0 → 12.13.0-alpha.1

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.
@@ -5,10 +5,12 @@ import * as client from '../../../../lib/index';
5
5
  import * as auth from '../../auth/authAsAdmin';
6
6
 
7
7
  const PROJECT_ID = String(process.env.PROJECT_ID);
8
- const SELLER_ID = '64b47a8e43423b261dbcabc5';
9
- const OFFER_IDENTIFIER = '20251204eventOffer01';
10
- const itemOfferedId = 'fmiqm5f2j';
11
- const PAYMENT_METHOD_ID = '5f9a52994f3709000abe6417';
8
+ const SELLER_ID = '59d20831e53ebc2b4e774466';
9
+ // const OFFER_IDENTIFIER = '20251204eventOffer01';
10
+ // /**
11
+ // * 決済サービスID
12
+ // */
13
+ // const PAYMENT_METHOD_ID = '5f9a52994f3709000abe6417';
12
14
 
13
15
  // tslint:disable-next-line:max-func-body-length
14
16
  async function main() {
@@ -17,6 +19,13 @@ async function main() {
17
19
  const loginTicket = authClient.verifyIdToken({});
18
20
  console.log('username is', loginTicket.getUsername());
19
21
 
22
+ const adminEventSeriesService = await (await client.loadChevreAdmin({
23
+ endpoint: <string>process.env.CHEVRE_ENDPOINT,
24
+ auth: authClient
25
+ })).createEventSeriesInstance({
26
+ project: { id: PROJECT_ID },
27
+ seller: { id: SELLER_ID }
28
+ });
20
29
  const acceptedPaymentMethodService = await (await client.loadChevreAdmin({
21
30
  endpoint: <string>process.env.CHEVRE_ENDPOINT,
22
31
  auth: authClient
@@ -24,7 +33,64 @@ async function main() {
24
33
  project: { id: PROJECT_ID },
25
34
  seller: { id: SELLER_ID }
26
35
  });
36
+ const adminPaymentProductService = await (await client.loadChevreAdmin({
37
+ endpoint: <string>process.env.CHEVRE_ENDPOINT,
38
+ auth: authClient
39
+ })).createPaymentProductInstance({
40
+ project: { id: PROJECT_ID },
41
+ seller: { id: SELLER_ID }
42
+ });
43
+
44
+ // 施設コンテンツの対応決済方法管理を有効にする
45
+ await adminEventSeriesService.upsertByVersion([
46
+ {
47
+ eventStatus: client.factory.eventStatusType.EventScheduled,
48
+ videoFormat: [],
49
+ kanaName: '',
50
+ startDate: moment('2023-12-09T12:00:00Z')
51
+ .toDate(),
52
+ endDate: moment('2034-12-09T15:00:00Z')
53
+ .toDate(),
54
+ typeOf: client.factory.eventType.ScreeningEventSeries,
55
+ duration: 'PT2H',
56
+ name: { ja: '対応決済方法管理のペット', en: 'Pet(adminAcceptedPaymentMethod)' },
57
+ location: {
58
+ id: '5bfb841d5a78d7948369979a'
59
+ },
60
+ workPerformed: {
61
+ identifier: '1622100',
62
+ version: '99'
63
+ },
64
+ offers: {
65
+ typeOf: client.factory.offerType.AggregateOffer // 対応決済方法管理を有効にする
66
+ }
67
+ }
68
+ ]);
69
+
70
+ const eventSeries = (await adminEventSeriesService.findEventSeries({
71
+ limit: 1,
72
+ page: 1,
73
+ locationId: '5bfb841d5a78d7948369979a',
74
+ workPerformedIdentifier: '1622100',
75
+ workPerformedVersion: '99'
76
+ }))
77
+ .shift();
78
+ console.log(eventSeries);
79
+ if (eventSeries === undefined) {
80
+ throw new Error('eventSeries not found');
81
+ }
82
+ // return;
83
+ const itemOfferedId = eventSeries.id;
84
+
85
+ // 対応させたい決済サービス検索
86
+ const paymentServices = await adminPaymentProductService.findPaymentServices({
87
+ limit: 20,
88
+ page: 1
89
+ });
90
+ console.log(paymentServices);
91
+ console.log(paymentServices.length, 'paymentServices found');
27
92
 
93
+ // 対応させたい決済サービス全てについて対応決済方法を作成
28
94
  const now = new Date();
29
95
  const validFrom = moment(now)
30
96
  .toDate();
@@ -32,14 +98,13 @@ async function main() {
32
98
  .add(1, 'minutes')
33
99
  .toDate();
34
100
  await acceptedPaymentMethodService.createAcceptedPaymentMethodsByIdentifier(
35
- [
36
- {
37
- identifier: OFFER_IDENTIFIER,
38
- validFrom,
39
- validThrough,
40
- acceptedPaymentMethod: { id: PAYMENT_METHOD_ID }
41
- }
42
- ],
101
+ paymentServices.map((paymentService) => ({
102
+ identifier: `Accept${paymentService.serviceType.codeValue}`,
103
+ validFrom,
104
+ validThrough,
105
+ acceptedPaymentMethod: { id: paymentService.id }
106
+
107
+ })),
43
108
  {
44
109
  itemOfferedId,
45
110
  itemOfferedTypeOf: client.factory.eventType.ScreeningEventSeries
@@ -48,14 +113,13 @@ async function main() {
48
113
  console.log('created.');
49
114
 
50
115
  await acceptedPaymentMethodService.updateAcceptedPaymentMethodsByIdentifier(
51
- [
52
- {
53
- identifier: OFFER_IDENTIFIER,
54
- validFrom,
55
- validThrough,
56
- acceptedPaymentMethod: { id: PAYMENT_METHOD_ID }
57
- }
58
- ],
116
+ paymentServices.map((paymentService) => ({
117
+ identifier: `Accept${paymentService.serviceType.codeValue}`,
118
+ validFrom,
119
+ validThrough,
120
+ acceptedPaymentMethod: { id: paymentService.id }
121
+
122
+ })),
59
123
  {
60
124
  itemOfferedId,
61
125
  itemOfferedTypeOf: client.factory.eventType.ScreeningEventSeries
@@ -64,7 +128,7 @@ async function main() {
64
128
  console.log('updated.');
65
129
 
66
130
  const offers = await acceptedPaymentMethodService.findAcceptedPaymentMethods({
67
- limit: 10,
131
+ limit: 20,
68
132
  page: 1,
69
133
  // itemOfferedId: '691511df7d9f0e2df3d6dcf7'
70
134
  itemOfferedId: itemOfferedId
@@ -1,8 +1,8 @@
1
1
  // tslint:disable:no-console
2
2
  // tslint:disable-next-line:no-implicit-dependencies
3
3
  import * as moment from 'moment';
4
- import { factory, loadChevreAdmin } from '../../../lib/index';
5
- import * as auth from '../auth/authAsAdmin';
4
+ import { factory, loadChevreAdmin } from '../../../../lib/index';
5
+ import * as auth from '../../auth/authAsAdmin';
6
6
 
7
7
  const project = { id: String(process.env.PROJECT_ID) };
8
8
 
@@ -12,7 +12,7 @@ async function main() {
12
12
  const loginTicket = authClient.verifyIdToken({});
13
13
  console.log('username is', loginTicket.getUsername());
14
14
 
15
- const eventSeriesService = await (await loadChevreAdmin({
15
+ const adminEventSeriesService = await (await loadChevreAdmin({
16
16
  endpoint: <string>process.env.CHEVRE_ENDPOINT,
17
17
  auth: authClient
18
18
  })).createEventSeriesInstance({
@@ -20,7 +20,7 @@ async function main() {
20
20
  seller: { id: '' }
21
21
  });
22
22
 
23
- await eventSeriesService.upsertByVersion([
23
+ await adminEventSeriesService.upsertByVersion([
24
24
  {
25
25
  eventStatus: factory.eventStatusType.EventScheduled,
26
26
  videoFormat: [
@@ -19,6 +19,12 @@ export function authorizeCreditCardAsyncForcibly(params: {
19
19
  typeOf: client.factory.transactionType.PlaceOrder;
20
20
  id: string;
21
21
  };
22
+ instrumentOptions: {
23
+ /**
24
+ * 対応決済方法オファーIDリスト
25
+ */
26
+ acceptedPaymentMethodOfferIds: string[];
27
+ };
22
28
  }) {
23
29
  return async (repos: {
24
30
  paymentService: client.cloudPay.service.Payment;
@@ -173,9 +173,17 @@ async function main() {
173
173
  issuedThrough: { id: paymentServiceId },
174
174
  ticketToken,
175
175
  eventIdsAsOrderedItem: eventIds
176
+ // eventIdsAsOrderedItem: []
177
+ // eventIdsAsOrderedItem: ['xx', 'xx']
178
+ // eventIdsAsOrderedItem: ['xx', 'xxx']
176
179
  // eventIdsAsOrderedItem: ['xxx', ...eventIds] // 存在しないイベントを指定すれば決済採用失敗
177
180
  },
178
- purpose: { id: transaction.id, typeOf: client.factory.transactionType.PlaceOrder }
181
+ purpose: { id: transaction.id, typeOf: client.factory.transactionType.PlaceOrder },
182
+ instrumentOptions: {
183
+ acceptedPaymentMethodOfferIds: [
184
+ '693e43e6929e69df1e88b189'
185
+ ] // TODO
186
+ }
179
187
  })({ paymentService });
180
188
  console.log('paymentUrl published.', paymentMethodId, paymentUrl);
181
189
 
@@ -192,7 +200,8 @@ async function main() {
192
200
  issuedThrough: { id: paymentServiceId },
193
201
  eventIdsAsOrderedItem: eventIds
194
202
  },
195
- purpose: { id: transaction.id, typeOf: client.factory.transactionType.PlaceOrder }
203
+ purpose: { id: transaction.id, typeOf: client.factory.transactionType.PlaceOrder },
204
+ instrumentOptions: { acceptedPaymentMethodOfferIds: [] }
196
205
  })({ paymentService });
197
206
  console.log('paymentUrl published.', publishPaymentUrlAsyncForciblySecondResult);
198
207
  } catch (error) {
@@ -233,7 +242,12 @@ async function main() {
233
242
  // eventIdsAsOrderedItem: ['xx', 'xx']
234
243
  // eventIdsAsOrderedItem: ['xx', 'xxx']
235
244
  },
236
- purpose: { id: transaction.id, typeOf: client.factory.transactionType.PlaceOrder }
245
+ purpose: { id: transaction.id, typeOf: client.factory.transactionType.PlaceOrder },
246
+ instrumentOptions: {
247
+ acceptedPaymentMethodOfferIds: [
248
+ '693e43e6929e69df1e88b189'
249
+ ] // TODO
250
+ }
237
251
  })({ paymentService });
238
252
  console.log('credit card payment authorized', creditCardPaymentAuth.id);
239
253
 
@@ -508,6 +522,12 @@ function publishPaymentUrlAsyncForcibly(params: {
508
522
  typeOf: client.factory.transactionType.PlaceOrder;
509
523
  id: string;
510
524
  };
525
+ instrumentOptions: {
526
+ /**
527
+ * 対応決済方法オファーIDリスト
528
+ */
529
+ acceptedPaymentMethodOfferIds: string[];
530
+ };
511
531
  }) {
512
532
  return async (repos: {
513
533
  paymentService: client.cloudPay.service.Payment;
@@ -127,7 +127,8 @@ async function main() {
127
127
  issuedThrough: { id: PAYMENT_SERVICE_ID },
128
128
  eventIdsAsOrderedItem: [screeningEvent.id]
129
129
  },
130
- purpose: { id: transaction.id, typeOf: client.factory.transactionType.PlaceOrder }
130
+ purpose: { id: transaction.id, typeOf: client.factory.transactionType.PlaceOrder },
131
+ instrumentOptions: { acceptedPaymentMethodOfferIds: [] }
131
132
  })({ paymentService });
132
133
  console.log('credit card payment authorized', creditCardPaymentAuth.id);
133
134
  // throw new Error('force error');
@@ -153,7 +154,8 @@ async function main() {
153
154
  issuedThrough: { id: PAYMENT_SERVICE_ID },
154
155
  eventIdsAsOrderedItem: [screeningEvent.id]
155
156
  },
156
- purpose: { id: transaction.id, typeOf: client.factory.transactionType.PlaceOrder }
157
+ purpose: { id: transaction.id, typeOf: client.factory.transactionType.PlaceOrder },
158
+ instrumentOptions: { acceptedPaymentMethodOfferIds: [] }
157
159
  })({ paymentService });
158
160
  console.log('credit card payment authorized', creditCardPaymentAuth.id);
159
161
 
@@ -187,7 +187,8 @@ async function main() {
187
187
  issuedThrough: { id: paymentServiceId },
188
188
  eventIdsAsOrderedItem: authorizeSeatReservationResults.map(({ eventId }) => eventId)
189
189
  },
190
- purpose: { id: transaction.id, typeOf: client.factory.transactionType.PlaceOrder }
190
+ purpose: { id: transaction.id, typeOf: client.factory.transactionType.PlaceOrder },
191
+ instrumentOptions: { acceptedPaymentMethodOfferIds: [] }
191
192
  })({ paymentService });
192
193
  console.log('credit card payment authorized', creditCardPaymentAuth.id);
193
194
 
@@ -209,7 +209,8 @@ async function main() {
209
209
  ticketToken, // メンバーシップチケットを指定
210
210
  eventIdsAsOrderedItem: [EVENT_ID]
211
211
  },
212
- purpose: { id: transaction.id, typeOf: client.factory.transactionType.PlaceOrder }
212
+ purpose: { id: transaction.id, typeOf: client.factory.transactionType.PlaceOrder },
213
+ instrumentOptions: { acceptedPaymentMethodOfferIds: [] }
213
214
  })({ paymentService });
214
215
  console.log('credit card payment authorized', creditCardPaymentAuth.id);
215
216
 
@@ -1,5 +1,26 @@
1
1
  import * as factory from '../factory';
2
2
  import { Service } from '../service';
3
+ export interface IFindParams {
4
+ /**
5
+ * max: 20
6
+ */
7
+ limit: number;
8
+ page: number;
9
+ id?: string;
10
+ /**
11
+ * 施設ID
12
+ */
13
+ locationId?: string;
14
+ /**
15
+ * コンテンツコード
16
+ */
17
+ workPerformedIdentifier?: string;
18
+ /**
19
+ * バージョン
20
+ */
21
+ workPerformedVersion?: string;
22
+ }
23
+ export declare type IEventSeriesAsFindResult = Pick<factory.eventSeries.IEvent, 'additionalProperty' | 'alternativeHeadline' | 'description' | 'dubLanguage' | 'duration' | 'endDate' | 'headline' | 'kanaName' | 'location' | 'name' | 'offers' | 'organizer' | 'soundFormat' | 'startDate' | 'subtitleLanguage' | 'typeOf' | 'videoFormat' | 'workPerformed' | 'id'>;
3
24
  /**
4
25
  * 施設コンテンツサービス
5
26
  */
@@ -9,4 +30,8 @@ export declare class EventSeriesService extends Service {
9
30
  * 存在しなければ作成し、存在すれば置換
10
31
  */
11
32
  upsertByVersion(params: factory.eventSeries.ICreateParams[]): Promise<void>;
33
+ /**
34
+ * 施設コンテンツ検索
35
+ */
36
+ findEventSeries(params: IFindParams): Promise<IEventSeriesAsFindResult[]>;
12
37
  }
@@ -53,8 +53,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
53
53
  Object.defineProperty(exports, "__esModule", { value: true });
54
54
  exports.EventSeriesService = void 0;
55
55
  var http_status_1 = require("http-status");
56
- var factory = require("../factory");
57
56
  var service_1 = require("../service");
57
+ var BASE_URI = '/eventSeries';
58
58
  /**
59
59
  * 施設コンテンツサービス
60
60
  */
@@ -72,7 +72,8 @@ var EventSeriesService = /** @class */ (function (_super) {
72
72
  return __generator(this, function (_a) {
73
73
  switch (_a.label) {
74
74
  case 0: return [4 /*yield*/, this.fetch({
75
- uri: "/events/" + factory.eventType.ScreeningEventSeries,
75
+ // uri: `/events/${factory.eventType.ScreeningEventSeries}`, // renew path(2025-12-15~)
76
+ uri: BASE_URI,
76
77
  method: 'PUT',
77
78
  body: params,
78
79
  qs: {},
@@ -85,6 +86,25 @@ var EventSeriesService = /** @class */ (function (_super) {
85
86
  });
86
87
  });
87
88
  };
89
+ /**
90
+ * 施設コンテンツ検索
91
+ */
92
+ EventSeriesService.prototype.findEventSeries = function (params) {
93
+ return __awaiter(this, void 0, void 0, function () {
94
+ var _this = this;
95
+ return __generator(this, function (_a) {
96
+ return [2 /*return*/, this.fetch({
97
+ uri: BASE_URI,
98
+ method: 'GET',
99
+ qs: params,
100
+ expectedStatusCodes: [http_status_1.OK]
101
+ })
102
+ .then(function (response) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
103
+ return [2 /*return*/, response.json()];
104
+ }); }); })];
105
+ });
106
+ });
107
+ };
88
108
  return EventSeriesService;
89
109
  }(service_1.Service));
90
110
  exports.EventSeriesService = EventSeriesService;
@@ -10,8 +10,9 @@ declare type IProjection = {
10
10
  export declare class EventSeriesService extends Service {
11
11
  /**
12
12
  * 施設コンテンツ検索
13
+ * @deprecated use chevreAdmin
13
14
  */
14
- projectFields(params: Omit<factory.eventSeries.ISearchConditions, 'project' | 'organizer'> & {
15
+ findEventSeriesDeprecated(params: Omit<factory.eventSeries.ISearchConditions, 'project' | 'organizer'> & {
15
16
  typeOf: factory.eventType.ScreeningEventSeries;
16
17
  $projection?: IProjection;
17
18
  }): Promise<factory.eventSeries.IEvent[]>;
@@ -65,8 +65,9 @@ var EventSeriesService = /** @class */ (function (_super) {
65
65
  }
66
66
  /**
67
67
  * 施設コンテンツ検索
68
+ * @deprecated use chevreAdmin
68
69
  */
69
- EventSeriesService.prototype.projectFields = function (params) {
70
+ EventSeriesService.prototype.findEventSeriesDeprecated = function (params) {
70
71
  return __awaiter(this, void 0, void 0, function () {
71
72
  var _this = this;
72
73
  return __generator(this, function (_a) {
@@ -37,6 +37,12 @@ export declare class PaymentService extends Service {
37
37
  authorizeCreditCard(params: {
38
38
  object: IAuthorizeCreditCardObject;
39
39
  purpose: IPurpose;
40
+ instrumentOptions: {
41
+ /**
42
+ * 対応決済方法オファーIDリスト
43
+ */
44
+ acceptedPaymentMethodOfferIds: string[];
45
+ };
40
46
  }, __?: {}): Promise<IAuthorizeResult>;
41
47
  /**
42
48
  * 決済カード決済承認
@@ -67,6 +73,12 @@ export declare class PaymentService extends Service {
67
73
  ticketToken: string;
68
74
  };
69
75
  purpose: IPurpose;
76
+ instrumentOptions: {
77
+ /**
78
+ * 対応決済方法オファーIDリスト
79
+ */
80
+ acceptedPaymentMethodOfferIds: string[];
81
+ };
70
82
  }): Promise<{
71
83
  /**
72
84
  * task ID
@@ -157,11 +157,12 @@ var PaymentService = /** @class */ (function (_super) {
157
157
  */
158
158
  PaymentService.prototype.authorizeCreditCard = function (params, __) {
159
159
  return __awaiter(this, void 0, void 0, function () {
160
- var object, purpose, amount, issuedThrough, paymentMethod, creditCard, method, paymentMethodId, name, additionalProperty, ticketToken, eventIdsAsOrderedItem, isException;
160
+ var object, purpose, instrumentOptions, amount, issuedThrough, paymentMethod, creditCard, method, paymentMethodId, name, additionalProperty, ticketToken, eventIdsAsOrderedItem, acceptedPaymentMethodOfferIds, isException;
161
161
  var _this = this;
162
162
  return __generator(this, function (_a) {
163
- object = params.object, purpose = params.purpose;
163
+ object = params.object, purpose = params.purpose, instrumentOptions = params.instrumentOptions;
164
164
  amount = object.amount, issuedThrough = object.issuedThrough, paymentMethod = object.paymentMethod, creditCard = object.creditCard, method = object.method, paymentMethodId = object.paymentMethodId, name = object.name, additionalProperty = object.additionalProperty, ticketToken = object.ticketToken, eventIdsAsOrderedItem = object.eventIdsAsOrderedItem;
165
+ acceptedPaymentMethodOfferIds = instrumentOptions.acceptedPaymentMethodOfferIds;
165
166
  // paymentMethodId or ticketToken required(2025-12-06~)
166
167
  if ((typeof paymentMethodId !== 'string' || paymentMethodId === '')
167
168
  && (typeof ticketToken !== 'string' || ticketToken === '')) {
@@ -180,7 +181,8 @@ var PaymentService = /** @class */ (function (_super) {
180
181
  expectedStatusCodes: [http_status_1.ACCEPTED, http_status_1.CREATED],
181
182
  body: {
182
183
  object: __assign(__assign(__assign(__assign(__assign(__assign(__assign({ amount: amount, issuedThrough: issuedThrough, paymentMethod: paymentMethod }, (creditCard !== undefined && creditCard !== null) ? { creditCard: creditCard } : undefined), (typeof name === 'string') ? { name: name } : undefined), (typeof method === 'string') ? { method: method } : undefined), (typeof paymentMethodId === 'string') ? { paymentMethodId: paymentMethodId } : undefined), (typeof ticketToken === 'string') ? { ticketToken: ticketToken } : undefined), (Array.isArray(additionalProperty)) ? { additionalProperty: additionalProperty } : undefined), (Array.isArray(eventIdsAsOrderedItem)) ? { eventIdsAsOrderedItem: eventIdsAsOrderedItem } : undefined),
183
- purpose: purpose
184
+ purpose: purpose,
185
+ instrumentOptions: { acceptedPaymentMethodOfferIds: acceptedPaymentMethodOfferIds }
184
186
  },
185
187
  qs: {
186
188
  async: true,
@@ -257,11 +259,12 @@ var PaymentService = /** @class */ (function (_super) {
257
259
  */
258
260
  PaymentService.prototype.publishCreditCardPaymentUrl = function (params) {
259
261
  return __awaiter(this, void 0, void 0, function () {
260
- var object, purpose, amount, creditCard, issuedThrough, paymentMethod, method, ticketToken, eventIdsAsOrderedItem;
262
+ var object, purpose, instrumentOptions, amount, creditCard, issuedThrough, paymentMethod, method, ticketToken, eventIdsAsOrderedItem, acceptedPaymentMethodOfferIds;
261
263
  var _this = this;
262
264
  return __generator(this, function (_a) {
263
- object = params.object, purpose = params.purpose;
265
+ object = params.object, purpose = params.purpose, instrumentOptions = params.instrumentOptions;
264
266
  amount = object.amount, creditCard = object.creditCard, issuedThrough = object.issuedThrough, paymentMethod = object.paymentMethod, method = object.method, ticketToken = object.ticketToken, eventIdsAsOrderedItem = object.eventIdsAsOrderedItem;
267
+ acceptedPaymentMethodOfferIds = instrumentOptions.acceptedPaymentMethodOfferIds;
265
268
  if (typeof ticketToken !== 'string' || ticketToken === '') {
266
269
  throw new factory.errors.ArgumentNull('object.ticketToken'); // required(2025-12-06~)
267
270
  }
@@ -275,7 +278,8 @@ var PaymentService = /** @class */ (function (_super) {
275
278
  expectedStatusCodes: [http_status_1.ACCEPTED],
276
279
  body: {
277
280
  object: __assign(__assign(__assign(__assign({ amount: amount, issuedThrough: issuedThrough, paymentMethod: paymentMethod }, (creditCard !== undefined && creditCard !== null) ? { creditCard: creditCard } : undefined), (typeof method === 'string') ? { method: method } : undefined), (typeof ticketToken === 'string') ? { ticketToken: ticketToken } : undefined), (Array.isArray(eventIdsAsOrderedItem)) ? { eventIdsAsOrderedItem: eventIdsAsOrderedItem } : undefined),
278
- purpose: purpose
281
+ purpose: purpose,
282
+ instrumentOptions: { acceptedPaymentMethodOfferIds: acceptedPaymentMethodOfferIds }
279
283
  },
280
284
  qs: {
281
285
  async: true,
@@ -18,6 +18,12 @@ export declare class PaymentService extends Service {
18
18
  authorizeCreditCardAsync(params: {
19
19
  object: IAuthorizeCreditCardObject;
20
20
  purpose: IPurpose;
21
+ instrumentOptions?: {
22
+ /**
23
+ * 対応決済方法オファーIDリスト
24
+ */
25
+ acceptedPaymentMethodOfferIds?: string[];
26
+ };
21
27
  }, options?: {
22
28
  /**
23
29
  * min: 1000 ms
@@ -57,6 +63,12 @@ export declare class PaymentService extends Service {
57
63
  publishCreditCardPaymentUrlAsync(params: {
58
64
  object: IPublishPaymentUrlObject;
59
65
  purpose: IPurpose;
66
+ instrumentOptions?: {
67
+ /**
68
+ * 対応決済方法オファーIDリスト
69
+ */
70
+ acceptedPaymentMethodOfferIds?: string[];
71
+ };
60
72
  }, options?: {
61
73
  /**
62
74
  * min: 1000 ms
@@ -134,17 +134,19 @@ var PaymentService = /** @class */ (function (_super) {
134
134
  * クレジットカード決済承認(非同期)
135
135
  */
136
136
  PaymentService.prototype.authorizeCreditCardAsync = function (params, options) {
137
+ var _a;
137
138
  return __awaiter(this, void 0, void 0, function () {
138
- var object, purpose, intervalAfterIssueTicketInMS, _a, auth, endpoint, project, seller, disableAutoRetry, retryableStatusCodes, chevrePay, paymentService, ticketToken;
139
- return __generator(this, function (_b) {
140
- switch (_b.label) {
139
+ var object, purpose, acceptedPaymentMethodOfferIds, intervalAfterIssueTicketInMS, _b, auth, endpoint, project, seller, disableAutoRetry, retryableStatusCodes, chevrePay, paymentService, ticketToken;
140
+ return __generator(this, function (_c) {
141
+ switch (_c.label) {
141
142
  case 0:
142
143
  object = params.object, purpose = params.purpose;
144
+ acceptedPaymentMethodOfferIds = (_a = params.instrumentOptions) === null || _a === void 0 ? void 0 : _a.acceptedPaymentMethodOfferIds;
143
145
  intervalAfterIssueTicketInMS = options === null || options === void 0 ? void 0 : options.intervalAfterIssueTicketInMS;
144
- _a = this.options, auth = _a.auth, endpoint = _a.endpoint, project = _a.project, seller = _a.seller, disableAutoRetry = _a.disableAutoRetry, retryableStatusCodes = _a.retryableStatusCodes;
146
+ _b = this.options, auth = _b.auth, endpoint = _b.endpoint, project = _b.project, seller = _b.seller, disableAutoRetry = _b.disableAutoRetry, retryableStatusCodes = _b.retryableStatusCodes;
145
147
  return [4 /*yield*/, index_1.loadChevrePay({ auth: auth, endpoint: endpoint, disableAutoRetry: disableAutoRetry })];
146
148
  case 1:
147
- chevrePay = _b.sent();
149
+ chevrePay = _c.sent();
148
150
  return [4 /*yield*/, chevrePay.createPaymentInstance({
149
151
  project: project,
150
152
  seller: { id: (typeof (seller === null || seller === void 0 ? void 0 : seller.id) === 'string') ? seller.id : '' },
@@ -154,16 +156,19 @@ var PaymentService = /** @class */ (function (_super) {
154
156
  ])
155
157
  })];
156
158
  case 2:
157
- paymentService = _b.sent();
159
+ paymentService = _c.sent();
158
160
  return [4 /*yield*/, this.issueTicketThroughCreditCardIfNotExists({ object: object, purpose: purpose }, {
159
161
  checkPaymentMethodId: true,
160
162
  intervalAfterIssueTicketInMS: intervalAfterIssueTicketInMS
161
163
  })];
162
164
  case 3:
163
- ticketToken = (_b.sent()).ticketToken;
165
+ ticketToken = (_c.sent()).ticketToken;
164
166
  return [2 /*return*/, paymentService.authorizeCreditCard({
165
167
  object: __assign(__assign({}, object), { ticketToken: ticketToken }),
166
- purpose: purpose
168
+ purpose: purpose,
169
+ instrumentOptions: {
170
+ acceptedPaymentMethodOfferIds: (Array.isArray(acceptedPaymentMethodOfferIds)) ? acceptedPaymentMethodOfferIds : []
171
+ }
167
172
  }, { async: true })];
168
173
  }
169
174
  });
@@ -209,17 +214,19 @@ var PaymentService = /** @class */ (function (_super) {
209
214
  * 決済採用(決済ロケーション発行)(非同期)
210
215
  */
211
216
  PaymentService.prototype.publishCreditCardPaymentUrlAsync = function (params, options) {
217
+ var _a;
212
218
  return __awaiter(this, void 0, void 0, function () {
213
- var object, purpose, intervalAfterIssueTicketInMS, _a, auth, endpoint, project, seller, disableAutoRetry, retryableStatusCodes, chevrePay, paymentService, ticketToken;
214
- return __generator(this, function (_b) {
215
- switch (_b.label) {
219
+ var object, purpose, acceptedPaymentMethodOfferIds, intervalAfterIssueTicketInMS, _b, auth, endpoint, project, seller, disableAutoRetry, retryableStatusCodes, chevrePay, paymentService, ticketToken;
220
+ return __generator(this, function (_c) {
221
+ switch (_c.label) {
216
222
  case 0:
217
223
  object = params.object, purpose = params.purpose;
224
+ acceptedPaymentMethodOfferIds = (_a = params.instrumentOptions) === null || _a === void 0 ? void 0 : _a.acceptedPaymentMethodOfferIds;
218
225
  intervalAfterIssueTicketInMS = options === null || options === void 0 ? void 0 : options.intervalAfterIssueTicketInMS;
219
- _a = this.options, auth = _a.auth, endpoint = _a.endpoint, project = _a.project, seller = _a.seller, disableAutoRetry = _a.disableAutoRetry, retryableStatusCodes = _a.retryableStatusCodes;
226
+ _b = this.options, auth = _b.auth, endpoint = _b.endpoint, project = _b.project, seller = _b.seller, disableAutoRetry = _b.disableAutoRetry, retryableStatusCodes = _b.retryableStatusCodes;
220
227
  return [4 /*yield*/, index_1.loadChevrePay({ auth: auth, endpoint: endpoint, disableAutoRetry: disableAutoRetry })];
221
228
  case 1:
222
- chevrePay = _b.sent();
229
+ chevrePay = _c.sent();
223
230
  return [4 /*yield*/, chevrePay.createPaymentInstance({
224
231
  project: project,
225
232
  seller: { id: (typeof (seller === null || seller === void 0 ? void 0 : seller.id) === 'string') ? seller.id : '' },
@@ -230,19 +237,22 @@ var PaymentService = /** @class */ (function (_super) {
230
237
  ])
231
238
  })];
232
239
  case 2:
233
- paymentService = _b.sent();
240
+ paymentService = _c.sent();
234
241
  return [4 /*yield*/, this.issueTicketThroughCreditCardIfNotExists({ object: object, purpose: purpose }, {
235
242
  checkPaymentMethodId: false,
236
243
  intervalAfterIssueTicketInMS: intervalAfterIssueTicketInMS
237
244
  })];
238
245
  case 3:
239
- ticketToken = (_b.sent()).ticketToken;
246
+ ticketToken = (_c.sent()).ticketToken;
240
247
  if (typeof ticketToken !== 'string' || ticketToken === '') {
241
248
  throw new factory.errors.ArgumentNull('object.ticketToken'); // required(2025-12-06~)
242
249
  }
243
250
  return [2 /*return*/, paymentService.publishCreditCardPaymentUrl({
244
251
  object: __assign(__assign({}, object), { ticketToken: ticketToken }),
245
- purpose: purpose
252
+ purpose: purpose,
253
+ instrumentOptions: {
254
+ acceptedPaymentMethodOfferIds: (Array.isArray(acceptedPaymentMethodOfferIds)) ? acceptedPaymentMethodOfferIds : []
255
+ }
246
256
  })];
247
257
  }
248
258
  });
package/lib/bundle.js CHANGED
@@ -3781,8 +3781,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
3781
3781
  Object.defineProperty(exports, "__esModule", { value: true });
3782
3782
  exports.EventSeriesService = void 0;
3783
3783
  var http_status_1 = require("http-status");
3784
- var factory = require("../factory");
3785
3784
  var service_1 = require("../service");
3785
+ var BASE_URI = '/eventSeries';
3786
3786
  /**
3787
3787
  * 施設コンテンツサービス
3788
3788
  */
@@ -3800,7 +3800,8 @@ var EventSeriesService = /** @class */ (function (_super) {
3800
3800
  return __generator(this, function (_a) {
3801
3801
  switch (_a.label) {
3802
3802
  case 0: return [4 /*yield*/, this.fetch({
3803
- uri: "/events/" + factory.eventType.ScreeningEventSeries,
3803
+ // uri: `/events/${factory.eventType.ScreeningEventSeries}`, // renew path(2025-12-15~)
3804
+ uri: BASE_URI,
3804
3805
  method: 'PUT',
3805
3806
  body: params,
3806
3807
  qs: {},
@@ -3813,11 +3814,30 @@ var EventSeriesService = /** @class */ (function (_super) {
3813
3814
  });
3814
3815
  });
3815
3816
  };
3817
+ /**
3818
+ * 施設コンテンツ検索
3819
+ */
3820
+ EventSeriesService.prototype.findEventSeries = function (params) {
3821
+ return __awaiter(this, void 0, void 0, function () {
3822
+ var _this = this;
3823
+ return __generator(this, function (_a) {
3824
+ return [2 /*return*/, this.fetch({
3825
+ uri: BASE_URI,
3826
+ method: 'GET',
3827
+ qs: params,
3828
+ expectedStatusCodes: [http_status_1.OK]
3829
+ })
3830
+ .then(function (response) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
3831
+ return [2 /*return*/, response.json()];
3832
+ }); }); })];
3833
+ });
3834
+ });
3835
+ };
3816
3836
  return EventSeriesService;
3817
3837
  }(service_1.Service));
3818
3838
  exports.EventSeriesService = EventSeriesService;
3819
3839
 
3820
- },{"../factory":176,"../service":181,"http-status":471}],30:[function(require,module,exports){
3840
+ },{"../service":181,"http-status":471}],30:[function(require,module,exports){
3821
3841
  "use strict";
3822
3842
  var __extends = (this && this.__extends) || (function () {
3823
3843
  var extendStatics = function (d, b) {
@@ -11221,8 +11241,9 @@ var EventSeriesService = /** @class */ (function (_super) {
11221
11241
  }
11222
11242
  /**
11223
11243
  * 施設コンテンツ検索
11244
+ * @deprecated use chevreAdmin
11224
11245
  */
11225
- EventSeriesService.prototype.projectFields = function (params) {
11246
+ EventSeriesService.prototype.findEventSeriesDeprecated = function (params) {
11226
11247
  return __awaiter(this, void 0, void 0, function () {
11227
11248
  var _this = this;
11228
11249
  return __generator(this, function (_a) {
@@ -18927,11 +18948,12 @@ var PaymentService = /** @class */ (function (_super) {
18927
18948
  */
18928
18949
  PaymentService.prototype.authorizeCreditCard = function (params, __) {
18929
18950
  return __awaiter(this, void 0, void 0, function () {
18930
- var object, purpose, amount, issuedThrough, paymentMethod, creditCard, method, paymentMethodId, name, additionalProperty, ticketToken, eventIdsAsOrderedItem, isException;
18951
+ var object, purpose, instrumentOptions, amount, issuedThrough, paymentMethod, creditCard, method, paymentMethodId, name, additionalProperty, ticketToken, eventIdsAsOrderedItem, acceptedPaymentMethodOfferIds, isException;
18931
18952
  var _this = this;
18932
18953
  return __generator(this, function (_a) {
18933
- object = params.object, purpose = params.purpose;
18954
+ object = params.object, purpose = params.purpose, instrumentOptions = params.instrumentOptions;
18934
18955
  amount = object.amount, issuedThrough = object.issuedThrough, paymentMethod = object.paymentMethod, creditCard = object.creditCard, method = object.method, paymentMethodId = object.paymentMethodId, name = object.name, additionalProperty = object.additionalProperty, ticketToken = object.ticketToken, eventIdsAsOrderedItem = object.eventIdsAsOrderedItem;
18956
+ acceptedPaymentMethodOfferIds = instrumentOptions.acceptedPaymentMethodOfferIds;
18935
18957
  // paymentMethodId or ticketToken required(2025-12-06~)
18936
18958
  if ((typeof paymentMethodId !== 'string' || paymentMethodId === '')
18937
18959
  && (typeof ticketToken !== 'string' || ticketToken === '')) {
@@ -18950,7 +18972,8 @@ var PaymentService = /** @class */ (function (_super) {
18950
18972
  expectedStatusCodes: [http_status_1.ACCEPTED, http_status_1.CREATED],
18951
18973
  body: {
18952
18974
  object: __assign(__assign(__assign(__assign(__assign(__assign(__assign({ amount: amount, issuedThrough: issuedThrough, paymentMethod: paymentMethod }, (creditCard !== undefined && creditCard !== null) ? { creditCard: creditCard } : undefined), (typeof name === 'string') ? { name: name } : undefined), (typeof method === 'string') ? { method: method } : undefined), (typeof paymentMethodId === 'string') ? { paymentMethodId: paymentMethodId } : undefined), (typeof ticketToken === 'string') ? { ticketToken: ticketToken } : undefined), (Array.isArray(additionalProperty)) ? { additionalProperty: additionalProperty } : undefined), (Array.isArray(eventIdsAsOrderedItem)) ? { eventIdsAsOrderedItem: eventIdsAsOrderedItem } : undefined),
18953
- purpose: purpose
18975
+ purpose: purpose,
18976
+ instrumentOptions: { acceptedPaymentMethodOfferIds: acceptedPaymentMethodOfferIds }
18954
18977
  },
18955
18978
  qs: {
18956
18979
  async: true,
@@ -19027,11 +19050,12 @@ var PaymentService = /** @class */ (function (_super) {
19027
19050
  */
19028
19051
  PaymentService.prototype.publishCreditCardPaymentUrl = function (params) {
19029
19052
  return __awaiter(this, void 0, void 0, function () {
19030
- var object, purpose, amount, creditCard, issuedThrough, paymentMethod, method, ticketToken, eventIdsAsOrderedItem;
19053
+ var object, purpose, instrumentOptions, amount, creditCard, issuedThrough, paymentMethod, method, ticketToken, eventIdsAsOrderedItem, acceptedPaymentMethodOfferIds;
19031
19054
  var _this = this;
19032
19055
  return __generator(this, function (_a) {
19033
- object = params.object, purpose = params.purpose;
19056
+ object = params.object, purpose = params.purpose, instrumentOptions = params.instrumentOptions;
19034
19057
  amount = object.amount, creditCard = object.creditCard, issuedThrough = object.issuedThrough, paymentMethod = object.paymentMethod, method = object.method, ticketToken = object.ticketToken, eventIdsAsOrderedItem = object.eventIdsAsOrderedItem;
19058
+ acceptedPaymentMethodOfferIds = instrumentOptions.acceptedPaymentMethodOfferIds;
19035
19059
  if (typeof ticketToken !== 'string' || ticketToken === '') {
19036
19060
  throw new factory.errors.ArgumentNull('object.ticketToken'); // required(2025-12-06~)
19037
19061
  }
@@ -19045,7 +19069,8 @@ var PaymentService = /** @class */ (function (_super) {
19045
19069
  expectedStatusCodes: [http_status_1.ACCEPTED],
19046
19070
  body: {
19047
19071
  object: __assign(__assign(__assign(__assign({ amount: amount, issuedThrough: issuedThrough, paymentMethod: paymentMethod }, (creditCard !== undefined && creditCard !== null) ? { creditCard: creditCard } : undefined), (typeof method === 'string') ? { method: method } : undefined), (typeof ticketToken === 'string') ? { ticketToken: ticketToken } : undefined), (Array.isArray(eventIdsAsOrderedItem)) ? { eventIdsAsOrderedItem: eventIdsAsOrderedItem } : undefined),
19048
- purpose: purpose
19072
+ purpose: purpose,
19073
+ instrumentOptions: { acceptedPaymentMethodOfferIds: acceptedPaymentMethodOfferIds }
19049
19074
  },
19050
19075
  qs: {
19051
19076
  async: true,
@@ -25061,17 +25086,19 @@ var PaymentService = /** @class */ (function (_super) {
25061
25086
  * クレジットカード決済承認(非同期)
25062
25087
  */
25063
25088
  PaymentService.prototype.authorizeCreditCardAsync = function (params, options) {
25089
+ var _a;
25064
25090
  return __awaiter(this, void 0, void 0, function () {
25065
- var object, purpose, intervalAfterIssueTicketInMS, _a, auth, endpoint, project, seller, disableAutoRetry, retryableStatusCodes, chevrePay, paymentService, ticketToken;
25066
- return __generator(this, function (_b) {
25067
- switch (_b.label) {
25091
+ var object, purpose, acceptedPaymentMethodOfferIds, intervalAfterIssueTicketInMS, _b, auth, endpoint, project, seller, disableAutoRetry, retryableStatusCodes, chevrePay, paymentService, ticketToken;
25092
+ return __generator(this, function (_c) {
25093
+ switch (_c.label) {
25068
25094
  case 0:
25069
25095
  object = params.object, purpose = params.purpose;
25096
+ acceptedPaymentMethodOfferIds = (_a = params.instrumentOptions) === null || _a === void 0 ? void 0 : _a.acceptedPaymentMethodOfferIds;
25070
25097
  intervalAfterIssueTicketInMS = options === null || options === void 0 ? void 0 : options.intervalAfterIssueTicketInMS;
25071
- _a = this.options, auth = _a.auth, endpoint = _a.endpoint, project = _a.project, seller = _a.seller, disableAutoRetry = _a.disableAutoRetry, retryableStatusCodes = _a.retryableStatusCodes;
25098
+ _b = this.options, auth = _b.auth, endpoint = _b.endpoint, project = _b.project, seller = _b.seller, disableAutoRetry = _b.disableAutoRetry, retryableStatusCodes = _b.retryableStatusCodes;
25072
25099
  return [4 /*yield*/, index_1.loadChevrePay({ auth: auth, endpoint: endpoint, disableAutoRetry: disableAutoRetry })];
25073
25100
  case 1:
25074
- chevrePay = _b.sent();
25101
+ chevrePay = _c.sent();
25075
25102
  return [4 /*yield*/, chevrePay.createPaymentInstance({
25076
25103
  project: project,
25077
25104
  seller: { id: (typeof (seller === null || seller === void 0 ? void 0 : seller.id) === 'string') ? seller.id : '' },
@@ -25081,16 +25108,19 @@ var PaymentService = /** @class */ (function (_super) {
25081
25108
  ])
25082
25109
  })];
25083
25110
  case 2:
25084
- paymentService = _b.sent();
25111
+ paymentService = _c.sent();
25085
25112
  return [4 /*yield*/, this.issueTicketThroughCreditCardIfNotExists({ object: object, purpose: purpose }, {
25086
25113
  checkPaymentMethodId: true,
25087
25114
  intervalAfterIssueTicketInMS: intervalAfterIssueTicketInMS
25088
25115
  })];
25089
25116
  case 3:
25090
- ticketToken = (_b.sent()).ticketToken;
25117
+ ticketToken = (_c.sent()).ticketToken;
25091
25118
  return [2 /*return*/, paymentService.authorizeCreditCard({
25092
25119
  object: __assign(__assign({}, object), { ticketToken: ticketToken }),
25093
- purpose: purpose
25120
+ purpose: purpose,
25121
+ instrumentOptions: {
25122
+ acceptedPaymentMethodOfferIds: (Array.isArray(acceptedPaymentMethodOfferIds)) ? acceptedPaymentMethodOfferIds : []
25123
+ }
25094
25124
  }, { async: true })];
25095
25125
  }
25096
25126
  });
@@ -25136,17 +25166,19 @@ var PaymentService = /** @class */ (function (_super) {
25136
25166
  * 決済採用(決済ロケーション発行)(非同期)
25137
25167
  */
25138
25168
  PaymentService.prototype.publishCreditCardPaymentUrlAsync = function (params, options) {
25169
+ var _a;
25139
25170
  return __awaiter(this, void 0, void 0, function () {
25140
- var object, purpose, intervalAfterIssueTicketInMS, _a, auth, endpoint, project, seller, disableAutoRetry, retryableStatusCodes, chevrePay, paymentService, ticketToken;
25141
- return __generator(this, function (_b) {
25142
- switch (_b.label) {
25171
+ var object, purpose, acceptedPaymentMethodOfferIds, intervalAfterIssueTicketInMS, _b, auth, endpoint, project, seller, disableAutoRetry, retryableStatusCodes, chevrePay, paymentService, ticketToken;
25172
+ return __generator(this, function (_c) {
25173
+ switch (_c.label) {
25143
25174
  case 0:
25144
25175
  object = params.object, purpose = params.purpose;
25176
+ acceptedPaymentMethodOfferIds = (_a = params.instrumentOptions) === null || _a === void 0 ? void 0 : _a.acceptedPaymentMethodOfferIds;
25145
25177
  intervalAfterIssueTicketInMS = options === null || options === void 0 ? void 0 : options.intervalAfterIssueTicketInMS;
25146
- _a = this.options, auth = _a.auth, endpoint = _a.endpoint, project = _a.project, seller = _a.seller, disableAutoRetry = _a.disableAutoRetry, retryableStatusCodes = _a.retryableStatusCodes;
25178
+ _b = this.options, auth = _b.auth, endpoint = _b.endpoint, project = _b.project, seller = _b.seller, disableAutoRetry = _b.disableAutoRetry, retryableStatusCodes = _b.retryableStatusCodes;
25147
25179
  return [4 /*yield*/, index_1.loadChevrePay({ auth: auth, endpoint: endpoint, disableAutoRetry: disableAutoRetry })];
25148
25180
  case 1:
25149
- chevrePay = _b.sent();
25181
+ chevrePay = _c.sent();
25150
25182
  return [4 /*yield*/, chevrePay.createPaymentInstance({
25151
25183
  project: project,
25152
25184
  seller: { id: (typeof (seller === null || seller === void 0 ? void 0 : seller.id) === 'string') ? seller.id : '' },
@@ -25157,19 +25189,22 @@ var PaymentService = /** @class */ (function (_super) {
25157
25189
  ])
25158
25190
  })];
25159
25191
  case 2:
25160
- paymentService = _b.sent();
25192
+ paymentService = _c.sent();
25161
25193
  return [4 /*yield*/, this.issueTicketThroughCreditCardIfNotExists({ object: object, purpose: purpose }, {
25162
25194
  checkPaymentMethodId: false,
25163
25195
  intervalAfterIssueTicketInMS: intervalAfterIssueTicketInMS
25164
25196
  })];
25165
25197
  case 3:
25166
- ticketToken = (_b.sent()).ticketToken;
25198
+ ticketToken = (_c.sent()).ticketToken;
25167
25199
  if (typeof ticketToken !== 'string' || ticketToken === '') {
25168
25200
  throw new factory.errors.ArgumentNull('object.ticketToken'); // required(2025-12-06~)
25169
25201
  }
25170
25202
  return [2 /*return*/, paymentService.publishCreditCardPaymentUrl({
25171
25203
  object: __assign(__assign({}, object), { ticketToken: ticketToken }),
25172
- purpose: purpose
25204
+ purpose: purpose,
25205
+ instrumentOptions: {
25206
+ acceptedPaymentMethodOfferIds: (Array.isArray(acceptedPaymentMethodOfferIds)) ? acceptedPaymentMethodOfferIds : []
25207
+ }
25173
25208
  })];
25174
25209
  }
25175
25210
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cinerino/sdk",
3
- "version": "12.13.0-alpha.0",
3
+ "version": "12.13.0-alpha.1",
4
4
  "description": "Cinerino SDK",
5
5
  "main": "./lib/index.js",
6
6
  "browser": {
@@ -1,403 +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
-
5
- const project = { id: String(process.env.PROJECT_ID) };
6
- const creditCard = {
7
- cardNo: '4111111111111111',
8
- expire: '2612',
9
- holderName: 'AA BB'
10
- };
11
- const profile = {
12
- email: <string>process.env.TEST_PROFILE_EMAIL,
13
- givenName: 'Taro',
14
- familyName: 'SDK',
15
- name: 'Taro ☆ SDK',
16
- telephone: '+819012345678'
17
- };
18
- const ASYNC_ACTION_GIVEUP_SEC = 10;
19
- const ASYNC_ACTION_CHECK_INTERVAL_MS = 1000;
20
- const SELLER_ID = '5d0abf30ac3fb200198ebb2c';
21
- const EVENT_ID = '120162210202405311202250';
22
-
23
- function authorizeOfferAsync(params: {
24
- /**
25
- * 承認アクションID
26
- */
27
- originalAuthorizeAction?: string;
28
- purpose: { id: string };
29
- }) {
30
- // tslint:disable-next-line:max-func-body-length
31
- return async (repos: {
32
- offerService: client.chevreTxc.service.Offer;
33
- }): Promise<{
34
- /**
35
- * 承認アクションID
36
- */
37
- id: string;
38
- result: {
39
- price?: Number;
40
- responseBody: { tmpReserveNum: string };
41
- };
42
- }> => {
43
- console.log('creating accept task..,');
44
- const acceptTask = await repos.offerService.acceptOffer(
45
- {
46
- object: {
47
- event: { id: EVENT_ID },
48
- acceptedOffer: [{
49
- seatSection: ' ',
50
- seatNumber: 'b-8',
51
- ticketInfo: {
52
- ticketCode: '171',
53
- mvtkAppPrice: 0,
54
- ticketCount: 1,
55
- addGlasses: 0,
56
- kbnEisyahousiki: '00',
57
- mvtkNum: '',
58
- mvtkKbnDenshiken: '00',
59
- mvtkKbnMaeuriken: '00',
60
- mvtkKbnKensyu: '00',
61
- mvtkSalesPrice: 0,
62
- kbnMgtk: ''
63
- }
64
- }],
65
- appliesToSurfrock: {
66
- identifier: '',
67
- serviceOutput: { typeOf: '' }
68
- }
69
- },
70
- purpose: { id: params.purpose.id, typeOf: client.factory.transactionType.PlaceOrder },
71
- ...(typeof params.originalAuthorizeAction === 'string')
72
- ? { potentialActions: { id: params.originalAuthorizeAction } }
73
- : undefined
74
- }
75
- );
76
- console.log('acceptTask created,', acceptTask);
77
-
78
- const giveUpPayment = moment()
79
- .add(ASYNC_ACTION_GIVEUP_SEC, 'seconds');
80
- let result: { id: string } | undefined;
81
- let error: any;
82
-
83
- // n秒おきに状態確認
84
- while (result === undefined && error === undefined) {
85
- // n秒待機
86
- await wait(ASYNC_ACTION_CHECK_INTERVAL_MS);
87
-
88
- // タスク作成から一定時間経過すればあきらめる
89
- if (moment()
90
- .isAfter(giveUpPayment)) {
91
- error = new Error('action gaven up');
92
- break;
93
- }
94
-
95
- const acceptAction = await repos.offerService.findAcceptAction({
96
- sameAs: { id: acceptTask.id },
97
- purpose: { id: params.purpose.id, typeOf: client.factory.transactionType.PlaceOrder }
98
- });
99
- console.log('acceptAction:,', acceptAction);
100
-
101
- if (typeof acceptAction.id === 'string') {
102
- if (acceptAction.actionStatus === client.factory.actionStatusType.CompletedActionStatus) {
103
- // ステータス完了であれば決済承認アクションIDを保管
104
- result = { id: acceptAction.id };
105
- break;
106
- } else {
107
- // 待機続行
108
- }
109
- }
110
-
111
- // エラーが存在すれば、これ以上待機する価値はなし
112
- if (acceptAction.error !== undefined) {
113
- error = acceptAction.error;
114
- break;
115
- }
116
- }
117
-
118
- if (typeof result?.id === 'string') {
119
- console.log('offer accepted.', result);
120
-
121
- // tslint:disable-next-line:no-magic-numbers
122
- await wait(3000);
123
- console.log('authorizing by acceptAction...', result.id);
124
-
125
- return repos.offerService.authorizeEventServiceByCOA({
126
- acceptAction: { id: result.id },
127
- purpose: { id: params.purpose.id, typeOf: client.factory.transactionType.PlaceOrder }
128
- });
129
- }
130
-
131
- throw error;
132
- };
133
- }
134
-
135
- function voidAuthorizeOfferAsync(params: {
136
- /**
137
- * 承認アクションID
138
- */
139
- originalAuthorizeAction: string;
140
- purpose: { id: string };
141
- }) {
142
- return async (repos: {
143
- offerService: client.chevreTxc.service.Offer;
144
- }): Promise<void> => {
145
- console.log('creating accept task..,');
146
- const voidTask = await repos.offerService.voidAuthorizationByCOA(
147
- {
148
- id: params.originalAuthorizeAction,
149
- purpose: { id: params.purpose.id, typeOf: client.factory.transactionType.PlaceOrder }
150
- }
151
- );
152
- console.log('voidTask created,', voidTask);
153
-
154
- const giveUpPayment = moment()
155
- .add(ASYNC_ACTION_GIVEUP_SEC, 'seconds');
156
- let result: { status: client.factory.taskStatus } | undefined;
157
- let error: any;
158
-
159
- // n秒おきに状態確認
160
- while (result === undefined && error === undefined) {
161
- // n秒待機
162
- await wait(ASYNC_ACTION_CHECK_INTERVAL_MS);
163
-
164
- // タスク作成から一定時間経過すればあきらめる
165
- if (moment()
166
- .isAfter(giveUpPayment)) {
167
- error = new Error('action gaven up');
168
- break;
169
- }
170
-
171
- const voidTaskWithStatus = await repos.offerService.findVoidTask({
172
- actionId: params.originalAuthorizeAction,
173
- taskId: voidTask.id,
174
- purpose: { id: params.purpose.id, typeOf: client.factory.transactionType.PlaceOrder }
175
- });
176
- console.log('voidTaskWithStatus:,', voidTaskWithStatus);
177
-
178
- if (voidTaskWithStatus.status === client.factory.taskStatus.Executed) {
179
- // ステータス完了であれば決済承認アクションIDを保管
180
- result = voidTaskWithStatus;
181
- break;
182
- } else {
183
- // 待機続行
184
- }
185
- }
186
-
187
- if (typeof result?.status === 'string') {
188
- console.log('voidTask executed.', result);
189
-
190
- return;
191
- }
192
-
193
- throw error;
194
- };
195
- }
196
-
197
- function authorizeCreditCardAsync(params: {
198
- object: {
199
- amount: number;
200
- paymentMethod: string;
201
- method: string;
202
- creditCard: typeof creditCard;
203
- issuedThrough: { id: string };
204
- eventIdsAsOrderedItem: string[];
205
- };
206
- purpose: { id: string; typeOf: client.factory.transactionType.PlaceOrder };
207
- }) {
208
- return async (repos: {
209
- paymentService: client.chevrePay.service.Payment;
210
- }): Promise<{
211
- /**
212
- * 承認アクションID
213
- */
214
- id: string;
215
- }> => {
216
- // 決済承認タスク作成
217
- const authorizeTask = await repos.paymentService.authorizeCreditCard(params, { async: true });
218
- const giveUpPayment = moment()
219
- .add(ASYNC_ACTION_GIVEUP_SEC, 'seconds');
220
- let result: { id: string } | undefined;
221
- let error: any;
222
-
223
- // n秒おきに状態確認
224
- while (result === undefined && error === undefined) {
225
- // n秒待機
226
- await wait(ASYNC_ACTION_CHECK_INTERVAL_MS);
227
-
228
- // タスク作成から一定時間経過すればあきらめる
229
- if (moment()
230
- .isAfter(giveUpPayment)) {
231
- error = new Error('action gaven up');
232
- break;
233
- }
234
-
235
- const authorizeAction = await repos.paymentService.findAuthorizeAction({
236
- sameAs: { id: authorizeTask.id },
237
- object: {
238
- typeOf: client.factory.service.paymentService.PaymentServiceType.CreditCard
239
- },
240
- purpose: params.purpose
241
- });
242
-
243
- if (typeof authorizeAction.id === 'string') {
244
- if (authorizeAction.actionStatus === client.factory.actionStatusType.CompletedActionStatus) {
245
- // ステータス完了であれば決済承認アクションIDを保管
246
- result = { id: authorizeAction.id };
247
- break;
248
- } else {
249
- // 待機続行
250
- }
251
- }
252
-
253
- // エラーが存在すれば、これ以上待機する価値はなし
254
- if (authorizeAction.error !== undefined) {
255
- error = authorizeAction.error;
256
- break;
257
- }
258
- }
259
-
260
- if (typeof result?.id === 'string') {
261
- return result;
262
- }
263
-
264
- throw error;
265
- };
266
- }
267
-
268
- // tslint:disable-next-line:max-func-body-length
269
- async function main() {
270
- const authClient = await client.auth.ClientCredentials.createInstance({
271
- domain: <string>process.env.CHEVRE_AUTHORIZE_SERVER_DOMAIN,
272
- clientId: <string>process.env.CHEVRE_CLIENT_ID,
273
- clientSecret: <string>process.env.CHEVRE_CLIENT_SECRET,
274
- scopes: [],
275
- state: ''
276
- });
277
- const placeOrderService = await (await client.loadChevreTxn({
278
- endpoint: `${<string>process.env.CHEVRE_ENDPOINT}/txn`,
279
- auth: authClient
280
- })).createPlaceOrderTransactionInstance({
281
- project,
282
- seller: { id: '' }
283
- });
284
- const offerService = await (await client.loadChevreTxc({
285
- endpoint: `${<string>process.env.CHEVRE_ENDPOINT}/txc`,
286
- auth: authClient
287
- })).createOfferInstance({
288
- project,
289
- seller: { id: '' }
290
- });
291
- const paymentService = await (await client.loadChevrePay({
292
- endpoint: `${<string>process.env.CHEVRE_ENDPOINT}/pay`,
293
- auth: authClient
294
- })).createPaymentInstance({
295
- project,
296
- seller: { id: '' }
297
- });
298
-
299
- console.log('starting transaction...');
300
- const transaction = await placeOrderService.start({
301
- agent: {
302
- memberOfToken: process.env.MEMBERSHIP_TOKEN
303
- },
304
- seller: { id: SELLER_ID },
305
- object: {
306
- // passport: { token: passportToken }
307
- }
308
- });
309
- console.log('transaction started', transaction.id);
310
-
311
- try {
312
- // throw new Error('test error');
313
-
314
- // tslint:disable-next-line:no-magic-numbers
315
- await wait(3000);
316
- let authorizeOfferAction = await authorizeOfferAsync({ purpose: { id: transaction.id } })({ offerService });
317
- console.log('offer authorized', authorizeOfferAction.id);
318
-
319
- // 変更
320
- await wait(3000);
321
- authorizeOfferAction = await authorizeOfferAsync({
322
- purpose: { id: transaction.id },
323
- originalAuthorizeAction: authorizeOfferAction.id
324
- })({ offerService });
325
- console.log('offer authorized', authorizeOfferAction.id);
326
-
327
- // オファー承認取消
328
- await wait(3000);
329
- await voidAuthorizeOfferAsync({
330
- purpose: { id: transaction.id },
331
- originalAuthorizeAction: authorizeOfferAction.id
332
- })({ offerService });
333
- console.log('authorization voided', authorizeOfferAction.id);
334
-
335
- // オファー再承認
336
- await wait(3000);
337
- authorizeOfferAction = await authorizeOfferAsync({ purpose: { id: transaction.id } })({ offerService });
338
- console.log('offer authorized', authorizeOfferAction.id);
339
-
340
- // 決済承認
341
- await wait(3000);
342
- console.log('authorizing credit card payment...');
343
- const authorizePayment = await authorizeCreditCardAsync({
344
- object: {
345
- amount: Number(authorizeOfferAction.result.price),
346
- paymentMethod: 'CreditCard',
347
- method: '1',
348
- creditCard,
349
- issuedThrough: { id: '5f9a6986cc98a1eb13a90285' },
350
- eventIdsAsOrderedItem: [EVENT_ID]
351
- },
352
- purpose: { id: transaction.id, typeOf: client.factory.transactionType.PlaceOrder }
353
- })({ paymentService });
354
- console.log('credit card payment authorized', authorizePayment.id);
355
-
356
- // tslint:disable-next-line:no-magic-numbers
357
- await wait(3000);
358
- const settingProfile: client.factory.person.IProfile = {
359
- givenName: profile.givenName,
360
- familyName: profile.familyName,
361
- telephone: profile.telephone,
362
- email: profile.email
363
- };
364
- console.log('setting customer profile...');
365
- await placeOrderService.setProfile({ id: transaction.id, agent: settingProfile });
366
- console.log('customer profile set');
367
-
368
- // tslint:disable-next-line:no-magic-numbers
369
- await wait(3000);
370
- await placeOrderService.updateObject({
371
- id: transaction.id,
372
- object: { name: 'order from samples' }
373
- });
374
-
375
- console.log('confirming transaction...');
376
- const confirmResult = await placeOrderService.confirm({
377
- id: transaction.id,
378
- sendEmailMessage: true,
379
- expectsMinimalResponse: true
380
- });
381
- console.log('transaction confirmed', confirmResult);
382
- } catch (error) {
383
- console.error(error);
384
-
385
- // tslint:disable-next-line:no-magic-numbers
386
- await wait(3000);
387
- await placeOrderService.cancel({ id: transaction.id });
388
- console.log('transaction canceled');
389
- }
390
- }
391
-
392
- async function wait(waitInMilliseconds: number) {
393
- return new Promise((resolve) => {
394
- console.log('waiting...', waitInMilliseconds);
395
- setTimeout(resolve, waitInMilliseconds);
396
- });
397
- }
398
-
399
- main()
400
- .then(() => {
401
- console.log('success!');
402
- })
403
- .catch(console.error);