@cinerino/sdk 7.0.0-alpha.7 → 7.0.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/example/src/chevre/transaction/processPlaceOrderCOA.ts +329 -133
- package/lib/abstract/{chevreTxncoa → chevreTxc}/offer.d.ts +22 -80
- package/lib/abstract/{chevreTxncoa → chevreTxc}/offer.js +27 -50
- package/lib/abstract/{chevreTxncoa.d.ts → chevreTxc.d.ts} +2 -2
- package/lib/abstract/{chevreTxncoa.js → chevreTxc.js} +7 -7
- package/lib/abstract/index.d.ts +3 -3
- package/lib/abstract/index.js +8 -8
- package/lib/bundle.js +293 -316
- package/lib/index.d.ts +2 -2
- package/lib/index.js +2 -2
- package/package.json +2 -2
|
@@ -3,7 +3,11 @@ import * as moment from 'moment';
|
|
|
3
3
|
import * as client from '../../../../lib/index';
|
|
4
4
|
|
|
5
5
|
const project = { id: String(process.env.PROJECT_ID) };
|
|
6
|
-
|
|
6
|
+
const creditCard = {
|
|
7
|
+
cardNo: '4111111111111111',
|
|
8
|
+
expire: '2612',
|
|
9
|
+
holderName: 'AA BB'
|
|
10
|
+
};
|
|
7
11
|
const profile = {
|
|
8
12
|
email: <string>process.env.TEST_PROFILE_EMAIL,
|
|
9
13
|
givenName: 'Taro',
|
|
@@ -11,9 +15,254 @@ const profile = {
|
|
|
11
15
|
name: 'Taro ☆ SDK',
|
|
12
16
|
telephone: '+819012345678'
|
|
13
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 = '120162210202405271202250';
|
|
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
|
+
};
|
|
205
|
+
purpose: { id: string; typeOf: client.factory.transactionType.PlaceOrder };
|
|
206
|
+
}) {
|
|
207
|
+
return async (repos: {
|
|
208
|
+
paymentService: client.chevrePay.service.Payment;
|
|
209
|
+
}): Promise<{
|
|
210
|
+
/**
|
|
211
|
+
* 承認アクションID
|
|
212
|
+
*/
|
|
213
|
+
id: string;
|
|
214
|
+
}> => {
|
|
215
|
+
// 決済承認タスク作成
|
|
216
|
+
const authorizeTask = await repos.paymentService.authorizeCreditCard(params, { async: true });
|
|
217
|
+
const giveUpPayment = moment()
|
|
218
|
+
.add(ASYNC_ACTION_GIVEUP_SEC, 'seconds');
|
|
219
|
+
let result: { id: string } | undefined;
|
|
220
|
+
let error: any;
|
|
221
|
+
|
|
222
|
+
// n秒おきに状態確認
|
|
223
|
+
while (result === undefined && error === undefined) {
|
|
224
|
+
// n秒待機
|
|
225
|
+
await wait(ASYNC_ACTION_CHECK_INTERVAL_MS);
|
|
226
|
+
|
|
227
|
+
// タスク作成から一定時間経過すればあきらめる
|
|
228
|
+
if (moment()
|
|
229
|
+
.isAfter(giveUpPayment)) {
|
|
230
|
+
error = new Error('action gaven up');
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
14
233
|
|
|
15
|
-
|
|
16
|
-
|
|
234
|
+
const authorizeAction = await repos.paymentService.findAuthorizeAction({
|
|
235
|
+
sameAs: { id: authorizeTask.id },
|
|
236
|
+
object: {
|
|
237
|
+
typeOf: client.factory.service.paymentService.PaymentServiceType.CreditCard
|
|
238
|
+
},
|
|
239
|
+
purpose: params.purpose
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
if (typeof authorizeAction.id === 'string') {
|
|
243
|
+
if (authorizeAction.actionStatus === client.factory.actionStatusType.CompletedActionStatus) {
|
|
244
|
+
// ステータス完了であれば決済承認アクションIDを保管
|
|
245
|
+
result = { id: authorizeAction.id };
|
|
246
|
+
break;
|
|
247
|
+
} else {
|
|
248
|
+
// 待機続行
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// エラーが存在すれば、これ以上待機する価値はなし
|
|
253
|
+
if (authorizeAction.error !== undefined) {
|
|
254
|
+
error = authorizeAction.error;
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (typeof result?.id === 'string') {
|
|
260
|
+
return result;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
throw error;
|
|
264
|
+
};
|
|
265
|
+
}
|
|
17
266
|
|
|
18
267
|
// tslint:disable-next-line:max-func-body-length
|
|
19
268
|
async function main() {
|
|
@@ -24,7 +273,6 @@ async function main() {
|
|
|
24
273
|
scopes: [],
|
|
25
274
|
state: ''
|
|
26
275
|
});
|
|
27
|
-
|
|
28
276
|
const placeOrderService = await (await client.loadChevreTxn({
|
|
29
277
|
endpoint: `${<string>process.env.CHEVRE_ENDPOINT}/txn`,
|
|
30
278
|
auth: authClient
|
|
@@ -32,166 +280,114 @@ async function main() {
|
|
|
32
280
|
project,
|
|
33
281
|
seller: { id: '' }
|
|
34
282
|
});
|
|
35
|
-
const offerService = await (await client.
|
|
36
|
-
endpoint: `${<string>process.env.CHEVRE_ENDPOINT}/
|
|
283
|
+
const offerService = await (await client.loadChevreTxc({
|
|
284
|
+
endpoint: `${<string>process.env.CHEVRE_ENDPOINT}/txc`,
|
|
37
285
|
auth: authClient
|
|
38
286
|
})).createOfferInstance({
|
|
39
287
|
project,
|
|
40
288
|
seller: { id: '' }
|
|
41
289
|
});
|
|
290
|
+
const paymentService = await (await client.loadChevrePay({
|
|
291
|
+
endpoint: `${<string>process.env.CHEVRE_ENDPOINT}/pay`,
|
|
292
|
+
auth: authClient
|
|
293
|
+
})).createPaymentInstance({
|
|
294
|
+
project,
|
|
295
|
+
seller: { id: '' }
|
|
296
|
+
});
|
|
42
297
|
|
|
43
298
|
console.log('starting transaction...');
|
|
44
299
|
const transaction = await placeOrderService.start({
|
|
45
300
|
agent: {},
|
|
46
|
-
seller: {
|
|
47
|
-
id: '5d0abf30ac3fb200198ebb2c'
|
|
48
|
-
},
|
|
301
|
+
seller: { id: SELLER_ID },
|
|
49
302
|
object: {
|
|
50
303
|
// passport: { token: passportToken }
|
|
51
304
|
}
|
|
52
305
|
});
|
|
53
306
|
console.log('transaction started', transaction.id);
|
|
54
307
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const acceptTask = await offerService.acceptOffer({
|
|
61
|
-
object: {
|
|
62
|
-
event: { id: '120162210202405231202250' },
|
|
63
|
-
acceptedOffer: [{
|
|
64
|
-
seatSection: ' ',
|
|
65
|
-
seatNumber: 'b-34',
|
|
66
|
-
ticketInfo: {
|
|
67
|
-
ticketCode: '171',
|
|
68
|
-
mvtkAppPrice: 0,
|
|
69
|
-
ticketCount: 1,
|
|
70
|
-
addGlasses: 0,
|
|
71
|
-
kbnEisyahousiki: '00',
|
|
72
|
-
mvtkNum: '',
|
|
73
|
-
mvtkKbnDenshiken: '00',
|
|
74
|
-
mvtkKbnMaeuriken: '00',
|
|
75
|
-
mvtkKbnKensyu: '00',
|
|
76
|
-
mvtkSalesPrice: 0,
|
|
77
|
-
kbnMgtk: ''
|
|
78
|
-
}
|
|
79
|
-
}],
|
|
80
|
-
appliesToSurfrock: {
|
|
81
|
-
identifier: '',
|
|
82
|
-
serviceOutput: { typeOf: '' }
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
purpose: { id: transaction.id, typeOf: client.factory.transactionType.PlaceOrder }
|
|
86
|
-
});
|
|
87
|
-
console.log('acceptTask created,', acceptTask);
|
|
88
|
-
|
|
89
|
-
const giveUpPayment = moment()
|
|
90
|
-
.add(10, 'seconds');
|
|
91
|
-
let result: { id: string } | undefined;
|
|
92
|
-
let error: any;
|
|
93
|
-
|
|
94
|
-
// n秒おきに状態確認
|
|
95
|
-
while (result === undefined && error === undefined) {
|
|
96
|
-
// n秒待機
|
|
97
|
-
await new Promise<void>((resolveWait) => {
|
|
98
|
-
setTimeout(
|
|
99
|
-
() => { resolveWait(); },
|
|
100
|
-
1000
|
|
101
|
-
);
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
// タスク作成から一定時間経過すればあきらめる
|
|
105
|
-
if (moment()
|
|
106
|
-
.isAfter(giveUpPayment)) {
|
|
107
|
-
error = new client.factory.errors.GatewayTimeout('action gaven up');
|
|
108
|
-
break;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const acceptAction = await offerService.findAcceptAction({
|
|
112
|
-
sameAs: { id: acceptTask.id },
|
|
113
|
-
purpose: { id: transaction.id, typeOf: client.factory.transactionType.PlaceOrder }
|
|
114
|
-
});
|
|
115
|
-
console.log('acceptAction:,', acceptAction);
|
|
116
|
-
|
|
117
|
-
if (typeof acceptAction.id === 'string') {
|
|
118
|
-
if (acceptAction.actionStatus === client.factory.actionStatusType.CompletedActionStatus) {
|
|
119
|
-
// ステータス完了であれば決済承認アクションIDを保管
|
|
120
|
-
result = { id: acceptAction.id };
|
|
121
|
-
break;
|
|
122
|
-
} else {
|
|
123
|
-
// 待機続行
|
|
124
|
-
}
|
|
125
|
-
}
|
|
308
|
+
try {
|
|
309
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
310
|
+
await wait(3000);
|
|
311
|
+
let authorizeOfferAction = await authorizeOfferAsync({ purpose: { id: transaction.id } })({ offerService });
|
|
312
|
+
console.log('offer authorized', authorizeOfferAction.id);
|
|
126
313
|
|
|
127
|
-
//
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
if (typeof result?.id === 'string') {
|
|
135
|
-
// no op
|
|
136
|
-
// return result;
|
|
137
|
-
} else {
|
|
138
|
-
throw error;
|
|
139
|
-
}
|
|
140
|
-
console.log('acceptAcion.result:', result);
|
|
314
|
+
// 変更
|
|
315
|
+
await wait(3000);
|
|
316
|
+
authorizeOfferAction = await authorizeOfferAsync({
|
|
317
|
+
purpose: { id: transaction.id },
|
|
318
|
+
originalAuthorizeAction: authorizeOfferAction.id
|
|
319
|
+
})({ offerService });
|
|
320
|
+
console.log('offer authorized', authorizeOfferAction.id);
|
|
141
321
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
322
|
+
// オファー承認取消
|
|
323
|
+
await wait(3000);
|
|
324
|
+
await voidAuthorizeOfferAsync({
|
|
325
|
+
purpose: { id: transaction.id },
|
|
326
|
+
originalAuthorizeAction: authorizeOfferAction.id
|
|
327
|
+
})({ offerService });
|
|
328
|
+
console.log('authorization voided', authorizeOfferAction.id);
|
|
145
329
|
|
|
146
|
-
|
|
330
|
+
// オファー再承認
|
|
331
|
+
await wait(3000);
|
|
332
|
+
authorizeOfferAction = await authorizeOfferAsync({ purpose: { id: transaction.id } })({ offerService });
|
|
333
|
+
console.log('offer authorized', authorizeOfferAction.id);
|
|
147
334
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
335
|
+
// 決済承認
|
|
336
|
+
await wait(3000);
|
|
337
|
+
console.log('authorizing credit card payment...');
|
|
338
|
+
const authorizePayment = await authorizeCreditCardAsync({
|
|
339
|
+
object: {
|
|
340
|
+
amount: Number(authorizeOfferAction.result.price),
|
|
341
|
+
paymentMethod: 'CreditCard',
|
|
342
|
+
method: '1',
|
|
343
|
+
creditCard,
|
|
344
|
+
issuedThrough: { id: '5f9a6986cc98a1eb13a90285' }
|
|
345
|
+
},
|
|
346
|
+
purpose: { id: transaction.id, typeOf: client.factory.transactionType.PlaceOrder }
|
|
347
|
+
})({ paymentService });
|
|
348
|
+
console.log('credit card payment authorized', authorizePayment.id);
|
|
157
349
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
350
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
351
|
+
await wait(3000);
|
|
352
|
+
const settingProfile: client.factory.person.IProfile = {
|
|
353
|
+
givenName: profile.givenName,
|
|
354
|
+
familyName: profile.familyName,
|
|
355
|
+
telephone: profile.telephone,
|
|
356
|
+
email: profile.email
|
|
357
|
+
};
|
|
358
|
+
console.log('setting customer profile...');
|
|
359
|
+
await placeOrderService.setProfile({ id: transaction.id, agent: settingProfile });
|
|
360
|
+
console.log('customer profile set');
|
|
161
361
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
// console.log('取引を中止します...');
|
|
169
|
-
// await placeOrderService.cancel({ id: transaction.id });
|
|
170
|
-
// console.log('取引を中止しました。');
|
|
362
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
363
|
+
await wait(3000);
|
|
364
|
+
await placeOrderService.updateObject({
|
|
365
|
+
id: transaction.id,
|
|
366
|
+
object: { name: 'order from samples' }
|
|
367
|
+
});
|
|
171
368
|
|
|
172
|
-
|
|
173
|
-
await new Promise<void>(async (resolve, reject) => {
|
|
174
|
-
setTimeout(
|
|
175
|
-
() => {
|
|
176
|
-
reject(new Error('confirming process took too long'));
|
|
177
|
-
},
|
|
178
|
-
5000
|
|
179
|
-
);
|
|
369
|
+
console.log('confirming transaction...');
|
|
180
370
|
const confirmResult = await placeOrderService.confirm({
|
|
181
371
|
id: transaction.id,
|
|
182
372
|
sendEmailMessage: true,
|
|
183
373
|
expectsMinimalResponse: true
|
|
184
|
-
// expectsReservationIds: true
|
|
185
374
|
});
|
|
186
|
-
const order = confirmResult.order;
|
|
187
375
|
console.log('transaction confirmed', confirmResult);
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
376
|
+
} catch (error) {
|
|
377
|
+
console.error(error);
|
|
378
|
+
|
|
379
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
380
|
+
await wait(3000);
|
|
381
|
+
await placeOrderService.cancel({ id: transaction.id });
|
|
382
|
+
console.log('transaction canceled');
|
|
383
|
+
}
|
|
191
384
|
}
|
|
192
385
|
|
|
193
386
|
async function wait(waitInMilliseconds: number) {
|
|
194
|
-
return new Promise((resolve) =>
|
|
387
|
+
return new Promise((resolve) => {
|
|
388
|
+
console.log('waiting...', waitInMilliseconds);
|
|
389
|
+
setTimeout(resolve, waitInMilliseconds);
|
|
390
|
+
});
|
|
195
391
|
}
|
|
196
392
|
|
|
197
393
|
main()
|
|
@@ -1,54 +1,6 @@
|
|
|
1
1
|
import * as factory from '../factory';
|
|
2
2
|
import { Service } from '../service';
|
|
3
3
|
import { IAuthorizeCOAEventServiceResult } from '../chevreTxn/transaction/placeOrder/factory';
|
|
4
|
-
export interface IPurpose {
|
|
5
|
-
typeOf: factory.transactionType;
|
|
6
|
-
id: string;
|
|
7
|
-
}
|
|
8
|
-
export declare enum FlgMember {
|
|
9
|
-
/**
|
|
10
|
-
* 非会員
|
|
11
|
-
*/
|
|
12
|
-
NonMember = "0",
|
|
13
|
-
/**
|
|
14
|
-
* 会員
|
|
15
|
-
*/
|
|
16
|
-
Member = "1"
|
|
17
|
-
}
|
|
18
|
-
export interface ICOAPointOffer {
|
|
19
|
-
/**
|
|
20
|
-
* オファーID
|
|
21
|
-
*/
|
|
22
|
-
id: string;
|
|
23
|
-
/**
|
|
24
|
-
* オファーコード
|
|
25
|
-
*/
|
|
26
|
-
identifier: string;
|
|
27
|
-
/**
|
|
28
|
-
* チケットコード
|
|
29
|
-
*/
|
|
30
|
-
ticketCode: string;
|
|
31
|
-
/**
|
|
32
|
-
* チケット名
|
|
33
|
-
*/
|
|
34
|
-
ticketName: string;
|
|
35
|
-
/**
|
|
36
|
-
* チケット名(カナ)
|
|
37
|
-
*/
|
|
38
|
-
ticketNameKana: string;
|
|
39
|
-
/**
|
|
40
|
-
* チケット名(英)
|
|
41
|
-
*/
|
|
42
|
-
ticketNameEng: string;
|
|
43
|
-
/**
|
|
44
|
-
* ポイント購入の場合の消費ポイント
|
|
45
|
-
*/
|
|
46
|
-
usePoint: number;
|
|
47
|
-
/**
|
|
48
|
-
* 会員用フラグ
|
|
49
|
-
*/
|
|
50
|
-
flgMember?: FlgMember;
|
|
51
|
-
}
|
|
52
4
|
interface IAppliesToSurfrock {
|
|
53
5
|
identifier: string;
|
|
54
6
|
serviceOutput: {
|
|
@@ -56,7 +8,7 @@ interface IAppliesToSurfrock {
|
|
|
56
8
|
};
|
|
57
9
|
}
|
|
58
10
|
/**
|
|
59
|
-
* オファーサービス
|
|
11
|
+
* COAオファーサービス
|
|
60
12
|
*/
|
|
61
13
|
export declare class OfferService extends Service {
|
|
62
14
|
acceptOffer(params: {
|
|
@@ -77,6 +29,12 @@ export declare class OfferService extends Service {
|
|
|
77
29
|
appliesToSurfrock?: IAppliesToSurfrock;
|
|
78
30
|
};
|
|
79
31
|
purpose: factory.action.authorize.offer.eventService.IPurpose;
|
|
32
|
+
potentialActions?: {
|
|
33
|
+
/**
|
|
34
|
+
* 仮予約済の場合、承認アクションIDを指定
|
|
35
|
+
*/
|
|
36
|
+
id?: string;
|
|
37
|
+
};
|
|
80
38
|
}): Promise<{
|
|
81
39
|
/**
|
|
82
40
|
* task id
|
|
@@ -87,7 +45,7 @@ export declare class OfferService extends Service {
|
|
|
87
45
|
sameAs: {
|
|
88
46
|
id: string;
|
|
89
47
|
};
|
|
90
|
-
purpose: IPurpose;
|
|
48
|
+
purpose: factory.action.authorize.offer.eventService.IPurpose;
|
|
91
49
|
}): Promise<{
|
|
92
50
|
/**
|
|
93
51
|
* 採用アクションID
|
|
@@ -106,7 +64,7 @@ export declare class OfferService extends Service {
|
|
|
106
64
|
};
|
|
107
65
|
}>;
|
|
108
66
|
/**
|
|
109
|
-
* 興行オファー承認
|
|
67
|
+
* 興行オファー承認(変更含む)
|
|
110
68
|
*/
|
|
111
69
|
authorizeEventServiceByCOA(params: {
|
|
112
70
|
acceptAction: {
|
|
@@ -118,45 +76,29 @@ export declare class OfferService extends Service {
|
|
|
118
76
|
purpose: factory.action.authorize.offer.eventService.IPurpose;
|
|
119
77
|
}): Promise<IAuthorizeCOAEventServiceResult>;
|
|
120
78
|
/**
|
|
121
|
-
* 興行オファー承認取消
|
|
79
|
+
* 興行オファー承認取消(非同期)
|
|
122
80
|
*/
|
|
123
81
|
voidAuthorizationByCOA(params: {
|
|
124
82
|
/**
|
|
125
83
|
* 承認アクションID
|
|
126
84
|
*/
|
|
127
85
|
id: string;
|
|
86
|
+
purpose: factory.action.authorize.offer.eventService.IPurpose;
|
|
87
|
+
}): Promise<{
|
|
128
88
|
/**
|
|
129
|
-
*
|
|
89
|
+
* task ID
|
|
130
90
|
*/
|
|
131
|
-
|
|
132
|
-
purposeRaw: string;
|
|
133
|
-
}): Promise<{
|
|
134
|
-
theaterCode?: string;
|
|
135
|
-
dateJouei?: string;
|
|
136
|
-
titleCode?: string;
|
|
137
|
-
titleBranchNum?: string;
|
|
138
|
-
timeBegin?: string;
|
|
139
|
-
tmpReserveNum?: string;
|
|
91
|
+
id: string;
|
|
140
92
|
}>;
|
|
141
93
|
/**
|
|
142
|
-
*
|
|
94
|
+
* 興行オファー承認取消タスク検索
|
|
143
95
|
*/
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
event: {
|
|
152
|
-
id: string;
|
|
153
|
-
};
|
|
154
|
-
};
|
|
155
|
-
/**
|
|
156
|
-
* token
|
|
157
|
-
*/
|
|
158
|
-
purpose: string;
|
|
159
|
-
purposeRaw: string;
|
|
160
|
-
}): Promise<IAuthorizeCOAEventServiceResult>;
|
|
96
|
+
findVoidTask(params: {
|
|
97
|
+
taskId: string;
|
|
98
|
+
actionId: string;
|
|
99
|
+
purpose: factory.action.authorize.offer.eventService.IPurpose;
|
|
100
|
+
}): Promise<{
|
|
101
|
+
status: factory.taskStatus;
|
|
102
|
+
}>;
|
|
161
103
|
}
|
|
162
104
|
export {};
|