@opengis/pay 1.1.4 → 1.1.5

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/pay",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "type": "module",
5
5
  "description": "pay plugins for billing",
6
6
  "main": "plugin.js",
@@ -1,5 +1,5 @@
1
1
  import {
2
- config, logger, pgClients, getSelectVal, dataUpdate, getTemplate,
2
+ config, logger, pgClients, dataUpdate, getTemplate,
3
3
  } from '@opengis/fastify-table/utils.js';
4
4
 
5
5
  import { sendNotification } from '@opengis/admin/utils.js';
@@ -23,13 +23,8 @@ import { sendNotification } from '@opengis/admin/utils.js';
23
23
 
24
24
  export default async function portmoneStatus(req, reply) {
25
25
  const {
26
- pg = pgClients.client, params = {}, headers = {}, body = {}, user,
26
+ pg = pgClients.client, params = {}, headers = {}, body = {}, user = {},
27
27
  } = req;
28
-
29
- if (!user?.uid) {
30
- return { message: 'access restricted', status: 403 };
31
- }
32
-
33
28
  const { host } = config.integrations?.pay || {};
34
29
 
35
30
  if (!host) {
@@ -53,8 +48,12 @@ export default async function portmoneStatus(req, reply) {
53
48
  } = data;
54
49
 
55
50
  if (trxStatus === 'success') {
56
- logger.file('integrations/portmone/status/skip', {
57
- origin, uid: user.uid, message: 'Transaction was already processed',
51
+ logger.file('payments/skip', {
52
+ type: 'status',
53
+ paymentId,
54
+ origin,
55
+ uid: user.uid,
56
+ message: 'Transaction was already processed',
58
57
  });
59
58
  return { message: 'Transaction was already processed', status: 400 };
60
59
  }
@@ -69,6 +68,7 @@ export default async function portmoneStatus(req, reply) {
69
68
  if (!config.debug && !origin?.startsWith(host)) {
70
69
  logger.file('payments/warn', {
71
70
  type: 'status',
71
+ paymentId,
72
72
  origin,
73
73
  uid: user.uid,
74
74
  refill,
@@ -79,6 +79,7 @@ export default async function portmoneStatus(req, reply) {
79
79
 
80
80
  logger.file('payments', {
81
81
  type: 'status',
82
+ paymentId,
82
83
  origin,
83
84
  uid: user.uid,
84
85
  refill,
@@ -108,20 +109,17 @@ export default async function portmoneStatus(req, reply) {
108
109
 
109
110
  logger.file('payments', {
110
111
  type: 'status',
112
+ paymentId,
113
+ responseStatus,
111
114
  to,
115
+ origin,
112
116
  redirect: redirectUrl,
113
- paymentId,
114
117
  uid: user.uid,
115
118
  });
116
119
 
117
- const cls2 = await getSelectVal({ pg, name: 'billing.account_id', values: [accountId] });
118
- const cls3 = await getSelectVal({ pg, name: 'billing.payment_status', values: [trxStatus] });
119
-
120
120
  Object.assign(data, {
121
121
  domain: req.hostname,
122
122
  total_balance: +(refill || 0) + (+totalBalance || 0),
123
- account_id_text: accountId ? cls2?.[accountId] || accountId : 'Інформація відсутня',
124
- payment_status_text: trxStatus ? cls3?.[trxStatus] || trxStatus : 'Інформація відсутня',
125
123
  });
126
124
 
127
125
  if (to) {
@@ -136,23 +134,16 @@ export default async function portmoneStatus(req, reply) {
136
134
  };
137
135
  await sendNotification(options);
138
136
  }
139
- logger.file('payments', {
140
- type: 'status',
141
- to,
142
- redirect: redirectUrl,
143
- paymentId,
144
- responseStatus,
145
- uid: user.uid,
146
- });
147
137
  return reply.redirect(redirectUrl || '/');
148
138
  }
149
139
  catch (err) {
150
140
  logger.file('payments/error', {
151
141
  type: 'status',
152
- error: err.toString(),
153
- uid: user.uid,
154
142
  paymentId,
143
+ origin,
155
144
  responseStatus,
145
+ uid: user.uid,
146
+ error: err.toString(),
156
147
  });
157
148
  return { error: err.toString(), status: 500 };
158
149
  }