@opengis/pay 1.1.13 → 1.1.14
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/module/pay/cls/billing.payment_status.json +8 -3
- package/module/pay/select/billing.subscription_id.sql +1 -0
- package/module/pay1/cls/billing.payment_status.json +22 -0
- package/module/pay1/pt/marketplace-service-payment-client-template.html +147 -0
- package/module/pay1/select/billing.account_id.sql +1 -0
- package/module/pay1/select/billing.service_id.sql +1 -0
- package/module/pay1/select/billing.subscription_id.sql +1 -0
- package/module/pay1/select/billing.user_id.sql +1 -0
- package/package.json +1 -1
- package/plugin.js +12 -2
- package/server/routes/payment.info.js +45 -0
- package/server/routes/portmone.redirect.js +17 -15
- /package/module/{pay → pay1}/card/billing.accounts.table/general_info.hbs +0 -0
- /package/module/{pay → pay1}/card/billing.accounts.table/index.yml +0 -0
- /package/module/{pay → pay1}/card/billing.accounts.table/users.hbs +0 -0
- /package/module/{pay → pay1}/card/billing.payments.table/general_info.hbs +0 -0
- /package/module/{pay → pay1}/card/billing.payments.table/index.yml +0 -0
- /package/module/{pay → pay1}/card/billing.users.table/general_info.hbs +0 -0
- /package/module/{pay → pay1}/card/billing.users.table/index.yml +0 -0
- /package/module/{pay → pay1}/form/billing.account_user.form.json +0 -0
- /package/module/{pay → pay1}/form/billing.accounts.form.json +0 -0
- /package/module/{pay → pay1}/form/billing.payment.form.json +0 -0
- /package/module/{pay → pay1}/form/billing.users.form.json +0 -0
- /package/module/{pay → pay1}/menu.json +0 -0
- /package/module/{pay → pay1}/table/billing.accounts.table.json +0 -0
- /package/module/{pay → pay1}/table/billing.payments.table.json +0 -0
- /package/module/{pay → pay1}/table/billing.users.table.json +0 -0
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
[
|
|
2
2
|
{
|
|
3
3
|
"id": "inprogress",
|
|
4
|
-
"text": "
|
|
5
|
-
"color": "
|
|
4
|
+
"text": "В процесі",
|
|
5
|
+
"color": "blue"
|
|
6
6
|
},
|
|
7
7
|
{
|
|
8
8
|
"id": "success",
|
|
9
9
|
"text": "Оплачено",
|
|
10
10
|
"color": "green"
|
|
11
11
|
},
|
|
12
|
+
{
|
|
13
|
+
"id": "unpaid",
|
|
14
|
+
"text": "Не оплачено",
|
|
15
|
+
"color": "gray"
|
|
16
|
+
},
|
|
12
17
|
{
|
|
13
18
|
"id": "error",
|
|
14
|
-
"text": "Помилка
|
|
19
|
+
"text": "Помилка оплати",
|
|
15
20
|
"color": "red"
|
|
16
21
|
}
|
|
17
22
|
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
select subscription_id,coalesce((select name from billing.products where product_id=a.product_id),'')||' '||coalesce(product_plan_type,'') from billing.subscriptions a
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "inprogress",
|
|
4
|
+
"text": "В процесі",
|
|
5
|
+
"color": "blue"
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"id": "success",
|
|
9
|
+
"text": "Оплачено",
|
|
10
|
+
"color": "green"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"id": "unpaid",
|
|
14
|
+
"text": "Не оплачено",
|
|
15
|
+
"color": "gray"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"id": "error",
|
|
19
|
+
"text": "Помилка оплати",
|
|
20
|
+
"color": "red"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
<div>
|
|
2
|
+
<br>
|
|
3
|
+
</div>
|
|
4
|
+
<div>
|
|
5
|
+
<table style="width:100%;">
|
|
6
|
+
<tbody>
|
|
7
|
+
<tr>
|
|
8
|
+
<td style="width:20px;"> </td>
|
|
9
|
+
<td align="center">
|
|
10
|
+
<table style="width:100%" bgcolor="#ffffff">
|
|
11
|
+
<tbody>
|
|
12
|
+
<tr>
|
|
13
|
+
<td align="center"><a href="//{{domain}}" class="logo"><img src="https://softpro.ua/tpl/img/logo.svg"/></a>
|
|
14
|
+
</td>
|
|
15
|
+
</tr>
|
|
16
|
+
|
|
17
|
+
<tr>
|
|
18
|
+
<td style="padding:7px 0" align="center"><span style="color:#555454;font-family:'Open-sans',sans-serif;font-size:small">
|
|
19
|
+
<span style="font-weight:500;font-size:16px;text-transform:uppercase;line-height:25px">{{select account_id data="billing.account_id"}}, дякуємо за здійснення замовлення на порталі <a href="//{{domain}}">{{domain}}</a></span> </span>
|
|
20
|
+
</td>
|
|
21
|
+
</tr>
|
|
22
|
+
<tr>
|
|
23
|
+
<td style="padding:0"> </td>
|
|
24
|
+
</tr>
|
|
25
|
+
<tr>
|
|
26
|
+
<td style="box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);padding:7px 0;border-radius:30px">
|
|
27
|
+
<table style="width:100%">
|
|
28
|
+
<tbody>
|
|
29
|
+
<tr >
|
|
30
|
+
<td style="padding:7px 0" width="10"> </td>
|
|
31
|
+
<td style="padding:7px 0">
|
|
32
|
+
<span style="color:#555454;font-family:'Open-sans',sans-serif;font-size:small"> </span>
|
|
33
|
+
{{#if service_id}}
|
|
34
|
+
<p style="color:#61677b;border-bottom:1px solid #61677b;margin:3px 0 7px;text-transform:uppercase;font-weight:500;font-size:18px;padding-bottom:10px">Послуга: {{service_id_text}}</p>
|
|
35
|
+
{{/if}}
|
|
36
|
+
<br>
|
|
37
|
+
<span style="color:#61677b"><strong>Дата замовлення:</strong> {{formatDate cdate format='dd.mm.yy hh:mi'}}</span>
|
|
38
|
+
<br>
|
|
39
|
+
<span style="color:#61677b"><strong>Статус замовлення:</strong> {{select payment_status data="billing.payment_status"}}</span>
|
|
40
|
+
{{#if withdrawal_sum}}
|
|
41
|
+
<br>
|
|
42
|
+
<span style="color:#61677b"><strong>Вартість послуги:</strong> {{num_format withdrawal_sum dec="2"}}</span>
|
|
43
|
+
{{/if}}
|
|
44
|
+
{{#if payment_amount}}
|
|
45
|
+
<br>
|
|
46
|
+
<span style="color:#61677b"><strong>Поповнення рахунку:</strong> {{num_format payment_amount dec="2"}}</span>
|
|
47
|
+
{{/if}}
|
|
48
|
+
{{#if total_balance}}
|
|
49
|
+
<br>
|
|
50
|
+
<span style="color:#61677b"><strong>Поточний баланс:</strong> {{num_format total_balance dec="2"}}</span>
|
|
51
|
+
{{/if}}
|
|
52
|
+
</td>
|
|
53
|
+
<td style="padding:7px 0" width="10"> </td>
|
|
54
|
+
</tr>
|
|
55
|
+
</tbody>
|
|
56
|
+
</table>
|
|
57
|
+
</td>
|
|
58
|
+
</tr>
|
|
59
|
+
|
|
60
|
+
<tr>
|
|
61
|
+
<td style="padding:7px 0">
|
|
62
|
+
<span style="color:#555454;font-family:'Open-sans',sans-serif;font-size:small"> </span>
|
|
63
|
+
<table style="width:100%;border-collapse:collapse" bgcolor="#ffffff">
|
|
64
|
+
<tbody>
|
|
65
|
+
<tr>
|
|
66
|
+
<th style="border:1px solid #d6d4d4;background-color:#fbfbfb;color:#61677b;font-family:Arial;font-size:13px;padding:10px" bgcolor="#f8f8f8">Назва послуги</th>
|
|
67
|
+
<th style="border:1px solid #d6d4d4;background-color:#fbfbfb;color:#61677b;font-family:Arial;font-size:13px;padding:10px" bgcolor="#f8f8f8" width="17%">Ціна послуги</th>
|
|
68
|
+
</tr>
|
|
69
|
+
<tr>
|
|
70
|
+
<td style="border:1px solid #d6d4d4">
|
|
71
|
+
<table>
|
|
72
|
+
<tbody>
|
|
73
|
+
<tr>
|
|
74
|
+
<td style="padding: 0 10px">
|
|
75
|
+
<font size="2" face="Open-sans, sans-serif" color="#555454">
|
|
76
|
+
<strong>
|
|
77
|
+
{{#if service_id}}
|
|
78
|
+
{{service_id_text}}
|
|
79
|
+
{{^}}
|
|
80
|
+
Поповнення рахунку
|
|
81
|
+
{{/if}}
|
|
82
|
+
</strong>
|
|
83
|
+
</font>
|
|
84
|
+
</td>
|
|
85
|
+
</tr>
|
|
86
|
+
</tbody>
|
|
87
|
+
</table>
|
|
88
|
+
</td>
|
|
89
|
+
<td style="border:1px solid #d6d4d4">
|
|
90
|
+
<table>
|
|
91
|
+
<tbody>
|
|
92
|
+
<tr>
|
|
93
|
+
<td width="10"> </td>
|
|
94
|
+
<td align="right">
|
|
95
|
+
<font size="2" face="Open-sans, sans-serif" color="#555454"> {{num_format (coalesce withdrawal_sum payment_amount)}} грн.</font>
|
|
96
|
+
</td>
|
|
97
|
+
<td width="10"> </td>
|
|
98
|
+
</tr>
|
|
99
|
+
</tbody>
|
|
100
|
+
</table>
|
|
101
|
+
</td>
|
|
102
|
+
</tr>
|
|
103
|
+
|
|
104
|
+
<tr>
|
|
105
|
+
<td colspan="2" style="border:1px solid #d6d4d4;text-align:center;color:#777;padding:7px 0"> </td>
|
|
106
|
+
</tr>
|
|
107
|
+
|
|
108
|
+
<tr>
|
|
109
|
+
<td colspan="1" style="border:1px solid #d6d4d4;color:#61677b;padding:7px 0" bgcolor="#f8f8f8">
|
|
110
|
+
<table style="width:100%;border-collapse:collapse">
|
|
111
|
+
<tbody>
|
|
112
|
+
<tr>
|
|
113
|
+
<td style="color:#61677b;padding:0" width="10"> </td>
|
|
114
|
+
<td style="color:#61677b;padding:0" align="right"><span style="color:#555454;font-family:'Open-sans',sans-serif;font-size:small"> <strong>Поточний баланс</strong> </span></td>
|
|
115
|
+
<td style="color:#61677b;padding:0" width="10"> </td>
|
|
116
|
+
</tr>
|
|
117
|
+
</tbody>
|
|
118
|
+
</table>
|
|
119
|
+
</td>
|
|
120
|
+
<td colspan="1" style="border:1px solid #d6d4d4;color:#61677b;padding:7px 0" bgcolor="#f8f8f8">
|
|
121
|
+
<table style="width:100%;border-collapse:collapse">
|
|
122
|
+
<tbody>
|
|
123
|
+
<tr>
|
|
124
|
+
<td style="color:#61677b;padding:0" width="10"> </td>
|
|
125
|
+
<td style="color:#61677b;padding:0" align="right"><span style="color:#555454;font-family:'Open-sans',sans-serif;font-size:large">{{total_balance}} грн. </span></td>
|
|
126
|
+
<td style="color:#61677b;padding:0" width="10"> </td>
|
|
127
|
+
</tr>
|
|
128
|
+
</tbody>
|
|
129
|
+
</table>
|
|
130
|
+
</td>
|
|
131
|
+
</tr>
|
|
132
|
+
</tbody>
|
|
133
|
+
</table>
|
|
134
|
+
</td>
|
|
135
|
+
</tr>
|
|
136
|
+
|
|
137
|
+
<tr>
|
|
138
|
+
<td style="border-top:4px solid #61677b;padding:7px 0"><span><a href="//{{domain}}"><img src="https://softpro.ua/tpl/img/logo.svg"/></a></span></td>
|
|
139
|
+
</tr>
|
|
140
|
+
</tbody>
|
|
141
|
+
</table>
|
|
142
|
+
</td>
|
|
143
|
+
<td style="width:20px;"> </td>
|
|
144
|
+
</tr>
|
|
145
|
+
</tbody>
|
|
146
|
+
</table>
|
|
147
|
+
</div>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
select account_id, account_name from billing.accounts order by account_name
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
select service_id, service_name from billing.service order by service_name
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
select subscription_id,coalesce((select name from billing.products where product_id=a.product_id),'')||' '||coalesce(product_plan_type,'') from billing.subscriptions a
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
select user_id, user_name || coalesce(login,'') as name from billing.users order by user_name
|
package/package.json
CHANGED
package/plugin.js
CHANGED
|
@@ -2,10 +2,11 @@ import fp from 'fastify-plugin';
|
|
|
2
2
|
|
|
3
3
|
import { config, execMigrations } from '@opengis/fastify-table/utils.js';
|
|
4
4
|
|
|
5
|
-
const { prefix = '/api' } = config;
|
|
6
|
-
|
|
7
5
|
import portmoneRedirect from './server/routes/portmone.redirect.js';
|
|
8
6
|
import portmoneStatus from './server/routes/portmone.status.js';
|
|
7
|
+
import paymentInfo from './server/routes/payment.info.js';
|
|
8
|
+
|
|
9
|
+
const { prefix = '/api' } = config;
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* This plugins adds some utilities to handle http errors
|
|
@@ -25,6 +26,15 @@ async function plugin(app) {
|
|
|
25
26
|
handler: portmoneRedirect,
|
|
26
27
|
});
|
|
27
28
|
|
|
29
|
+
app.route({
|
|
30
|
+
method: 'GET',
|
|
31
|
+
url: `${prefix}/payment-info/:id`,
|
|
32
|
+
config: {
|
|
33
|
+
policy: ['site'],
|
|
34
|
+
},
|
|
35
|
+
handler: paymentInfo,
|
|
36
|
+
});
|
|
37
|
+
|
|
28
38
|
app.route({
|
|
29
39
|
method: 'POST',
|
|
30
40
|
url: `${prefix}/portmone/:id/:status`,
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { metaFormat, pgClients } from '@opengis/fastify-table/utils.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Апі для отримання інформації за ID
|
|
5
|
+
*
|
|
6
|
+
* @method GET
|
|
7
|
+
* @alias paymentInfo
|
|
8
|
+
* @type api
|
|
9
|
+
* @param {String} params.id - ID платежу
|
|
10
|
+
* @returns {Number} status - номер помилки. Повертається, якщо була допущенна помилка в отриманих параметрах, або з бази. Це може бути 400 або 500
|
|
11
|
+
* @returns {String} error - опис помилки
|
|
12
|
+
* @returns {String} message - повідомлення про успішне виконання і передача певних даних або помилку
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export default async function paymentInfo({
|
|
16
|
+
pg = pgClients.client, user = {}, params = {},
|
|
17
|
+
}) {
|
|
18
|
+
if (!user?.uid) {
|
|
19
|
+
return { message: 'unauthorized', status: 401 };
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (!params?.id) {
|
|
23
|
+
return { message: 'not enough query params: id', status: 400 };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const { rows = [] } = await pg.query(`select
|
|
27
|
+
payment_id,
|
|
28
|
+
account_id,
|
|
29
|
+
payment_amount,
|
|
30
|
+
payment_status,
|
|
31
|
+
total_balance,
|
|
32
|
+
payment_num,
|
|
33
|
+
subscription_id
|
|
34
|
+
from billing.payments
|
|
35
|
+
where payment_id = $1
|
|
36
|
+
and account_id in (select account_id from billing.account_user where user_id = $2)`, [params.id, user.uid]);
|
|
37
|
+
|
|
38
|
+
if (!rows.length) {
|
|
39
|
+
return { message: 'payment not found', status: 404 };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
await metaFormat({ rows, cls: { account_id: 'billing.account_id', payment_status: 'billing.payment_status', subscription_id: 'billing.subscription_id' } });
|
|
43
|
+
|
|
44
|
+
return rows[0];
|
|
45
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import request from 'request-promise';
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
-
config, pgClients, logger, dataInsert, dataUpdate,
|
|
4
|
+
config, pgClients, logger, dataInsert, dataUpdate, handlebarsSync,
|
|
5
5
|
} from '@opengis/fastify-table/utils.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -25,7 +25,7 @@ export default async function PortmoneRedirect(req, reply) {
|
|
|
25
25
|
pg = pgClients.client, user = {}, query = {}, headers = {},
|
|
26
26
|
} = req;
|
|
27
27
|
|
|
28
|
-
const { host, payeeId } = config.integrations?.pay || {};
|
|
28
|
+
const { host, payeeId, paymentRedirect = config.paymentRedirect } = config.integrations?.pay || {};
|
|
29
29
|
const domain = req.hostname.split(':').shift();
|
|
30
30
|
|
|
31
31
|
if (!host) {
|
|
@@ -63,31 +63,32 @@ export default async function PortmoneRedirect(req, reply) {
|
|
|
63
63
|
if (!config.auth?.disableRestricted) return { message: 'access restricted: referer', status: 403 };
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
const { payment_id: paymentId } = data.payment_id
|
|
67
|
-
? await
|
|
68
|
-
table: 'billing.payments',
|
|
69
|
-
id: data.payment_id,
|
|
70
|
-
data: {
|
|
71
|
-
referer_url: headers?.referer,
|
|
72
|
-
payment_status: 'inprogress',
|
|
73
|
-
},
|
|
74
|
-
uid: user?.uid || '0',
|
|
75
|
-
})
|
|
76
|
-
: await dataInsert({
|
|
66
|
+
const { payment_id: paymentId } = !data.payment_id
|
|
67
|
+
? await dataInsert({
|
|
77
68
|
table: 'billing.payments',
|
|
78
69
|
data: {
|
|
79
70
|
payment_amount: paymentAmount,
|
|
80
71
|
account_id: accountId,
|
|
81
|
-
referer_url: headers?.referer,
|
|
82
72
|
payment_status: 'inprogress',
|
|
83
73
|
},
|
|
84
74
|
uid: user?.uid || '0',
|
|
85
|
-
}).then(el => el.rows?.[0] || {})
|
|
75
|
+
}).then(el => el.rows?.[0] || {})
|
|
76
|
+
: { payment_id: data.payment_id };
|
|
86
77
|
|
|
87
78
|
if (!paymentId) {
|
|
88
79
|
return { message: 'payment not found', status: 404 };
|
|
89
80
|
}
|
|
90
81
|
|
|
82
|
+
await dataUpdate({
|
|
83
|
+
table: 'billing.payments',
|
|
84
|
+
id: paymentId,
|
|
85
|
+
data: {
|
|
86
|
+
referer_url: paymentRedirect ? handlebarsSync.compile(paymentRedirect)({ id: paymentId }) : headers?.referer,
|
|
87
|
+
payment_status: 'inprogress',
|
|
88
|
+
},
|
|
89
|
+
uid: user?.uid || '0',
|
|
90
|
+
});
|
|
91
|
+
|
|
91
92
|
const protocol = headers?.referer.split('://').shift();
|
|
92
93
|
|
|
93
94
|
const formData = {
|
|
@@ -107,6 +108,7 @@ export default async function PortmoneRedirect(req, reply) {
|
|
|
107
108
|
accountId,
|
|
108
109
|
price: paymentAmount,
|
|
109
110
|
domain,
|
|
111
|
+
paymentRedirectUrl: paymentRedirect ? handlebarsSync.compile(paymentRedirect)({ id: paymentId }) : headers?.referer,
|
|
110
112
|
uid: user?.uid || '0',
|
|
111
113
|
};
|
|
112
114
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|