strapi-plugin-payone-provider 1.1.3 → 1.3.0
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/README.md +1156 -380
- package/admin/src/index.js +4 -1
- package/admin/src/pages/App/components/AppHeader.js +37 -0
- package/admin/src/pages/App/components/AppTabs.js +134 -0
- package/admin/src/pages/App/components/ConfigurationPanel.js +34 -35
- package/admin/src/pages/App/components/GooglePaybutton.js +300 -0
- package/admin/src/pages/App/components/HistoryPanel.js +25 -38
- package/admin/src/pages/App/components/PaymentActionsPanel.js +119 -280
- package/admin/src/pages/App/components/StatusBadge.js +3 -1
- package/admin/src/pages/App/components/TransactionHistoryItem.js +4 -1
- package/admin/src/pages/App/components/paymentActions/AuthorizationForm.js +122 -0
- package/admin/src/pages/App/components/paymentActions/CaptureForm.js +64 -0
- package/admin/src/pages/App/components/paymentActions/CardDetailsInput.js +189 -0
- package/admin/src/pages/App/components/paymentActions/PaymentMethodSelector.js +52 -0
- package/admin/src/pages/App/components/paymentActions/PaymentResult.js +148 -0
- package/admin/src/pages/App/components/paymentActions/PreauthorizationForm.js +122 -0
- package/admin/src/pages/App/components/paymentActions/RefundForm.js +89 -0
- package/admin/src/pages/App/index.js +41 -465
- package/admin/src/pages/App/styles.css +294 -0
- package/admin/src/pages/constants/paymentConstants.js +37 -0
- package/admin/src/pages/hooks/usePaymentActions.js +456 -0
- package/admin/src/pages/hooks/useSettings.js +111 -0
- package/admin/src/pages/hooks/useTransactionHistory.js +87 -0
- package/admin/src/pages/utils/api.js +10 -0
- package/admin/src/pages/utils/injectGooglePayScript.js +31 -0
- package/admin/src/pages/utils/paymentUtils.js +119 -15
- package/package.json +1 -1
- package/server/controllers/payone.js +71 -64
- package/server/routes/index.js +17 -0
- package/server/services/paymentService.js +271 -0
- package/server/services/payone.js +25 -648
- package/server/services/settingsService.js +59 -0
- package/server/services/testConnectionService.js +190 -0
- package/server/services/transactionService.js +114 -0
- package/server/utils/normalize.js +51 -0
- package/server/utils/paymentMethodParams.js +126 -0
- package/server/utils/requestBuilder.js +121 -0
- package/server/utils/responseParser.js +134 -0
|
@@ -0,0 +1,134 @@
|
|
|
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 errorCode = data.errorcode || data.ErrorCode || data.Error?.ErrorCode;
|
|
58
|
+
|
|
59
|
+
// Check for redirect URL in various possible fields
|
|
60
|
+
const redirecturl =
|
|
61
|
+
data.redirecturl ||
|
|
62
|
+
data.RedirectUrl ||
|
|
63
|
+
data.redirect_url ||
|
|
64
|
+
data.redirectUrl ||
|
|
65
|
+
data.RedirectURL ||
|
|
66
|
+
data.redirectURL ||
|
|
67
|
+
data.url ||
|
|
68
|
+
data.Url ||
|
|
69
|
+
data.URL ||
|
|
70
|
+
null;
|
|
71
|
+
|
|
72
|
+
// 3DS required error codes (4219, etc.)
|
|
73
|
+
const requires3DSErrorCodes = ["4219", 4219];
|
|
74
|
+
const is3DSRequiredError = requires3DSErrorCodes.includes(errorCode);
|
|
75
|
+
|
|
76
|
+
return (status === "REDIRECT" && !!redirecturl) || is3DSRequiredError;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Check if response indicates an error
|
|
81
|
+
* @param {Object} data - Response data
|
|
82
|
+
* @returns {boolean} True if response indicates error
|
|
83
|
+
*/
|
|
84
|
+
const isErrorResponse = (data) => {
|
|
85
|
+
const status = (data.status || data.Status || "").toUpperCase();
|
|
86
|
+
const errorCode = data.errorcode || data.ErrorCode || data.Error?.ErrorCode;
|
|
87
|
+
|
|
88
|
+
return status === "ERROR" || status === "INVALID" || !!errorCode;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Extract 3D Secure redirect URL from response
|
|
93
|
+
* @param {Object} data - Response data
|
|
94
|
+
* @returns {string|null} Redirect URL
|
|
95
|
+
*/
|
|
96
|
+
const get3DSRedirectUrl = (data) => {
|
|
97
|
+
// Check all possible redirect URL fields
|
|
98
|
+
const redirecturl =
|
|
99
|
+
data.redirecturl ||
|
|
100
|
+
data.RedirectUrl ||
|
|
101
|
+
data.redirect_url ||
|
|
102
|
+
data.redirectUrl ||
|
|
103
|
+
data.RedirectURL ||
|
|
104
|
+
data.redirectURL ||
|
|
105
|
+
data.url ||
|
|
106
|
+
data.Url ||
|
|
107
|
+
data.URL ||
|
|
108
|
+
data.redirect ||
|
|
109
|
+
data.Redirect ||
|
|
110
|
+
null;
|
|
111
|
+
|
|
112
|
+
if (redirecturl) {
|
|
113
|
+
return redirecturl;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// If 3DS required but no redirect URL, might need 3dscheck
|
|
117
|
+
const errorCode = data.errorcode || data.ErrorCode || data.Error?.ErrorCode;
|
|
118
|
+
const requires3DSErrorCodes = ["4219", 4219];
|
|
119
|
+
if (requires3DSErrorCodes.includes(errorCode)) {
|
|
120
|
+
// Return null - will need to handle 3dscheck separately
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return null;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
module.exports = {
|
|
128
|
+
parseResponse,
|
|
129
|
+
extractTxId,
|
|
130
|
+
requires3DSRedirect,
|
|
131
|
+
get3DSRedirectUrl,
|
|
132
|
+
isErrorResponse
|
|
133
|
+
};
|
|
134
|
+
|