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.
- package/README.md +1041 -377
- 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 +126 -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 +95 -280
- package/admin/src/pages/App/components/TransactionHistoryItem.js +4 -1
- package/admin/src/pages/App/components/paymentActions/AuthorizationForm.js +93 -0
- package/admin/src/pages/App/components/paymentActions/CaptureForm.js +64 -0
- package/admin/src/pages/App/components/paymentActions/PaymentMethodSelector.js +52 -0
- package/admin/src/pages/App/components/paymentActions/PaymentResult.js +85 -0
- package/admin/src/pages/App/components/paymentActions/PreauthorizationForm.js +93 -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 +271 -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 +113 -13
- package/package.json +1 -1
- package/server/controllers/payone.js +71 -64
- package/server/routes/index.js +17 -0
- package/server/services/paymentService.js +214 -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 +110 -0
- 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
|
+
|