@cinerino/sdk 12.12.1 → 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.
- package/example/src/chevre/admic/syncEventSeries.ts +44 -0
- package/example/src/chevre/admic/syncEvents.ts +46 -0
- package/example/src/chevre/admin/adminAcceptedPaymentMethods.ts +85 -21
- package/example/src/chevre/{adminScreeningEventSeries.ts → admin/adminEventSeries.ts} +4 -4
- package/example/src/cloud/transaction/authorizeCreditCardAsyncForcibly.ts +6 -0
- package/example/src/cloud/transaction/processPlaceOrderByCreditCard3DS.ts +28 -5
- package/example/src/cloud/transaction/processPlaceOrderCOAEventByCreditCard.ts +4 -2
- package/example/src/cloud/transaction/processPlaceOrderUsingMemberProgramTier.ts +2 -1
- package/example/src/cloud/transaction/processPlaceOrderUsingTicketIssuedThroughCreditCard.ts +2 -1
- package/lib/abstract/chevreAdmic/sync.d.ts +22 -0
- package/lib/abstract/chevreAdmic/sync.js +102 -0
- package/lib/abstract/chevreAdmic.d.ts +17 -0
- package/lib/abstract/chevreAdmic.js +83 -0
- package/lib/abstract/chevreAdmin/eventSeries.d.ts +25 -0
- package/lib/abstract/chevreAdmin/eventSeries.js +22 -2
- package/lib/abstract/chevreConsole/eventSeries.d.ts +2 -1
- package/lib/abstract/chevreConsole/eventSeries.js +2 -1
- package/lib/abstract/chevrePay/payment.d.ts +12 -0
- package/lib/abstract/chevrePay/payment.js +10 -6
- package/lib/abstract/cloud/pay/payment.d.ts +12 -0
- package/lib/abstract/cloud/pay/payment.js +26 -16
- package/lib/abstract/index.d.ts +3 -1
- package/lib/abstract/index.js +24 -1
- package/lib/bundle.js +926 -674
- package/lib/index.d.ts +2 -2
- package/lib/index.js +2 -1
- package/package.json +2 -2
- package/example/src/chevre/transaction/processPlaceOrderCOA.ts +0 -403
package/lib/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* API Node.js Client
|
|
3
3
|
*/
|
|
4
|
-
import { chevre, chevreAdmin, chevreAsset, chevreConsole, chevrePay, chevreTxc, chevreTxn, cloudAdmin, cloudAsset, cloudPay, cloudSearch, cloudTxc, cloudTxn, factory, loadChevre, loadChevreAdmin, loadChevreAsset, loadChevreConsole, loadChevrePay, loadChevreTxc, loadChevreTxn, loadCloudAdmin, loadCloudAsset, loadCloudPay, loadCloudSearch, loadCloudTxc, loadCloudTxn, loadPecorino, loadService, loadWaiterAdmin, pecorino, service, transporters, waiterAdmin } from './abstract';
|
|
4
|
+
import { chevre, chevreAdmic, chevreAdmin, chevreAsset, chevreConsole, chevrePay, chevreTxc, chevreTxn, cloudAdmin, cloudAsset, cloudPay, cloudSearch, cloudTxc, cloudTxn, factory, loadChevre, loadChevreAdmic, loadChevreAdmin, loadChevreAsset, loadChevreConsole, loadChevrePay, loadChevreTxc, loadChevreTxn, loadCloudAdmin, loadCloudAsset, loadCloudPay, loadCloudSearch, loadCloudTxc, loadCloudTxn, loadPecorino, loadService, loadWaiterAdmin, pecorino, service, transporters, waiterAdmin } from './abstract';
|
|
5
5
|
import type ClientCredentialsClient from './auth/clientCredentialsClient';
|
|
6
6
|
import type { ImplicitGrantClient, IOptions as IImplicitGrantClientOptions } from './auth/implicitGrantClient';
|
|
7
7
|
import type OAuth2client from './auth/oAuth2client';
|
|
8
|
-
export { loadChevre, loadChevreAdmin, loadChevreAsset, loadChevreConsole, loadChevrePay, loadChevreTxc, loadChevreTxn, loadCloudAdmin, loadCloudAsset, loadCloudPay, loadCloudSearch, loadCloudTxc, loadCloudTxn, loadPecorino, loadService, loadWaiterAdmin, chevre, chevreAdmin, chevreAsset, chevreConsole, chevrePay, chevreTxc, chevreTxn, cloudAdmin, cloudAsset, cloudPay, cloudSearch, cloudTxc, cloudTxn, pecorino, service, factory, transporters, waiterAdmin };
|
|
8
|
+
export { loadChevre, loadChevreAdmic, loadChevreAdmin, loadChevreAsset, loadChevreConsole, loadChevrePay, loadChevreTxc, loadChevreTxn, loadCloudAdmin, loadCloudAsset, loadCloudPay, loadCloudSearch, loadCloudTxc, loadCloudTxn, loadPecorino, loadService, loadWaiterAdmin, chevre, chevreAdmic, chevreAdmin, chevreAsset, chevreConsole, chevrePay, chevreTxc, chevreTxn, cloudAdmin, cloudAsset, cloudPay, cloudSearch, cloudTxc, cloudTxn, pecorino, service, factory, transporters, waiterAdmin };
|
|
9
9
|
/**
|
|
10
10
|
* each OAuth2 clients
|
|
11
11
|
*/
|
package/lib/index.js
CHANGED
|
@@ -41,13 +41,14 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
|
41
41
|
return to;
|
|
42
42
|
};
|
|
43
43
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
-
exports.createAuthInstance = exports.auth = exports.transporters = exports.factory = exports.loadWaiterAdmin = exports.loadService = exports.loadPecorino = exports.loadCloudTxn = exports.loadCloudTxc = exports.loadCloudSearch = exports.loadCloudPay = exports.loadCloudAsset = exports.loadCloudAdmin = exports.loadChevreTxn = exports.loadChevreTxc = exports.loadChevrePay = exports.loadChevreConsole = exports.loadChevreAsset = exports.loadChevreAdmin = exports.loadChevre = void 0;
|
|
44
|
+
exports.createAuthInstance = exports.auth = exports.transporters = exports.factory = exports.loadWaiterAdmin = exports.loadService = exports.loadPecorino = exports.loadCloudTxn = exports.loadCloudTxc = exports.loadCloudSearch = exports.loadCloudPay = exports.loadCloudAsset = exports.loadCloudAdmin = exports.loadChevreTxn = exports.loadChevreTxc = exports.loadChevrePay = exports.loadChevreConsole = exports.loadChevreAsset = exports.loadChevreAdmin = exports.loadChevreAdmic = exports.loadChevre = void 0;
|
|
45
45
|
/**
|
|
46
46
|
* API Node.js Client
|
|
47
47
|
*/
|
|
48
48
|
var abstract_1 = require("./abstract");
|
|
49
49
|
Object.defineProperty(exports, "factory", { enumerable: true, get: function () { return abstract_1.factory; } });
|
|
50
50
|
Object.defineProperty(exports, "loadChevre", { enumerable: true, get: function () { return abstract_1.loadChevre; } });
|
|
51
|
+
Object.defineProperty(exports, "loadChevreAdmic", { enumerable: true, get: function () { return abstract_1.loadChevreAdmic; } });
|
|
51
52
|
Object.defineProperty(exports, "loadChevreAdmin", { enumerable: true, get: function () { return abstract_1.loadChevreAdmin; } });
|
|
52
53
|
Object.defineProperty(exports, "loadChevreAsset", { enumerable: true, get: function () { return abstract_1.loadChevreAsset; } });
|
|
53
54
|
Object.defineProperty(exports, "loadChevreConsole", { enumerable: true, get: function () { return abstract_1.loadChevreConsole; } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cinerino/sdk",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.13.0-alpha.1",
|
|
4
4
|
"description": "Cinerino SDK",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"browser": {
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"watchify": "^3.11.1"
|
|
94
94
|
},
|
|
95
95
|
"dependencies": {
|
|
96
|
-
"@chevre/factory": "5.4.0-alpha.
|
|
96
|
+
"@chevre/factory": "5.4.0-alpha.5",
|
|
97
97
|
"debug": "3.2.7",
|
|
98
98
|
"http-status": "1.7.4",
|
|
99
99
|
"idtoken-verifier": "2.0.3",
|
|
@@ -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);
|