strapi-plugin-payone-provider 1.6.7 → 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.
Files changed (94) hide show
  1. package/README.md +24 -11
  2. package/admin/src/components/Initializer/index.jsx +3 -3
  3. package/admin/src/components/PluginIcon/index.jsx +3 -3
  4. package/admin/src/index.js +33 -11
  5. package/admin/src/pages/App/components/AppHeader.jsx +17 -32
  6. package/admin/src/pages/App/components/AppTabs.jsx +36 -156
  7. package/admin/src/pages/App/components/ApplePayBtn.jsx +9 -11
  8. package/admin/src/pages/App/components/ApplePayConfig.jsx +221 -161
  9. package/admin/src/pages/App/components/ApplePayConfigPanel.jsx +33 -45
  10. package/admin/src/pages/App/components/DocsPanel.jsx +66 -1726
  11. package/admin/src/pages/App/components/GooglePayConfig.jsx +136 -169
  12. package/admin/src/pages/App/components/GooglePayConfigPanel.jsx +37 -55
  13. package/admin/src/pages/App/components/GooglePaybutton.jsx +101 -43
  14. package/admin/src/pages/App/components/RenderInput.jsx +94 -0
  15. package/admin/src/pages/App/components/StatusBadge.jsx +27 -16
  16. package/admin/src/pages/App/components/configuration/ConfigurationFields.jsx +255 -0
  17. package/admin/src/pages/App/components/configuration/ConfigurationPanel.jsx +54 -0
  18. package/admin/src/pages/App/components/configuration/TestConnection.jsx +130 -0
  19. package/admin/src/pages/App/components/docs/ApplePaySection.jsx +260 -0
  20. package/admin/src/pages/App/components/docs/BaseUrlSection.jsx +53 -0
  21. package/admin/src/pages/App/components/docs/CaptureRefundSection.jsx +113 -0
  22. package/admin/src/pages/App/components/docs/CodeBlock.jsx +59 -0
  23. package/admin/src/pages/App/components/docs/CreditCardSection.jsx +93 -0
  24. package/admin/src/pages/App/components/docs/GooglePaySection.jsx +248 -0
  25. package/admin/src/pages/App/components/docs/PayPalSection.jsx +116 -0
  26. package/admin/src/pages/App/components/docs/PaymentMethodsSection.jsx +55 -0
  27. package/admin/src/pages/App/components/docs/TableOfContents.jsx +47 -0
  28. package/admin/src/pages/App/components/docs/TestCredentialsSection.jsx +304 -0
  29. package/admin/src/pages/App/components/docs/ThreeDSecureSection.jsx +188 -0
  30. package/admin/src/pages/App/components/icons/BankIcon.jsx +1 -1
  31. package/admin/src/pages/App/components/icons/ChevronDownIcon.jsx +1 -1
  32. package/admin/src/pages/App/components/icons/ChevronUpIcon.jsx +1 -1
  33. package/admin/src/pages/App/components/icons/CreditCardIcon.jsx +1 -1
  34. package/admin/src/pages/App/components/icons/ErrorIcon.jsx +1 -1
  35. package/admin/src/pages/App/components/icons/InfoIcon.jsx +1 -1
  36. package/admin/src/pages/App/components/icons/MarkCircle.jsx +19 -0
  37. package/admin/src/pages/App/components/icons/PaymentIcon.jsx +1 -1
  38. package/admin/src/pages/App/components/icons/PendingIcon.jsx +1 -1
  39. package/admin/src/pages/App/components/icons/PersonIcon.jsx +1 -1
  40. package/admin/src/pages/App/components/icons/SuccessIcon.jsx +1 -1
  41. package/admin/src/pages/App/components/icons/WalletIcon.jsx +1 -1
  42. package/admin/src/pages/App/components/payment-actions/ApplePayPanel.jsx +51 -0
  43. package/admin/src/pages/App/components/payment-actions/AuthorizationForm.jsx +341 -0
  44. package/admin/src/pages/App/components/payment-actions/CaptureForm.jsx +128 -0
  45. package/admin/src/pages/App/components/{paymentActions → payment-actions}/CardDetailsInput.jsx +77 -72
  46. package/admin/src/pages/App/components/payment-actions/PaymentActionsPanel.jsx +194 -0
  47. package/admin/src/pages/App/components/payment-actions/PaymentMethodSelector.jsx +313 -0
  48. package/admin/src/pages/App/components/payment-actions/PaymentResult.jsx +133 -0
  49. package/admin/src/pages/App/components/payment-actions/PreauthorizationForm.jsx +280 -0
  50. package/admin/src/pages/App/components/payment-actions/RefundForm.jsx +121 -0
  51. package/admin/src/pages/App/components/transaction-history/FiltersPanel.jsx +145 -0
  52. package/admin/src/pages/App/components/transaction-history/HistoryPanel.jsx +50 -0
  53. package/admin/src/pages/App/components/transaction-history/TransactionTable.jsx +163 -0
  54. package/admin/src/pages/App/components/transaction-history/details/TransactionDetails.jsx +156 -0
  55. package/admin/src/pages/App/components/{TransactionHistoryItem.jsx → transaction-history/details/TransactionHistoryItem.jsx} +16 -28
  56. package/admin/src/pages/App/index.jsx +27 -67
  57. package/admin/src/pages/App/styles.css +46 -169
  58. package/admin/src/pages/constants/paymentConstants.js +52 -16
  59. package/admin/src/pages/hooks/use-system-theme.js +27 -0
  60. package/admin/src/pages/hooks/usePaymentActions.js +273 -210
  61. package/admin/src/pages/hooks/useSettings.js +87 -48
  62. package/admin/src/pages/hooks/useTransactionHistory.js +109 -47
  63. package/admin/src/pages/utils/api.js +57 -72
  64. package/admin/src/pages/utils/applePayConstants.js +2 -28
  65. package/admin/src/pages/utils/countryLanguageUtils.js +280 -0
  66. package/admin/src/pages/utils/getInputComponent.jsx +225 -0
  67. package/admin/src/pages/utils/googlePayConstants.js +2 -9
  68. package/admin/src/pages/utils/paymentUtils.js +13 -25
  69. package/admin/src/pages/utils/tooltipHelpers.js +18 -0
  70. package/admin/src/pages/utils/transactionTableUtils.js +60 -0
  71. package/package.json +7 -12
  72. package/server/config/index.js +18 -2
  73. package/server/controllers/payone.js +80 -31
  74. package/server/policies/is-auth.js +9 -3
  75. package/server/policies/isSuperAdmin.js +7 -5
  76. package/server/services/paymentService.js +6 -22
  77. package/server/services/payone.js +3 -3
  78. package/server/services/settingsService.js +13 -3
  79. package/server/services/testConnectionService.js +11 -73
  80. package/server/services/transactionService.js +61 -32
  81. package/server/utils/normalize.js +0 -12
  82. package/server/utils/paymentMethodParams.js +0 -1
  83. package/server/utils/responseParser.js +9 -14
  84. package/strapi-admin.js +3 -1
  85. package/admin/src/pages/App/components/ConfigurationPanel.jsx +0 -517
  86. package/admin/src/pages/App/components/HistoryPanel.jsx +0 -312
  87. package/admin/src/pages/App/components/PaymentActionsPanel.jsx +0 -280
  88. package/admin/src/pages/App/components/paymentActions/ApplePayPanel.jsx +0 -95
  89. package/admin/src/pages/App/components/paymentActions/AuthorizationForm.jsx +0 -197
  90. package/admin/src/pages/App/components/paymentActions/CaptureForm.jsx +0 -65
  91. package/admin/src/pages/App/components/paymentActions/PaymentMethodSelector.jsx +0 -306
  92. package/admin/src/pages/App/components/paymentActions/PaymentResult.jsx +0 -192
  93. package/admin/src/pages/App/components/paymentActions/PreauthorizationForm.jsx +0 -142
  94. package/admin/src/pages/App/components/paymentActions/RefundForm.jsx +0 -90
@@ -1,32 +1,49 @@
1
- import { useState, useEffect } from "react";
2
- import { useNotification } from "@strapi/helper-plugin";
3
- import payoneRequests from "../utils/api";
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
- useEffect(() => {
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 payoneRequests.getSettings();
29
- if (response?.data) setSettings(response.data);
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]: value };
97
+ updatedSettings = { ...prev, [field]: booleanValue };
48
98
  return updatedSettings;
49
99
  });
50
100
 
51
101
  setIsSaving(true);
52
102
  try {
53
- await payoneRequests.updateSettings(updatedSettings);
54
- toggleNotification({
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]: !value }));
106
+ setSettings((prev) => ({ ...prev, [field]: !booleanValue }));
60
107
  toggleNotification({
61
- type: "warning",
62
- message: "Failed to update payment method"
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 payoneRequests.updateSettings(settings);
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: "warning",
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 payoneRequests.testConnection();
93
- if (response.data) {
94
- const result = response.data;
95
- setTestResult(result);
96
- if (result.success !== undefined) {
97
- toggleNotification({
98
- type: Boolean(result.success) ? "success" : "warning",
99
- message: result.message || "Test completed"
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
- throw new Error("Invalid response format from server");
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
- toggleNotification({
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,86 +1,148 @@
1
- import { useState, useEffect } from "react";
2
- import { useNotification } from "@strapi/helper-plugin";
3
- import payoneRequests from "../utils/api";
1
+ import * as React from "react";
2
+ import { useNotification, useQueryParams } from "@strapi/strapi/admin";
3
+ import usePayoneRequests from "../utils/api";
4
4
 
5
5
  const PAGE_SIZE = 10;
6
6
 
7
7
  const useTransactionHistory = () => {
8
- const toggleNotification = useNotification();
9
- const [transactionHistory, setTransactionHistory] = useState([]);
10
- const [isLoadingHistory, setIsLoadingHistory] = useState(false);
11
- const [selectedTransaction, setSelectedTransaction] = useState(null);
12
- const [currentPage, setCurrentPage] = useState(1);
13
- const [filters, setFilters] = useState({
8
+ const { toggleNotification } = useNotification();
9
+ const { getTransactionHistory } = usePayoneRequests();
10
+ const [{ query }, setQuery] = useQueryParams();
11
+
12
+ const [filters, setFilters] = React.useState({
14
13
  search: "",
14
+ status: "",
15
15
  request_type: "",
16
16
  payment_method: "",
17
17
  date_from: "",
18
- date_to: ""
18
+ date_to: "",
19
19
  });
20
20
 
21
- useEffect(() => {
22
- loadTransactionHistory();
23
- }, []);
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
+
24
42
 
25
43
  const loadTransactionHistory = async () => {
26
44
  setIsLoadingHistory(true);
27
45
  try {
28
- const result = await payoneRequests.getTransactionHistory(filters);
29
- setTransactionHistory(result.data || []);
30
- setCurrentPage(1);
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);
31
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
+ }));
32
79
  toggleNotification({
33
- type: "warning",
34
- message: "Failed to load transaction history"
80
+ type: "danger",
81
+ message: "Failed to load transaction history",
35
82
  });
36
83
  } finally {
37
84
  setIsLoadingHistory(false);
38
85
  }
39
86
  };
40
87
 
41
- const handleFilterChange = (field, value) => {
42
- setFilters((prev) => ({ ...prev, [field]: value }));
43
- };
44
-
45
- const handleFilterApply = () => {
88
+ React.useEffect(() => {
46
89
  loadTransactionHistory();
47
- };
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
+ ]);
48
100
 
49
101
  const handleTransactionSelect = (transaction) => {
50
- if (selectedTransaction?.id === transaction?.id) {
51
- setSelectedTransaction(null);
52
- } else {
53
- setSelectedTransaction(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);
54
115
  }
55
116
  };
56
117
 
57
- const handlePageChange = (page) => {
58
- setCurrentPage(page);
59
- setSelectedTransaction(null);
118
+ const handleFiltersChange = (newFilters) => {
119
+ if (newFilters && typeof newFilters === "object") {
120
+ setFilters((prev) => ({
121
+ ...prev,
122
+ ...newFilters,
123
+ }));
124
+ }
60
125
  };
61
126
 
62
- // Pagination calculations
63
- const totalPages = Math.ceil(transactionHistory.length / PAGE_SIZE);
64
- const startIndex = (currentPage - 1) * PAGE_SIZE;
65
- const endIndex = startIndex + PAGE_SIZE;
66
- const paginatedTransactions = transactionHistory.slice(startIndex, endIndex);
127
+ React.useEffect(() => {
128
+ setSelectedTransaction(null);
129
+ }, [filters, pagination.page]);
67
130
 
68
131
  return {
69
- transactionHistory,
70
- paginatedTransactions,
132
+ transactions: Array.isArray(transactionHistory) ? transactionHistory : [],
71
133
  isLoadingHistory,
72
134
  selectedTransaction,
73
- filters,
74
- currentPage,
75
- totalPages,
76
- pageSize: PAGE_SIZE,
77
- handleFilterChange,
78
- handleFilterApply,
135
+ currentPage: pagination.page,
136
+ totalPages: pagination.pageCount,
137
+ totalCount: pagination.total,
138
+ pageSize: pagination.pageSize,
79
139
  handleTransactionSelect,
80
- handlePageChange,
81
- loadTransactionHistory
140
+ loadTransactionHistory,
141
+ filters,
142
+ handleFiltersChange,
143
+ pagination,
144
+ handlePaginationChange,
82
145
  };
83
146
  };
84
147
 
85
148
  export default useTransactionHistory;
86
-
@@ -1,85 +1,70 @@
1
- import { request } from "@strapi/helper-plugin";
2
- import pluginId from "../../pluginId";
1
+ import { useFetchClient } from '@strapi/strapi/admin';
2
+ import pluginId from '../../pluginId';
3
3
 
4
- const payoneRequests = {
5
- getSettings: () => {
6
- return request(`/${pluginId}/settings`, {
7
- method: "GET"
8
- });
9
- },
4
+ const usePayoneRequests = () => {
5
+ const { get, post, put } = useFetchClient();
10
6
 
11
- updateSettings: (data) => {
12
- return request(`/${pluginId}/settings`, {
13
- method: "PUT",
14
- body: data
15
- });
16
- },
7
+ const getSettings = () => get(`/${pluginId}/settings`);
17
8
 
18
- getTransactionHistory: (params = {}) => {
19
- const queryString = new URLSearchParams(params).toString();
20
- return request(
21
- `/${pluginId}/transaction-history${queryString ? `?${queryString}` : ""}`,
22
- {
23
- method: "GET"
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
- return request(`/${pluginId}/test-connection`, {
30
- method: "POST"
31
- });
32
- },
39
+ const testConnection = () =>
40
+ post(`/${pluginId}/test-connection`);
33
41
 
34
- preauthorization: (data) => {
35
- return request(`/${pluginId}/preauthorization`, {
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: (data) => {
45
- return request(`/${pluginId}/authorization`, {
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: (data) => {
55
- return request(`/${pluginId}/capture`, {
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: (data) => {
65
- return request(`/${pluginId}/refund`, {
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: (data) => {
75
- return request(`/${pluginId}/3ds-callback`, {
76
- method: "POST",
77
- body: data,
78
- headers: {
79
- "Content-Type": "application/json"
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 payoneRequests;
70
+ export default usePayoneRequests;
@@ -1,12 +1,4 @@
1
- /**
2
- * Apple Pay Constants
3
- * Based on Apple Pay documentation and Payone requirements
4
- * https://developer.apple.com/documentation/applepayontheweb
5
- * https://docs.payone.com/payment-methods/apple-pay/apple-pay-without-dev
6
- */
7
-
8
- // Apple Pay supported countries
9
- // Note: Apple Pay availability varies by country
1
+
10
2
  export const APPLE_PAY_SUPPORTED_COUNTRIES = [
11
3
  { code: "US", name: "United States" },
12
4
  { code: "GB", name: "United Kingdom" },
@@ -46,8 +38,6 @@ export const APPLE_PAY_SUPPORTED_COUNTRIES = [
46
38
  { code: "ZA", name: "South Africa" }
47
39
  ];
48
40
 
49
- // Apple Pay supported currencies
50
- // Note: Some currencies may be restricted in certain countries
51
41
  export const APPLE_PAY_SUPPORTED_CURRENCIES = [
52
42
  { code: "USD", name: "US Dollar", symbol: "$" },
53
43
  { code: "EUR", name: "Euro", symbol: "€" },
@@ -77,7 +67,6 @@ export const APPLE_PAY_SUPPORTED_CURRENCIES = [
77
67
  { code: "HUF", name: "Hungarian Forint", symbol: "Ft" }
78
68
  ];
79
69
 
80
- // Apple Pay supported payment networks
81
70
  export const APPLE_PAY_SUPPORTED_NETWORKS = [
82
71
  { code: "amex", name: "American Express" },
83
72
  { code: "discover", name: "Discover" },
@@ -92,15 +81,12 @@ export const APPLE_PAY_SUPPORTED_NETWORKS = [
92
81
  { code: "privateLabel", name: "Private Label" }
93
82
  ];
94
83
 
95
- // Merchant capabilities
96
84
  export const APPLE_PAY_MERCHANT_CAPABILITIES = [
97
85
  { code: "supports3DS", name: "3D Secure", description: "Required for most payment methods" },
98
86
  { code: "supportsCredit", name: "Credit Cards", description: "Support credit card payments" },
99
87
  { code: "supportsDebit", name: "Debit Cards", description: "Support debit card payments" }
100
88
  ];
101
89
 
102
- // Country-currency restrictions
103
- // Some currencies are not available in certain countries
104
90
  export const COUNTRY_CURRENCY_RESTRICTIONS = {
105
91
  US: ["USD"],
106
92
  GB: ["GBP", "EUR"],
@@ -126,20 +112,16 @@ export const COUNTRY_CURRENCY_RESTRICTIONS = {
126
112
  ZA: ["ZAR"]
127
113
  };
128
114
 
129
- // Get supported currencies for a country
130
115
  export const getSupportedCurrenciesForCountry = (countryCode) => {
131
116
  const restrictions = COUNTRY_CURRENCY_RESTRICTIONS[countryCode];
132
117
  if (restrictions) {
133
- return APPLE_PAY_SUPPORTED_CURRENCIES.filter(currency =>
118
+ return APPLE_PAY_SUPPORTED_CURRENCIES.filter(currency =>
134
119
  restrictions.includes(currency.code)
135
120
  );
136
121
  }
137
- // Default: return all currencies if no restrictions
138
122
  return APPLE_PAY_SUPPORTED_CURRENCIES;
139
123
  };
140
124
 
141
- // Get supported networks for a country
142
- // Some networks are country-specific
143
125
  export const getSupportedNetworksForCountry = (countryCode) => {
144
126
  const countryNetworks = {
145
127
  US: ["amex", "discover", "masterCard", "visa"],
@@ -157,30 +139,23 @@ export const getSupportedNetworksForCountry = (countryCode) => {
157
139
  return countryNetworks[countryCode] || countryNetworks.default;
158
140
  };
159
141
 
160
- // Test data for Apple Pay
161
- // Based on Apple Pay sandbox testing documentation
162
142
  export const APPLE_PAY_TEST_DATA = {
163
- // Test card numbers (for sandbox testing)
164
143
  testCards: {
165
144
  visa: "4111111111111111",
166
145
  mastercard: "5555555555554444",
167
146
  amex: "378282246310005",
168
147
  discover: "6011111111111117"
169
148
  },
170
- // Test merchant identifiers (for development)
171
149
  testMerchantIdentifier: "merchant.com.payone.test",
172
- // Test domain
173
150
  testDomain: "test.payone.com"
174
151
  };
175
152
 
176
- // Apple Pay button styles
177
153
  export const APPLE_PAY_BUTTON_STYLES = [
178
154
  { code: "black", name: "Black" },
179
155
  { code: "white", name: "White with outline" },
180
156
  { code: "white-outline", name: "White" }
181
157
  ];
182
158
 
183
- // Apple Pay button types
184
159
  export const APPLE_PAY_BUTTON_TYPES = [
185
160
  { code: "plain", name: "Plain" },
186
161
  { code: "buy", name: "Buy" },
@@ -201,7 +176,6 @@ export const APPLE_PAY_BUTTON_TYPES = [
201
176
  { code: "set-up", name: "Set Up" }
202
177
  ];
203
178
 
204
- // Default Apple Pay configuration
205
179
  export const DEFAULT_APPLE_PAY_CONFIG = {
206
180
  countryCode: "DE",
207
181
  currencyCode: "EUR",