@chevre/domain 22.2.0-alpha.2 → 22.2.0-alpha.4
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/lib/chevre/service/offer/event/authorize/factory.js +20 -6
- package/lib/chevre/service/transaction/placeOrder/confirm/validation.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrder/confirm/validation.js +36 -2
- package/lib/chevre/service/transaction/placeOrder/confirm.js +1 -1
- package/package.json +3 -3
|
@@ -137,15 +137,31 @@ function acceptedOffers2amount(params) {
|
|
|
137
137
|
return amount;
|
|
138
138
|
}
|
|
139
139
|
exports.acceptedOffers2amount = acceptedOffers2amount;
|
|
140
|
+
function acceptedOffers2programMembershipUsed(params) {
|
|
141
|
+
const programMembershipUsed = [];
|
|
142
|
+
const permitIdentifiers = [];
|
|
143
|
+
params.acceptedOffers.forEach(({ itemOffered }) => {
|
|
144
|
+
var _a;
|
|
145
|
+
if (((_a = itemOffered.programMembershipUsed) === null || _a === void 0 ? void 0 : _a.typeOf) === factory.permit.PermitType.Permit) {
|
|
146
|
+
// メンバーシップコードに対してユニークに集計
|
|
147
|
+
if (!permitIdentifiers.includes(itemOffered.programMembershipUsed.identifier)) {
|
|
148
|
+
permitIdentifiers.push(itemOffered.programMembershipUsed.identifier);
|
|
149
|
+
programMembershipUsed.push(itemOffered.programMembershipUsed);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
return programMembershipUsed;
|
|
154
|
+
}
|
|
140
155
|
function acceptedOffers2authorizeResult(params) {
|
|
141
156
|
const { acceptedOffers, acceptedOffers4result, noOfferSpecified, ticketOffers } = params;
|
|
142
|
-
// const priceCurrency = acceptedOffers[0]?.priceSpecification?.priceCurrency;
|
|
143
157
|
const priceCurrency = factory.priceCurrency.JPY; // fix(2024-07-03~)
|
|
144
158
|
// redefine as typeOf: AggregateOffer(2024-06-18~)
|
|
145
159
|
let offers;
|
|
146
160
|
let price;
|
|
161
|
+
let programMembershipUsed = [];
|
|
147
162
|
if (!noOfferSpecified) {
|
|
148
163
|
price = acceptedOffers2amount({ acceptedOffers: acceptedOffers4result }); // オファー指定の場合のみ金額計算(2023-11-27~)
|
|
164
|
+
programMembershipUsed = acceptedOffers2programMembershipUsed({ acceptedOffers: acceptedOffers4result });
|
|
149
165
|
// オファーIDごとに集計
|
|
150
166
|
const offerIds = [...new Set(acceptedOffers.map((o) => o.id))];
|
|
151
167
|
offers = offerIds.map((offerId) => {
|
|
@@ -153,10 +169,6 @@ function acceptedOffers2authorizeResult(params) {
|
|
|
153
169
|
if (acceptedOffer === undefined) {
|
|
154
170
|
throw new factory.errors.Internal(`acceptedOffer not found [id:${offerId}]`);
|
|
155
171
|
}
|
|
156
|
-
// const acceptedOffer = acceptedOffers.find(({ id }) => id === offerId);
|
|
157
|
-
// if (acceptedOffer === undefined) {
|
|
158
|
-
// throw new factory.errors.Internal(`acceptedOffer not found [id:${offerId}]`);
|
|
159
|
-
// }
|
|
160
172
|
const amountOfThisGood = acceptedOffers.filter(({ id }) => id === offerId).length;
|
|
161
173
|
const { acceptedPaymentMethod, priceSpecification } = acceptedOffer;
|
|
162
174
|
const unitPriceSpec = priceSpecification.priceComponent.find((spec) => spec.typeOf === factory.priceSpecificationType.UnitPriceSpecification
|
|
@@ -169,7 +181,9 @@ function acceptedOffers2authorizeResult(params) {
|
|
|
169
181
|
return Object.assign({ id: offerId, includesObject: { amountOfThisGood }, typeOf: factory.offerType.Offer, priceSpecification: Object.assign(Object.assign({}, (eligibleQuantity !== undefined) ? { eligibleQuantity } : undefined), (eligibleTransactionVolume !== undefined) ? { eligibleTransactionVolume } : undefined) }, (acceptedPaymentMethod !== undefined) ? { acceptedPaymentMethod } : undefined);
|
|
170
182
|
});
|
|
171
183
|
}
|
|
172
|
-
return Object.assign(Object.assign({ typeOf: factory.offerType.AggregateOffer, priceCurrency, amount: []
|
|
184
|
+
return Object.assign(Object.assign({ typeOf: factory.offerType.AggregateOffer, priceCurrency, amount: [], itemOffered: {
|
|
185
|
+
serviceOutput: { programMembershipUsed } // add programMembershipUsed required(2024-08-15~)
|
|
186
|
+
} }, (typeof price === 'number') ? { price } : undefined), (Array.isArray(offers)) ? { offers } : undefined);
|
|
173
187
|
}
|
|
174
188
|
exports.acceptedOffers2authorizeResult = acceptedOffers2authorizeResult;
|
|
175
189
|
function responseBody2acceptedOffers4result(params) {
|
|
@@ -41,7 +41,7 @@ export declare function validatePaymentMethods(params: {
|
|
|
41
41
|
* 興行オファー適用条件確認
|
|
42
42
|
*/
|
|
43
43
|
export declare function validateEventOffers(params: {
|
|
44
|
-
order: factory.transaction.placeOrder.IOrderAsResult
|
|
44
|
+
order: Pick<factory.transaction.placeOrder.IOrderAsResult, 'price'>;
|
|
45
45
|
paymentMethods: factory.order.IReferencedInvoice[];
|
|
46
46
|
authorizeEventServiceOfferActions: Pick<IAuthorizeEventServiceOffer, 'id' | 'instrument' | 'object' | 'result'>[];
|
|
47
47
|
}): void;
|
|
@@ -350,11 +350,12 @@ exports.validatePaymentMethods = validatePaymentMethods;
|
|
|
350
350
|
// tslint:disable-next-line:max-func-body-length
|
|
351
351
|
function validateEventOffers(params) {
|
|
352
352
|
var _a, _b;
|
|
353
|
-
const
|
|
353
|
+
const { paymentMethods } = params;
|
|
354
|
+
const firstCreditCardPaymentMethodIdentifier = (_b = (_a = paymentMethods.find((referenceInvoice) => {
|
|
354
355
|
return referenceInvoice.issuedThrough.typeOf === factory.service.paymentService.PaymentServiceType.CreditCard
|
|
355
356
|
|| referenceInvoice.issuedThrough.typeOf === factory.service.paymentService.PaymentServiceType.FaceToFace;
|
|
356
357
|
})) === null || _a === void 0 ? void 0 : _a.paymentMethod) === null || _b === void 0 ? void 0 : _b.identifier;
|
|
357
|
-
const numCreditCardOrFaceToFacePaymentMethod =
|
|
358
|
+
const numCreditCardOrFaceToFacePaymentMethod = paymentMethods.filter((referenceInvoice) => {
|
|
358
359
|
return referenceInvoice.issuedThrough.typeOf === factory.service.paymentService.PaymentServiceType.CreditCard
|
|
359
360
|
|| referenceInvoice.issuedThrough.typeOf === factory.service.paymentService.PaymentServiceType.FaceToFace;
|
|
360
361
|
}).length;
|
|
@@ -411,5 +412,38 @@ function validateEventOffers(params) {
|
|
|
411
412
|
});
|
|
412
413
|
}
|
|
413
414
|
});
|
|
415
|
+
// check programMembershipUsed(2024-08-15~)
|
|
416
|
+
const programMembershipRequired = params.authorizeEventServiceOfferActions.reduce((a, b) => {
|
|
417
|
+
var _a, _b;
|
|
418
|
+
const programMembershipUsedfromResult = (_b = (_a = b.result) === null || _a === void 0 ? void 0 : _a.itemOffered) === null || _b === void 0 ? void 0 : _b.serviceOutput.programMembershipUsed;
|
|
419
|
+
if (Array.isArray(programMembershipUsedfromResult)) {
|
|
420
|
+
a.push(...programMembershipUsedfromResult);
|
|
421
|
+
}
|
|
422
|
+
return a;
|
|
423
|
+
}, []);
|
|
424
|
+
const satisfyProgramMembershipRequirement = programMembershipRequired.every(({ identifier, issuedThrough }) => {
|
|
425
|
+
let satisfyThisRequirement = false;
|
|
426
|
+
switch (issuedThrough.typeOf) {
|
|
427
|
+
case factory.product.ProductType.MembershipService:
|
|
428
|
+
// 検証の必要なし
|
|
429
|
+
satisfyThisRequirement = true;
|
|
430
|
+
break;
|
|
431
|
+
case factory.service.paymentService.PaymentServiceType.CreditCard:
|
|
432
|
+
satisfyThisRequirement = paymentMethods.some((paymentMethod) => paymentMethod.paymentMethodId === identifier
|
|
433
|
+
&& paymentMethod.issuedThrough.id === issuedThrough.id
|
|
434
|
+
&& paymentMethod.issuedThrough.typeOf === issuedThrough.typeOf);
|
|
435
|
+
break;
|
|
436
|
+
case factory.service.paymentService.PaymentServiceType.FaceToFace:
|
|
437
|
+
satisfyThisRequirement = paymentMethods.some((paymentMethod) => paymentMethod.paymentMethodId === identifier
|
|
438
|
+
&& paymentMethod.issuedThrough.typeOf === issuedThrough.typeOf);
|
|
439
|
+
break;
|
|
440
|
+
default:
|
|
441
|
+
// no op
|
|
442
|
+
}
|
|
443
|
+
return satisfyThisRequirement;
|
|
444
|
+
});
|
|
445
|
+
if (!satisfyProgramMembershipRequirement) {
|
|
446
|
+
throw new factory.errors.Argument('Transaction', `programMembershipUsed requirement not satisfied`);
|
|
447
|
+
}
|
|
414
448
|
}
|
|
415
449
|
exports.validateEventOffers = validateEventOffers;
|
|
@@ -293,7 +293,7 @@ function createResult(params, options) {
|
|
|
293
293
|
price
|
|
294
294
|
});
|
|
295
295
|
(0, validation_1.validateEventOffers)({
|
|
296
|
-
order:
|
|
296
|
+
order: { price },
|
|
297
297
|
paymentMethods,
|
|
298
298
|
authorizeEventServiceOfferActions: params.authorizeEventServiceOfferActions
|
|
299
299
|
});
|
package/package.json
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.381.0-alpha.
|
|
13
|
-
"@cinerino/sdk": "10.5.0-alpha.
|
|
12
|
+
"@chevre/factory": "4.381.0-alpha.4",
|
|
13
|
+
"@cinerino/sdk": "10.5.0-alpha.1",
|
|
14
14
|
"@motionpicture/coa-service": "9.4.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.3.0",
|
|
16
16
|
"@sendgrid/mail": "6.4.0",
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"postversion": "git push origin --tags",
|
|
111
111
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
112
112
|
},
|
|
113
|
-
"version": "22.2.0-alpha.
|
|
113
|
+
"version": "22.2.0-alpha.4"
|
|
114
114
|
}
|