@chevre/domain 21.7.0-alpha.2 → 21.7.0-alpha.3

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.
@@ -7,7 +7,7 @@ exports.createStartParams = void 0;
7
7
  const factory = require("../../../factory");
8
8
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
9
9
  function createStartParams(params) {
10
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
10
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
11
11
  const paymentServiceId = (params.paymentService !== undefined)
12
12
  ? String(params.paymentService.id)
13
13
  : '';
@@ -56,34 +56,63 @@ function createStartParams(params) {
56
56
  }
57
57
  const informPaymentParams = createInformPaymentParams({ paymentService: params.paymentService });
58
58
  const accountId = (_g = params.object.paymentMethod) === null || _g === void 0 ? void 0 : _g.accountId;
59
- const creditCardAsPaymentServiceOutputCurrency = (_k = (_j = (_h = params.paymentService) === null || _h === void 0 ? void 0 : _h.serviceOutput) === null || _j === void 0 ? void 0 : _j.amount) === null || _k === void 0 ? void 0 : _k.currency;
60
- const paymentMethod = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ additionalProperty: (Array.isArray((_l = params.object.paymentMethod) === null || _l === void 0 ? void 0 : _l.additionalProperty))
61
- ? (_m = params.object.paymentMethod) === null || _m === void 0 ? void 0 : _m.additionalProperty
62
- : [], name: (typeof ((_o = params.object.paymentMethod) === null || _o === void 0 ? void 0 : _o.name) === 'string')
59
+ // currencyはデフォルトでJPY
60
+ let paymentMethodCurrency = factory.priceCurrency.JPY;
61
+ if (params.paymentServiceType === factory.service.paymentService.PaymentServiceType.PaymentCard) {
62
+ // ひとまず使用していないので空文字
63
+ paymentMethodCurrency = '';
64
+ }
65
+ else if (params.paymentServiceType === factory.service.paymentService.PaymentServiceType.CreditCard) {
66
+ // カード通貨区分が存在すれば適用
67
+ const creditCardAsPaymentServiceOutputCurrency = (_l = (_k = (_j = (_h = params.paymentService) === null || _h === void 0 ? void 0 : _h.serviceOutput) === null || _j === void 0 ? void 0 : _j.paymentMethod) === null || _k === void 0 ? void 0 : _k.amount) === null || _l === void 0 ? void 0 : _l.currency;
68
+ if (typeof creditCardAsPaymentServiceOutputCurrency === 'string') {
69
+ paymentMethodCurrency = creditCardAsPaymentServiceOutputCurrency;
70
+ }
71
+ }
72
+ const paymentMethodAmount = {
73
+ typeOf: 'MonetaryAmount',
74
+ currency: paymentMethodCurrency,
75
+ value: params.amount
76
+ };
77
+ const paymentMethod = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ additionalProperty: (Array.isArray((_m = params.object.paymentMethod) === null || _m === void 0 ? void 0 : _m.additionalProperty))
78
+ ? (_o = params.object.paymentMethod) === null || _o === void 0 ? void 0 : _o.additionalProperty
79
+ : [], name: (typeof ((_p = params.object.paymentMethod) === null || _p === void 0 ? void 0 : _p.name) === 'string')
63
80
  ? params.object.paymentMethod.name
64
- : paymentMethodType, amount: params.amount, paymentMethodId: params.transactionNumber, typeOf: paymentMethodType }, (typeof ((_p = params.object.paymentMethod) === null || _p === void 0 ? void 0 : _p.description) === 'string')
65
- ? { description: (_q = params.object.paymentMethod) === null || _q === void 0 ? void 0 : _q.description }
81
+ : paymentMethodType,
82
+ // MonetaryAmount対応(2023-08-12~)
83
+ // amount: params.amount,
84
+ amount: paymentMethodAmount, paymentMethodId: params.transactionNumber, typeOf: paymentMethodType }, (typeof ((_q = params.object.paymentMethod) === null || _q === void 0 ? void 0 : _q.description) === 'string')
85
+ ? { description: (_r = params.object.paymentMethod) === null || _r === void 0 ? void 0 : _r.description }
66
86
  : undefined), (totalPaymentDue !== undefined)
67
87
  ? { totalPaymentDue: totalPaymentDue }
68
- : undefined), (typeof accountId === 'string') ? { accountId: accountId } : undefined), (typeof ((_r = params.object.paymentMethod) === null || _r === void 0 ? void 0 : _r.method) === 'string')
69
- ? { method: (_s = params.object.paymentMethod) === null || _s === void 0 ? void 0 : _s.method }
70
- : undefined), (((_t = params.object.paymentMethod) === null || _t === void 0 ? void 0 : _t.creditCard) !== undefined)
71
- ? { creditCard: (_u = params.object.paymentMethod) === null || _u === void 0 ? void 0 : _u.creditCard }
72
- : undefined), (Array.isArray((_v = params.object.paymentMethod) === null || _v === void 0 ? void 0 : _v.movieTickets))
73
- ? { movieTickets: (_w = params.object.paymentMethod) === null || _w === void 0 ? void 0 : _w.movieTickets }
88
+ : undefined), (typeof accountId === 'string') ? { accountId: accountId } : undefined), (typeof ((_s = params.object.paymentMethod) === null || _s === void 0 ? void 0 : _s.method) === 'string')
89
+ ? { method: (_t = params.object.paymentMethod) === null || _t === void 0 ? void 0 : _t.method }
90
+ : undefined), (((_u = params.object.paymentMethod) === null || _u === void 0 ? void 0 : _u.creditCard) !== undefined)
91
+ ? { creditCard: (_v = params.object.paymentMethod) === null || _v === void 0 ? void 0 : _v.creditCard }
92
+ : undefined), (Array.isArray((_w = params.object.paymentMethod) === null || _w === void 0 ? void 0 : _w.movieTickets))
93
+ ? { movieTickets: (_x = params.object.paymentMethod) === null || _x === void 0 ? void 0 : _x.movieTickets }
74
94
  : undefined);
75
- const serviceOutput = (typeof creditCardAsPaymentServiceOutputCurrency === 'string')
76
- ? {
77
- amount: {
78
- currency: creditCardAsPaymentServiceOutputCurrency,
79
- value: paymentMethod.amount // 通貨区分としての金額
80
- }
81
- }
82
- : undefined;
83
- const object = Object.assign({
95
+ // const serviceOutput: factory.order.IOrderPaymentMethodIssuedThroughServiceOutput | undefined =
96
+ // (typeof creditCardAsPaymentServiceOutputCurrency === 'string')
97
+ // ? {
98
+ // amount: {
99
+ // currency: creditCardAsPaymentServiceOutputCurrency, // カード通貨区分
100
+ // value: paymentMethod.amount // 通貨区分としての金額
101
+ // }
102
+ // }
103
+ // : undefined;
104
+ const object = {
84
105
  // パラメータから必要なもののみ取り込む
85
- accountId: (typeof accountId === 'string') ? accountId : '', paymentMethodId: params.transactionNumber, typeOf: params.paymentServiceType, id: paymentServiceId, onPaymentStatusChanged: { informPayment: informPaymentParams }, paymentMethod }, (typeof serviceOutput !== undefined) ? { serviceOutput } : undefined);
86
- return Object.assign({ project: { typeOf: factory.organizationType.Project, id: params.project.id }, transactionNumber: params.transactionNumber, typeOf: factory.assetTransactionType.Pay, agent: params.agent, recipient: params.recipient, object, expires: params.expires }, (typeof ((_x = params.location) === null || _x === void 0 ? void 0 : _x.typeOf) === 'string')
106
+ accountId: (typeof accountId === 'string') ? accountId : '',
107
+ paymentMethodId: params.transactionNumber,
108
+ typeOf: params.paymentServiceType,
109
+ id: paymentServiceId,
110
+ onPaymentStatusChanged: { informPayment: informPaymentParams },
111
+ paymentMethod
112
+ // CreditCardIFのカード通貨区分を追加(2023-08-07~)
113
+ // ...(typeof serviceOutput !== undefined) ? { serviceOutput } : undefined
114
+ };
115
+ return Object.assign({ project: { typeOf: factory.organizationType.Project, id: params.project.id }, transactionNumber: params.transactionNumber, typeOf: factory.assetTransactionType.Pay, agent: params.agent, recipient: params.recipient, object, expires: params.expires }, (typeof ((_y = params.location) === null || _y === void 0 ? void 0 : _y.typeOf) === 'string')
87
116
  ? { location: params.location }
88
117
  : undefined);
89
118
  }
@@ -68,11 +68,17 @@ function createPayObject(params) {
68
68
  };
69
69
  break;
70
70
  case factory.service.paymentService.PaymentServiceType.CreditCard:
71
- payObject = Object.assign({ typeOf: transaction.object.typeOf, id: (typeof transaction.object.id === 'string') ? transaction.object.id : '', paymentMethod: Object.assign({ additionalProperty: (Array.isArray(additionalProperty)) ? additionalProperty : [], name: paymentMethodName, paymentMethodId: paymentMethodId, totalPaymentDue: {
71
+ payObject = {
72
+ typeOf: transaction.object.typeOf,
73
+ id: (typeof transaction.object.id === 'string') ? transaction.object.id : '',
74
+ paymentMethod: Object.assign({ additionalProperty: (Array.isArray(additionalProperty)) ? additionalProperty : [], name: paymentMethodName, paymentMethodId: paymentMethodId, totalPaymentDue: {
72
75
  typeOf: 'MonetaryAmount',
73
76
  currency: factory.priceCurrency.JPY,
74
77
  value: Number(paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.amount)
75
- }, typeOf: paymentMethodType }, (typeof (paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.accountId) === 'string') ? { accountId: paymentMethod.accountId } : undefined) }, (paymentServiceOutput !== undefined) ? { serviceOutput: paymentServiceOutput } : undefined);
78
+ }, typeOf: paymentMethodType }, (typeof (paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.accountId) === 'string') ? { accountId: paymentMethod.accountId } : undefined)
79
+ // CreditCardIFのカード通貨区分を追加(2023-08-07~)
80
+ // ...(paymentServiceOutput !== undefined) ? { serviceOutput: paymentServiceOutput } : undefined
81
+ };
76
82
  break;
77
83
  case factory.service.paymentService.PaymentServiceType.MovieTicket:
78
84
  payObject = Object.assign({ typeOf: transaction.object.typeOf, id: (typeof transaction.object.id === 'string') ? transaction.object.id : '', paymentMethod: {
@@ -94,7 +100,6 @@ function createPayObject(params) {
94
100
  return payObject;
95
101
  }
96
102
  function createPayObjectServiceOutput(params) {
97
- var _a, _b;
98
103
  const transaction = params.transaction;
99
104
  const paymentMethod = transaction.object.paymentMethod;
100
105
  const order = params.order;
@@ -105,17 +110,21 @@ function createPayObjectServiceOutput(params) {
105
110
  break;
106
111
  case factory.service.paymentService.PaymentServiceType.CreditCard:
107
112
  // CreditCardIFのカード通貨区分を追加(2023-08-07~)
108
- const creditCardAsPaymentServiceOutput = (typeof ((_b = (_a = transaction.object.serviceOutput) === null || _a === void 0 ? void 0 : _a.amount) === null || _b === void 0 ? void 0 : _b.currency) === 'string')
109
- ? {
110
- amount: {
111
- currency: transaction.object.serviceOutput.amount.currency,
112
- value: transaction.object.paymentMethod.amount
113
- }
114
- }
115
- : undefined;
116
- if (creditCardAsPaymentServiceOutput !== undefined) {
117
- paymentServiceOutput = creditCardAsPaymentServiceOutput;
118
- }
113
+ // const creditCardAsPaymentServiceOutput: factory.order.IOrderPaymentMethodIssuedThroughServiceOutput | undefined =
114
+ // (typeof transaction.object.paymentMethod?.amount !== 'number'
115
+ // && typeof transaction.object.paymentMethod?.amount?.currency === 'string')
116
+ // ? {
117
+ // paymentMethod: {
118
+ // amount: {
119
+ // currency: transaction.object.paymentMethod.amount.currency,
120
+ // value: transaction.object.paymentMethod.amount.value
121
+ // }
122
+ // }
123
+ // }
124
+ // : undefined;
125
+ // if (creditCardAsPaymentServiceOutput !== undefined) {
126
+ // paymentServiceOutput = creditCardAsPaymentServiceOutput;
127
+ // }
119
128
  break;
120
129
  case factory.service.paymentService.PaymentServiceType.MovieTicket:
121
130
  const paymentMethodType = paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.typeOf;
@@ -6,7 +6,7 @@ exports.createStartParams = void 0;
6
6
  */
7
7
  const factory = require("../../../factory");
8
8
  function createStartParams(params) {
9
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
9
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
10
10
  const paymentMethodType = (_a = params.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.typeOf;
11
11
  if (typeof paymentMethodType !== 'string') {
12
12
  throw new factory.errors.ArgumentNull('object.paymentMethod.typeOf');
@@ -23,7 +23,7 @@ function createStartParams(params) {
23
23
  let refundFee;
24
24
  if (((_g = params.paymentService) === null || _g === void 0 ? void 0 : _g.typeOf) === factory.service.paymentService.PaymentServiceType.CreditCard) {
25
25
  // カード通貨区分の存在する決済サービスを考慮(2023-08-09~)
26
- const paymentServiceOutputAmountCurrency = (_j = (_h = params.paymentService.serviceOutput) === null || _h === void 0 ? void 0 : _h.amount) === null || _j === void 0 ? void 0 : _j.currency;
26
+ const paymentServiceOutputAmountCurrency = (_k = (_j = (_h = params.paymentService.serviceOutput) === null || _h === void 0 ? void 0 : _h.paymentMethod) === null || _j === void 0 ? void 0 : _j.amount) === null || _k === void 0 ? void 0 : _k.currency;
27
27
  if (typeof paymentServiceOutputAmountCurrency !== 'string') {
28
28
  if (typeof params.object.refundFee === 'number') {
29
29
  refundFee = params.object.refundFee;
@@ -80,17 +80,32 @@ function createMovieTicket(params) {
80
80
  };
81
81
  }
82
82
  function createAuthorizeResult(params) {
83
- var _a, _b, _c, _d, _e, _f;
83
+ var _a, _b, _c, _d;
84
84
  const payTransactionObject = params.payTransaction.object;
85
85
  const totalPaymentDue = (_a = payTransactionObject.paymentMethod) === null || _a === void 0 ? void 0 : _a.totalPaymentDue;
86
86
  if (typeof (totalPaymentDue === null || totalPaymentDue === void 0 ? void 0 : totalPaymentDue.typeOf) !== 'string') {
87
87
  throw new factory.errors.ServiceUnavailable('payTransaction.object.paymentMethod.totalPaymentDue undefined');
88
88
  }
89
- const issuedThrough = Object.assign({ typeOf: payTransactionObject.typeOf, id: (typeof payTransactionObject.id === 'string') ? payTransactionObject.id : '' }, (typeof ((_c = (_b = payTransactionObject.serviceOutput) === null || _b === void 0 ? void 0 : _b.amount) === null || _c === void 0 ? void 0 : _c.currency) === 'string')
90
- ? { serviceOutput: payTransactionObject.serviceOutput }
91
- : undefined);
89
+ const issuedThrough = {
90
+ typeOf: payTransactionObject.typeOf,
91
+ id: (typeof payTransactionObject.id === 'string') ? payTransactionObject.id : ''
92
+ // CreditCardIFのカード通貨区分を追加(2023-08-07~)
93
+ // ...(typeof payTransactionObject.paymentMethod?.amount !== 'number'
94
+ // && typeof payTransactionObject.paymentMethod?.amount?.currency === 'string')
95
+ // ? {
96
+ // serviceOutput: {
97
+ // paymentMethod: {
98
+ // amount: {
99
+ // currency: payTransactionObject.paymentMethod.amount.currency,
100
+ // value: payTransactionObject.paymentMethod.amount.value
101
+ // }
102
+ // }
103
+ // }
104
+ // }
105
+ // : undefined
106
+ };
92
107
  return {
93
- accountId: (typeof ((_d = payTransactionObject.paymentMethod) === null || _d === void 0 ? void 0 : _d.accountId) === 'string')
108
+ accountId: (typeof ((_b = payTransactionObject.paymentMethod) === null || _b === void 0 ? void 0 : _b.accountId) === 'string')
94
109
  ? payTransactionObject.paymentMethod.accountId
95
110
  : '',
96
111
  // 廃止(2023-08-07~)
@@ -98,10 +113,10 @@ function createAuthorizeResult(params) {
98
113
  issuedThrough,
99
114
  paymentMethod: params.object.paymentMethod,
100
115
  paymentStatus: factory.paymentStatusType.PaymentDue,
101
- paymentMethodId: (typeof ((_e = payTransactionObject.paymentMethod) === null || _e === void 0 ? void 0 : _e.paymentMethodId) === 'string')
116
+ paymentMethodId: (typeof ((_c = payTransactionObject.paymentMethod) === null || _c === void 0 ? void 0 : _c.paymentMethodId) === 'string')
102
117
  ? payTransactionObject.paymentMethod.paymentMethodId
103
118
  : '',
104
- name: (typeof ((_f = payTransactionObject.paymentMethod) === null || _f === void 0 ? void 0 : _f.name) === 'string')
119
+ name: (typeof ((_d = payTransactionObject.paymentMethod) === null || _d === void 0 ? void 0 : _d.name) === 'string')
105
120
  ? payTransactionObject.paymentMethod.name
106
121
  : params.object.paymentMethod,
107
122
  totalPaymentDue: totalPaymentDue,
@@ -114,7 +114,9 @@ function processAuthorizeCreditCard(params) {
114
114
  shopPass: params.shopPass,
115
115
  orderId: params.orderId,
116
116
  jobCd: GMO.utils.util.JobCd.Auth,
117
- amount: params.object.amount,
117
+ amount: (typeof params.object.amount === 'number')
118
+ ? params.object.amount
119
+ : params.object.amount.value,
118
120
  siteId: (_a = params.availableChannel.credentials) === null || _a === void 0 ? void 0 : _a.siteId,
119
121
  sitePass: (_b = params.availableChannel.credentials) === null || _b === void 0 ? void 0 : _b.sitePass
120
122
  };
@@ -127,7 +127,7 @@ function validatePaymentMethod(params, paymentServiceId) {
127
127
  }
128
128
  function processAccountTransaction(params) {
129
129
  return (repos) => __awaiter(this, void 0, void 0, function* () {
130
- var _a, _b, _c, _d, _e, _f;
130
+ var _a, _b, _c, _d, _e, _f, _g, _h;
131
131
  let pendingTransaction;
132
132
  const defaultName = `${factory.assetTransactionType.Pay} Transaction ${params.transactionNumber}`;
133
133
  const agent = Object.assign(Object.assign({}, params.agent), { name: (typeof params.agent.name === 'string') ? params.agent.name : defaultName });
@@ -165,7 +165,11 @@ function processAccountTransaction(params) {
165
165
  expires: params.expires,
166
166
  recipient: recipient,
167
167
  object: {
168
- amount: { value: (_f = params.paymentMethod) === null || _f === void 0 ? void 0 : _f.amount },
168
+ amount: {
169
+ value: (typeof ((_f = params.paymentMethod) === null || _f === void 0 ? void 0 : _f.amount) === 'number')
170
+ ? (_g = params.paymentMethod) === null || _g === void 0 ? void 0 : _g.amount
171
+ : (_h = params.paymentMethod) === null || _h === void 0 ? void 0 : _h.amount.value
172
+ },
169
173
  description: description,
170
174
  fromLocation: {
171
175
  accountNumber: accountNumber
@@ -214,9 +214,9 @@ function validatePaymentMethods(params) {
214
214
  if (typeof settings_1.settings.maxNumCreditCardPaymentMethod === 'number') {
215
215
  // CreditCard IFの決済方法の最大値検証
216
216
  const creditCardPaymentMethodCount = params.order.paymentMethods.filter((p) => {
217
- var _a, _b;
217
+ var _a, _b, _c;
218
218
  // カード通貨区分の存在する決済サービスを考慮(2023-08-09~)
219
- const serviceOutputAmountCurrency = (_b = (_a = p.issuedThrough.serviceOutput) === null || _a === void 0 ? void 0 : _a.amount) === null || _b === void 0 ? void 0 : _b.currency;
219
+ const serviceOutputAmountCurrency = (_c = (_b = (_a = p.issuedThrough.serviceOutput) === null || _a === void 0 ? void 0 : _a.paymentMethod) === null || _b === void 0 ? void 0 : _b.amount) === null || _c === void 0 ? void 0 : _c.currency;
220
220
  return p.issuedThrough.typeOf === factory.service.paymentService.PaymentServiceType.CreditCard
221
221
  && typeof serviceOutputAmountCurrency !== 'string';
222
222
  }).length;
package/package.json CHANGED
@@ -9,8 +9,8 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "^4.325.0-alpha.1",
13
- "@cinerino/sdk": "3.163.0",
12
+ "@chevre/factory": "4.325.0-alpha.2",
13
+ "@cinerino/sdk": "3.164.0",
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.0",
16
16
  "@sendgrid/mail": "6.4.0",
@@ -117,5 +117,5 @@
117
117
  "postversion": "git push origin --tags",
118
118
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
119
119
  },
120
- "version": "21.7.0-alpha.2"
120
+ "version": "21.7.0-alpha.3"
121
121
  }