@cinerino/sdk 10.4.0 → 10.5.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.
@@ -13040,6 +13040,25 @@ var PaymentService = /** @class */ (function (_super) {
13040
13040
  });
13041
13041
  });
13042
13042
  };
13043
+ PaymentService.prototype.issueTicketThroughFaceToFace = function (params) {
13044
+ return __awaiter(this, void 0, void 0, function () {
13045
+ var _this = this;
13046
+ return __generator(this, function (_a) {
13047
+ return [2 /*return*/, this.fetch({
13048
+ uri: "/payment/" + factory.service.paymentService.PaymentServiceType.FaceToFace + "/tickets",
13049
+ method: 'POST',
13050
+ expectedStatusCodes: [http_status_1.CREATED],
13051
+ body: params,
13052
+ qs: {
13053
+ purpose: { id: params.purpose.id } // 追加(2024-04-01~)
13054
+ }
13055
+ })
13056
+ .then(function (response) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
13057
+ return [2 /*return*/, response.json()];
13058
+ }); }); })];
13059
+ });
13060
+ });
13061
+ };
13043
13062
  return PaymentService;
13044
13063
  }(service_1.Service));
13045
13064
  exports.PaymentService = PaymentService;
@@ -89,6 +89,7 @@ async function main() {
89
89
  id: '5fadf737c679f7000a3c85b6',
90
90
  // pointAward?: IAcceptedPointAward;
91
91
  serviceOutput: {
92
+ identifier: 'xxx', // 自動的に上書きされる
92
93
  accessCode: '1234',
93
94
  typeOf: client.factory.permit.PermitType.Permit,
94
95
  project: { id: project.id, typeOf: client.factory.organizationType.Project },
@@ -0,0 +1,176 @@
1
+ // tslint:disable:no-console no-implicit-dependencies no-magic-numbers
2
+ import * as client from '../../../../lib/index';
3
+ import * as auth from '../../auth/authAsAdmin';
4
+
5
+ const project = { id: String(process.env.PROJECT_ID) };
6
+
7
+ const profile = {
8
+ email: <string>process.env.TEST_PROFILE_EMAIL,
9
+ givenName: 'Taro',
10
+ familyName: 'SDK',
11
+ name: 'Taro ☆ SDK',
12
+ telephone: '+819012345678'
13
+ };
14
+
15
+ export type IAuthorizeReservationAction
16
+ = client.factory.action.authorize.offer.eventService.IAction<client.factory.service.webAPI.Identifier.Chevre>;
17
+
18
+ // tslint:disable-next-line:max-func-body-length
19
+ async function main() {
20
+ const authClient = await auth.login();
21
+ await authClient.refreshAccessToken();
22
+ const loginTicket = authClient.verifyIdToken({});
23
+ console.log('username is', loginTicket.getUsername());
24
+
25
+ // authClient.credentials.access_token = '';
26
+ // authClient.credentials.refresh_token = '';
27
+ const sellerService = await (await client.loadChevre({
28
+ endpoint: <string>process.env.CHEVRE_ENDPOINT,
29
+ auth: authClient
30
+ })).createSellerInstance({
31
+ project
32
+ });
33
+
34
+ // 販売劇場検索
35
+ const searchSellersResult = await sellerService.search({
36
+ branchCode: { $eq: '001' },
37
+ $projection: {}
38
+ });
39
+ // tslint:disable-next-line:insecure-random
40
+ const seller = searchSellersResult.data[Math.floor(searchSellersResult.data.length * Math.random())];
41
+ if (seller === undefined) {
42
+ throw new Error('No seller');
43
+ }
44
+ console.log('ordering from seller...', (<client.factory.multilingualString>seller.name).ja);
45
+ const sellerId = String(seller.id);
46
+
47
+ const placeOrderService = await (await client.loadChevreTxn({
48
+ endpoint: <string>process.env.CHEVRE_ENDPOINT_TXN,
49
+ auth: authClient
50
+ })).createPlaceOrderTransactionInstance({
51
+ project,
52
+ seller: { id: sellerId }
53
+ });
54
+ const offerService = await (await client.loadChevreTxn({
55
+ endpoint: <string>process.env.CHEVRE_ENDPOINT_TXN,
56
+ auth: authClient
57
+ })).createOfferInstance({
58
+ project,
59
+ seller: { id: sellerId }
60
+ });
61
+ const paymentService = await (await client.loadChevrePay({
62
+ endpoint: <string>process.env.CHEVRE_ENDPOINT_PAY,
63
+ auth: authClient
64
+ })).createPaymentInstance({
65
+ project,
66
+ seller: { id: sellerId }
67
+ });
68
+
69
+ console.log('starting transaction...');
70
+ const transaction = await placeOrderService.start({
71
+ agent: {
72
+ identifier: [
73
+ {
74
+ name: 'SampleName',
75
+ value: 'SampleValue'
76
+ }
77
+ ]
78
+ },
79
+ seller: { id: String(seller.id) },
80
+ object: {
81
+ // passport: { token: passportToken }
82
+ }
83
+ });
84
+ console.log('transaction started', transaction.id);
85
+
86
+ await wait(3000);
87
+
88
+ // メンバーシップチケット発行
89
+ const { ticketToken } = await paymentService.issueTicketThroughFaceToFace({
90
+ purpose: { id: transaction.id, typeOf: client.factory.transactionType.PlaceOrder }
91
+ });
92
+ console.log('ticket issued. ticketToken:', ticketToken);
93
+
94
+ await wait(3000);
95
+
96
+ // オファー承認
97
+ await offerService.authorizeEventService({
98
+ object: {
99
+ reservationFor: {
100
+ id: 'blxonxv2b'
101
+ },
102
+ acceptedOffer: [{
103
+ id: 'bkpnwjw1w',
104
+ itemOffered: {
105
+ serviceOutput: {
106
+ typeOf: client.factory.reservationType.EventReservation,
107
+ reservedTicket: {
108
+ typeOf: 'Ticket',
109
+ ticketedSeat: {
110
+ typeOf: client.factory.placeType.Seat,
111
+ seatNumber: 'A-9',
112
+ seatSection: 'Default',
113
+ seatRow: ''
114
+ }
115
+ },
116
+ programMembershipUsed: {
117
+ ticketToken,
118
+ // ticketToken: '1acf96d0-a565-4cb9-aaf4-8bc37568efce',
119
+ typeOf: 'Ticket'
120
+ } // チケット指定
121
+ }
122
+ },
123
+ additionalProperty: [{ name: 'sampleName', value: 'sampleValue' }]
124
+ }]
125
+ },
126
+ purpose: { id: transaction.id, typeOf: client.factory.transactionType.PlaceOrder }
127
+
128
+ });
129
+
130
+ await wait(3000);
131
+
132
+ // 決済承認
133
+ await paymentService.authorizeAnyPayment({
134
+ object: {
135
+ amount: 999,
136
+ issuedThrough: { id: '' },
137
+ paymentMethod: 'Cash',
138
+ ticketToken // チケット指定
139
+ },
140
+ purpose: { id: transaction.id, typeOf: client.factory.transactionType.PlaceOrder }
141
+ });
142
+ console.log('payment authorized');
143
+
144
+ await wait(3000);
145
+
146
+ const settingProfile: client.factory.person.IProfile = {
147
+ givenName: profile.givenName,
148
+ familyName: profile.familyName,
149
+ telephone: profile.telephone,
150
+ email: profile.email
151
+ };
152
+ console.log('setting customer profile...');
153
+ await placeOrderService.setProfile({ id: transaction.id, agent: settingProfile });
154
+ console.log('customer profile set');
155
+
156
+ await wait(3000);
157
+
158
+ console.log('confirming transaction...');
159
+ const confirmResult = await placeOrderService.confirm({
160
+ id: transaction.id,
161
+ sendEmailMessage: true,
162
+ expectsMinimalResponse: true
163
+ // expectsReservationIds: true
164
+ });
165
+ console.log('transaction confirmed', confirmResult);
166
+ }
167
+
168
+ async function wait(waitInMilliseconds: number) {
169
+ return new Promise((resolve) => setTimeout(resolve, waitInMilliseconds));
170
+ }
171
+
172
+ main()
173
+ .then(() => {
174
+ console.log('success!');
175
+ })
176
+ .catch(console.error);
@@ -31,7 +31,7 @@ export declare type IMovieTicketMkknInfo = factory.action.check.paymentMethod.mo
31
31
  */
32
32
  knyknrNo: string;
33
33
  };
34
- export declare type IAuthorizeAnyPaymentObject = Pick<factory.action.authorize.paymentMethod.any.IObjectWithoutDetail, 'amount' | 'issuedThrough' | 'paymentMethod' | 'name' | 'additionalProperty'>;
34
+ export declare type IAuthorizeAnyPaymentObject = Pick<factory.action.authorize.paymentMethod.any.IObjectWithoutDetail, 'amount' | 'issuedThrough' | 'paymentMethod' | 'name' | 'additionalProperty' | 'ticketToken'>;
35
35
  export declare type IAuthorizeCreditCardObject = Pick<factory.action.authorize.paymentMethod.any.IObjectWithoutDetail, 'amount' | 'issuedThrough' | 'paymentMethod' | 'creditCard' | 'method' | 'paymentMethodId' | 'name' | 'additionalProperty'>;
36
36
  export declare type IAuthorizeMovieTicketObject = Pick<factory.action.authorize.paymentMethod.any.IObjectWithoutDetail, 'issuedThrough' | 'paymentMethod' | 'movieTickets' | 'name' | 'additionalProperty'>;
37
37
  export declare type IAuthorizePaymentCardObject = Pick<factory.action.authorize.paymentMethod.any.IObjectWithoutDetail, 'amount' | 'issuedThrough' | 'paymentMethod' | 'fromLocation' | 'name' | 'additionalProperty'> & {
@@ -188,4 +188,9 @@ export declare class PaymentService extends Service {
188
188
  };
189
189
  result?: IPublishPaymentUrlResult;
190
190
  }>;
191
+ issueTicketThroughFaceToFace(params: {
192
+ purpose: IPurpose;
193
+ }): Promise<{
194
+ ticketToken: string;
195
+ }>;
191
196
  }
@@ -399,6 +399,25 @@ var PaymentService = /** @class */ (function (_super) {
399
399
  });
400
400
  });
401
401
  };
402
+ PaymentService.prototype.issueTicketThroughFaceToFace = function (params) {
403
+ return __awaiter(this, void 0, void 0, function () {
404
+ var _this = this;
405
+ return __generator(this, function (_a) {
406
+ return [2 /*return*/, this.fetch({
407
+ uri: "/payment/" + factory.service.paymentService.PaymentServiceType.FaceToFace + "/tickets",
408
+ method: 'POST',
409
+ expectedStatusCodes: [http_status_1.CREATED],
410
+ body: params,
411
+ qs: {
412
+ purpose: { id: params.purpose.id } // 追加(2024-04-01~)
413
+ }
414
+ })
415
+ .then(function (response) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
416
+ return [2 /*return*/, response.json()];
417
+ }); }); })];
418
+ });
419
+ });
420
+ };
402
421
  return PaymentService;
403
422
  }(service_1.Service));
404
423
  exports.PaymentService = PaymentService;
@@ -1,6 +1,8 @@
1
1
  import * as factory from '../factory';
2
2
  import { IOptions, Service } from '../service';
3
- declare type IPermitAsResponse = Omit<factory.permit.IPermit, 'accessCode' | 'additionalProperty' | 'issuedBy'>;
3
+ declare type IPermitAsResponse = Pick<factory.permit.IPermit, 'amount' | 'dateIssued' | 'depositAmount' | 'identifier' | 'name' | 'paymentAccount' | 'paymentAmount' | 'project' | 'typeOf' | 'validFor' | 'validFrom' | 'validUntil'> & {
4
+ issuedThrough?: factory.permit.IIssuedThroughAsProduct;
5
+ };
4
6
  /**
5
7
  * 許可証サービス
6
8
  */
package/lib/bundle.js CHANGED
@@ -14272,6 +14272,25 @@ var PaymentService = /** @class */ (function (_super) {
14272
14272
  });
14273
14273
  });
14274
14274
  };
14275
+ PaymentService.prototype.issueTicketThroughFaceToFace = function (params) {
14276
+ return __awaiter(this, void 0, void 0, function () {
14277
+ var _this = this;
14278
+ return __generator(this, function (_a) {
14279
+ return [2 /*return*/, this.fetch({
14280
+ uri: "/payment/" + factory.service.paymentService.PaymentServiceType.FaceToFace + "/tickets",
14281
+ method: 'POST',
14282
+ expectedStatusCodes: [http_status_1.CREATED],
14283
+ body: params,
14284
+ qs: {
14285
+ purpose: { id: params.purpose.id } // 追加(2024-04-01~)
14286
+ }
14287
+ })
14288
+ .then(function (response) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
14289
+ return [2 /*return*/, response.json()];
14290
+ }); }); })];
14291
+ });
14292
+ });
14293
+ };
14275
14294
  return PaymentService;
14276
14295
  }(service_1.Service));
14277
14296
  exports.PaymentService = PaymentService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cinerino/sdk",
3
- "version": "10.4.0",
3
+ "version": "10.5.0-alpha.1",
4
4
  "description": "Cinerino SDK",
5
5
  "main": "./lib/index.js",
6
6
  "browser": {
@@ -92,7 +92,7 @@
92
92
  "watchify": "^3.11.1"
93
93
  },
94
94
  "dependencies": {
95
- "@chevre/factory": "4.380.0",
95
+ "@chevre/factory": "4.381.0-alpha.3",
96
96
  "debug": "3.2.7",
97
97
  "http-status": "1.7.4",
98
98
  "idtoken-verifier": "2.0.3",