@chevre/domain 21.20.0-alpha.4 → 21.20.0-alpha.6

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.
@@ -64,6 +64,8 @@ declare function refundCreditCard(params: factory.task.refund.IData, requirePayA
64
64
  interface IGMOInfo {
65
65
  shopId: string;
66
66
  shopPass: string;
67
+ returnUrls3ds: string[];
68
+ callbackType3ds?: factory.service.paymentService.ICallbackType3ds;
67
69
  }
68
70
  declare function getGMOInfoFromSeller(params: {
69
71
  paymentMethodType: string;
@@ -48,7 +48,7 @@ function authorize(params, paymentServiceId, options) {
48
48
  if (typeof sellerId !== 'string') {
49
49
  throw new factory.errors.ArgumentNull('recipient.id');
50
50
  }
51
- const { shopId, shopPass } = yield getGMOInfoFromSeller({ paymentMethodType, seller: { id: sellerId }, paymentServiceId })(repos);
51
+ const { shopId, shopPass, returnUrls3ds, callbackType3ds } = yield getGMOInfoFromSeller({ paymentMethodType, seller: { id: sellerId }, paymentServiceId })(repos);
52
52
  // GMOオーダーIDはカスタム指定可能
53
53
  const orderId = params.transactionNumber;
54
54
  if (typeof orderId !== 'string') {
@@ -72,6 +72,8 @@ function authorize(params, paymentServiceId, options) {
72
72
  // projectSettings: project.settings,
73
73
  shopId: shopId,
74
74
  shopPass: shopPass,
75
+ returnUrls3ds,
76
+ callbackType3ds,
75
77
  orderId: orderId,
76
78
  availableChannel: availableChannel,
77
79
  object: params.object.paymentMethod
@@ -136,6 +138,17 @@ function processAuthorizeCreditCard(params) {
136
138
  const retUrl = creditCard === null || creditCard === void 0 ? void 0 : creditCard.retUrl;
137
139
  // 3DS拡張(2024-01-02~)
138
140
  if (typeof retUrl === 'string' && retUrl.length > 0) {
141
+ let returnUrlObject;
142
+ try {
143
+ returnUrlObject = new URL(retUrl);
144
+ }
145
+ catch (error) {
146
+ throw new factory.errors.Argument('object.creditCard.retUrl', 'retUrl unparsable');
147
+ }
148
+ const returnUrlShouldBeIncluded = `${returnUrlObject.origin}${returnUrlObject.pathname}`;
149
+ if (!params.returnUrls3ds.includes(returnUrlShouldBeIncluded)) {
150
+ throw new factory.errors.Argument('object.creditCard.retUrl', 'invalid returnUrl');
151
+ }
139
152
  entryTranArgs = {
140
153
  shopId: params.shopId,
141
154
  shopPass: params.shopPass,
@@ -166,7 +179,7 @@ function processAuthorizeCreditCard(params) {
166
179
  cardSeq: cardSeq,
167
180
  seqMode: GMO.utils.util.SeqMode.Physics,
168
181
  retUrl,
169
- callbackType: GMO.utils.util.CallbackType.Get
182
+ callbackType: (params.callbackType3ds === 'GET') ? GMO.utils.util.CallbackType.Get : GMO.utils.util.CallbackType.Post
170
183
  };
171
184
  execTranResult = yield creditCardService.execTran3ds(execTranArgs);
172
185
  }
@@ -573,21 +586,7 @@ function processChangeTransaction(params) {
573
586
  }
574
587
  function getGMOInfoFromSeller(params) {
575
588
  return (repos) => __awaiter(this, void 0, void 0, function* () {
576
- // const sellers = <Pick<factory.seller.ISeller, 'paymentAccepted' | 'project'>[]>await repos.seller.search(
577
- // {
578
- // limit: 1,
579
- // page: 1,
580
- // id: { $eq: String(params.seller.id) }
581
- // },
582
- // ['paymentAccepted', 'project'],
583
- // []
584
- // );
585
- // const seller = sellers.shift();
586
- // if (seller === undefined) {
587
- // throw new factory.errors.NotFound(factory.organizationType.Corporation);
588
- // }
589
- var _a, _b;
590
- // const paymentAccepted = seller.paymentAccepted?.some((a) => a.paymentMethodType === params.paymentMethodType);
589
+ var _a, _b, _c, _d;
591
590
  const paymentAccepted = yield repos.paymentAccepted.isAcceptedBySeller({
592
591
  seller: { id: params.seller.id },
593
592
  codeValue: params.paymentMethodType
@@ -602,33 +601,20 @@ function getGMOInfoFromSeller(params) {
602
601
  provider: { id: { $eq: params.seller.id } },
603
602
  id: { $eq: params.paymentServiceId }
604
603
  });
605
- // const paymentServices = <factory.service.paymentService.IService[]>await repos.product.search(
606
- // {
607
- // limit: 1,
608
- // page: 1,
609
- // project: { id: { $eq: seller.project.id } },
610
- // typeOf: { $eq: factory.service.paymentService.PaymentServiceType.CreditCard },
611
- // // serviceType: { codeValue: { $eq: params.paymentMethodType } },
612
- // id: { $eq: params.paymentServiceId }
613
- // },
614
- // [],
615
- // []
616
- // );
617
604
  const paymentService = paymentServices.shift();
618
605
  if (paymentService === undefined) {
619
606
  throw new factory.errors.NotFound('PaymentService');
620
607
  }
621
608
  const provider = paymentService.provider;
622
- // const provider = paymentService.provider?.find((p) => p.id === params.seller.id);
623
- // if (provider === undefined) {
624
- // throw new factory.errors.NotFound('PaymentService provider');
625
- // }
626
609
  const shopId = (_a = provider.credentials) === null || _a === void 0 ? void 0 : _a.shopId;
627
610
  const shopPass = (_b = provider.credentials) === null || _b === void 0 ? void 0 : _b.shopPass;
628
611
  if (typeof shopId !== 'string' || typeof shopPass !== 'string') {
629
612
  throw new factory.errors.Argument('transaction', 'Provider credentials not enough');
630
613
  }
631
- return { shopId, shopPass };
614
+ const returnUrls3dsSetting = (_c = provider.credentials) === null || _c === void 0 ? void 0 : _c.returnUrls3ds;
615
+ const returnUrls3ds = (Array.isArray(returnUrls3dsSetting)) ? returnUrls3dsSetting : [];
616
+ const callbackType3ds = (_d = provider.credentials) === null || _d === void 0 ? void 0 : _d.callbackType3ds;
617
+ return { shopId, shopPass, returnUrls3ds, callbackType3ds };
632
618
  });
633
619
  }
634
620
  exports.getGMOInfoFromSeller = getGMOInfoFromSeller;
@@ -0,0 +1,32 @@
1
+ import * as factory from '../../../factory';
2
+ import type { MongoRepository as AcceptedOfferRepo } from '../../../repo/acceptedOffer';
3
+ import type { MongoRepository as EventRepo } from '../../../repo/event';
4
+ import type { MongoRepository as MerchantReturnPolicyRepo } from '../../../repo/merchantReturnPolicy';
5
+ import type { MongoRepository as OfferRepo } from '../../../repo/offer';
6
+ import type { MongoRepository as OfferItemConditionRepo } from '../../../repo/offerItemCondition';
7
+ import type { MongoRepository as OrderRepo } from '../../../repo/order';
8
+ import type { MongoRepository as ProjectRepo } from '../../../repo/project';
9
+ import type { MongoRepository as ReservationRepo } from '../../../repo/reservation';
10
+ import type { MongoRepository as SellerRepo } from '../../../repo/seller';
11
+ interface IPreStartOperationRepos {
12
+ acceptedOffer: AcceptedOfferRepo;
13
+ event: EventRepo;
14
+ merchantReturnPolicy: MerchantReturnPolicyRepo;
15
+ offer: OfferRepo;
16
+ offerItemCondition: OfferItemConditionRepo;
17
+ order: OrderRepo;
18
+ project: ProjectRepo;
19
+ reservation: ReservationRepo;
20
+ seller: SellerRepo;
21
+ }
22
+ type IPreStartOperation<T> = (repos: IPreStartOperationRepos) => Promise<T>;
23
+ type IFixedSeller = Pick<factory.seller.ISeller, 'id' | 'name' | 'project' | 'hasMerchantReturnPolicy' | 'typeOf'>;
24
+ /**
25
+ * 返品取引開始前処理
26
+ */
27
+ declare function preStart(params: factory.transaction.returnOrder.IStartParamsWithoutDetail): IPreStartOperation<{
28
+ transactionObject: factory.transaction.returnOrder.IObject;
29
+ seller: IFixedSeller;
30
+ expiresInSeconds: number;
31
+ }>;
32
+ export { preStart };