@chevre/domain 21.31.0 → 21.32.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.
@@ -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;
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,24 @@ 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
+ const creditCardService = new GMO.service.Credit({
59
+ endpoint: String(availableChannel.serviceUrl),
60
+ useFetch: credentials_1.credentials.gmo.useFetch
61
+ }, { timeout });
52
62
  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;
63
+ const redirectUrl = (_d = pendingPaymentAgencyTransaction === null || pendingPaymentAgencyTransaction === void 0 ? void 0 : pendingPaymentAgencyTransaction.execTranResult) === null || _d === void 0 ? void 0 : _d.redirectUrl;
54
64
  if (pendingPaymentAgencyTransaction !== undefined
55
65
  && typeof redirectUrl === 'string' && redirectUrl.length > 0) {
56
66
  authorizeResult = yield processAuthorizeCreditCard3ds({
57
67
  availableChannel,
58
68
  pendingPaymentAgencyTransaction
59
- })();
69
+ })({ creditCardService });
60
70
  }
61
71
  else {
62
72
  authorizeResult = yield processAuthorizeCreditCard({
@@ -68,7 +78,7 @@ function authorize(params, paymentServiceId, options) {
68
78
  availableChannel: availableChannel,
69
79
  object: params.object.paymentMethod,
70
80
  processPublishPaymentUrl: options.processPublishPaymentUrl
71
- })();
81
+ })({ creditCardService });
72
82
  }
73
83
  }
74
84
  catch (error) {
@@ -86,17 +96,13 @@ function authorize(params, paymentServiceId, options) {
86
96
  exports.authorize = authorize;
87
97
  function processAuthorizeCreditCard(params) {
88
98
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
89
- return () => __awaiter(this, void 0, void 0, function* () {
99
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
90
100
  var _a, _b, _c, _d, _e, _f;
91
101
  // GMOオーソリ取得
92
102
  let entryTranArgs;
93
103
  let entryTranResult;
94
104
  let execTranArgs;
95
105
  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
106
  const creditCard = params.object.creditCard;
101
107
  const { cardSeq, memberId } = creditCard;
102
108
  if (typeof memberId === 'string' && memberId.length > 0 && typeof cardSeq === 'number') {
@@ -132,9 +138,9 @@ function processAuthorizeCreditCard(params) {
132
138
  // tdTenantName: '',
133
139
  tds2Type: GMO.utils.util.Tds2Type.Error
134
140
  };
135
- entryTranResult = yield creditCardService.entryTran(entryTranArgs);
141
+ entryTranResult = yield repos.creditCardService.entryTran(entryTranArgs);
136
142
  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);
143
+ execTranResult = yield repos.creditCardService.execTran3ds(execTranArgs);
138
144
  }
139
145
  else {
140
146
  entryTranArgs = {
@@ -148,22 +154,18 @@ function processAuthorizeCreditCard(params) {
148
154
  siteId: (_c = params.availableChannel.credentials) === null || _c === void 0 ? void 0 : _c.siteId,
149
155
  sitePass: (_d = params.availableChannel.credentials) === null || _d === void 0 ? void 0 : _d.sitePass
150
156
  };
151
- entryTranResult = yield creditCardService.entryTran(entryTranArgs);
157
+ entryTranResult = yield repos.creditCardService.entryTran(entryTranArgs);
152
158
  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);
159
+ execTranResult = yield repos.creditCardService.execTran(execTranArgs);
154
160
  }
155
161
  return { entryTranArgs, entryTranResult, execTranArgs, execTranResult };
156
162
  });
157
163
  }
158
164
  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 });
165
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
164
166
  const { entryTranArgs, entryTranResult, execTranArgs, execTranResult } = params.pendingPaymentAgencyTransaction;
165
167
  const { accessId, accessPass } = entryTranResult;
166
- const secureTran2Result = yield creditCardService.secureTran2({ accessId, accessPass });
168
+ const secureTran2Result = yield repos.creditCardService.secureTran2({ accessId, accessPass });
167
169
  return { entryTranArgs, entryTranResult, execTranArgs, execTranResult, secureTran2Result };
168
170
  });
169
171
  }
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.0"
114
114
  }