strapi-plugin-payone-provider 4.6.9 → 5.6.9
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 +24 -11
- package/admin/src/components/Initializer/index.jsx +3 -3
- package/admin/src/components/PluginIcon/index.jsx +3 -3
- package/admin/src/index.js +33 -11
- package/admin/src/pages/App/components/AppHeader.jsx +17 -32
- package/admin/src/pages/App/components/AppTabs.jsx +36 -162
- package/admin/src/pages/App/components/ApplePayBtn.jsx +9 -11
- package/admin/src/pages/App/components/ApplePayConfig.jsx +221 -161
- package/admin/src/pages/App/components/ApplePayConfigPanel.jsx +33 -45
- package/admin/src/pages/App/components/DocsPanel.jsx +66 -1726
- package/admin/src/pages/App/components/GooglePayConfig.jsx +136 -169
- package/admin/src/pages/App/components/GooglePayConfigPanel.jsx +37 -55
- package/admin/src/pages/App/components/GooglePaybutton.jsx +101 -43
- package/admin/src/pages/App/components/RenderInput.jsx +94 -0
- package/admin/src/pages/App/components/StatusBadge.jsx +24 -71
- package/admin/src/pages/App/components/configuration/ConfigurationFields.jsx +255 -0
- package/admin/src/pages/App/components/configuration/ConfigurationPanel.jsx +54 -0
- package/admin/src/pages/App/components/configuration/TestConnection.jsx +130 -0
- package/admin/src/pages/App/components/docs/ApplePaySection.jsx +260 -0
- package/admin/src/pages/App/components/docs/BaseUrlSection.jsx +53 -0
- package/admin/src/pages/App/components/docs/CaptureRefundSection.jsx +113 -0
- package/admin/src/pages/App/components/docs/CodeBlock.jsx +59 -0
- package/admin/src/pages/App/components/docs/CreditCardSection.jsx +93 -0
- package/admin/src/pages/App/components/docs/GooglePaySection.jsx +248 -0
- package/admin/src/pages/App/components/docs/PayPalSection.jsx +116 -0
- package/admin/src/pages/App/components/docs/PaymentMethodsSection.jsx +55 -0
- package/admin/src/pages/App/components/docs/TableOfContents.jsx +47 -0
- package/admin/src/pages/App/components/docs/TestCredentialsSection.jsx +304 -0
- package/admin/src/pages/App/components/docs/ThreeDSecureSection.jsx +188 -0
- package/admin/src/pages/App/components/icons/BankIcon.jsx +1 -1
- package/admin/src/pages/App/components/icons/ChevronDownIcon.jsx +1 -1
- package/admin/src/pages/App/components/icons/ChevronUpIcon.jsx +1 -1
- package/admin/src/pages/App/components/icons/CreditCardIcon.jsx +1 -1
- package/admin/src/pages/App/components/icons/ErrorIcon.jsx +1 -1
- package/admin/src/pages/App/components/icons/InfoIcon.jsx +1 -1
- package/admin/src/pages/App/components/icons/MarkCircle.jsx +19 -0
- package/admin/src/pages/App/components/icons/PaymentIcon.jsx +1 -1
- package/admin/src/pages/App/components/icons/PendingIcon.jsx +1 -1
- package/admin/src/pages/App/components/icons/PersonIcon.jsx +1 -1
- package/admin/src/pages/App/components/icons/SuccessIcon.jsx +1 -1
- package/admin/src/pages/App/components/icons/WalletIcon.jsx +1 -1
- package/admin/src/pages/App/components/payment-actions/ApplePayPanel.jsx +51 -0
- package/admin/src/pages/App/components/payment-actions/AuthorizationForm.jsx +341 -0
- package/admin/src/pages/App/components/payment-actions/CaptureForm.jsx +128 -0
- package/admin/src/pages/App/components/{paymentActions → payment-actions}/CardDetailsInput.jsx +77 -72
- package/admin/src/pages/App/components/payment-actions/PaymentActionsPanel.jsx +194 -0
- package/admin/src/pages/App/components/payment-actions/PaymentMethodSelector.jsx +313 -0
- package/admin/src/pages/App/components/payment-actions/PaymentResult.jsx +133 -0
- package/admin/src/pages/App/components/payment-actions/PreauthorizationForm.jsx +280 -0
- package/admin/src/pages/App/components/payment-actions/RefundForm.jsx +121 -0
- package/admin/src/pages/App/components/transaction-history/FiltersPanel.jsx +145 -0
- package/admin/src/pages/App/components/transaction-history/HistoryPanel.jsx +50 -0
- package/admin/src/pages/App/components/transaction-history/TransactionTable.jsx +163 -0
- package/admin/src/pages/App/components/transaction-history/details/TransactionDetails.jsx +156 -0
- package/admin/src/pages/App/components/{TransactionHistoryItem.jsx → transaction-history/details/TransactionHistoryItem.jsx} +16 -28
- package/admin/src/pages/App/index.jsx +27 -70
- package/admin/src/pages/App/styles.css +46 -169
- package/admin/src/pages/constants/paymentConstants.js +52 -16
- package/admin/src/pages/hooks/use-system-theme.js +27 -0
- package/admin/src/pages/hooks/usePaymentActions.js +273 -210
- package/admin/src/pages/hooks/useSettings.js +87 -48
- package/admin/src/pages/hooks/useTransactionHistory.js +105 -108
- package/admin/src/pages/utils/api.js +57 -72
- package/admin/src/pages/utils/applePayConstants.js +2 -28
- package/admin/src/pages/utils/countryLanguageUtils.js +280 -0
- package/admin/src/pages/utils/getInputComponent.jsx +225 -0
- package/admin/src/pages/utils/googlePayConstants.js +2 -9
- package/admin/src/pages/utils/paymentUtils.js +13 -25
- package/admin/src/pages/utils/tooltipHelpers.js +18 -0
- package/admin/src/pages/utils/transactionTableUtils.js +60 -0
- package/package.json +8 -14
- package/server/config/index.js +18 -2
- package/server/controllers/payone.js +80 -31
- package/server/policies/is-auth.js +9 -3
- package/server/policies/isSuperAdmin.js +7 -5
- package/server/services/paymentService.js +6 -22
- package/server/services/payone.js +3 -3
- package/server/services/settingsService.js +13 -3
- package/server/services/testConnectionService.js +11 -73
- package/server/services/transactionService.js +63 -98
- package/server/utils/normalize.js +0 -12
- package/server/utils/paymentMethodParams.js +0 -1
- package/server/utils/responseParser.js +9 -14
- package/strapi-admin.js +3 -1
- package/admin/src/pages/App/components/ConfigurationPanel.jsx +0 -517
- package/admin/src/pages/App/components/CustomerInfoPopover.jsx +0 -147
- package/admin/src/pages/App/components/HistoryPanel.jsx +0 -94
- package/admin/src/pages/App/components/PaymentActionsPanel.jsx +0 -280
- package/admin/src/pages/App/components/RawDataPopover.jsx +0 -113
- package/admin/src/pages/App/components/TransactionHistoryTable/TransactionHistoryTableFilters.jsx +0 -113
- package/admin/src/pages/App/components/TransactionHistoryTable/TransactionHistoryTablePagination.jsx +0 -180
- package/admin/src/pages/App/components/TransactionHistoryTable/index.jsx +0 -225
- package/admin/src/pages/App/components/paymentActions/ApplePayPanel.jsx +0 -95
- package/admin/src/pages/App/components/paymentActions/AuthorizationForm.jsx +0 -197
- package/admin/src/pages/App/components/paymentActions/CaptureForm.jsx +0 -65
- package/admin/src/pages/App/components/paymentActions/PaymentMethodSelector.jsx +0 -306
- package/admin/src/pages/App/components/paymentActions/PaymentResult.jsx +0 -192
- package/admin/src/pages/App/components/paymentActions/PreauthorizationForm.jsx +0 -142
- package/admin/src/pages/App/components/paymentActions/RefundForm.jsx +0 -90
|
@@ -1,32 +1,49 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useNotification } from "@strapi/
|
|
3
|
-
import
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useNotification } from "@strapi/strapi/admin";
|
|
3
|
+
import usePayoneRequests from "../utils/api";
|
|
4
4
|
|
|
5
5
|
const useSettings = () => {
|
|
6
|
-
const toggleNotification = useNotification();
|
|
7
|
-
const [settings, setSettings] = useState({
|
|
6
|
+
const { toggleNotification } = useNotification();
|
|
7
|
+
const [settings, setSettings] = React.useState({
|
|
8
8
|
aid: "",
|
|
9
9
|
portalid: "",
|
|
10
10
|
mid: "",
|
|
11
11
|
key: "",
|
|
12
12
|
mode: "test",
|
|
13
13
|
api_version: "3.10",
|
|
14
|
-
enable3DSecure: false
|
|
14
|
+
enable3DSecure: false,
|
|
15
|
+
enableCreditCard: false,
|
|
16
|
+
enablePayPal: false,
|
|
17
|
+
enableGooglePay: false,
|
|
18
|
+
enableApplePay: false,
|
|
19
|
+
enableSofort: false,
|
|
20
|
+
enableSepaDirectDebit: false
|
|
15
21
|
});
|
|
16
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
17
|
-
const [isSaving, setIsSaving] = useState(false);
|
|
18
|
-
const [isTesting, setIsTesting] = useState(false);
|
|
19
|
-
const [testResult, setTestResult] = useState(null);
|
|
22
|
+
const [isLoading, setIsLoading] = React.useState(false);
|
|
23
|
+
const [isSaving, setIsSaving] = React.useState(false);
|
|
24
|
+
const [isTesting, setIsTesting] = React.useState(false);
|
|
25
|
+
const [testResult, setTestResult] = React.useState(null);
|
|
26
|
+
const { getSettings, updateSettings, testConnection } = usePayoneRequests();
|
|
27
|
+
const saveTimeoutRef = React.useRef(null);
|
|
20
28
|
|
|
21
|
-
|
|
29
|
+
|
|
30
|
+
React.useEffect(() => {
|
|
22
31
|
loadSettings();
|
|
32
|
+
return () => {
|
|
33
|
+
if (saveTimeoutRef.current) {
|
|
34
|
+
clearTimeout(saveTimeoutRef.current);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
23
37
|
}, []);
|
|
24
38
|
|
|
25
39
|
const loadSettings = async () => {
|
|
26
40
|
setIsLoading(true);
|
|
27
41
|
try {
|
|
28
|
-
const response = await
|
|
29
|
-
|
|
42
|
+
const response = await getSettings();
|
|
43
|
+
const settingsData = response?.data?.data || response?.data;
|
|
44
|
+
if (settingsData && typeof settingsData === 'object') {
|
|
45
|
+
setSettings(settingsData);
|
|
46
|
+
}
|
|
30
47
|
} catch (error) {
|
|
31
48
|
toggleNotification({
|
|
32
49
|
type: "warning",
|
|
@@ -39,27 +56,57 @@ const useSettings = () => {
|
|
|
39
56
|
|
|
40
57
|
const handleInputChange = (field, value) => {
|
|
41
58
|
setSettings((prev) => ({ ...prev, [field]: value }));
|
|
59
|
+
|
|
60
|
+
if (saveTimeoutRef.current) {
|
|
61
|
+
clearTimeout(saveTimeoutRef.current);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
saveTimeoutRef.current = setTimeout(async () => {
|
|
65
|
+
let updatedSettings;
|
|
66
|
+
setSettings((prev) => {
|
|
67
|
+
updatedSettings = { ...prev };
|
|
68
|
+
return prev;
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
setIsSaving(true);
|
|
72
|
+
try {
|
|
73
|
+
await updateSettings(updatedSettings);
|
|
74
|
+
await loadSettings();
|
|
75
|
+
} catch (error) {
|
|
76
|
+
setSettings((prev) => {
|
|
77
|
+
const previousValue = prev[field];
|
|
78
|
+
return { ...prev, [field]: previousValue };
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
toggleNotification({
|
|
82
|
+
type: "danger",
|
|
83
|
+
message: "Failed to update settings"
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
} finally {
|
|
87
|
+
setIsSaving(false);
|
|
88
|
+
}
|
|
89
|
+
}, 1000);
|
|
42
90
|
};
|
|
43
91
|
|
|
44
92
|
const handlePaymentMethodToggle = async (field, value) => {
|
|
93
|
+
const booleanValue = Boolean(value);
|
|
45
94
|
let updatedSettings;
|
|
95
|
+
|
|
46
96
|
setSettings((prev) => {
|
|
47
|
-
updatedSettings = { ...prev, [field]:
|
|
97
|
+
updatedSettings = { ...prev, [field]: booleanValue };
|
|
48
98
|
return updatedSettings;
|
|
49
99
|
});
|
|
50
100
|
|
|
51
101
|
setIsSaving(true);
|
|
52
102
|
try {
|
|
53
|
-
await
|
|
54
|
-
|
|
55
|
-
type: "success",
|
|
56
|
-
message: "Payment method updated successfully"
|
|
57
|
-
});
|
|
103
|
+
await updateSettings(updatedSettings);
|
|
104
|
+
await loadSettings();
|
|
58
105
|
} catch (error) {
|
|
59
|
-
setSettings((prev) => ({ ...prev, [field]: !
|
|
106
|
+
setSettings((prev) => ({ ...prev, [field]: !booleanValue }));
|
|
60
107
|
toggleNotification({
|
|
61
|
-
type: "
|
|
62
|
-
message: "Failed to update
|
|
108
|
+
type: "danger",
|
|
109
|
+
message: "Failed to update settings"
|
|
63
110
|
});
|
|
64
111
|
} finally {
|
|
65
112
|
setIsSaving(false);
|
|
@@ -69,7 +116,7 @@ const useSettings = () => {
|
|
|
69
116
|
const handleSave = async () => {
|
|
70
117
|
setIsSaving(true);
|
|
71
118
|
try {
|
|
72
|
-
await
|
|
119
|
+
await updateSettings(settings);
|
|
73
120
|
toggleNotification({
|
|
74
121
|
type: "success",
|
|
75
122
|
message: "Settings saved successfully"
|
|
@@ -77,7 +124,7 @@ const useSettings = () => {
|
|
|
77
124
|
await loadSettings();
|
|
78
125
|
} catch (error) {
|
|
79
126
|
toggleNotification({
|
|
80
|
-
type: "
|
|
127
|
+
type: "danger",
|
|
81
128
|
message: "Failed to save settings"
|
|
82
129
|
});
|
|
83
130
|
} finally {
|
|
@@ -89,33 +136,25 @@ const useSettings = () => {
|
|
|
89
136
|
setIsTesting(true);
|
|
90
137
|
setTestResult(null);
|
|
91
138
|
try {
|
|
92
|
-
const response = await
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
setTestResult(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
});
|
|
101
|
-
}
|
|
139
|
+
const response = await testConnection();
|
|
140
|
+
console.log("response in handleTestConnection:", response.data);
|
|
141
|
+
if (response.data && response.data.success) {
|
|
142
|
+
setTestResult(response.data);
|
|
143
|
+
toggleNotification({
|
|
144
|
+
type: "success",
|
|
145
|
+
message: response.data.message || "Test completed"
|
|
146
|
+
});
|
|
102
147
|
} else {
|
|
103
|
-
|
|
148
|
+
setTestResult(response.data);
|
|
149
|
+
toggleNotification({
|
|
150
|
+
type: "danger",
|
|
151
|
+
message: response.data.error.ErrorMessage || "Failed to test connection"
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
throw new Error(response.data.error.ErrorMessage);
|
|
104
155
|
}
|
|
105
156
|
} catch (error) {
|
|
106
|
-
|
|
107
|
-
type: "warning",
|
|
108
|
-
message: "Failed to test connection"
|
|
109
|
-
});
|
|
110
|
-
setTestResult({
|
|
111
|
-
success: false,
|
|
112
|
-
message:
|
|
113
|
-
"Failed to test connection. Please check your network and server logs for details.",
|
|
114
|
-
details: {
|
|
115
|
-
errorCode: "NETWORK",
|
|
116
|
-
rawResponse: error.message || "Network error"
|
|
117
|
-
}
|
|
118
|
-
});
|
|
157
|
+
throw new Error(error.message);
|
|
119
158
|
} finally {
|
|
120
159
|
setIsTesting(false);
|
|
121
160
|
}
|
|
@@ -1,151 +1,148 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useNotification } from "@strapi/
|
|
3
|
-
import
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useNotification, useQueryParams } from "@strapi/strapi/admin";
|
|
3
|
+
import usePayoneRequests from "../utils/api";
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const PAGE_SIZE = 10;
|
|
6
6
|
|
|
7
7
|
const useTransactionHistory = () => {
|
|
8
|
-
const toggleNotification = useNotification();
|
|
9
|
-
const
|
|
10
|
-
const [
|
|
11
|
-
const [selectedTransaction, setSelectedTransaction] = useState(null);
|
|
12
|
-
const [currentPage, setCurrentPage] = useState(1);
|
|
13
|
-
const [pageSize, setPageSize] = useState(DEFAULT_PAGE_SIZE);
|
|
14
|
-
// Calculate default dates
|
|
15
|
-
const getDefaultDateFrom = () => {
|
|
16
|
-
const date = new Date();
|
|
17
|
-
date.setDate(date.getDate() - 30);
|
|
18
|
-
return date.toISOString().split('T')[0];
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const getDefaultDateTo = () => {
|
|
22
|
-
const date = new Date();
|
|
23
|
-
date.setDate(date.getDate() + 1); // Add 1 day to include today's transactions
|
|
24
|
-
return date.toISOString().split('T')[0];
|
|
25
|
-
};
|
|
8
|
+
const { toggleNotification } = useNotification();
|
|
9
|
+
const { getTransactionHistory } = usePayoneRequests();
|
|
10
|
+
const [{ query }, setQuery] = useQueryParams();
|
|
26
11
|
|
|
27
|
-
const [filters, setFilters] = useState({
|
|
12
|
+
const [filters, setFilters] = React.useState({
|
|
28
13
|
search: "",
|
|
14
|
+
status: "",
|
|
29
15
|
request_type: "",
|
|
30
16
|
payment_method: "",
|
|
31
|
-
date_from:
|
|
32
|
-
date_to:
|
|
33
|
-
status: ""
|
|
17
|
+
date_from: "",
|
|
18
|
+
date_to: "",
|
|
34
19
|
});
|
|
35
20
|
|
|
36
|
-
const [
|
|
37
|
-
|
|
38
|
-
|
|
21
|
+
const [pagination, setPagination] = React.useState({
|
|
22
|
+
page: parseInt(query?.page || "1", 10),
|
|
23
|
+
pageSize: parseInt(query?.pageSize || String(PAGE_SIZE), 10),
|
|
24
|
+
pageCount: 1,
|
|
25
|
+
total: 0,
|
|
39
26
|
});
|
|
40
27
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
28
|
+
const [transactionHistory, setTransactionHistory] = React.useState([]);
|
|
29
|
+
const [isLoadingHistory, setIsLoadingHistory] = React.useState(false);
|
|
30
|
+
const [selectedTransaction, setSelectedTransaction] = React.useState(null);
|
|
31
|
+
|
|
32
|
+
React.useEffect(() => {
|
|
33
|
+
const page = parseInt(query?.page || "1", 10);
|
|
34
|
+
const pageSize = parseInt(query?.pageSize || String(PAGE_SIZE), 10);
|
|
35
|
+
setPagination((prev) => ({
|
|
36
|
+
...prev,
|
|
37
|
+
page,
|
|
38
|
+
pageSize,
|
|
39
|
+
}));
|
|
40
|
+
}, [query?.page, query?.pageSize]);
|
|
41
|
+
|
|
44
42
|
|
|
45
43
|
const loadTransactionHistory = async () => {
|
|
46
44
|
setIsLoadingHistory(true);
|
|
47
45
|
try {
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
const response = await getTransactionHistory({
|
|
47
|
+
filters,
|
|
48
|
+
pagination
|
|
49
|
+
});
|
|
50
|
+
const result = response?.data || response;
|
|
51
|
+
const historyData = Array.isArray(result?.data) ? result.data : [];
|
|
52
|
+
const paginationMeta = result?.meta?.pagination;
|
|
53
|
+
|
|
54
|
+
if (paginationMeta && paginationMeta.total !== undefined) {
|
|
55
|
+
setPagination((prev) => ({
|
|
56
|
+
...prev,
|
|
57
|
+
pageCount: paginationMeta.pageCount || 1,
|
|
58
|
+
total: paginationMeta.total || 0,
|
|
59
|
+
}));
|
|
60
|
+
} else {
|
|
61
|
+
const calculatedTotal = historyData.length;
|
|
62
|
+
const calculatedPageCount = Math.ceil(calculatedTotal / pagination.pageSize) || 1;
|
|
63
|
+
setPagination((prev) => ({
|
|
64
|
+
...prev,
|
|
65
|
+
pageCount: calculatedPageCount,
|
|
66
|
+
total: calculatedTotal,
|
|
67
|
+
}));
|
|
52
68
|
}
|
|
53
|
-
|
|
54
|
-
setTransactionHistory(
|
|
55
|
-
setCurrentPage(1);
|
|
69
|
+
|
|
70
|
+
setTransactionHistory(historyData);
|
|
56
71
|
} catch (error) {
|
|
72
|
+
console.error("Error loading transaction history:", error);
|
|
73
|
+
setTransactionHistory([]);
|
|
74
|
+
setPagination((prev) => ({
|
|
75
|
+
...prev,
|
|
76
|
+
pageCount: 1,
|
|
77
|
+
total: 0,
|
|
78
|
+
}));
|
|
57
79
|
toggleNotification({
|
|
58
|
-
type: "
|
|
59
|
-
message: "Failed to load transaction history"
|
|
80
|
+
type: "danger",
|
|
81
|
+
message: "Failed to load transaction history",
|
|
60
82
|
});
|
|
61
83
|
} finally {
|
|
62
84
|
setIsLoadingHistory(false);
|
|
63
85
|
}
|
|
64
86
|
};
|
|
65
87
|
|
|
66
|
-
|
|
67
|
-
setFilters((prev) => ({ ...prev, [field]: value }));
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const handleFilterApply = () => {
|
|
88
|
+
React.useEffect(() => {
|
|
71
89
|
loadTransactionHistory();
|
|
72
|
-
}
|
|
90
|
+
}, [
|
|
91
|
+
filters.search,
|
|
92
|
+
filters.status,
|
|
93
|
+
filters.request_type,
|
|
94
|
+
filters.payment_method,
|
|
95
|
+
filters.date_from,
|
|
96
|
+
filters.date_to,
|
|
97
|
+
pagination.page,
|
|
98
|
+
pagination.pageSize,
|
|
99
|
+
]);
|
|
73
100
|
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (!prev.sortOrder) {
|
|
79
|
-
return { sortBy: column, sortOrder: "asc" };
|
|
80
|
-
} else if (prev.sortOrder === "asc") {
|
|
81
|
-
return { sortBy: column, sortOrder: "desc" };
|
|
82
|
-
} else {
|
|
83
|
-
return { sortBy: null, sortOrder: null };
|
|
84
|
-
}
|
|
85
|
-
} else {
|
|
86
|
-
// If clicking a different column, reset and set new column to asc
|
|
87
|
-
return { sortBy: column, sortOrder: "asc" };
|
|
88
|
-
}
|
|
89
|
-
});
|
|
101
|
+
const handleTransactionSelect = (transaction) => {
|
|
102
|
+
setSelectedTransaction(
|
|
103
|
+
selectedTransaction?.id === transaction?.id ? null : transaction
|
|
104
|
+
);
|
|
90
105
|
};
|
|
91
106
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
// Only reload if sorting is actually set or cleared
|
|
101
|
-
loadTransactionHistory();
|
|
102
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
103
|
-
}, [sorting.sortBy, sorting.sortOrder]);
|
|
104
|
-
|
|
105
|
-
const handleTransactionSelect = (transaction) => {
|
|
106
|
-
if (selectedTransaction?.id === transaction?.id) {
|
|
107
|
-
setSelectedTransaction(null);
|
|
108
|
-
} else {
|
|
109
|
-
setSelectedTransaction(transaction);
|
|
107
|
+
const handlePaginationChange = (newPagination) => {
|
|
108
|
+
if (newPagination && typeof newPagination === "object") {
|
|
109
|
+
const updatedQuery = {
|
|
110
|
+
...query,
|
|
111
|
+
page: query.page || 1,
|
|
112
|
+
pageSize: String(newPagination.pageSize || pagination.pageSize),
|
|
113
|
+
};
|
|
114
|
+
setQuery(updatedQuery, "push", false);
|
|
110
115
|
}
|
|
111
116
|
};
|
|
112
117
|
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
118
|
+
const handleFiltersChange = (newFilters) => {
|
|
119
|
+
if (newFilters && typeof newFilters === "object") {
|
|
120
|
+
setFilters((prev) => ({
|
|
121
|
+
...prev,
|
|
122
|
+
...newFilters,
|
|
123
|
+
}));
|
|
124
|
+
}
|
|
116
125
|
};
|
|
117
126
|
|
|
118
|
-
|
|
119
|
-
setPageSize(newPageSize);
|
|
120
|
-
setCurrentPage(1); // Reset to first page when page size changes
|
|
127
|
+
React.useEffect(() => {
|
|
121
128
|
setSelectedTransaction(null);
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
// Pagination calculations
|
|
125
|
-
const totalPages = Math.ceil(transactionHistory.length / pageSize);
|
|
126
|
-
const startIndex = (currentPage - 1) * pageSize;
|
|
127
|
-
const endIndex = startIndex + pageSize;
|
|
128
|
-
const paginatedTransactions = transactionHistory.slice(startIndex, endIndex);
|
|
129
|
+
}, [filters, pagination.page]);
|
|
129
130
|
|
|
130
131
|
return {
|
|
131
|
-
transactionHistory,
|
|
132
|
-
paginatedTransactions,
|
|
132
|
+
transactions: Array.isArray(transactionHistory) ? transactionHistory : [],
|
|
133
133
|
isLoadingHistory,
|
|
134
134
|
selectedTransaction,
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
pageSize,
|
|
140
|
-
handleFilterChange,
|
|
141
|
-
handleFilterApply,
|
|
142
|
-
handleSort,
|
|
135
|
+
currentPage: pagination.page,
|
|
136
|
+
totalPages: pagination.pageCount,
|
|
137
|
+
totalCount: pagination.total,
|
|
138
|
+
pageSize: pagination.pageSize,
|
|
143
139
|
handleTransactionSelect,
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
140
|
+
loadTransactionHistory,
|
|
141
|
+
filters,
|
|
142
|
+
handleFiltersChange,
|
|
143
|
+
pagination,
|
|
144
|
+
handlePaginationChange,
|
|
147
145
|
};
|
|
148
146
|
};
|
|
149
147
|
|
|
150
148
|
export default useTransactionHistory;
|
|
151
|
-
|
|
@@ -1,85 +1,70 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import pluginId from
|
|
1
|
+
import { useFetchClient } from '@strapi/strapi/admin';
|
|
2
|
+
import pluginId from '../../pluginId';
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
return request(`/${pluginId}/settings`, {
|
|
7
|
-
method: "GET"
|
|
8
|
-
});
|
|
9
|
-
},
|
|
4
|
+
const usePayoneRequests = () => {
|
|
5
|
+
const { get, post, put } = useFetchClient();
|
|
10
6
|
|
|
11
|
-
|
|
12
|
-
return request(`/${pluginId}/settings`, {
|
|
13
|
-
method: "PUT",
|
|
14
|
-
body: data
|
|
15
|
-
});
|
|
16
|
-
},
|
|
7
|
+
const getSettings = () => get(`/${pluginId}/settings`);
|
|
17
8
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
9
|
+
const updateSettings = (data) =>
|
|
10
|
+
put(`/${pluginId}/settings`, data);
|
|
11
|
+
|
|
12
|
+
const getTransactionHistory = (params = {}) => {
|
|
13
|
+
const queryParams = new URLSearchParams();
|
|
14
|
+
|
|
15
|
+
if (params.filters) {
|
|
16
|
+
Object.keys(params.filters).forEach((key) => {
|
|
17
|
+
const value = params.filters[key];
|
|
18
|
+
if (value !== undefined && value !== null && value !== '') {
|
|
19
|
+
queryParams.append(`filters[${key}]`, String(value));
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (params.pagination) {
|
|
25
|
+
if (params.pagination.page) {
|
|
26
|
+
queryParams.append('pagination[page]', String(params.pagination.page));
|
|
24
27
|
}
|
|
28
|
+
if (params.pagination.pageSize) {
|
|
29
|
+
queryParams.append('pagination[pageSize]', String(params.pagination.pageSize));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const queryString = queryParams.toString();
|
|
34
|
+
return get(
|
|
35
|
+
`/${pluginId}/transaction-history${queryString ? `?${queryString}` : ''}`
|
|
25
36
|
);
|
|
26
|
-
}
|
|
37
|
+
};
|
|
27
38
|
|
|
28
|
-
testConnection
|
|
29
|
-
|
|
30
|
-
method: "POST"
|
|
31
|
-
});
|
|
32
|
-
},
|
|
39
|
+
const testConnection = () =>
|
|
40
|
+
post(`/${pluginId}/test-connection`);
|
|
33
41
|
|
|
34
|
-
preauthorization
|
|
35
|
-
|
|
36
|
-
method: "POST",
|
|
37
|
-
body: data,
|
|
38
|
-
headers: {
|
|
39
|
-
"Content-Type": "application/json"
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
},
|
|
42
|
+
const preauthorization = (data) =>
|
|
43
|
+
post(`/${pluginId}/preauthorization`, data);
|
|
43
44
|
|
|
44
|
-
authorization
|
|
45
|
-
|
|
46
|
-
method: "POST",
|
|
47
|
-
body: data,
|
|
48
|
-
headers: {
|
|
49
|
-
"Content-Type": "application/json"
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
},
|
|
45
|
+
const authorization = (data) =>
|
|
46
|
+
post(`/${pluginId}/authorization`, data);
|
|
53
47
|
|
|
54
|
-
capture
|
|
55
|
-
|
|
56
|
-
method: "POST",
|
|
57
|
-
body: data,
|
|
58
|
-
headers: {
|
|
59
|
-
"Content-Type": "application/json"
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
},
|
|
48
|
+
const capture = (data) =>
|
|
49
|
+
post(`/${pluginId}/capture`, data);
|
|
63
50
|
|
|
64
|
-
refund
|
|
65
|
-
|
|
66
|
-
method: "POST",
|
|
67
|
-
body: data,
|
|
68
|
-
headers: {
|
|
69
|
-
"Content-Type": "application/json"
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
},
|
|
51
|
+
const refund = (data) =>
|
|
52
|
+
post(`/${pluginId}/refund`, data);
|
|
73
53
|
|
|
74
|
-
handle3DSCallback
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
54
|
+
const handle3DSCallback = (data) =>
|
|
55
|
+
post(`/${pluginId}/3ds-callback`, data);
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
getSettings,
|
|
59
|
+
updateSettings,
|
|
60
|
+
getTransactionHistory,
|
|
61
|
+
testConnection,
|
|
62
|
+
preauthorization,
|
|
63
|
+
authorization,
|
|
64
|
+
capture,
|
|
65
|
+
refund,
|
|
66
|
+
handle3DSCallback,
|
|
67
|
+
};
|
|
83
68
|
};
|
|
84
69
|
|
|
85
|
-
export default
|
|
70
|
+
export default usePayoneRequests;
|