@opengis/pay 1.0.0 → 1.1.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.
Files changed (38) hide show
  1. package/README.md +7 -6
  2. package/module/pay/card/billing.accounts.table/general_info.hbs +11 -0
  3. package/module/pay/card/billing.accounts.table/index.yml +15 -0
  4. package/module/pay/card/billing.accounts.table/users.hbs +12 -0
  5. package/module/pay/card/billing.payments.table/general_info.hbs +13 -0
  6. package/module/pay/card/billing.payments.table/index.yml +10 -0
  7. package/module/pay/card/billing.users.table/general_info.hbs +11 -0
  8. package/module/pay/card/billing.users.table/index.yml +10 -0
  9. package/module/pay/cls/billing.payment_status.json +17 -0
  10. package/module/pay/form/billing.account_user.form.json +15 -0
  11. package/module/pay/form/billing.accounts.form.json +31 -0
  12. package/module/pay/form/billing.payment.form.json +23 -0
  13. package/module/pay/form/billing.users.form.json +39 -0
  14. package/module/pay/menu.json +24 -0
  15. package/{server/templates → module/pay}/pt/marketplace-service-payment-client-template.html +6 -8
  16. package/module/pay/select/billing.account_id.sql +1 -0
  17. package/module/pay/select/billing.user_id.sql +1 -0
  18. package/module/pay/table/billing.accounts.table.json +61 -0
  19. package/module/pay/table/billing.payments.table.json +68 -0
  20. package/module/pay/table/billing.users.table.json +71 -0
  21. package/package.json +8 -12
  22. package/plugin.js +12 -16
  23. package/server/migrations/1_users.sql +121 -0
  24. package/server/migrations/2_accounts.sql +59 -0
  25. package/server/migrations/3_utils.sql +74 -0
  26. package/server/migrations/4_subscriptions.sql +36 -0
  27. package/server/migrations/5_payments.sql +37 -0
  28. package/server/migrations/6_invoices.sql +55 -0
  29. package/server/routes/portmone.redirect.js +137 -0
  30. package/server/routes/portmone.status.js +159 -0
  31. package/config.js +0 -7
  32. package/controllers/portmone/portmone.redirect.js +0 -80
  33. package/controllers/portmone/portmone.status.js +0 -113
  34. package/server/migrations/users.sql +0 -89
  35. package/server/plugins/hook.js +0 -16
  36. package/server/templates/cls/billing.trx_status.json +0 -14
  37. package/server/templates/select/billing.account_id.sql +0 -5
  38. /package/{server/templates → module/pay}/select/billing.service_id.sql +0 -0
package/README.md CHANGED
@@ -1,15 +1,16 @@
1
- # settings
1
+ # pay
2
2
 
3
- [![NPM version](https://img.shields.io/npm/v/@opengis/billing)](https://www.npmjs.com/package/@opengis/billing)
3
+ [![NPM version](https://img.shields.io/npm/v/@opengis/pay)](https://www.npmjs.com/package/@opengis/pay)
4
4
  [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/)
5
5
 
6
- It standardizes the entire authorization process, while taking care of everything from login to logout
6
+ It standardizes the entire payment process
7
7
 
8
8
  ## Install
9
9
 
10
10
  ```bash
11
- npm i @opengis/billing
11
+ npm i @opengis/pay
12
12
  ```
13
+
13
14
  ## Publish
14
15
 
15
16
  ```bash
@@ -20,9 +21,9 @@ npm publish
20
21
  ## Usage
21
22
 
22
23
  ```js
23
- fastify.register(import('@opengis/billing'), config);
24
+ app.register(import('@opengis/pay'), config);
24
25
  ```
25
26
 
26
27
  ## Documenation
27
28
 
28
- For a detailed understanding of `billing`, its features, and how to use them, refer to our [Documentation](https://apidocs.softpro.ua/opengis/plugin/).
29
+ For a detailed understanding of `pay plugin` for billing, its features, and how to use them, refer to our [Documentation](https://apidocs.softpro.ua/opengis/plugin/pay.html).
@@ -0,0 +1,11 @@
1
+ {{{descriptionList this columns="Назва,account_name,ЄДРПОУ,account_edrpou,Email,account_email,On/Off,enabled"}}}
2
+
3
+ <style>
4
+ .label {
5
+ display: inline-block;
6
+ padding: 4px 8px;
7
+ border-radius: 5px;
8
+ font-size: 12px;
9
+ font-weight: bold;
10
+ }
11
+ </style>
@@ -0,0 +1,15 @@
1
+ component: default
2
+ # title: Мій підпис
3
+ tokens:
4
+ id: { id: "{{id}}" }
5
+ panels:
6
+ - type: container
7
+ col: 4
8
+ items:
9
+ - name: general_info
10
+ title: Загальна інформація
11
+ - type: container
12
+ col: 8
13
+ items:
14
+ - name: users
15
+ title: Користувачі
@@ -0,0 +1,12 @@
1
+
2
+ {{#contentList table="(select users.user_id, user_name || coalesce(login,'') as name, au_id, account_id from billing.users left join ( SELECT user_id, au_id, account_id FROM billing.account_user )r on users.user_id=r.user_id)q" query="account_id='{{id}}'" limit="50" sql1=1}}
3
+ {{{button this token=(token table="billing.account_user" obj=(concat 'account_id=' @root.id) form="billing.account_user.form") title="Додати"}}}
4
+
5
+ {{{tableList rows table='billing.account_user' id='au_id' form="billing.account_user.form" uid=../user.uid
6
+ nodata='<div class="bg-gray-200 text-center p-6 rounded-xl"><h3 class="text-lg font-semibold">Інформація відсутня</h3></div>'
7
+ comma=";"
8
+ columns="Користувач,<a href='/card/billing.users.table/{{user_id}}'>{{name}}</a>"
9
+ }}}
10
+
11
+
12
+ {{/contentList}}
@@ -0,0 +1,13 @@
1
+
2
+
3
+ {{{descriptionList this columns="Організація,account_id,Сума,payment_amount,Статус,payment_status,Дії,<a class=\"inline-flex items-center px-3 py-2 text-sm font-medium text-white duration-300 bg-blue-600 border border-transparent rounded-lg gap-x-2 hover:bg-blue-700 hover:text-white\" href=\"/api/portmone-redirect?id={{id}}\">Оплатити</a>"}}}
4
+
5
+ <style>
6
+ .label {
7
+ display: inline-block;
8
+ padding: 4px 8px;
9
+ border-radius: 5px;
10
+ font-size: 12px;
11
+ font-weight: bold;
12
+ }
13
+ </style>
@@ -0,0 +1,10 @@
1
+ component: default
2
+ # title: Мій підпис
3
+ tokens:
4
+ id: { id: "{{id}}" }
5
+ panels:
6
+ - type: container
7
+ col: 12
8
+ items:
9
+ - name: general_info
10
+ title: Загальна інформація
@@ -0,0 +1,11 @@
1
+ {{{descriptionList this columns="Прізвище,sur_name,Ім'я,user_name,Email,email,On/Off,enabled"}}}
2
+
3
+ <style>
4
+ .label {
5
+ display: inline-block;
6
+ padding: 4px 8px;
7
+ border-radius: 5px;
8
+ font-size: 12px;
9
+ font-weight: bold;
10
+ }
11
+ </style>
@@ -0,0 +1,10 @@
1
+ component: default
2
+ # title: Мій підпис
3
+ tokens:
4
+ id: { id: "{{id}}" }
5
+ panels:
6
+ - type: container
7
+ col: 12
8
+ items:
9
+ - name: general_info
10
+ title: Загальна інформація
@@ -0,0 +1,17 @@
1
+ [
2
+ {
3
+ "id": "inprogress",
4
+ "text": "Не оплачено",
5
+ "color": "gray"
6
+ },
7
+ {
8
+ "id": "success",
9
+ "text": "Оплачено",
10
+ "color": "green"
11
+ },
12
+ {
13
+ "id": "error",
14
+ "text": "Помилка при оплаті",
15
+ "color": "red"
16
+ }
17
+ ]
@@ -0,0 +1,15 @@
1
+ {
2
+ "schema": {
3
+ "user_id": {
4
+ "type": "Autocomplete",
5
+ "data": "billing.user_id",
6
+ "ua": "Користувач",
7
+ "validators": [
8
+ "required"
9
+ ]
10
+ }
11
+ },
12
+ "style": {
13
+ "label": "vertical"
14
+ }
15
+ }
@@ -0,0 +1,31 @@
1
+ {
2
+ "schema": {
3
+ "account_name": {
4
+ "type": "Text",
5
+ "ua": "Назва організації",
6
+ "validators": [
7
+ "required"
8
+ ]
9
+ },
10
+ "account_edrpou": {
11
+ "type": "Text",
12
+ "ua": "ЄДРПОУ"
13
+ },
14
+ "account_email": {
15
+ "type": "Text",
16
+ "ua": "Пошта організації",
17
+ "i": "Повідомлення про статус платежів будуть надіслані на дану ел. адресу",
18
+ "validators": [
19
+ "required"
20
+ ]
21
+ },
22
+ "enabled": {
23
+ "type": "Switcher",
24
+ "default": true,
25
+ "ua": "On / Off"
26
+ }
27
+ },
28
+ "style": {
29
+ "label": "vertical"
30
+ }
31
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "schema": {
3
+ "payment_amount": {
4
+ "type": "Number",
5
+ "min": 0,
6
+ "ua": "Сума платежу",
7
+ "validators": [
8
+ "required"
9
+ ]
10
+ },
11
+ "account_id": {
12
+ "type": "Autocomplete",
13
+ "data": "billing.account_id",
14
+ "ua": "Назва організації",
15
+ "validators": [
16
+ "required"
17
+ ]
18
+ }
19
+ },
20
+ "style": {
21
+ "label": "vertical"
22
+ }
23
+ }
@@ -0,0 +1,39 @@
1
+ {
2
+ "schema": {
3
+ "sur_name": {
4
+ "type": "Text",
5
+ "ua": "Прізвище",
6
+ "validators": [
7
+ "required"
8
+ ]
9
+ },
10
+ "user_name": {
11
+ "type": "Text",
12
+ "ua": "Ім'я",
13
+ "validators": [
14
+ "required"
15
+ ]
16
+ },
17
+ "father_name": {
18
+ "type": "Text",
19
+ "ua": "По-батькові"
20
+ },
21
+ "email": {
22
+ "type": "Text",
23
+ "ua": "Email"
24
+ },
25
+ "phone": {
26
+ "type": "MarkedText",
27
+ "mask": "+389999999999",
28
+ "ua": "Номер телефону"
29
+ },
30
+ "enabled": {
31
+ "type": "Switcher",
32
+ "default": true,
33
+ "ua": "On / Off"
34
+ }
35
+ },
36
+ "style": {
37
+ "label": "vertical"
38
+ }
39
+ }
@@ -0,0 +1,24 @@
1
+ [
2
+ {
3
+ "ua": "Платежі / Payments",
4
+ "menu": [
5
+ {
6
+ "ua": "Реєстр платежів",
7
+ "table": "billing.payments.table",
8
+ "path": "billing.payments"
9
+ },
10
+ {
11
+ "ua": "Реєстр організацій",
12
+ "table": "billing.accounts.table",
13
+ "path": "billing.accounts"
14
+ },
15
+ {
16
+ "ua": "Реєстр користувачів",
17
+ "table": "billing.users.table",
18
+ "path": "billing.users"
19
+ }
20
+ ]
21
+ }
22
+ ]
23
+
24
+
@@ -16,7 +16,7 @@
16
16
 
17
17
  <tr>
18
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">{{account_id_text}}, дякуємо за здійснення замовлення на порталі <a href="//{{domain}}">{{domain}}</a></span> </span>
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
20
  </td>
21
21
  </tr>
22
22
  <tr>
@@ -36,14 +36,14 @@
36
36
  <br>
37
37
  <span style="color:#61677b"><strong>Дата замовлення:</strong> {{formatDate cdate format='dd.mm.yy hh:mi'}}</span>
38
38
  <br>
39
- <span style="color:#61677b"><strong>Статус замовлення:</strong> {{trx_status_text}}</span>
39
+ <span style="color:#61677b"><strong>Статус замовлення:</strong> {{select payment_status data="billing.payment_status"}}</span>
40
40
  {{#if withdrawal_sum}}
41
41
  <br>
42
42
  <span style="color:#61677b"><strong>Вартість послуги:</strong> {{num_format withdrawal_sum dec="2"}}</span>
43
43
  {{/if}}
44
- {{#if refill_sum}}
44
+ {{#if payment_amount}}
45
45
  <br>
46
- <span style="color:#61677b"><strong>Поповнення рахунку:</strong> {{num_format refill_sum dec="2"}}</span>
46
+ <span style="color:#61677b"><strong>Поповнення рахунку:</strong> {{num_format payment_amount dec="2"}}</span>
47
47
  {{/if}}
48
48
  {{#if total_balance}}
49
49
  <br>
@@ -77,9 +77,7 @@
77
77
  {{#if service_id}}
78
78
  {{service_id_text}}
79
79
  {{^}}
80
- {{#if refill_sum}}
81
- Поповнення рахунку
82
- {{/if}}
80
+ Поповнення рахунку
83
81
  {{/if}}
84
82
  </strong>
85
83
  </font>
@@ -94,7 +92,7 @@
94
92
  <tr>
95
93
  <td width="10">&nbsp;</td>
96
94
  <td align="right">
97
- <font size="2" face="Open-sans, sans-serif" color="#555454"> {{num_format (coalesce withdrawal_sum refill_sum)}} грн.</font>
95
+ <font size="2" face="Open-sans, sans-serif" color="#555454"> {{num_format (coalesce withdrawal_sum payment_amount)}} грн.</font>
98
96
  </td>
99
97
  <td width="10">&nbsp;</td>
100
98
  </tr>
@@ -0,0 +1 @@
1
+ select account_id, account_name from billing.accounts order by account_name
@@ -0,0 +1 @@
1
+ select user_id, user_name || coalesce(login,'') as name from billing.users order by user_name
@@ -0,0 +1,61 @@
1
+ {
2
+ "key": "account_id",
3
+ "table": "billing.accounts",
4
+ "order": "cdate desc",
5
+ "form": "billing.accounts.form",
6
+ "title_column": "account_name",
7
+ "title_full": {
8
+ "ua": "Реєстр організацій"
9
+ },
10
+ "actions": [
11
+ "add",
12
+ "edit",
13
+ "del"
14
+ ],
15
+ "columns": [
16
+ {
17
+ "name": "account_name",
18
+ "format": "text",
19
+ "title": "Назва організації"
20
+ },
21
+ {
22
+ "name": "account_edrpou",
23
+ "format": "text",
24
+ "title": "ЄДРПОУ"
25
+ },
26
+ {
27
+ "name": "account_email",
28
+ "format": "text",
29
+ "title": "Email"
30
+ },
31
+ {
32
+ "name": "enabled",
33
+ "hidden": true,
34
+ "format": "yes/no",
35
+ "title": "On / off"
36
+ }
37
+ ],
38
+ "filter_list": [
39
+ {
40
+ "name": "account_name",
41
+ "type": "Text",
42
+ "ua": "Назва організації"
43
+ },
44
+ {
45
+ "name": "account_edrpou",
46
+ "type": "Text",
47
+ "ua": "ЄДРПОУ"
48
+ },
49
+ {
50
+ "name": "account_email",
51
+ "type": "Text",
52
+ "ua": "Email"
53
+ },
54
+ {
55
+ "name": "enabled",
56
+ "type": "Check",
57
+ "data": "yes_no",
58
+ "ua": "On / off"
59
+ }
60
+ ]
61
+ }
@@ -0,0 +1,68 @@
1
+ {
2
+ "key": "payment_id",
3
+ "table": "billing.payments",
4
+ "order": "cdate desc",
5
+ "title_column": "account_id",
6
+ "form": "billing.payment.form",
7
+ "title_full": {
8
+ "ua": "Реєстр платежів"
9
+ },
10
+ "actions": [
11
+ "add",
12
+ "edit",
13
+ "del"
14
+ ],
15
+ "columns": [
16
+ {
17
+ "name": "account_id",
18
+ "data": "billing.account_id",
19
+ "format": "select",
20
+ "ua": "Назва організації"
21
+ },
22
+ {
23
+ "name": "payment_amount",
24
+ "format": "text",
25
+ "ua": "Сума поповнення рахунку"
26
+ },
27
+ {
28
+ "name": "total_balance",
29
+ "format": "text",
30
+ "ua": "Поточний баланс"
31
+ },
32
+ {
33
+ "name": "payment_status",
34
+ "data": "billing.payment_status",
35
+ "format": "badge",
36
+ "ua": "Статус транзації"
37
+ },
38
+ {
39
+ "name": "success_date",
40
+ "format": "date",
41
+ "ua": "Дата успішного завершення транзакції"
42
+ }
43
+ ],
44
+ "filter_list": [
45
+ {
46
+ "name": "account_id",
47
+ "data": "billing.account_id",
48
+ "type": "Text",
49
+ "ua": "Назва організації"
50
+ },
51
+ {
52
+ "name": "payment_amount",
53
+ "type": "Range",
54
+ "ua": "Сума поповнення рахунку"
55
+ },
56
+ {
57
+ "name": "payment_status",
58
+ "data": "billing.payment_status",
59
+ "type": "Check",
60
+ "ua": "Статус транзації"
61
+ },
62
+ {
63
+ "name": "success_date",
64
+ "type": "Date",
65
+ "ua": "Дата успішного завершення транзакції"
66
+ }
67
+ ]
68
+ }
@@ -0,0 +1,71 @@
1
+ {
2
+ "key": "user_id",
3
+ "table": "billing.users",
4
+ "order": "cdate desc",
5
+ "form": "billing.users.form",
6
+ "title_column": "user_name",
7
+ "title_full": {
8
+ "ua": "Реєстр користувачів"
9
+ },
10
+ "actions": [
11
+ "add",
12
+ "edit",
13
+ "del"
14
+ ],
15
+ "columns": [
16
+ {
17
+ "name": "user_name",
18
+ "format": "text",
19
+ "title": "Ім'я"
20
+ },
21
+ {
22
+ "name": "sur_name",
23
+ "format": "text",
24
+ "title": "Прізвище"
25
+ },
26
+ {
27
+ "name": "father_name",
28
+ "format": "text",
29
+ "title": "По-батькові"
30
+ },
31
+ {
32
+ "name": "email",
33
+ "format": "text",
34
+ "title": "Email"
35
+ },
36
+ {
37
+ "name": "enabled",
38
+ "hidden": true,
39
+ "format": "yes/no",
40
+ "title": "On / off"
41
+ }
42
+ ],
43
+ "filter_list": [
44
+ {
45
+ "name": "user_name",
46
+ "type": "Text",
47
+ "ua": "Ім'я користувача"
48
+ },
49
+ {
50
+ "name": "sur_name",
51
+ "type": "Text",
52
+ "ua": "Прізвище користувача"
53
+ },
54
+ {
55
+ "name": "father_name",
56
+ "type": "Text",
57
+ "ua": "По-батькові користувача"
58
+ },
59
+ {
60
+ "name": "email",
61
+ "type": "Text",
62
+ "ua": "Email"
63
+ },
64
+ {
65
+ "name": "enabled",
66
+ "type": "Check",
67
+ "data": "yes_no",
68
+ "ua": "On / off"
69
+ }
70
+ ]
71
+ }
package/package.json CHANGED
@@ -1,29 +1,25 @@
1
1
  {
2
2
  "name": "@opengis/pay",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "type": "module",
5
5
  "description": "pay plugins for billing",
6
6
  "main": "plugin.js",
7
7
  "browser": "plugin.js",
8
8
  "files": [
9
- "controllers/*",
10
- "funcs/*",
11
9
  "server/*",
12
- "plugin.js",
13
- "config.js"
10
+ "module/*",
11
+ "plugin.js"
14
12
  ],
15
13
  "scripts": {
16
- "test": "node --test",
14
+ "test": "node --test test/**/*.test.js",
17
15
  "start": "node --watch-path=server server",
18
- "dev": "fastify start -w -l info -P server/app.js",
19
- "debug": "cross-env NODE_ENV=production node server --inspect-brk",
20
- "prod": "cross-env NODE_ENV=production npm run start",
21
- "release": "npm run build && npm publish",
16
+ "admin": "cross-env NODE_ENV=admin npm run start",
22
17
  "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
23
18
  },
24
19
  "dependencies": {
25
- "@opengis/fastify-auth": "^1.0.22",
26
- "@opengis/fastify-table": "^1.0.82",
20
+ "@opengis/admin": "^0.2.14",
21
+ "@opengis/fastify-auth": "^1.0.53",
22
+ "@opengis/fastify-table": "^1.1.96",
27
23
  "cross-env": "^7.0.3",
28
24
  "fastify": "^4.26.1",
29
25
  "fastify-plugin": "^4.0.0",
package/plugin.js CHANGED
@@ -1,9 +1,11 @@
1
1
  import fp from 'fastify-plugin';
2
2
 
3
- import portmoneRedirect from './controllers/portmone/portmone.redirect.js';
4
- import portmoneStatus from './controllers/portmone/portmone.status.js';
3
+ import { config, execMigrations } from '@opengis/fastify-table/utils.js';
5
4
 
6
- import config from './config.js';
5
+ const { prefix = '/api' } = config;
6
+
7
+ import portmoneRedirect from './server/routes/portmone.redirect.js';
8
+ import portmoneStatus from './server/routes/portmone.status.js';
7
9
 
8
10
  /**
9
11
  * This plugins adds some utilities to handle http errors
@@ -11,25 +13,19 @@ import config from './config.js';
11
13
  * @see https://github.com/fastify/fastify-sensible
12
14
  */
13
15
 
14
- async function plugin(fastify, opt = {}) {
15
- config.redis = opt.redis;
16
- config.pg = opt.pg;
17
- const prefix = opt?.prefix || config.prefix || '/api';
18
-
19
- fastify.register(import('./server/plugins/hook.js'));
20
-
21
- fastify.route({
16
+ async function plugin(app) {
17
+ app.route({
22
18
  method: 'GET',
23
- path: `${prefix}/portmone-redirect`,
24
- config: { policy: ['public'] },
19
+ url: `${prefix}/portmone-redirect`,
25
20
  handler: portmoneRedirect,
26
21
  });
27
- fastify.route({
22
+ app.route({
28
23
  method: 'POST',
29
- path: `${prefix}/portmone/:id/:status`,
30
- config: { policy: ['public'] },
24
+ url: `${prefix}/portmone/:id/:status`,
31
25
  handler: portmoneStatus,
32
26
  });
27
+
28
+ execMigrations().catch(err => console.log(err));
33
29
  }
34
30
 
35
31
  export default fp(plugin);