strapi-plugin-payone-provider 1.1.3 → 1.2.4

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 (36) hide show
  1. package/README.md +1041 -377
  2. package/admin/src/index.js +4 -1
  3. package/admin/src/pages/App/components/AppHeader.js +37 -0
  4. package/admin/src/pages/App/components/AppTabs.js +126 -0
  5. package/admin/src/pages/App/components/ConfigurationPanel.js +34 -35
  6. package/admin/src/pages/App/components/GooglePaybutton.js +300 -0
  7. package/admin/src/pages/App/components/HistoryPanel.js +25 -38
  8. package/admin/src/pages/App/components/PaymentActionsPanel.js +95 -280
  9. package/admin/src/pages/App/components/TransactionHistoryItem.js +4 -1
  10. package/admin/src/pages/App/components/paymentActions/AuthorizationForm.js +93 -0
  11. package/admin/src/pages/App/components/paymentActions/CaptureForm.js +64 -0
  12. package/admin/src/pages/App/components/paymentActions/PaymentMethodSelector.js +52 -0
  13. package/admin/src/pages/App/components/paymentActions/PaymentResult.js +85 -0
  14. package/admin/src/pages/App/components/paymentActions/PreauthorizationForm.js +93 -0
  15. package/admin/src/pages/App/components/paymentActions/RefundForm.js +89 -0
  16. package/admin/src/pages/App/index.js +41 -465
  17. package/admin/src/pages/App/styles.css +294 -0
  18. package/admin/src/pages/constants/paymentConstants.js +37 -0
  19. package/admin/src/pages/hooks/usePaymentActions.js +271 -0
  20. package/admin/src/pages/hooks/useSettings.js +111 -0
  21. package/admin/src/pages/hooks/useTransactionHistory.js +87 -0
  22. package/admin/src/pages/utils/api.js +10 -0
  23. package/admin/src/pages/utils/injectGooglePayScript.js +31 -0
  24. package/admin/src/pages/utils/paymentUtils.js +113 -13
  25. package/package.json +1 -1
  26. package/server/controllers/payone.js +71 -64
  27. package/server/routes/index.js +17 -0
  28. package/server/services/paymentService.js +214 -0
  29. package/server/services/payone.js +25 -648
  30. package/server/services/settingsService.js +59 -0
  31. package/server/services/testConnectionService.js +190 -0
  32. package/server/services/transactionService.js +114 -0
  33. package/server/utils/normalize.js +51 -0
  34. package/server/utils/paymentMethodParams.js +126 -0
  35. package/server/utils/requestBuilder.js +110 -0
  36. package/server/utils/responseParser.js +80 -0
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Parse Payone API response
5
+ * @param {string|Object} responseText - Response text or object
6
+ * @param {Object} logger - Logger instance
7
+ * @returns {Object} Parsed response
8
+ */
9
+ const parseResponse = (responseText, logger) => {
10
+ try {
11
+ if (typeof responseText === "object") {
12
+ return responseText;
13
+ }
14
+ if (responseText.trim().startsWith("{")) {
15
+ return JSON.parse(responseText);
16
+ }
17
+ } catch (e) {
18
+ if (logger) {
19
+ logger.error("Payone parseResponse error:", e);
20
+ }
21
+ }
22
+
23
+ // Parse URL-encoded response
24
+ const params = new URLSearchParams(responseText);
25
+ const response = {};
26
+ for (const [key, value] of params) {
27
+ response[key.toLowerCase()] = value;
28
+ response[key] = value;
29
+ }
30
+ return response;
31
+ };
32
+
33
+ /**
34
+ * Extract transaction ID from response
35
+ * @param {Object} data - Response data
36
+ * @returns {string|null} Transaction ID
37
+ */
38
+ const extractTxId = (data) => {
39
+ return (
40
+ data.txid ||
41
+ data.TxId ||
42
+ data.tx_id ||
43
+ data.transactionid ||
44
+ data.transaction_id ||
45
+ data.id ||
46
+ null
47
+ );
48
+ };
49
+
50
+ /**
51
+ * Check if response requires 3D Secure redirect
52
+ * @param {Object} data - Response data
53
+ * @returns {boolean} True if 3DS redirect is required
54
+ */
55
+ const requires3DSRedirect = (data) => {
56
+ const status = (data.status || data.Status || "").toUpperCase();
57
+ const redirecturl = data.redirecturl || data.RedirectUrl || data.redirect_url;
58
+
59
+ return status === "REDIRECT" && !!redirecturl;
60
+ };
61
+
62
+ /**
63
+ * Extract 3D Secure redirect URL from response
64
+ * @param {Object} data - Response data
65
+ * @returns {string|null} Redirect URL
66
+ */
67
+ const get3DSRedirectUrl = (data) => {
68
+ if (requires3DSRedirect(data)) {
69
+ return data.redirecturl || data.RedirectUrl || data.redirect_url || null;
70
+ }
71
+ return null;
72
+ };
73
+
74
+ module.exports = {
75
+ parseResponse,
76
+ extractTxId,
77
+ requires3DSRedirect,
78
+ get3DSRedirectUrl
79
+ };
80
+