@cinerino/sdk 10.5.0 → 10.6.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/example/playground/public/lib/bundle.js +57 -3
- package/example/src/chevre/transaction/processPlaceOrder.ts +75 -52
- package/example/src/chevre/transaction/{processPlaceOrderUsingMembership.ts → processPlaceOrderUsingTicketIssuedThroughFaceToFace.ts} +35 -14
- package/example/src/cloud/transaction/authorizeCreditCardAsyncForcibly.ts +74 -0
- package/example/src/cloud/transaction/processPlaceOrderUsingTicketIssuedThroughCreditCard.ts +239 -0
- package/example/src/cloud/transaction/processPlaceOrderUsingTicketIssuedThroughFaceToFace.ts +2 -2
- package/lib/abstract/chevre/seller/factory.d.ts +9 -1
- package/lib/abstract/chevreAdmin/seller/factory.d.ts +0 -1
- package/lib/abstract/chevreAdmin/seller.d.ts +2 -1
- package/lib/abstract/chevrePay/payment/factory.d.ts +1 -1
- package/lib/abstract/chevrePay/payment.d.ts +11 -0
- package/lib/abstract/chevrePay/payment.js +22 -1
- package/lib/abstract/cloud/pay/payment.d.ts +14 -0
- package/lib/abstract/cloud/pay/payment.js +28 -0
- package/lib/bundle.js +51 -2
- package/package.json +2 -2
|
@@ -13042,15 +13042,38 @@ var PaymentService = /** @class */ (function (_super) {
|
|
|
13042
13042
|
};
|
|
13043
13043
|
PaymentService.prototype.issueTicketThroughFaceToFace = function (params) {
|
|
13044
13044
|
return __awaiter(this, void 0, void 0, function () {
|
|
13045
|
+
var purpose;
|
|
13045
13046
|
var _this = this;
|
|
13046
13047
|
return __generator(this, function (_a) {
|
|
13048
|
+
purpose = params.purpose;
|
|
13047
13049
|
return [2 /*return*/, this.fetch({
|
|
13048
13050
|
uri: "/payment/" + factory.service.paymentService.PaymentServiceType.FaceToFace + "/tickets",
|
|
13049
13051
|
method: 'POST',
|
|
13050
13052
|
expectedStatusCodes: [http_status_1.CREATED],
|
|
13051
|
-
body:
|
|
13053
|
+
body: { purpose: purpose },
|
|
13052
13054
|
qs: {
|
|
13053
|
-
purpose: { id: params.purpose.id }
|
|
13055
|
+
purpose: { id: params.purpose.id }
|
|
13056
|
+
}
|
|
13057
|
+
})
|
|
13058
|
+
.then(function (response) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
13059
|
+
return [2 /*return*/, response.json()];
|
|
13060
|
+
}); }); })];
|
|
13061
|
+
});
|
|
13062
|
+
});
|
|
13063
|
+
};
|
|
13064
|
+
PaymentService.prototype.issueTicketThroughCreditCard = function (params) {
|
|
13065
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
13066
|
+
var purpose, ticketedPermit;
|
|
13067
|
+
var _this = this;
|
|
13068
|
+
return __generator(this, function (_a) {
|
|
13069
|
+
purpose = params.purpose, ticketedPermit = params.ticketedPermit;
|
|
13070
|
+
return [2 /*return*/, this.fetch({
|
|
13071
|
+
uri: "/payment/" + factory.service.paymentService.PaymentServiceType.CreditCard + "/tickets",
|
|
13072
|
+
method: 'POST',
|
|
13073
|
+
expectedStatusCodes: [http_status_1.CREATED],
|
|
13074
|
+
body: { purpose: purpose, ticketedPermit: ticketedPermit },
|
|
13075
|
+
qs: {
|
|
13076
|
+
purpose: { id: params.purpose.id }
|
|
13054
13077
|
}
|
|
13055
13078
|
})
|
|
13056
13079
|
.then(function (response) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
@@ -20703,6 +20726,9 @@ var PaymentService = /** @class */ (function (_super) {
|
|
|
20703
20726
|
});
|
|
20704
20727
|
});
|
|
20705
20728
|
};
|
|
20729
|
+
/**
|
|
20730
|
+
* 対面決済によるチケット発行
|
|
20731
|
+
*/
|
|
20706
20732
|
PaymentService.prototype.issueTicketThroughFaceToFace = function (params) {
|
|
20707
20733
|
return __awaiter(this, void 0, void 0, function () {
|
|
20708
20734
|
var _a, auth, endpoint, project, seller, disableAutoRetry, retryableStatusCodes, chevrePay, paymentService;
|
|
@@ -20728,6 +20754,34 @@ var PaymentService = /** @class */ (function (_super) {
|
|
|
20728
20754
|
});
|
|
20729
20755
|
});
|
|
20730
20756
|
};
|
|
20757
|
+
/**
|
|
20758
|
+
* CreditCardIF決済によるチケット発行
|
|
20759
|
+
*/
|
|
20760
|
+
PaymentService.prototype.issueTicketThroughCreditCard = function (params) {
|
|
20761
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
20762
|
+
var _a, auth, endpoint, project, seller, disableAutoRetry, retryableStatusCodes, chevrePay, paymentService;
|
|
20763
|
+
return __generator(this, function (_b) {
|
|
20764
|
+
switch (_b.label) {
|
|
20765
|
+
case 0:
|
|
20766
|
+
_a = this.options, auth = _a.auth, endpoint = _a.endpoint, project = _a.project, seller = _a.seller, disableAutoRetry = _a.disableAutoRetry, retryableStatusCodes = _a.retryableStatusCodes;
|
|
20767
|
+
return [4 /*yield*/, index_1.loadChevrePay({ auth: auth, endpoint: endpoint, disableAutoRetry: disableAutoRetry })];
|
|
20768
|
+
case 1:
|
|
20769
|
+
chevrePay = _b.sent();
|
|
20770
|
+
return [4 /*yield*/, chevrePay.createPaymentInstance({
|
|
20771
|
+
project: project,
|
|
20772
|
+
seller: { id: (typeof (seller === null || seller === void 0 ? void 0 : seller.id) === 'string') ? seller.id : '' },
|
|
20773
|
+
retryableStatusCodes: __spreadArray(__spreadArray([], (Array.isArray(retryableStatusCodes)) ? retryableStatusCodes : []), [
|
|
20774
|
+
http_status_1.CONFLICT,
|
|
20775
|
+
http_status_1.TOO_MANY_REQUESTS
|
|
20776
|
+
])
|
|
20777
|
+
})];
|
|
20778
|
+
case 2:
|
|
20779
|
+
paymentService = _b.sent();
|
|
20780
|
+
return [2 /*return*/, paymentService.issueTicketThroughCreditCard(params)];
|
|
20781
|
+
}
|
|
20782
|
+
});
|
|
20783
|
+
});
|
|
20784
|
+
};
|
|
20731
20785
|
return PaymentService;
|
|
20732
20786
|
}(service_1.Service));
|
|
20733
20787
|
exports.PaymentService = PaymentService;
|
|
@@ -25211,7 +25265,7 @@ var CategorySetIdentifier;
|
|
|
25211
25265
|
*/
|
|
25212
25266
|
CategorySetIdentifier["DistributorType"] = "DistributorType";
|
|
25213
25267
|
/**
|
|
25214
|
-
*
|
|
25268
|
+
* メンバーシップ区分
|
|
25215
25269
|
*/
|
|
25216
25270
|
CategorySetIdentifier["MembershipType"] = "MembershipType";
|
|
25217
25271
|
/**
|
|
@@ -30,13 +30,6 @@ async function main() {
|
|
|
30
30
|
})).createSellerInstance({
|
|
31
31
|
project
|
|
32
32
|
});
|
|
33
|
-
const placeOrderService = await (await client.loadChevreTxn({
|
|
34
|
-
endpoint: `${<string>process.env.CHEVRE_ENDPOINT}/txn`,
|
|
35
|
-
auth: authClient
|
|
36
|
-
})).createPlaceOrderTransactionInstance({
|
|
37
|
-
project,
|
|
38
|
-
seller: { id: '' }
|
|
39
|
-
});
|
|
40
33
|
|
|
41
34
|
console.log('finding profile...');
|
|
42
35
|
// const profile = await personService.getProfile({ personId: 'me' });
|
|
@@ -47,12 +40,34 @@ async function main() {
|
|
|
47
40
|
branchCode: { $eq: '001' },
|
|
48
41
|
$projection: {}
|
|
49
42
|
});
|
|
50
|
-
|
|
51
|
-
const seller = searchSellersResult.data[Math.floor(searchSellersResult.data.length * Math.random())];
|
|
43
|
+
const seller = searchSellersResult.data.shift();
|
|
52
44
|
if (seller === undefined) {
|
|
53
45
|
throw new Error('No seller');
|
|
54
46
|
}
|
|
55
47
|
console.log('ordering from seller...', (<client.factory.multilingualString>seller.name).ja);
|
|
48
|
+
const sellerId = String(seller.id);
|
|
49
|
+
|
|
50
|
+
const placeOrderService = await (await client.loadChevreTxn({
|
|
51
|
+
endpoint: <string>process.env.CHEVRE_ENDPOINT_TXN,
|
|
52
|
+
auth: authClient
|
|
53
|
+
})).createPlaceOrderTransactionInstance({
|
|
54
|
+
project,
|
|
55
|
+
seller: { id: sellerId }
|
|
56
|
+
});
|
|
57
|
+
const offerService = await (await client.loadChevreTxn({
|
|
58
|
+
endpoint: <string>process.env.CHEVRE_ENDPOINT_TXN,
|
|
59
|
+
auth: authClient
|
|
60
|
+
})).createOfferInstance({
|
|
61
|
+
project,
|
|
62
|
+
seller: { id: sellerId }
|
|
63
|
+
});
|
|
64
|
+
const paymentService = await (await client.loadChevrePay({
|
|
65
|
+
endpoint: <string>process.env.CHEVRE_ENDPOINT_PAY,
|
|
66
|
+
auth: authClient
|
|
67
|
+
})).createPaymentInstance({
|
|
68
|
+
project,
|
|
69
|
+
seller: { id: sellerId }
|
|
70
|
+
});
|
|
56
71
|
|
|
57
72
|
console.log('starting transaction...');
|
|
58
73
|
const transaction = await placeOrderService.start({
|
|
@@ -61,24 +76,7 @@ async function main() {
|
|
|
61
76
|
{
|
|
62
77
|
name: 'SampleName',
|
|
63
78
|
value: 'SampleValue'
|
|
64
|
-
}
|
|
65
|
-
...(typeof process.env.LINE_NOTIFY_URL === 'string' && process.env.LINE_NOTIFY_URL.length > 0)
|
|
66
|
-
? [
|
|
67
|
-
{
|
|
68
|
-
name: 'onOrderPlaced.recipient.url',
|
|
69
|
-
value: process.env.LINE_NOTIFY_URL
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
name: 'onOrderPlaced.object.customer.identifier',
|
|
73
|
-
value: 'onOrderPlaced.object.customer.identifier.value1'
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
name: 'onOrderPlaced.object.customer.identifier',
|
|
77
|
-
value: 'onOrderPlaced.object.customer.identifier.value2'
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
]
|
|
81
|
-
: []
|
|
79
|
+
}
|
|
82
80
|
]
|
|
83
81
|
},
|
|
84
82
|
seller: {
|
|
@@ -90,9 +88,55 @@ async function main() {
|
|
|
90
88
|
});
|
|
91
89
|
console.log('transaction started', transaction.id);
|
|
92
90
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
91
|
+
await wait(3000);
|
|
92
|
+
|
|
93
|
+
// オファー承認
|
|
94
|
+
await offerService.authorizeEventService({
|
|
95
|
+
object: {
|
|
96
|
+
reservationFor: {
|
|
97
|
+
id: 'blxd1gryb'
|
|
98
|
+
},
|
|
99
|
+
acceptedOffer: [{
|
|
100
|
+
id: '3001', // 0yen offer
|
|
101
|
+
itemOffered: {
|
|
102
|
+
serviceOutput: {
|
|
103
|
+
typeOf: client.factory.reservationType.EventReservation,
|
|
104
|
+
reservedTicket: {
|
|
105
|
+
typeOf: 'Ticket',
|
|
106
|
+
ticketedSeat: {
|
|
107
|
+
typeOf: client.factory.placeType.Seat,
|
|
108
|
+
seatNumber: 'B-3',
|
|
109
|
+
seatSection: 'Default',
|
|
110
|
+
seatRow: ''
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
// programMembershipUsed: {
|
|
114
|
+
// ticketToken: 'a1b8a25c-188c-4ba4-8d12-639d3a20dc7d',
|
|
115
|
+
// typeOf: 'Ticket'
|
|
116
|
+
// }
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}]
|
|
120
|
+
},
|
|
121
|
+
purpose: { id: transaction.id, typeOf: client.factory.transactionType.PlaceOrder }
|
|
122
|
+
});
|
|
123
|
+
console.log('offer authorized');
|
|
124
|
+
|
|
125
|
+
await wait(3000);
|
|
126
|
+
|
|
127
|
+
// 決済承認
|
|
128
|
+
await paymentService.authorizeAnyPayment({
|
|
129
|
+
object: {
|
|
130
|
+
amount: 0,
|
|
131
|
+
issuedThrough: { id: '' },
|
|
132
|
+
paymentMethod: 'Cash'
|
|
133
|
+
// ticketToken
|
|
134
|
+
},
|
|
135
|
+
purpose: { id: transaction.id, typeOf: client.factory.transactionType.PlaceOrder }
|
|
136
|
+
});
|
|
137
|
+
console.log('payment authorized');
|
|
138
|
+
|
|
139
|
+
await wait(3000);
|
|
96
140
|
|
|
97
141
|
const settingProfile: client.factory.person.IProfile = {
|
|
98
142
|
givenName: 'Taro',
|
|
@@ -104,28 +148,7 @@ async function main() {
|
|
|
104
148
|
await placeOrderService.setProfile({ id: transaction.id, agent: settingProfile });
|
|
105
149
|
console.log('customer profile set');
|
|
106
150
|
|
|
107
|
-
|
|
108
|
-
// setInterval(
|
|
109
|
-
// async () => {
|
|
110
|
-
// i += 1;
|
|
111
|
-
// try {
|
|
112
|
-
// console.log('setting customer profile...');
|
|
113
|
-
// await placeOrderService.setProfile({ id: transaction.id, agent: settingProfile });
|
|
114
|
-
// console.log('customer profile set');
|
|
115
|
-
|
|
116
|
-
// } catch (error) {
|
|
117
|
-
// console.error('setting profile failed.', error.message);
|
|
118
|
-
// }
|
|
119
|
-
// },
|
|
120
|
-
// // tslint:disable-next-line:no-magic-numbers
|
|
121
|
-
// 500
|
|
122
|
-
// );
|
|
123
|
-
|
|
124
|
-
// return;
|
|
125
|
-
|
|
126
|
-
// 購入情報確認時間
|
|
127
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
128
|
-
await wait(5000);
|
|
151
|
+
await wait(3000);
|
|
129
152
|
|
|
130
153
|
await placeOrderService.updateObject({
|
|
131
154
|
id: transaction.id,
|
|
@@ -36,8 +36,7 @@ async function main() {
|
|
|
36
36
|
branchCode: { $eq: '001' },
|
|
37
37
|
$projection: {}
|
|
38
38
|
});
|
|
39
|
-
|
|
40
|
-
const seller = searchSellersResult.data[Math.floor(searchSellersResult.data.length * Math.random())];
|
|
39
|
+
const seller = searchSellersResult.data.shift();
|
|
41
40
|
if (seller === undefined) {
|
|
42
41
|
throw new Error('No seller');
|
|
43
42
|
}
|
|
@@ -100,7 +99,7 @@ async function main() {
|
|
|
100
99
|
id: 'blxd1gryb'
|
|
101
100
|
},
|
|
102
101
|
acceptedOffer: [{
|
|
103
|
-
id: 'bkpnwjw1w', //
|
|
102
|
+
id: 'bkpnwjw1w', // メンバーシップ対象オファーを指定
|
|
104
103
|
itemOffered: {
|
|
105
104
|
serviceOutput: {
|
|
106
105
|
typeOf: client.factory.reservationType.EventReservation,
|
|
@@ -108,7 +107,7 @@ async function main() {
|
|
|
108
107
|
typeOf: 'Ticket',
|
|
109
108
|
ticketedSeat: {
|
|
110
109
|
typeOf: client.factory.placeType.Seat,
|
|
111
|
-
seatNumber: 'B-
|
|
110
|
+
seatNumber: 'B-3',
|
|
112
111
|
seatSection: 'Default',
|
|
113
112
|
seatRow: ''
|
|
114
113
|
}
|
|
@@ -129,10 +128,11 @@ async function main() {
|
|
|
129
128
|
|
|
130
129
|
await wait(3000);
|
|
131
130
|
|
|
132
|
-
// 決済承認
|
|
131
|
+
// YEN決済承認
|
|
133
132
|
await paymentService.authorizeAnyPayment({
|
|
134
133
|
object: {
|
|
135
|
-
amount: 999,
|
|
134
|
+
// amount: 999,
|
|
135
|
+
amount: 0,
|
|
136
136
|
issuedThrough: { id: '' },
|
|
137
137
|
paymentMethod: 'Cash',
|
|
138
138
|
ticketToken // チケット指定
|
|
@@ -143,6 +143,19 @@ async function main() {
|
|
|
143
143
|
|
|
144
144
|
await wait(3000);
|
|
145
145
|
|
|
146
|
+
// ポイント決済承認
|
|
147
|
+
await paymentService.authorizeAnyPayment({
|
|
148
|
+
object: {
|
|
149
|
+
amount: 999,
|
|
150
|
+
issuedThrough: { id: '' },
|
|
151
|
+
paymentMethod: 'PointCard'
|
|
152
|
+
},
|
|
153
|
+
purpose: { id: transaction.id, typeOf: client.factory.transactionType.PlaceOrder }
|
|
154
|
+
});
|
|
155
|
+
console.log('payment authorized');
|
|
156
|
+
|
|
157
|
+
await wait(3000);
|
|
158
|
+
|
|
146
159
|
const settingProfile: client.factory.person.IProfile = {
|
|
147
160
|
givenName: profile.givenName,
|
|
148
161
|
familyName: profile.familyName,
|
|
@@ -155,14 +168,22 @@ async function main() {
|
|
|
155
168
|
|
|
156
169
|
await wait(3000);
|
|
157
170
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
171
|
+
try {
|
|
172
|
+
console.log('confirming transaction...');
|
|
173
|
+
const confirmResult = await placeOrderService.confirm({
|
|
174
|
+
id: transaction.id,
|
|
175
|
+
sendEmailMessage: true,
|
|
176
|
+
expectsMinimalResponse: true
|
|
177
|
+
// expectsReservationIds: true
|
|
178
|
+
});
|
|
179
|
+
console.log('transaction confirmed', confirmResult);
|
|
180
|
+
} catch (error) {
|
|
181
|
+
console.error(error);
|
|
182
|
+
console.log('canceling transaction...');
|
|
183
|
+
await wait(3000);
|
|
184
|
+
await placeOrderService.cancel({ id: transaction.id });
|
|
185
|
+
console.log('transaction canceled');
|
|
186
|
+
}
|
|
166
187
|
}
|
|
167
188
|
|
|
168
189
|
async function wait(waitInMilliseconds: number) {
|
|
@@ -0,0 +1,74 @@
|
|
|
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
|
+
async function wait(waitInMilliseconds: number) {
|
|
6
|
+
return new Promise((resolve) => setTimeout(resolve, waitInMilliseconds));
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const USE_FORCE_AUTHORIZE_PAYMENT_ASYNC_GIVE_UP_SECONDS = 10;
|
|
10
|
+
const USE_FORCE_AUTHORIZE_PAYMENT_ASYNC_CHECK_INTERVAL_MS = 1000;
|
|
11
|
+
export function authorizeCreditCardAsyncForcibly(params: {
|
|
12
|
+
object: Pick<
|
|
13
|
+
client.factory.action.authorize.paymentMethod.any.IObjectWithoutDetail,
|
|
14
|
+
'amount' | 'issuedThrough' | 'paymentMethod' | 'creditCard' | 'method' | 'paymentMethodId' | 'name' | 'additionalProperty' | 'ticketToken'
|
|
15
|
+
>;
|
|
16
|
+
purpose: {
|
|
17
|
+
typeOf: client.factory.transactionType.PlaceOrder;
|
|
18
|
+
id: string;
|
|
19
|
+
};
|
|
20
|
+
}) {
|
|
21
|
+
return async (repos: {
|
|
22
|
+
paymentService: client.cloudPay.service.Payment;
|
|
23
|
+
}): Promise<{ id: string }> => {
|
|
24
|
+
// 決済承認タスク作成
|
|
25
|
+
const authorizeTask = await repos.paymentService.authorizeCreditCardAsync(params);
|
|
26
|
+
const giveUpPayment = moment()
|
|
27
|
+
.add(USE_FORCE_AUTHORIZE_PAYMENT_ASYNC_GIVE_UP_SECONDS, 'seconds');
|
|
28
|
+
let result: { id: string } | undefined;
|
|
29
|
+
let error: { name?: string; message?: string } | undefined;
|
|
30
|
+
|
|
31
|
+
// n秒おきに状態確認
|
|
32
|
+
while (result === undefined && error === undefined) {
|
|
33
|
+
await wait(USE_FORCE_AUTHORIZE_PAYMENT_ASYNC_CHECK_INTERVAL_MS); // n秒待機
|
|
34
|
+
|
|
35
|
+
// タスク作成から一定時間経過すればあきらめる
|
|
36
|
+
if (moment()
|
|
37
|
+
.isAfter(giveUpPayment)) {
|
|
38
|
+
error = new client.factory.errors.GatewayTimeout('action given up');
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const authorizeAction = await repos.paymentService.findAuthorizeAction({
|
|
43
|
+
sameAs: { id: authorizeTask.id },
|
|
44
|
+
object: {
|
|
45
|
+
typeOf: client.factory.service.paymentService.PaymentServiceType.CreditCard
|
|
46
|
+
},
|
|
47
|
+
purpose: params.purpose
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// アクションIDが存在し、CompletedActionStatusであればタスク完了とみなす
|
|
51
|
+
if (typeof authorizeAction.id === 'string') {
|
|
52
|
+
if (authorizeAction.actionStatus === client.factory.actionStatusType.CompletedActionStatus) {
|
|
53
|
+
// ステータス完了であれば決済承認アクションIDを保管
|
|
54
|
+
result = { id: authorizeAction.id };
|
|
55
|
+
break;
|
|
56
|
+
} else {
|
|
57
|
+
// 待機続行
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// エラーが存在すれば、これ以上待機する価値はなし
|
|
62
|
+
if (authorizeAction.error !== undefined) {
|
|
63
|
+
error = authorizeAction.error;
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (typeof result?.id === 'string') {
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
throw error;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
// tslint:disable:no-console no-implicit-dependencies no-magic-numbers
|
|
2
|
+
import * as client from '../../../../lib/index';
|
|
3
|
+
import { auth } from '../../auth/clientCredentials';
|
|
4
|
+
import { authorizeCreditCardAsyncForcibly } from './authorizeCreditCardAsyncForcibly';
|
|
5
|
+
|
|
6
|
+
const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 出力メンバーシップを持つ決済サービスID
|
|
10
|
+
*/
|
|
11
|
+
const PAYMENT_SERVICE_ID = '64f193ad5e79fe8a06ca3156';
|
|
12
|
+
/**
|
|
13
|
+
* 予約対象イベントID
|
|
14
|
+
*/
|
|
15
|
+
const EVENT_ID = 'blxd1gryf';
|
|
16
|
+
const profile = {
|
|
17
|
+
email: <string>process.env.TEST_PROFILE_EMAIL,
|
|
18
|
+
givenName: 'Taro',
|
|
19
|
+
familyName: 'SDK',
|
|
20
|
+
name: 'Taro ☆ SDK',
|
|
21
|
+
telephone: '+819012345678'
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// 取引に使用するクレジットカード
|
|
25
|
+
const creditCard = {
|
|
26
|
+
cardNo: '4111111111111111',
|
|
27
|
+
expire: '2412',
|
|
28
|
+
holderName: 'AA BB'
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 対面決済とメンバーシップを使用した注文取引
|
|
33
|
+
* 基本的な考え方
|
|
34
|
+
*
|
|
35
|
+
* マスタ管理として
|
|
36
|
+
* - 区分管理でメンバーシップ区分を定義
|
|
37
|
+
* - 単価オファーに対象メンバーシップを設定
|
|
38
|
+
*
|
|
39
|
+
* の上で、取引は↓の流れ
|
|
40
|
+
* - 決済サービスを使用してメンバーシップチケットを発行する
|
|
41
|
+
* - 興行オファー承認時にチケットを適用する
|
|
42
|
+
* - 決済承認時にもチケットを適用する
|
|
43
|
+
*
|
|
44
|
+
* バックエンドでは↓が検証されます
|
|
45
|
+
* - 対象メンバーシップの設定されたオファーは、チケットを適用しなければ承認をとれない
|
|
46
|
+
* - チケット適用のオファー承認が取引に存在する場合、チケットを適用した決済承認が存在しなければ取引を確定できない
|
|
47
|
+
*/
|
|
48
|
+
// tslint:disable-next-line:max-func-body-length
|
|
49
|
+
async function main() {
|
|
50
|
+
const authClient = await auth();
|
|
51
|
+
|
|
52
|
+
const sellerService = new (await client.loadService()).Seller({
|
|
53
|
+
endpoint: <string>process.env.API_ENDPOINT,
|
|
54
|
+
auth: authClient,
|
|
55
|
+
project
|
|
56
|
+
});
|
|
57
|
+
const searchSellersResult = await sellerService.search({
|
|
58
|
+
branchCode: { $eq: '001' },
|
|
59
|
+
$projection: {}
|
|
60
|
+
});
|
|
61
|
+
const seller = searchSellersResult.data.shift();
|
|
62
|
+
if (seller === undefined) {
|
|
63
|
+
throw new Error('No seller');
|
|
64
|
+
}
|
|
65
|
+
console.log('ordering from seller...', (<client.factory.multilingualString>seller.name).ja);
|
|
66
|
+
const sellerId = String(seller.id);
|
|
67
|
+
|
|
68
|
+
const searchPaymentServicesResult = await sellerService.searchPaymentServices({
|
|
69
|
+
id: sellerId,
|
|
70
|
+
qs: {
|
|
71
|
+
limit: 100,
|
|
72
|
+
page: 1,
|
|
73
|
+
typeOf: { $eq: client.factory.service.paymentService.PaymentServiceType.CreditCard }
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
// 出力メンバーシップを持つ決済サービスが存在するか?
|
|
78
|
+
const paymentServicesWithPermitAsOutput = searchPaymentServicesResult.data.filter(({ serviceOutput }) => {
|
|
79
|
+
return serviceOutput?.some(({ typeOf }) => typeOf === client.factory.permit.PermitType.Permit);
|
|
80
|
+
});
|
|
81
|
+
console.log(paymentServicesWithPermitAsOutput.length, '個の出力メンバーシップを持つ決済サービスが存在します');
|
|
82
|
+
const membershipTypesFromPaymentService = paymentServicesWithPermitAsOutput.map(({ serviceOutput }) => {
|
|
83
|
+
let membershipType: string | undefined;
|
|
84
|
+
serviceOutput?.forEach((output) => {
|
|
85
|
+
if (output.typeOf === client.factory.permit.PermitType.Permit) {
|
|
86
|
+
membershipType = output.issuedThrough.serviceType.codeValue;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
return membershipType;
|
|
91
|
+
});
|
|
92
|
+
console.log('利用可能な出力メンバーシップ区分:', membershipTypesFromPaymentService);
|
|
93
|
+
|
|
94
|
+
const eventService = new (await client.loadService()).Event({
|
|
95
|
+
endpoint: <string>process.env.API_ENDPOINT,
|
|
96
|
+
auth: authClient,
|
|
97
|
+
project,
|
|
98
|
+
seller: { id: sellerId }
|
|
99
|
+
});
|
|
100
|
+
const placeOrderService = await (await client.loadCloudTxn({
|
|
101
|
+
endpoint: <string>process.env.API_TXN_ENDPOINT,
|
|
102
|
+
auth: authClient
|
|
103
|
+
})).createPlaceOrderInstance({
|
|
104
|
+
project,
|
|
105
|
+
seller: { id: sellerId }
|
|
106
|
+
});
|
|
107
|
+
const paymentService = await (await client.loadCloudPay({
|
|
108
|
+
endpoint: <string>process.env.API_PAY_ENDPOINT,
|
|
109
|
+
auth: authClient
|
|
110
|
+
})).createPaymentInstance({
|
|
111
|
+
project,
|
|
112
|
+
seller: { id: sellerId }
|
|
113
|
+
});
|
|
114
|
+
const offerService = await (await client.loadCloudTxn({
|
|
115
|
+
endpoint: <string>process.env.API_TXN_ENDPOINT,
|
|
116
|
+
auth: authClient
|
|
117
|
+
})).createOfferInstance({
|
|
118
|
+
project,
|
|
119
|
+
seller: { id: sellerId }
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
console.log('starting transaction...');
|
|
123
|
+
const transaction = await placeOrderService.start({
|
|
124
|
+
seller: { id: String(seller.id) },
|
|
125
|
+
object: {
|
|
126
|
+
// passport: { token: passportToken }
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
console.log('transaction started', transaction.id);
|
|
130
|
+
|
|
131
|
+
await wait(3000);
|
|
132
|
+
|
|
133
|
+
try {
|
|
134
|
+
// 対象メンバーシップを持つオファーが存在するか?
|
|
135
|
+
const offers = await eventService.searchTicketOffers({
|
|
136
|
+
limit: 100,
|
|
137
|
+
page: 1,
|
|
138
|
+
event: { id: EVENT_ID }
|
|
139
|
+
});
|
|
140
|
+
const offersWithEligibleMembershipType = offers.filter(({ eligibleMembershipType }) => {
|
|
141
|
+
return Array.isArray(eligibleMembershipType);
|
|
142
|
+
});
|
|
143
|
+
console.log(offersWithEligibleMembershipType.length, '個の対象メンバーシップを持つオファーが存在します');
|
|
144
|
+
const membershipTypesFromOffer = offersWithEligibleMembershipType.map(({ eligibleMembershipType }) => {
|
|
145
|
+
return eligibleMembershipType?.[0].codeValue;
|
|
146
|
+
});
|
|
147
|
+
console.log('利用可能な対象メンバーシップ区分:', membershipTypesFromOffer);
|
|
148
|
+
|
|
149
|
+
// メンバーシップチケット発行
|
|
150
|
+
const { ticketToken } = await paymentService.issueTicketThroughCreditCard({
|
|
151
|
+
ticketedPermit: { issuedThrough: { id: PAYMENT_SERVICE_ID } },
|
|
152
|
+
purpose: { id: transaction.id, typeOf: client.factory.transactionType.PlaceOrder }
|
|
153
|
+
});
|
|
154
|
+
console.log('ticket issued. ticketToken:', ticketToken);
|
|
155
|
+
|
|
156
|
+
await wait(3000);
|
|
157
|
+
|
|
158
|
+
// オファー承認
|
|
159
|
+
await offerService.authorizeEventService({
|
|
160
|
+
object: {
|
|
161
|
+
reservationFor: { id: EVENT_ID },
|
|
162
|
+
acceptedOffer: [{
|
|
163
|
+
id: 'bkpnwjw1w', // メンバーシップ適用オファーを指定
|
|
164
|
+
itemOffered: {
|
|
165
|
+
serviceOutput: {
|
|
166
|
+
typeOf: client.factory.reservationType.EventReservation,
|
|
167
|
+
reservedTicket: {
|
|
168
|
+
typeOf: 'Ticket',
|
|
169
|
+
ticketedSeat: {
|
|
170
|
+
typeOf: client.factory.placeType.Seat,
|
|
171
|
+
seatNumber: 'B-4',
|
|
172
|
+
seatSection: 'Default',
|
|
173
|
+
seatRow: ''
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
programMembershipUsed: { ticketToken, typeOf: 'Ticket' } // メンバーシップチケットを指定
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}]
|
|
180
|
+
},
|
|
181
|
+
purpose: { id: transaction.id, typeOf: client.factory.transactionType.PlaceOrder }
|
|
182
|
+
});
|
|
183
|
+
console.log('offer authorized');
|
|
184
|
+
|
|
185
|
+
await wait(3000);
|
|
186
|
+
|
|
187
|
+
// 決済承認
|
|
188
|
+
console.log('authorizing credit card payment...');
|
|
189
|
+
const creditCardPaymentAuth = await authorizeCreditCardAsyncForcibly({
|
|
190
|
+
object: {
|
|
191
|
+
amount: 999,
|
|
192
|
+
paymentMethod: 'MembershipCreditCard',
|
|
193
|
+
method: '1',
|
|
194
|
+
creditCard,
|
|
195
|
+
issuedThrough: { id: PAYMENT_SERVICE_ID },
|
|
196
|
+
ticketToken // メンバーシップチケットを指定
|
|
197
|
+
},
|
|
198
|
+
purpose: { id: transaction.id, typeOf: client.factory.transactionType.PlaceOrder }
|
|
199
|
+
})({ paymentService });
|
|
200
|
+
console.log('credit card payment authorized', creditCardPaymentAuth.id);
|
|
201
|
+
|
|
202
|
+
await wait(3000);
|
|
203
|
+
|
|
204
|
+
const settingProfile: client.factory.person.IProfile = {
|
|
205
|
+
givenName: profile.givenName,
|
|
206
|
+
familyName: profile.familyName,
|
|
207
|
+
telephone: profile.telephone,
|
|
208
|
+
email: profile.email
|
|
209
|
+
};
|
|
210
|
+
console.log('setting customer profile...');
|
|
211
|
+
await placeOrderService.setProfile({ id: transaction.id, agent: settingProfile });
|
|
212
|
+
console.log('customer profile set');
|
|
213
|
+
|
|
214
|
+
await wait(3000);
|
|
215
|
+
|
|
216
|
+
console.log('confirming transaction...');
|
|
217
|
+
const confirmResult = await placeOrderService.confirmWithMiminalResponse({
|
|
218
|
+
id: transaction.id
|
|
219
|
+
});
|
|
220
|
+
console.log('transaction confirmed', confirmResult);
|
|
221
|
+
} catch (error) {
|
|
222
|
+
console.error(error);
|
|
223
|
+
console.log('canceling transaction...');
|
|
224
|
+
await wait(3000);
|
|
225
|
+
await placeOrderService.cancel({ id: transaction.id });
|
|
226
|
+
console.log('transaction canceled');
|
|
227
|
+
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
async function wait(waitInMilliseconds: number) {
|
|
232
|
+
return new Promise((resolve) => setTimeout(resolve, waitInMilliseconds));
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
main()
|
|
236
|
+
.then(() => {
|
|
237
|
+
console.log('success!');
|
|
238
|
+
})
|
|
239
|
+
.catch(console.error);
|
package/example/src/cloud/transaction/processPlaceOrderUsingTicketIssuedThroughFaceToFace.ts
CHANGED
|
@@ -18,7 +18,7 @@ const profile = {
|
|
|
18
18
|
*
|
|
19
19
|
* マスタ管理として
|
|
20
20
|
* - 区分管理でメンバーシップ区分を定義
|
|
21
|
-
* -
|
|
21
|
+
* - 単価オファーに対象メンバーシップを設定
|
|
22
22
|
*
|
|
23
23
|
* の上で、取引は↓の流れ
|
|
24
24
|
* - 決済サービスを使用してメンバーシップチケットを発行する
|
|
@@ -26,7 +26,7 @@ const profile = {
|
|
|
26
26
|
* - 決済承認時にもチケットを適用する
|
|
27
27
|
*
|
|
28
28
|
* バックエンドでは↓が検証されます
|
|
29
|
-
* -
|
|
29
|
+
* - 対象メンバーシップの設定されたオファーは、チケットを適用しなければ承認をとれない
|
|
30
30
|
* - チケット適用のオファー承認が取引に存在する場合、チケットを適用した決済承認が存在しなければ取引を確定できない
|
|
31
31
|
*/
|
|
32
32
|
// tslint:disable-next-line:max-func-body-length
|
|
@@ -5,7 +5,15 @@ export declare type IPaymentServiceByProvider = Pick<factory.service.paymentServ
|
|
|
5
5
|
credentials?: IReadableProviderCredentials;
|
|
6
6
|
};
|
|
7
7
|
};
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* 販売者の提供決済サービス検索条件
|
|
10
|
+
*/
|
|
11
|
+
export declare type ISearchPaymentServiceConditions = Pick<factory.product.ISearchConditions, 'limit' | 'page' | 'sort'> & {
|
|
12
|
+
typeOf?: {
|
|
13
|
+
$eq?: factory.service.paymentService.PaymentServiceType;
|
|
14
|
+
$in?: factory.service.paymentService.PaymentServiceType[];
|
|
15
|
+
};
|
|
16
|
+
};
|
|
9
17
|
export declare type IPaymentAccepted = Pick<factory.categoryCode.ICategoryCode, 'codeValue' | 'additionalProperty' | 'color' | 'image' | 'name'>;
|
|
10
18
|
export declare type IMakesProductOffer = Pick<factory.product.IOffer, 'availabilityEnds' | 'availabilityStarts' | 'seller' | 'validFrom' | 'validThrough'> & {
|
|
11
19
|
itemOffered: Pick<factory.product.IProduct, 'id' | 'name' | 'typeOf'>;
|
|
@@ -8,7 +8,6 @@ export declare type IPaymentServiceByProvider = Pick<factory.service.paymentServ
|
|
|
8
8
|
export declare type IProvidePaymentService = Pick<factory.service.paymentService.IService, 'id' | 'name' | 'typeOf'> & {
|
|
9
9
|
provider: Pick<factory.service.paymentService.IProvider, 'id' | 'credentials'>;
|
|
10
10
|
};
|
|
11
|
-
export declare type ISearchPaymentServiceConditions = Pick<factory.product.ISearchConditions, 'limit' | 'page' | 'sort' | 'typeOf'>;
|
|
12
11
|
export declare type IPaymentAccepted = Pick<factory.categoryCode.ICategoryCode, 'codeValue' | 'additionalProperty' | 'color' | 'image' | 'name'>;
|
|
13
12
|
export declare type IMakesProductOffer = Pick<factory.product.IOffer, 'availabilityEnds' | 'availabilityStarts' | 'seller' | 'validFrom' | 'validThrough'> & {
|
|
14
13
|
itemOffered: Pick<factory.product.IProduct, 'id' | 'name' | 'typeOf'>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { ISearchPaymentServiceConditions } from '../chevre/seller/factory';
|
|
1
2
|
import * as factory from '../factory';
|
|
2
3
|
import { IOptions, ISearchResult, IUnset, Service } from '../service';
|
|
3
|
-
import { IMakesProductOffer, IPaymentAccepted, IPaymentServiceByProvider, IProvidePaymentService
|
|
4
|
+
import { IMakesProductOffer, IPaymentAccepted, IPaymentServiceByProvider, IProvidePaymentService } from './seller/factory';
|
|
4
5
|
declare type IKeyOfProjection = keyof factory.seller.ISeller | '_id';
|
|
5
6
|
declare type IProjection = {
|
|
6
7
|
[key in IKeyOfProjection]?: 0 | 1;
|
|
@@ -32,7 +32,7 @@ export declare type IMovieTicketMkknInfo = factory.action.check.paymentMethod.mo
|
|
|
32
32
|
knyknrNo: string;
|
|
33
33
|
};
|
|
34
34
|
export declare type IAuthorizeAnyPaymentObject = Pick<factory.action.authorize.paymentMethod.any.IObjectWithoutDetail, 'amount' | 'issuedThrough' | 'paymentMethod' | 'name' | 'additionalProperty' | 'ticketToken'>;
|
|
35
|
-
export declare type IAuthorizeCreditCardObject = Pick<factory.action.authorize.paymentMethod.any.IObjectWithoutDetail, 'amount' | 'issuedThrough' | 'paymentMethod' | 'creditCard' | 'method' | 'paymentMethodId' | 'name' | 'additionalProperty'>;
|
|
35
|
+
export declare type IAuthorizeCreditCardObject = Pick<factory.action.authorize.paymentMethod.any.IObjectWithoutDetail, 'amount' | 'issuedThrough' | 'paymentMethod' | 'creditCard' | 'method' | 'paymentMethodId' | 'name' | 'additionalProperty' | 'ticketToken'>;
|
|
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'> & {
|
|
38
38
|
description?: string;
|
|
@@ -191,4 +191,15 @@ export declare class PaymentService extends Service {
|
|
|
191
191
|
issueTicketThroughFaceToFace(params: {
|
|
192
192
|
purpose: IPurpose;
|
|
193
193
|
}): Promise<ITicket>;
|
|
194
|
+
issueTicketThroughCreditCard(params: {
|
|
195
|
+
ticketedPermit: {
|
|
196
|
+
issuedThrough: {
|
|
197
|
+
/**
|
|
198
|
+
* 発行決済サービスID
|
|
199
|
+
*/
|
|
200
|
+
id: string;
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
purpose: IPurpose;
|
|
204
|
+
}): Promise<ITicket>;
|
|
194
205
|
}
|
|
@@ -411,7 +411,28 @@ var PaymentService = /** @class */ (function (_super) {
|
|
|
411
411
|
expectedStatusCodes: [http_status_1.CREATED],
|
|
412
412
|
body: { purpose: purpose },
|
|
413
413
|
qs: {
|
|
414
|
-
purpose: { id: params.purpose.id }
|
|
414
|
+
purpose: { id: params.purpose.id }
|
|
415
|
+
}
|
|
416
|
+
})
|
|
417
|
+
.then(function (response) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
418
|
+
return [2 /*return*/, response.json()];
|
|
419
|
+
}); }); })];
|
|
420
|
+
});
|
|
421
|
+
});
|
|
422
|
+
};
|
|
423
|
+
PaymentService.prototype.issueTicketThroughCreditCard = function (params) {
|
|
424
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
425
|
+
var purpose, ticketedPermit;
|
|
426
|
+
var _this = this;
|
|
427
|
+
return __generator(this, function (_a) {
|
|
428
|
+
purpose = params.purpose, ticketedPermit = params.ticketedPermit;
|
|
429
|
+
return [2 /*return*/, this.fetch({
|
|
430
|
+
uri: "/payment/" + factory.service.paymentService.PaymentServiceType.CreditCard + "/tickets",
|
|
431
|
+
method: 'POST',
|
|
432
|
+
expectedStatusCodes: [http_status_1.CREATED],
|
|
433
|
+
body: { purpose: purpose, ticketedPermit: ticketedPermit },
|
|
434
|
+
qs: {
|
|
435
|
+
purpose: { id: params.purpose.id }
|
|
415
436
|
}
|
|
416
437
|
})
|
|
417
438
|
.then(function (response) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
@@ -226,4 +226,18 @@ export declare class PaymentService extends Service {
|
|
|
226
226
|
issueTicketThroughFaceToFace(params: {
|
|
227
227
|
purpose: IPurpose;
|
|
228
228
|
}): Promise<ITicket>;
|
|
229
|
+
/**
|
|
230
|
+
* CreditCardIF決済によるチケット発行
|
|
231
|
+
*/
|
|
232
|
+
issueTicketThroughCreditCard(params: {
|
|
233
|
+
ticketedPermit: {
|
|
234
|
+
issuedThrough: {
|
|
235
|
+
/**
|
|
236
|
+
* 発行決済サービスID
|
|
237
|
+
*/
|
|
238
|
+
id: string;
|
|
239
|
+
};
|
|
240
|
+
};
|
|
241
|
+
purpose: IPurpose;
|
|
242
|
+
}): Promise<ITicket>;
|
|
229
243
|
}
|
|
@@ -527,6 +527,34 @@ var PaymentService = /** @class */ (function (_super) {
|
|
|
527
527
|
});
|
|
528
528
|
});
|
|
529
529
|
};
|
|
530
|
+
/**
|
|
531
|
+
* CreditCardIF決済によるチケット発行
|
|
532
|
+
*/
|
|
533
|
+
PaymentService.prototype.issueTicketThroughCreditCard = function (params) {
|
|
534
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
535
|
+
var _a, auth, endpoint, project, seller, disableAutoRetry, retryableStatusCodes, chevrePay, paymentService;
|
|
536
|
+
return __generator(this, function (_b) {
|
|
537
|
+
switch (_b.label) {
|
|
538
|
+
case 0:
|
|
539
|
+
_a = this.options, auth = _a.auth, endpoint = _a.endpoint, project = _a.project, seller = _a.seller, disableAutoRetry = _a.disableAutoRetry, retryableStatusCodes = _a.retryableStatusCodes;
|
|
540
|
+
return [4 /*yield*/, index_1.loadChevrePay({ auth: auth, endpoint: endpoint, disableAutoRetry: disableAutoRetry })];
|
|
541
|
+
case 1:
|
|
542
|
+
chevrePay = _b.sent();
|
|
543
|
+
return [4 /*yield*/, chevrePay.createPaymentInstance({
|
|
544
|
+
project: project,
|
|
545
|
+
seller: { id: (typeof (seller === null || seller === void 0 ? void 0 : seller.id) === 'string') ? seller.id : '' },
|
|
546
|
+
retryableStatusCodes: __spreadArray(__spreadArray([], (Array.isArray(retryableStatusCodes)) ? retryableStatusCodes : []), [
|
|
547
|
+
http_status_1.CONFLICT,
|
|
548
|
+
http_status_1.TOO_MANY_REQUESTS
|
|
549
|
+
])
|
|
550
|
+
})];
|
|
551
|
+
case 2:
|
|
552
|
+
paymentService = _b.sent();
|
|
553
|
+
return [2 /*return*/, paymentService.issueTicketThroughCreditCard(params)];
|
|
554
|
+
}
|
|
555
|
+
});
|
|
556
|
+
});
|
|
557
|
+
};
|
|
530
558
|
return PaymentService;
|
|
531
559
|
}(service_1.Service));
|
|
532
560
|
exports.PaymentService = PaymentService;
|
package/lib/bundle.js
CHANGED
|
@@ -14284,7 +14284,28 @@ var PaymentService = /** @class */ (function (_super) {
|
|
|
14284
14284
|
expectedStatusCodes: [http_status_1.CREATED],
|
|
14285
14285
|
body: { purpose: purpose },
|
|
14286
14286
|
qs: {
|
|
14287
|
-
purpose: { id: params.purpose.id }
|
|
14287
|
+
purpose: { id: params.purpose.id }
|
|
14288
|
+
}
|
|
14289
|
+
})
|
|
14290
|
+
.then(function (response) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
14291
|
+
return [2 /*return*/, response.json()];
|
|
14292
|
+
}); }); })];
|
|
14293
|
+
});
|
|
14294
|
+
});
|
|
14295
|
+
};
|
|
14296
|
+
PaymentService.prototype.issueTicketThroughCreditCard = function (params) {
|
|
14297
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
14298
|
+
var purpose, ticketedPermit;
|
|
14299
|
+
var _this = this;
|
|
14300
|
+
return __generator(this, function (_a) {
|
|
14301
|
+
purpose = params.purpose, ticketedPermit = params.ticketedPermit;
|
|
14302
|
+
return [2 /*return*/, this.fetch({
|
|
14303
|
+
uri: "/payment/" + factory.service.paymentService.PaymentServiceType.CreditCard + "/tickets",
|
|
14304
|
+
method: 'POST',
|
|
14305
|
+
expectedStatusCodes: [http_status_1.CREATED],
|
|
14306
|
+
body: { purpose: purpose, ticketedPermit: ticketedPermit },
|
|
14307
|
+
qs: {
|
|
14308
|
+
purpose: { id: params.purpose.id }
|
|
14288
14309
|
}
|
|
14289
14310
|
})
|
|
14290
14311
|
.then(function (response) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
@@ -20733,6 +20754,34 @@ var PaymentService = /** @class */ (function (_super) {
|
|
|
20733
20754
|
});
|
|
20734
20755
|
});
|
|
20735
20756
|
};
|
|
20757
|
+
/**
|
|
20758
|
+
* CreditCardIF決済によるチケット発行
|
|
20759
|
+
*/
|
|
20760
|
+
PaymentService.prototype.issueTicketThroughCreditCard = function (params) {
|
|
20761
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
20762
|
+
var _a, auth, endpoint, project, seller, disableAutoRetry, retryableStatusCodes, chevrePay, paymentService;
|
|
20763
|
+
return __generator(this, function (_b) {
|
|
20764
|
+
switch (_b.label) {
|
|
20765
|
+
case 0:
|
|
20766
|
+
_a = this.options, auth = _a.auth, endpoint = _a.endpoint, project = _a.project, seller = _a.seller, disableAutoRetry = _a.disableAutoRetry, retryableStatusCodes = _a.retryableStatusCodes;
|
|
20767
|
+
return [4 /*yield*/, index_1.loadChevrePay({ auth: auth, endpoint: endpoint, disableAutoRetry: disableAutoRetry })];
|
|
20768
|
+
case 1:
|
|
20769
|
+
chevrePay = _b.sent();
|
|
20770
|
+
return [4 /*yield*/, chevrePay.createPaymentInstance({
|
|
20771
|
+
project: project,
|
|
20772
|
+
seller: { id: (typeof (seller === null || seller === void 0 ? void 0 : seller.id) === 'string') ? seller.id : '' },
|
|
20773
|
+
retryableStatusCodes: __spreadArray(__spreadArray([], (Array.isArray(retryableStatusCodes)) ? retryableStatusCodes : []), [
|
|
20774
|
+
http_status_1.CONFLICT,
|
|
20775
|
+
http_status_1.TOO_MANY_REQUESTS
|
|
20776
|
+
])
|
|
20777
|
+
})];
|
|
20778
|
+
case 2:
|
|
20779
|
+
paymentService = _b.sent();
|
|
20780
|
+
return [2 /*return*/, paymentService.issueTicketThroughCreditCard(params)];
|
|
20781
|
+
}
|
|
20782
|
+
});
|
|
20783
|
+
});
|
|
20784
|
+
};
|
|
20736
20785
|
return PaymentService;
|
|
20737
20786
|
}(service_1.Service));
|
|
20738
20787
|
exports.PaymentService = PaymentService;
|
|
@@ -25216,7 +25265,7 @@ var CategorySetIdentifier;
|
|
|
25216
25265
|
*/
|
|
25217
25266
|
CategorySetIdentifier["DistributorType"] = "DistributorType";
|
|
25218
25267
|
/**
|
|
25219
|
-
*
|
|
25268
|
+
* メンバーシップ区分
|
|
25220
25269
|
*/
|
|
25221
25270
|
CategorySetIdentifier["MembershipType"] = "MembershipType";
|
|
25222
25271
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cinerino/sdk",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.6.0-alpha.0",
|
|
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.381.0-alpha.
|
|
95
|
+
"@chevre/factory": "4.381.0-alpha.8",
|
|
96
96
|
"debug": "3.2.7",
|
|
97
97
|
"http-status": "1.7.4",
|
|
98
98
|
"idtoken-verifier": "2.0.3",
|