strapi-plugin-payone-provider 5.7.24 → 5.7.26
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 +1191 -1191
- package/admin/src/components/Initializer/index.jsx +16 -16
- package/admin/src/components/PluginIcon/index.jsx +17 -17
- package/admin/src/index.js +57 -57
- package/admin/src/pages/App/components/AppHeader.jsx +45 -45
- package/admin/src/pages/App/components/AppTabs.jsx +105 -105
- package/admin/src/pages/App/components/ApplePayBtn.jsx +355 -355
- package/admin/src/pages/App/components/ApplePayConfig.jsx +357 -357
- package/admin/src/pages/App/components/DocsPanel.jsx +53 -53
- package/admin/src/pages/App/components/RenderInput.jsx +78 -78
- package/admin/src/pages/App/components/StatusBadge.jsx +87 -87
- package/admin/src/pages/App/components/icons/BankIcon.jsx +10 -10
- package/admin/src/pages/App/components/icons/ChevronDownIcon.jsx +9 -9
- package/admin/src/pages/App/components/icons/ChevronUpIcon.jsx +9 -9
- package/admin/src/pages/App/components/icons/CreditCardIcon.jsx +9 -9
- package/admin/src/pages/App/components/icons/ErrorIcon.jsx +10 -10
- package/admin/src/pages/App/components/icons/InfoIcon.jsx +9 -9
- package/admin/src/pages/App/components/icons/MarkCircle.jsx +19 -19
- package/admin/src/pages/App/components/icons/PaymentIcon.jsx +10 -10
- package/admin/src/pages/App/components/icons/PendingIcon.jsx +9 -9
- package/admin/src/pages/App/components/icons/PersonIcon.jsx +9 -9
- package/admin/src/pages/App/components/icons/SuccessIcon.jsx +9 -9
- package/admin/src/pages/App/components/icons/WalletIcon.jsx +9 -9
- package/admin/src/pages/App/components/icons/index.jsx +12 -12
- package/admin/src/pages/App/components/payment-actions/AuthorizationForm.jsx +334 -334
- package/admin/src/pages/App/components/payment-actions/CaptureForm.jsx +120 -120
- package/admin/src/pages/App/components/payment-actions/PaymentActionsPanel.jsx +183 -183
- package/admin/src/pages/App/components/payment-actions/PaymentMethodSelector.jsx +315 -315
- package/admin/src/pages/App/components/payment-actions/PaymentResult.jsx +129 -129
- package/admin/src/pages/App/components/payment-actions/PreauthorizationForm.jsx +273 -273
- package/admin/src/pages/App/components/payment-actions/RefundForm.jsx +114 -114
- package/admin/src/pages/App/components/transaction-history/ImportExportBar.jsx +153 -153
- package/admin/src/pages/App/components/transaction-history/details/TransactionHistoryItem.jsx +526 -526
- package/admin/src/pages/App/index.jsx +96 -96
- package/admin/src/pages/App/styles.css +176 -176
- package/admin/src/pages/constants/paymentConstants.js +71 -71
- package/admin/src/pages/hooks/use-system-theme.js +27 -27
- package/admin/src/pages/hooks/usePaymentActions.js +498 -498
- package/admin/src/pages/hooks/usePluginTranslations.js +12 -12
- package/admin/src/pages/hooks/useSettings.js +183 -183
- package/admin/src/pages/hooks/useTransactionHistory.js +148 -148
- package/admin/src/pages/utils/api.js +97 -97
- package/admin/src/pages/utils/applePayConstants.js +196 -196
- package/admin/src/pages/utils/formatTransactionData.js +15 -15
- package/admin/src/pages/utils/getInputComponent.jsx +200 -200
- package/admin/src/pages/utils/paymentUtils.js +661 -661
- package/admin/src/pages/utils/tooltipHelpers.js +18 -18
- package/admin/src/pages/utils/transactionTableUtils.js +71 -71
- package/admin/src/pluginId.js +9 -9
- package/admin/src/translations/de.json +235 -235
- package/admin/src/translations/en.json +235 -235
- package/admin/src/translations/fr.json +235 -235
- package/admin/src/translations/ru.json +235 -235
- package/admin/src/utils/prefixPluginTranslations.js +13 -13
- package/package.json +45 -45
- package/server/bootstrap.js +107 -107
- package/server/config/index.js +83 -83
- package/server/content-types/index.js +4 -4
- package/server/content-types/transactions/index.js +4 -4
- package/server/content-types/transactions/schema.json +86 -86
- package/server/controllers/index.js +7 -7
- package/server/controllers/payone.js +506 -451
- package/server/destroy.js +5 -5
- package/server/index.js +23 -23
- package/server/policies/index.js +7 -7
- package/server/policies/is-auth.js +29 -29
- package/server/policies/isSuperAdmin.js +20 -20
- package/server/register.js +5 -5
- package/server/routes/index.js +218 -218
- package/server/services/applePayService.js +295 -295
- package/server/services/index.js +9 -9
- package/server/services/paymentService.js +223 -223
- package/server/services/payone.js +78 -78
- package/server/services/settingsService.js +59 -59
- package/server/services/testConnectionService.js +115 -115
- package/server/services/transactionService.js +262 -262
- package/server/utils/csvTransactions.js +82 -82
- package/server/utils/normalize.js +39 -39
- package/server/utils/paymentMethodParams.js +288 -288
- package/server/utils/requestBuilder.js +100 -100
- package/server/utils/responseParser.js +141 -141
- package/strapi-admin.js +4 -4
- package/strapi-server.js +3 -3
|
@@ -1,148 +1,148 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { useNotification, useQueryParams } from "@strapi/strapi/admin";
|
|
3
|
-
import usePayoneRequests from "../utils/api";
|
|
4
|
-
|
|
5
|
-
const PAGE_SIZE = 10;
|
|
6
|
-
|
|
7
|
-
const useTransactionHistory = () => {
|
|
8
|
-
const { toggleNotification } = useNotification();
|
|
9
|
-
const { getTransactionHistory } = usePayoneRequests();
|
|
10
|
-
const [{ query }, setQuery] = useQueryParams();
|
|
11
|
-
|
|
12
|
-
const [filters, setFilters] = React.useState({
|
|
13
|
-
search: "",
|
|
14
|
-
status: "",
|
|
15
|
-
request_type: "",
|
|
16
|
-
payment_method: "",
|
|
17
|
-
date_from: "",
|
|
18
|
-
date_to: "",
|
|
19
|
-
});
|
|
20
|
-
|
|
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,
|
|
26
|
-
});
|
|
27
|
-
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
const loadTransactionHistory = async () => {
|
|
44
|
-
setIsLoadingHistory(true);
|
|
45
|
-
try {
|
|
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
|
-
}));
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
setTransactionHistory(historyData);
|
|
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
|
-
}));
|
|
79
|
-
toggleNotification({
|
|
80
|
-
type: "danger",
|
|
81
|
-
message: "Failed to load transaction history",
|
|
82
|
-
});
|
|
83
|
-
} finally {
|
|
84
|
-
setIsLoadingHistory(false);
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
React.useEffect(() => {
|
|
89
|
-
loadTransactionHistory();
|
|
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
|
-
]);
|
|
100
|
-
|
|
101
|
-
const handleTransactionSelect = (transaction) => {
|
|
102
|
-
setSelectedTransaction(
|
|
103
|
-
selectedTransaction?.id === transaction?.id ? null : transaction
|
|
104
|
-
);
|
|
105
|
-
};
|
|
106
|
-
|
|
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);
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
const handleFiltersChange = (newFilters) => {
|
|
119
|
-
if (newFilters && typeof newFilters === "object") {
|
|
120
|
-
setFilters((prev) => ({
|
|
121
|
-
...prev,
|
|
122
|
-
...newFilters,
|
|
123
|
-
}));
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
React.useEffect(() => {
|
|
128
|
-
setSelectedTransaction(null);
|
|
129
|
-
}, [filters, pagination.page]);
|
|
130
|
-
|
|
131
|
-
return {
|
|
132
|
-
transactions: Array.isArray(transactionHistory) ? transactionHistory : [],
|
|
133
|
-
isLoadingHistory,
|
|
134
|
-
selectedTransaction,
|
|
135
|
-
currentPage: pagination.page,
|
|
136
|
-
totalPages: pagination.pageCount,
|
|
137
|
-
totalCount: pagination.total,
|
|
138
|
-
pageSize: pagination.pageSize,
|
|
139
|
-
handleTransactionSelect,
|
|
140
|
-
loadTransactionHistory,
|
|
141
|
-
filters,
|
|
142
|
-
handleFiltersChange,
|
|
143
|
-
pagination,
|
|
144
|
-
handlePaginationChange,
|
|
145
|
-
};
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
export default useTransactionHistory;
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useNotification, useQueryParams } from "@strapi/strapi/admin";
|
|
3
|
+
import usePayoneRequests from "../utils/api";
|
|
4
|
+
|
|
5
|
+
const PAGE_SIZE = 10;
|
|
6
|
+
|
|
7
|
+
const useTransactionHistory = () => {
|
|
8
|
+
const { toggleNotification } = useNotification();
|
|
9
|
+
const { getTransactionHistory } = usePayoneRequests();
|
|
10
|
+
const [{ query }, setQuery] = useQueryParams();
|
|
11
|
+
|
|
12
|
+
const [filters, setFilters] = React.useState({
|
|
13
|
+
search: "",
|
|
14
|
+
status: "",
|
|
15
|
+
request_type: "",
|
|
16
|
+
payment_method: "",
|
|
17
|
+
date_from: "",
|
|
18
|
+
date_to: "",
|
|
19
|
+
});
|
|
20
|
+
|
|
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,
|
|
26
|
+
});
|
|
27
|
+
|
|
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
|
+
|
|
42
|
+
|
|
43
|
+
const loadTransactionHistory = async () => {
|
|
44
|
+
setIsLoadingHistory(true);
|
|
45
|
+
try {
|
|
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
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
setTransactionHistory(historyData);
|
|
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
|
+
}));
|
|
79
|
+
toggleNotification({
|
|
80
|
+
type: "danger",
|
|
81
|
+
message: "Failed to load transaction history",
|
|
82
|
+
});
|
|
83
|
+
} finally {
|
|
84
|
+
setIsLoadingHistory(false);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
React.useEffect(() => {
|
|
89
|
+
loadTransactionHistory();
|
|
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
|
+
]);
|
|
100
|
+
|
|
101
|
+
const handleTransactionSelect = (transaction) => {
|
|
102
|
+
setSelectedTransaction(
|
|
103
|
+
selectedTransaction?.id === transaction?.id ? null : transaction
|
|
104
|
+
);
|
|
105
|
+
};
|
|
106
|
+
|
|
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);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const handleFiltersChange = (newFilters) => {
|
|
119
|
+
if (newFilters && typeof newFilters === "object") {
|
|
120
|
+
setFilters((prev) => ({
|
|
121
|
+
...prev,
|
|
122
|
+
...newFilters,
|
|
123
|
+
}));
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
React.useEffect(() => {
|
|
128
|
+
setSelectedTransaction(null);
|
|
129
|
+
}, [filters, pagination.page]);
|
|
130
|
+
|
|
131
|
+
return {
|
|
132
|
+
transactions: Array.isArray(transactionHistory) ? transactionHistory : [],
|
|
133
|
+
isLoadingHistory,
|
|
134
|
+
selectedTransaction,
|
|
135
|
+
currentPage: pagination.page,
|
|
136
|
+
totalPages: pagination.pageCount,
|
|
137
|
+
totalCount: pagination.total,
|
|
138
|
+
pageSize: pagination.pageSize,
|
|
139
|
+
handleTransactionSelect,
|
|
140
|
+
loadTransactionHistory,
|
|
141
|
+
filters,
|
|
142
|
+
handleFiltersChange,
|
|
143
|
+
pagination,
|
|
144
|
+
handlePaginationChange,
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
export default useTransactionHistory;
|
|
@@ -1,98 +1,98 @@
|
|
|
1
|
-
import { useFetchClient } from '@strapi/strapi/admin';
|
|
2
|
-
import pluginId from '../../pluginId';
|
|
3
|
-
|
|
4
|
-
const usePayoneRequests = () => {
|
|
5
|
-
const { get, post, put } = useFetchClient();
|
|
6
|
-
|
|
7
|
-
const getSettings = () => get(`/${pluginId}/settings`);
|
|
8
|
-
|
|
9
|
-
const updateSettings = (data) =>
|
|
10
|
-
put(`/${pluginId}/settings`, data);
|
|
11
|
-
|
|
12
|
-
const getTransactionHistory = (params = {}) => {
|
|
13
|
-
const queryParams = new URLSearchParams();
|
|
14
|
-
|
|
15
|
-
if (params.filters && typeof params.filters === "object") {
|
|
16
|
-
Object.keys(params.filters).forEach((key) => {
|
|
17
|
-
const value = params.filters[key];
|
|
18
|
-
const v = value == null ? "" : String(value).trim();
|
|
19
|
-
if (v !== "" && v.toLowerCase() !== "all") {
|
|
20
|
-
queryParams.append(`filters[${key}]`, String(value));
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (params.pagination) {
|
|
26
|
-
if (params.pagination.page) {
|
|
27
|
-
queryParams.append('pagination[page]', String(params.pagination.page));
|
|
28
|
-
}
|
|
29
|
-
if (params.pagination.pageSize) {
|
|
30
|
-
queryParams.append('pagination[pageSize]', String(params.pagination.pageSize));
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const queryString = queryParams.toString();
|
|
35
|
-
return get(
|
|
36
|
-
`/${pluginId}/transaction-history${queryString ? `?${queryString}` : ''}`
|
|
37
|
-
);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const exportTransactions = (params = {}) => {
|
|
41
|
-
const queryParams = new URLSearchParams();
|
|
42
|
-
const format = params.format === "csv" ? "csv" : "json";
|
|
43
|
-
queryParams.append("format", format);
|
|
44
|
-
if (params.sort_by) queryParams.append("sort_by", params.sort_by);
|
|
45
|
-
if (params.sort_order) queryParams.append("sort_order", params.sort_order);
|
|
46
|
-
if (params.filters && typeof params.filters === "object") {
|
|
47
|
-
Object.keys(params.filters).forEach((key) => {
|
|
48
|
-
const value = params.filters[key];
|
|
49
|
-
const v = value == null ? "" : String(value).trim();
|
|
50
|
-
if (v !== "" && v.toLowerCase() !== "all") {
|
|
51
|
-
queryParams.append(`filters[${key}]`, String(value));
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
const queryString = queryParams.toString();
|
|
56
|
-
return get(`/${pluginId}/transactions/export?${queryString}`);
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const importTransactions = (payload) => {
|
|
60
|
-
return post(`/${pluginId}/transactions/import`, payload, {
|
|
61
|
-
headers: { "Content-Type": "application/json" },
|
|
62
|
-
});
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const testConnection = () =>
|
|
66
|
-
post(`/${pluginId}/test-connection`);
|
|
67
|
-
|
|
68
|
-
const preauthorization = (data) =>
|
|
69
|
-
post(`/${pluginId}/preauthorization`, data);
|
|
70
|
-
|
|
71
|
-
const authorization = (data) =>
|
|
72
|
-
post(`/${pluginId}/authorization`, data);
|
|
73
|
-
|
|
74
|
-
const capture = (data) =>
|
|
75
|
-
post(`/${pluginId}/capture`, data);
|
|
76
|
-
|
|
77
|
-
const refund = (data) =>
|
|
78
|
-
post(`/${pluginId}/refund`, data);
|
|
79
|
-
|
|
80
|
-
const handle3DSCallback = (data) =>
|
|
81
|
-
post(`/${pluginId}/3ds-callback`, data);
|
|
82
|
-
|
|
83
|
-
return {
|
|
84
|
-
getSettings,
|
|
85
|
-
updateSettings,
|
|
86
|
-
getTransactionHistory,
|
|
87
|
-
exportTransactions,
|
|
88
|
-
importTransactions,
|
|
89
|
-
testConnection,
|
|
90
|
-
preauthorization,
|
|
91
|
-
authorization,
|
|
92
|
-
capture,
|
|
93
|
-
refund,
|
|
94
|
-
handle3DSCallback,
|
|
95
|
-
};
|
|
96
|
-
};
|
|
97
|
-
|
|
1
|
+
import { useFetchClient } from '@strapi/strapi/admin';
|
|
2
|
+
import pluginId from '../../pluginId';
|
|
3
|
+
|
|
4
|
+
const usePayoneRequests = () => {
|
|
5
|
+
const { get, post, put } = useFetchClient();
|
|
6
|
+
|
|
7
|
+
const getSettings = () => get(`/${pluginId}/settings`);
|
|
8
|
+
|
|
9
|
+
const updateSettings = (data) =>
|
|
10
|
+
put(`/${pluginId}/settings`, data);
|
|
11
|
+
|
|
12
|
+
const getTransactionHistory = (params = {}) => {
|
|
13
|
+
const queryParams = new URLSearchParams();
|
|
14
|
+
|
|
15
|
+
if (params.filters && typeof params.filters === "object") {
|
|
16
|
+
Object.keys(params.filters).forEach((key) => {
|
|
17
|
+
const value = params.filters[key];
|
|
18
|
+
const v = value == null ? "" : String(value).trim();
|
|
19
|
+
if (v !== "" && v.toLowerCase() !== "all") {
|
|
20
|
+
queryParams.append(`filters[${key}]`, String(value));
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (params.pagination) {
|
|
26
|
+
if (params.pagination.page) {
|
|
27
|
+
queryParams.append('pagination[page]', String(params.pagination.page));
|
|
28
|
+
}
|
|
29
|
+
if (params.pagination.pageSize) {
|
|
30
|
+
queryParams.append('pagination[pageSize]', String(params.pagination.pageSize));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const queryString = queryParams.toString();
|
|
35
|
+
return get(
|
|
36
|
+
`/${pluginId}/transaction-history${queryString ? `?${queryString}` : ''}`
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const exportTransactions = (params = {}) => {
|
|
41
|
+
const queryParams = new URLSearchParams();
|
|
42
|
+
const format = params.format === "csv" ? "csv" : "json";
|
|
43
|
+
queryParams.append("format", format);
|
|
44
|
+
if (params.sort_by) queryParams.append("sort_by", params.sort_by);
|
|
45
|
+
if (params.sort_order) queryParams.append("sort_order", params.sort_order);
|
|
46
|
+
if (params.filters && typeof params.filters === "object") {
|
|
47
|
+
Object.keys(params.filters).forEach((key) => {
|
|
48
|
+
const value = params.filters[key];
|
|
49
|
+
const v = value == null ? "" : String(value).trim();
|
|
50
|
+
if (v !== "" && v.toLowerCase() !== "all") {
|
|
51
|
+
queryParams.append(`filters[${key}]`, String(value));
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
const queryString = queryParams.toString();
|
|
56
|
+
return get(`/${pluginId}/transactions/export?${queryString}`);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const importTransactions = (payload) => {
|
|
60
|
+
return post(`/${pluginId}/transactions/import`, payload, {
|
|
61
|
+
headers: { "Content-Type": "application/json" },
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const testConnection = () =>
|
|
66
|
+
post(`/${pluginId}/test-connection`);
|
|
67
|
+
|
|
68
|
+
const preauthorization = (data) =>
|
|
69
|
+
post(`/${pluginId}/preauthorization`, data);
|
|
70
|
+
|
|
71
|
+
const authorization = (data) =>
|
|
72
|
+
post(`/${pluginId}/authorization`, data);
|
|
73
|
+
|
|
74
|
+
const capture = (data) =>
|
|
75
|
+
post(`/${pluginId}/capture`, data);
|
|
76
|
+
|
|
77
|
+
const refund = (data) =>
|
|
78
|
+
post(`/${pluginId}/refund`, data);
|
|
79
|
+
|
|
80
|
+
const handle3DSCallback = (data) =>
|
|
81
|
+
post(`/${pluginId}/3ds-callback`, data);
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
getSettings,
|
|
85
|
+
updateSettings,
|
|
86
|
+
getTransactionHistory,
|
|
87
|
+
exportTransactions,
|
|
88
|
+
importTransactions,
|
|
89
|
+
testConnection,
|
|
90
|
+
preauthorization,
|
|
91
|
+
authorization,
|
|
92
|
+
capture,
|
|
93
|
+
refund,
|
|
94
|
+
handle3DSCallback,
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
|
|
98
98
|
export default usePayoneRequests;
|