@chevre/domain 21.31.0 → 21.32.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.
@@ -25,6 +25,7 @@ export declare const credentials: {
25
25
  };
26
26
  gmo: {
27
27
  timeout: number;
28
+ timeoutBackground: number | undefined;
28
29
  useFetch: boolean;
29
30
  };
30
31
  lineNotify: {
@@ -30,6 +30,9 @@ exports.credentials = {
30
30
  gmo: {
31
31
  // tslint:disable-next-line:no-magic-numbers
32
32
  timeout: (typeof process.env.GMO_TIMEOUT === 'string') ? Number(process.env.GMO_TIMEOUT) : 5000,
33
+ timeoutBackground: (typeof process.env.GMO_TIMEOUT_BACKGROUND === 'string')
34
+ ? Number(process.env.GMO_TIMEOUT_BACKGROUND)
35
+ : undefined,
33
36
  useFetch: process.env.GMO_USE_FETCH === '1'
34
37
  },
35
38
  lineNotify: {
@@ -98,6 +98,16 @@ export declare function start(params: factory.assetTransaction.pay.IStartParamsW
98
98
  useCheckMovieTicketBeforePay: boolean;
99
99
  useCheckByIdentifierIfNotYet: boolean;
100
100
  pendingPaymentAgencyTransaction?: CreditCardPayment.IPaymentAgencyTransaction;
101
+ /**
102
+ * 実行者
103
+ */
104
+ executor?: {
105
+ /**
106
+ * task ID
107
+ * taskによって実行されている場合値が存在する
108
+ */
109
+ id?: string;
110
+ };
101
111
  }): IStartOperation<factory.assetTransaction.pay.ITransaction>;
102
112
  /**
103
113
  * 取引確定
@@ -143,7 +143,7 @@ exports.check = check;
143
143
  */
144
144
  function start(params, options) {
145
145
  return (repos) => __awaiter(this, void 0, void 0, function* () {
146
- var _a, _b;
146
+ var _a, _b, _c;
147
147
  // 金額をfix
148
148
  const amount = (_a = params.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.amount;
149
149
  if (typeof amount !== 'number') {
@@ -173,7 +173,7 @@ function start(params, options) {
173
173
  break;
174
174
  case factory.service.paymentService.PaymentServiceType.CreditCard:
175
175
  transaction =
176
- yield processAuthorizeCreditCard(params, transaction, String(paymentService === null || paymentService === void 0 ? void 0 : paymentService.id), Object.assign({}, (options.pendingPaymentAgencyTransaction !== undefined)
176
+ yield processAuthorizeCreditCard(params, transaction, String(paymentService === null || paymentService === void 0 ? void 0 : paymentService.id), Object.assign({ executor: (typeof ((_c = options.executor) === null || _c === void 0 ? void 0 : _c.id) === 'string') ? { id: options.executor.id } : {} }, (options.pendingPaymentAgencyTransaction !== undefined)
177
177
  ? { pendingPaymentAgencyTransaction: options.pendingPaymentAgencyTransaction }
178
178
  : undefined))(repos);
179
179
  break;
@@ -331,7 +331,8 @@ function processAuthorizeAccount(params, transaction, paymentServiceId) {
331
331
  }
332
332
  function processAuthorizeCreditCard(params, transaction, paymentServiceId, options) {
333
333
  return (repos) => __awaiter(this, void 0, void 0, function* () {
334
- const authorizeResult = yield CreditCardPayment.authorize(params, paymentServiceId, Object.assign({ processPublishPaymentUrl: false }, (options.pendingPaymentAgencyTransaction !== undefined)
334
+ var _a;
335
+ const authorizeResult = yield CreditCardPayment.authorize(params, paymentServiceId, Object.assign({ processPublishPaymentUrl: false, executor: (typeof ((_a = options.executor) === null || _a === void 0 ? void 0 : _a.id) === 'string') ? { id: options.executor.id } : {} }, (options.pendingPaymentAgencyTransaction !== undefined)
335
336
  ? { pendingPaymentAgencyTransaction: options.pendingPaymentAgencyTransaction }
336
337
  : undefined))(repos);
337
338
  return saveAuthorizeResult({
@@ -365,7 +365,7 @@ function authorize(params) {
365
365
  transactionNumber: transactionNumber,
366
366
  location: params.location
367
367
  });
368
- payTransaction = yield PayTransactionService.start(startParams, Object.assign({ useCheckMovieTicketBeforePay: params.options.useCheckMovieTicketBeforePay, useCheckByIdentifierIfNotYet: params.options.useCheckByIdentifierIfNotYet }, (pendingPaymentAgencyTransaction !== undefined) ? { pendingPaymentAgencyTransaction } : undefined))(repos);
368
+ payTransaction = yield PayTransactionService.start(startParams, Object.assign({ useCheckMovieTicketBeforePay: params.options.useCheckMovieTicketBeforePay, useCheckByIdentifierIfNotYet: params.options.useCheckByIdentifierIfNotYet, executor: (typeof taskId === 'string') ? { id: taskId } : {} }, (pendingPaymentAgencyTransaction !== undefined) ? { pendingPaymentAgencyTransaction } : undefined))(repos);
369
369
  }
370
370
  catch (error) {
371
371
  try {
@@ -29,6 +29,16 @@ declare function authorize(params: factory.assetTransaction.pay.IStartParamsWith
29
29
  * 決済URL発行処理かどうか
30
30
  */
31
31
  processPublishPaymentUrl: boolean;
32
+ /**
33
+ * 実行者
34
+ */
35
+ executor?: {
36
+ /**
37
+ * task ID
38
+ * taskによって実行されている場合値が存在する
39
+ */
40
+ id?: string;
41
+ };
32
42
  }): (repos: {
33
43
  paymentAccepted: PaymentAcceptedRepo;
34
44
  paymentService: PaymentServiceRepo;
@@ -26,7 +26,7 @@ const debug = createDebug('chevre-domain:service:payment');
26
26
  */
27
27
  function authorize(params, paymentServiceId, options) {
28
28
  return (repos) => __awaiter(this, void 0, void 0, function* () {
29
- var _a, _b, _c;
29
+ var _a, _b, _c, _d, _e;
30
30
  // CreditCard系統の決済方法タイプは動的
31
31
  const paymentMethodType = (_a = params.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.identifier;
32
32
  if (typeof paymentMethodType !== 'string') {
@@ -49,14 +49,25 @@ function authorize(params, paymentServiceId, options) {
49
49
  }
50
50
  let authorizeResult;
51
51
  try {
52
+ // タスクによって実行されているかどうか
53
+ const executedByTask = typeof ((_c = options.executor) === null || _c === void 0 ? void 0 : _c.id) === 'string' && options.executor.id !== '';
54
+ // 非同期承認時に長時間対応(2024-05-18~)
55
+ const timeout = (executedByTask && typeof credentials_1.credentials.gmo.timeoutBackground === 'number')
56
+ ? credentials_1.credentials.gmo.timeoutBackground
57
+ : credentials_1.credentials.gmo.timeout;
58
+ debug('processAuthorizeCreditCard processing... executor:', (_d = options.executor) === null || _d === void 0 ? void 0 : _d.id, 'timeout:', timeout);
59
+ const creditCardService = new GMO.service.Credit({
60
+ endpoint: String(availableChannel.serviceUrl),
61
+ useFetch: credentials_1.credentials.gmo.useFetch
62
+ }, { timeout });
52
63
  const pendingPaymentAgencyTransaction = options.pendingPaymentAgencyTransaction;
53
- const redirectUrl = (_c = pendingPaymentAgencyTransaction === null || pendingPaymentAgencyTransaction === void 0 ? void 0 : pendingPaymentAgencyTransaction.execTranResult) === null || _c === void 0 ? void 0 : _c.redirectUrl;
64
+ const redirectUrl = (_e = pendingPaymentAgencyTransaction === null || pendingPaymentAgencyTransaction === void 0 ? void 0 : pendingPaymentAgencyTransaction.execTranResult) === null || _e === void 0 ? void 0 : _e.redirectUrl;
54
65
  if (pendingPaymentAgencyTransaction !== undefined
55
66
  && typeof redirectUrl === 'string' && redirectUrl.length > 0) {
56
67
  authorizeResult = yield processAuthorizeCreditCard3ds({
57
68
  availableChannel,
58
69
  pendingPaymentAgencyTransaction
59
- })();
70
+ })({ creditCardService });
60
71
  }
61
72
  else {
62
73
  authorizeResult = yield processAuthorizeCreditCard({
@@ -68,7 +79,7 @@ function authorize(params, paymentServiceId, options) {
68
79
  availableChannel: availableChannel,
69
80
  object: params.object.paymentMethod,
70
81
  processPublishPaymentUrl: options.processPublishPaymentUrl
71
- })();
82
+ })({ creditCardService });
72
83
  }
73
84
  }
74
85
  catch (error) {
@@ -86,17 +97,13 @@ function authorize(params, paymentServiceId, options) {
86
97
  exports.authorize = authorize;
87
98
  function processAuthorizeCreditCard(params) {
88
99
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
89
- return () => __awaiter(this, void 0, void 0, function* () {
100
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
90
101
  var _a, _b, _c, _d, _e, _f;
91
102
  // GMOオーソリ取得
92
103
  let entryTranArgs;
93
104
  let entryTranResult;
94
105
  let execTranArgs;
95
106
  let execTranResult;
96
- const creditCardService = new GMO.service.Credit({
97
- endpoint: String(params.availableChannel.serviceUrl),
98
- useFetch: credentials_1.credentials.gmo.useFetch
99
- }, { timeout: credentials_1.credentials.gmo.timeout });
100
107
  const creditCard = params.object.creditCard;
101
108
  const { cardSeq, memberId } = creditCard;
102
109
  if (typeof memberId === 'string' && memberId.length > 0 && typeof cardSeq === 'number') {
@@ -132,9 +139,9 @@ function processAuthorizeCreditCard(params) {
132
139
  // tdTenantName: '',
133
140
  tds2Type: GMO.utils.util.Tds2Type.Error
134
141
  };
135
- entryTranResult = yield creditCardService.entryTran(entryTranArgs);
142
+ entryTranResult = yield repos.creditCardService.entryTran(entryTranArgs);
136
143
  execTranArgs = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ accessId: entryTranResult.accessId, accessPass: entryTranResult.accessPass, orderId: params.orderId, method: params.object.method, siteId: (_a = params.availableChannel.credentials) === null || _a === void 0 ? void 0 : _a.siteId, sitePass: (_b = params.availableChannel.credentials) === null || _b === void 0 ? void 0 : _b.sitePass, seqMode: GMO.utils.util.SeqMode.Physics, retUrl, callbackType: (params.callbackType3ds === 'GET') ? GMO.utils.util.CallbackType.Get : GMO.utils.util.CallbackType.Post }, (typeof cardNo === 'string') ? { cardNo } : undefined), (typeof cardPass === 'string') ? { cardPass } : undefined), (typeof expire === 'string') ? { expire } : undefined), (typeof token === 'string') ? { token } : undefined), (typeof memberId === 'string') ? { memberId } : undefined), (typeof cardSeq === 'number') ? { cardSeq } : undefined);
137
- execTranResult = yield creditCardService.execTran3ds(execTranArgs);
144
+ execTranResult = yield repos.creditCardService.execTran3ds(execTranArgs);
138
145
  }
139
146
  else {
140
147
  entryTranArgs = {
@@ -148,22 +155,18 @@ function processAuthorizeCreditCard(params) {
148
155
  siteId: (_c = params.availableChannel.credentials) === null || _c === void 0 ? void 0 : _c.siteId,
149
156
  sitePass: (_d = params.availableChannel.credentials) === null || _d === void 0 ? void 0 : _d.sitePass
150
157
  };
151
- entryTranResult = yield creditCardService.entryTran(entryTranArgs);
158
+ entryTranResult = yield repos.creditCardService.entryTran(entryTranArgs);
152
159
  execTranArgs = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ accessId: entryTranResult.accessId, accessPass: entryTranResult.accessPass, orderId: params.orderId, method: params.object.method, siteId: (_e = params.availableChannel.credentials) === null || _e === void 0 ? void 0 : _e.siteId, sitePass: (_f = params.availableChannel.credentials) === null || _f === void 0 ? void 0 : _f.sitePass, seqMode: GMO.utils.util.SeqMode.Physics }, (typeof cardNo === 'string') ? { cardNo } : undefined), (typeof cardPass === 'string') ? { cardPass } : undefined), (typeof expire === 'string') ? { expire } : undefined), (typeof token === 'string') ? { token } : undefined), (typeof memberId === 'string') ? { memberId } : undefined), (typeof cardSeq === 'number') ? { cardSeq } : undefined);
153
- execTranResult = yield creditCardService.execTran(execTranArgs);
160
+ execTranResult = yield repos.creditCardService.execTran(execTranArgs);
154
161
  }
155
162
  return { entryTranArgs, entryTranResult, execTranArgs, execTranResult };
156
163
  });
157
164
  }
158
165
  function processAuthorizeCreditCard3ds(params) {
159
- return () => __awaiter(this, void 0, void 0, function* () {
160
- const creditCardService = new GMO.service.Credit({
161
- endpoint: String(params.availableChannel.serviceUrl),
162
- useFetch: credentials_1.credentials.gmo.useFetch
163
- }, { timeout: credentials_1.credentials.gmo.timeout });
166
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
164
167
  const { entryTranArgs, entryTranResult, execTranArgs, execTranResult } = params.pendingPaymentAgencyTransaction;
165
168
  const { accessId, accessPass } = entryTranResult;
166
- const secureTran2Result = yield creditCardService.secureTran2({ accessId, accessPass });
169
+ const secureTran2Result = yield repos.creditCardService.secureTran2({ accessId, accessPass });
167
170
  return { entryTranArgs, entryTranResult, execTranArgs, execTranResult, secureTran2Result };
168
171
  });
169
172
  }
package/package.json CHANGED
@@ -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": "21.31.0"
113
+ "version": "21.32.0-alpha.1"
114
114
  }