strapi-plugin-payone-provider 1.0.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 (42) hide show
  1. package/README.md +571 -0
  2. package/admin/src/components/Initializer/index.js +16 -0
  3. package/admin/src/components/PluginIcon/index.js +6 -0
  4. package/admin/src/index.js +37 -0
  5. package/admin/src/pages/App/components/ConfigurationPanel.js +265 -0
  6. package/admin/src/pages/App/components/HistoryPanel.js +298 -0
  7. package/admin/src/pages/App/components/PaymentActionsPanel.js +333 -0
  8. package/admin/src/pages/App/components/StatusBadge.js +22 -0
  9. package/admin/src/pages/App/components/TransactionHistoryItem.js +374 -0
  10. package/admin/src/pages/App/components/icons/BankIcon.js +10 -0
  11. package/admin/src/pages/App/components/icons/ChevronDownIcon.js +9 -0
  12. package/admin/src/pages/App/components/icons/ChevronUpIcon.js +9 -0
  13. package/admin/src/pages/App/components/icons/CreditCardIcon.js +9 -0
  14. package/admin/src/pages/App/components/icons/ErrorIcon.js +10 -0
  15. package/admin/src/pages/App/components/icons/InfoIcon.js +9 -0
  16. package/admin/src/pages/App/components/icons/PaymentIcon.js +10 -0
  17. package/admin/src/pages/App/components/icons/PendingIcon.js +9 -0
  18. package/admin/src/pages/App/components/icons/PersonIcon.js +9 -0
  19. package/admin/src/pages/App/components/icons/SuccessIcon.js +9 -0
  20. package/admin/src/pages/App/components/icons/WalletIcon.js +9 -0
  21. package/admin/src/pages/App/components/icons/index.js +11 -0
  22. package/admin/src/pages/App/index.js +483 -0
  23. package/admin/src/pages/utils/api.js +75 -0
  24. package/admin/src/pages/utils/formatTransactionData.js +16 -0
  25. package/admin/src/pages/utils/paymentUtils.js +528 -0
  26. package/admin/src/pluginId.js +5 -0
  27. package/package.json +43 -0
  28. package/server/bootstrap.js +26 -0
  29. package/server/config/index.js +42 -0
  30. package/server/controllers/index.js +7 -0
  31. package/server/controllers/payone.js +134 -0
  32. package/server/destroy.js +5 -0
  33. package/server/index.js +21 -0
  34. package/server/policies/index.js +6 -0
  35. package/server/policies/isAuth.js +23 -0
  36. package/server/policies/isSuperAdmin.js +18 -0
  37. package/server/register.js +5 -0
  38. package/server/routes/index.js +124 -0
  39. package/server/services/index.js +7 -0
  40. package/server/services/payone.js +679 -0
  41. package/strapi-admin.js +3 -0
  42. package/strapi-server.js +3 -0
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+
3
+ module.exports = ({ strapi }) => ({
4
+ async getSettings(ctx) {
5
+ try {
6
+ const settings = await strapi
7
+ .plugin("payone-provider")
8
+ .service("payone")
9
+ .getSettings();
10
+
11
+ if (settings && settings.key) {
12
+ settings.key = "***HIDDEN***";
13
+ }
14
+
15
+ ctx.body = { data: settings };
16
+ } catch (error) {
17
+ ctx.throw(500, error);
18
+ }
19
+ },
20
+
21
+ async updateSettings(ctx) {
22
+ try {
23
+ const { body } = ctx.request;
24
+
25
+ const currentSettings = await strapi
26
+ .plugin("payone-provider")
27
+ .service("payone")
28
+ .getSettings();
29
+
30
+ if (body.key === "***HIDDEN***" || !body.key) {
31
+ body.key = currentSettings.key;
32
+ }
33
+
34
+ const settings = await strapi
35
+ .plugin("payone-provider")
36
+ .service("payone")
37
+ .updateSettings(body);
38
+
39
+ if (settings && settings.key) {
40
+ settings.key = "***HIDDEN***";
41
+ }
42
+
43
+ ctx.body = { data: settings };
44
+ } catch (error) {
45
+ ctx.throw(500, error);
46
+ }
47
+ },
48
+
49
+ async preauthorization(ctx) {
50
+ try {
51
+ const params = ctx.request.body;
52
+ const result = await strapi
53
+ .plugin("payone-provider")
54
+ .service("payone")
55
+ .preauthorization(params);
56
+
57
+ ctx.body = { data: result };
58
+ } catch (error) {
59
+ ctx.throw(500, error);
60
+ }
61
+ },
62
+
63
+ async authorization(ctx) {
64
+ try {
65
+ const params = ctx.request.body;
66
+ strapi.log.info("Payone authorization controller called with:", params);
67
+
68
+ const result = await strapi
69
+ .plugin("payone-provider")
70
+ .service("payone")
71
+ .authorization(params);
72
+
73
+ ctx.body = { data: result };
74
+ } catch (error) {
75
+ strapi.log.error("Payone authorization error:", error);
76
+ ctx.throw(500, error);
77
+ }
78
+ },
79
+
80
+ async capture(ctx) {
81
+ try {
82
+ const params = ctx.request.body;
83
+ const result = await strapi
84
+ .plugin("payone-provider")
85
+ .service("payone")
86
+ .capture(params);
87
+
88
+ ctx.body = { data: result };
89
+ } catch (error) {
90
+ ctx.throw(500, error);
91
+ }
92
+ },
93
+
94
+ async refund(ctx) {
95
+ try {
96
+ const params = ctx.request.body;
97
+ const result = await strapi
98
+ .plugin("payone-provider")
99
+ .service("payone")
100
+ .refund(params);
101
+
102
+ ctx.body = { data: result };
103
+ } catch (error) {
104
+ ctx.throw(500, error);
105
+ }
106
+ },
107
+
108
+ async getTransactionHistory(ctx) {
109
+ try {
110
+ const filters = ctx.query || {};
111
+ const history = await strapi
112
+ .plugin("payone-provider")
113
+ .service("payone")
114
+ .getTransactionHistory(filters);
115
+
116
+ ctx.body = { data: history };
117
+ } catch (error) {
118
+ ctx.throw(500, error);
119
+ }
120
+ },
121
+
122
+ async testConnection(ctx) {
123
+ try {
124
+ const result = await strapi
125
+ .plugin("payone-provider")
126
+ .service("payone")
127
+ .testConnection();
128
+
129
+ ctx.body = { data: result };
130
+ } catch (error) {
131
+ ctx.throw(500, error);
132
+ }
133
+ }
134
+ });
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ module.exports = ({ strapi }) => {
4
+ // Cleanup when plugin is destroyed
5
+ };
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ const register = require("./register");
4
+ const bootstrap = require("./bootstrap");
5
+ const destroy = require("./destroy");
6
+ const config = require("./config");
7
+ const controllers = require("./controllers");
8
+ const routes = require("./routes");
9
+ const services = require("./services");
10
+ const policies = require("./policies");
11
+
12
+ module.exports = {
13
+ register,
14
+ bootstrap,
15
+ destroy,
16
+ config,
17
+ controllers,
18
+ routes,
19
+ services,
20
+ policies
21
+ };
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ module.exports = {
4
+ isSuperAdmin: require("./isSuperAdmin"),
5
+ isAuth: require("./isAuth")
6
+ };
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ module.exports = async (ctx, config, { strapi }) => {
4
+ const { authorization } = ctx.request.header || {};
5
+
6
+ if (authorization && authorization.startsWith("Bearer ")) {
7
+ const token = authorization.split(" ")[1];
8
+
9
+ try {
10
+ const apiTokenService = strapi.services["admin::api-token"];
11
+ const accessKey = await apiTokenService.hash(token);
12
+ const storedToken = await apiTokenService.getBy({ accessKey });
13
+
14
+ if (storedToken) {
15
+ return true;
16
+ }
17
+ } catch (e) {
18
+ strapi.log.warn("payone-provider isAuth policy error:", e.message);
19
+ }
20
+ }
21
+
22
+ return false;
23
+ };
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ module.exports = async (ctx, next) => {
4
+ const adminUser = ctx.state && ctx.state.user;
5
+
6
+ if (!adminUser) {
7
+ return ctx.unauthorized("Admin authentication required");
8
+ }
9
+
10
+ const roles = Array.isArray(adminUser.roles) ? adminUser.roles : [];
11
+ const isSuperAdmin = roles.some((role) => role.code === "strapi-super-admin");
12
+
13
+ if (!isSuperAdmin) {
14
+ return ctx.forbidden("Only super admins can access this resource");
15
+ }
16
+
17
+ return next();
18
+ };
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ module.exports = ({ strapi }) => {
4
+ // Register the plugin with Strapi
5
+ };
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+
3
+ module.exports = {
4
+ admin: {
5
+ type: "admin",
6
+ routes: [
7
+ {
8
+ method: "GET",
9
+ path: "/settings",
10
+ handler: "payone.getSettings",
11
+ config: {
12
+ policies: ["admin::isAuthenticatedAdmin"]
13
+ }
14
+ },
15
+ {
16
+ method: "PUT",
17
+ path: "/settings",
18
+ handler: "payone.updateSettings",
19
+ config: {
20
+ policies: ["admin::isAuthenticatedAdmin"]
21
+ }
22
+ },
23
+ {
24
+ method: "GET",
25
+ path: "/transaction-history",
26
+ handler: "payone.getTransactionHistory",
27
+ config: {
28
+ policies: ["admin::isAuthenticatedAdmin"]
29
+ }
30
+ },
31
+ {
32
+ method: "POST",
33
+ path: "/test-connection",
34
+ handler: "payone.testConnection",
35
+ config: {
36
+ policies: ["admin::isAuthenticatedAdmin"]
37
+ }
38
+ },
39
+
40
+ {
41
+ method: "POST",
42
+ path: "/preauthorization",
43
+ handler: "payone.preauthorization",
44
+ config: {
45
+ policies: ["admin::isAuthenticatedAdmin"]
46
+ }
47
+ },
48
+ {
49
+ method: "POST",
50
+ path: "/authorization",
51
+ handler: "payone.authorization",
52
+ config: {
53
+ policies: ["admin::isAuthenticatedAdmin"]
54
+ }
55
+ },
56
+ {
57
+ method: "POST",
58
+ path: "/capture",
59
+ handler: "payone.capture",
60
+ config: {
61
+ policies: ["admin::isAuthenticatedAdmin"]
62
+ }
63
+ },
64
+ {
65
+ method: "POST",
66
+ path: "/refund",
67
+ handler: "payone.refund",
68
+ config: {
69
+ policies: ["admin::isAuthenticatedAdmin"]
70
+ }
71
+ }
72
+ ]
73
+ },
74
+ "content-api": {
75
+ type: "content-api",
76
+ routes: [
77
+ {
78
+ method: "POST",
79
+ path: "/preauthorization",
80
+ handler: "payone.preauthorization",
81
+ config: {
82
+ policies: ["plugin::payone-provider.isAuth"],
83
+ auth: false
84
+ }
85
+ },
86
+ {
87
+ method: "POST",
88
+ path: "/authorization",
89
+ handler: "payone.authorization",
90
+ config: {
91
+ policies: ["plugin::payone-provider.isAuth"],
92
+ auth: false
93
+ }
94
+ },
95
+ {
96
+ method: "POST",
97
+ path: "/capture",
98
+ handler: "payone.capture",
99
+ config: {
100
+ policies: ["plugin::payone-provider.isAuth"],
101
+ auth: false
102
+ }
103
+ },
104
+ {
105
+ method: "POST",
106
+ path: "/refund",
107
+ handler: "payone.refund",
108
+ config: {
109
+ policies: ["plugin::payone-provider.isAuth"],
110
+ auth: false
111
+ }
112
+ },
113
+ {
114
+ method: "POST",
115
+ path: "/test-connection",
116
+ handler: "payone.testConnection",
117
+ config: {
118
+ policies: ["plugin::payone-provider.isAuth"],
119
+ auth: false
120
+ }
121
+ }
122
+ ]
123
+ }
124
+ };
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ const payone = require("./payone");
4
+
5
+ module.exports = {
6
+ payone
7
+ };