@chevre/domain 25.2.0-alpha.25 → 25.2.0-alpha.26

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.
@@ -37,4 +37,19 @@ export declare class AcceptPayActionRepo extends ActionProcessRepo<IAcceptPayAct
37
37
  transactionNumber: string;
38
38
  };
39
39
  }, inclusion: IKeyOfProjection[]): Promise<IAcceptPayAction[]>;
40
+ /**
41
+ * アクションIDからレシピのafterMediaを参照する
42
+ */
43
+ findPaymentUrlById(params: {
44
+ project: {
45
+ id: string;
46
+ };
47
+ /**
48
+ * アクションID
49
+ */
50
+ id: string;
51
+ }): Promise<{
52
+ paymentMethodId: string;
53
+ paymentUrl?: string;
54
+ }>;
40
55
  }
@@ -29,25 +29,6 @@ class AcceptPayActionRepo extends actionProcess_1.ActionProcessRepo {
29
29
  ...(typeof limit === 'number') ? { limit } : undefined,
30
30
  ...(typeof page === 'number') ? { page } : undefined,
31
31
  }, inclusion);
32
- // const andConditions: FilterQuery<IAcceptPayAction>[] = [
33
- // { typeOf: { $eq: factory.actionType.AcceptAction } },
34
- // { 'project.id': { $eq: params.project.id } },
35
- // { 'object.typeOf': { $exists: true, $eq: factory.assetTransactionType.Pay } },
36
- // { 'purpose.id': { $exists: true, $eq: params.purpose.id } }
37
- // ];
38
- // let positiveProjectionFields: IKeyOfProjection[] = AVAILABLE_PROJECT_FIELDS;
39
- // if (Array.isArray(inclusion) && inclusion.length > 0) {
40
- // positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
41
- // }
42
- // const projection: ProjectionType<IAcceptPayAction> = {
43
- // _id: 0,
44
- // id: { $toString: '$_id' },
45
- // ...Object.fromEntries<1>(positiveProjectionFields.map((key) => ([key, 1])))
46
- // };
47
- // const query = this.actionModel.find({ $and: andConditions }, projection);
48
- // return query.setOptions({ maxTimeMS: MONGO_MAX_TIME_MS })
49
- // .lean<IAcceptPayAction[]>()
50
- // .exec();
51
32
  }
52
33
  /**
53
34
  * 決済取引番号から完了済の決済採用アクションを参照する
@@ -66,5 +47,52 @@ class AcceptPayActionRepo extends actionProcess_1.ActionProcessRepo {
66
47
  }
67
48
  }, inclusion);
68
49
  }
50
+ /**
51
+ * アクションIDからレシピのafterMediaを参照する
52
+ */
53
+ async findPaymentUrlById(params) {
54
+ const acceptActionWithResult = await this.actionModel.findOne({
55
+ typeOf: { $eq: factory_1.factory.actionType.AcceptAction }, // 採用アクション
56
+ _id: { $eq: params.id }
57
+ }, {
58
+ _id: 0,
59
+ result: 1,
60
+ object: 1
61
+ })
62
+ .lean() // 2024-08-26~
63
+ .exec();
64
+ if (acceptActionWithResult === null) {
65
+ throw new factory_1.factory.errors.NotFound(this.actionModel.modelName);
66
+ }
67
+ const paymentMethodId = acceptActionWithResult.object.transactionNumber;
68
+ // アクション未完了であればpaymentMethodIdだけ返す
69
+ if (acceptActionWithResult.result === undefined) {
70
+ return { paymentMethodId };
71
+ }
72
+ const recipe = await this.actionRecipeModel.findOne({
73
+ 'project.id': { $eq: params.project.id },
74
+ 'recipeFor.id': { $eq: params.id }
75
+ }, {
76
+ _id: 0,
77
+ step: 1
78
+ })
79
+ .lean()
80
+ .exec();
81
+ const afterMedia = recipe?.step[0]?.itemListElement[1]?.itemListElement[0]?.afterMedia;
82
+ let paymentUrl;
83
+ // 3DS拡張(2024-01-02~)
84
+ const retUrl = acceptActionWithResult.object.object.paymentMethod.creditCard?.retUrl;
85
+ if (typeof retUrl === 'string' && retUrl.length > 0) {
86
+ paymentUrl = afterMedia?.redirectUrl;
87
+ }
88
+ else {
89
+ paymentUrl = afterMedia?.acsUrl;
90
+ }
91
+ // アクション完了済であれば、レシピからpaymentUrlを必ず参照できるはず
92
+ if (typeof paymentUrl !== 'string' || paymentUrl === '') {
93
+ throw new factory_1.factory.errors.Internal(`Payment URL unable to publish. [retUrl: ${retUrl}]`);
94
+ }
95
+ return { paymentMethodId, paymentUrl };
96
+ }
69
97
  }
70
98
  exports.AcceptPayActionRepo = AcceptPayActionRepo;
@@ -167,7 +167,7 @@ function publishPaymentUrl(params, options) {
167
167
  }
168
168
  const actionResult = {
169
169
  paymentMethodId: result.paymentMethodId,
170
- paymentUrl: result.paymentUrl
170
+ // paymentUrl: result.paymentUrl // result.paymentUrlは廃止(2026-07-14~)
171
171
  };
172
172
  await repos.acceptPayAction.completeWithVoid({ typeOf: actionAttributes.typeOf, id: action.id, result: actionResult, recipe });
173
173
  return result;
@@ -18,7 +18,9 @@ interface IFindAcceptActionResult {
18
18
  name?: string;
19
19
  message?: string;
20
20
  };
21
- result?: factory.action.accept.pay.IResult;
21
+ result?: Pick<factory.action.accept.pay.IResult, 'paymentMethodId'> & {
22
+ paymentUrl: string;
23
+ };
22
24
  }
23
25
  declare function findAcceptAction(params: {
24
26
  project: {
@@ -42,12 +42,20 @@ function findAcceptAction(params) {
42
42
  if (acceptAction.purpose?.id !== params.purpose.id) {
43
43
  throw new factory_1.factory.errors.NotFound('Action');
44
44
  }
45
- const acceptActionWithResult = await repos.acceptPayAction.findById({ id: acceptAction.id, typeOf: factory_1.factory.actionType.AcceptAction }, ['result', 'object'], []);
45
+ // result.paymentUrl廃止につき、paymentUrlはrecipeを参照する(2026-07-14~)
46
+ // const acceptActionWithResult = await repos.acceptPayAction.findById(
47
+ // { id: acceptAction.id, typeOf: factory.actionType.AcceptAction },
48
+ // ['result', 'object'],
49
+ // []
50
+ // ) as Pick<factory.action.accept.pay.IAction, 'result' | 'object'>;
51
+ const acceptPayResult = await repos.acceptPayAction.findPaymentUrlById({
52
+ project: { id: params.project.id },
53
+ id: acceptAction.id
54
+ });
46
55
  action = {
47
56
  id: acceptAction.id,
48
57
  actionStatus: acceptAction.actionStatus,
49
- // add object.transactionNumber(2025-08-26~)
50
- object: { transactionNumber: acceptActionWithResult.object.transactionNumber },
58
+ object: { transactionNumber: acceptPayResult.paymentMethodId }, // add object.transactionNumber(2025-08-26~)
51
59
  ...(acceptAction.error !== undefined)
52
60
  ? {
53
61
  error: (Array.isArray(acceptAction.error))
@@ -55,11 +63,11 @@ function findAcceptAction(params) {
55
63
  : acceptAction.error
56
64
  }
57
65
  : undefined,
58
- ...(acceptActionWithResult?.result !== undefined)
66
+ ...(typeof acceptPayResult.paymentUrl === 'string')
59
67
  ? {
60
68
  result: {
61
- paymentMethodId: acceptActionWithResult.result.paymentMethodId,
62
- paymentUrl: acceptActionWithResult.result.paymentUrl
69
+ paymentMethodId: acceptPayResult.paymentMethodId,
70
+ paymentUrl: acceptPayResult.paymentUrl
63
71
  }
64
72
  }
65
73
  : undefined
@@ -115,8 +115,8 @@ function validatePaymentUrl(params) {
115
115
  // check existing accept action(2025-02-26~)
116
116
  const acceptActionExists = acceptPayActions.some(({ object, result }) => {
117
117
  return object.transactionNumber === paymentMethodId
118
- && result?.paymentMethodId === paymentMethodId
119
- && typeof result?.paymentUrl === 'string';
118
+ && result?.paymentMethodId === paymentMethodId;
119
+ // && typeof result?.paymentUrl === 'string'; // result.paymentUrlは廃止(2026-07-14~)
120
120
  });
121
121
  debug('validatePaymentUrl: acceptActionExists:', acceptActionExists);
122
122
  if (!acceptActionExists) {
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "dependencies": {
12
12
  "@aws-sdk/client-cognito-identity-provider": "3.600.0",
13
13
  "@aws-sdk/credential-providers": "3.600.0",
14
- "@chevre/factory": "9.5.0-alpha.8",
14
+ "@chevre/factory": "9.5.0-alpha.9",
15
15
  "@motionpicture/coa-service": "10.0.0",
16
16
  "@motionpicture/gmo-service": "6.1.0-alpha.0",
17
17
  "@sendgrid/client": "8.1.4",
@@ -91,5 +91,5 @@
91
91
  "postversion": "git push origin --tags",
92
92
  "prepublishOnly": "npm run clean && npm run build"
93
93
  },
94
- "version": "25.2.0-alpha.25"
94
+ "version": "25.2.0-alpha.26"
95
95
  }