strapi-plugin-payone-provider 1.5.8-beta.1 → 1.6.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/admin/src/index.js +3 -3
- package/admin/src/pages/App/components/ApplePayBtn.jsx +304 -0
- package/admin/src/pages/App/components/{ApplePayButton.js → ApplePayButton.jsx} +4 -46
- package/admin/src/pages/App/components/{ApplePayConfig.js → ApplePayConfig.jsx} +64 -130
- package/admin/src/pages/App/components/{PaymentActionsPanel.js → PaymentActionsPanel.jsx} +62 -14
- package/admin/src/pages/App/components/icons/index.jsx +11 -0
- package/admin/src/pages/App/components/paymentActions/{AuthorizationForm.js → AuthorizationForm.jsx} +45 -35
- package/admin/src/pages/App/components/paymentActions/{PaymentMethodSelector.js → PaymentMethodSelector.jsx} +111 -31
- package/admin/src/pages/App/components/paymentActions/{PreauthorizationForm.js → PreauthorizationForm.jsx} +3 -70
- package/admin/src/pages/constants/paymentConstants.js +1 -2
- package/admin/src/pages/hooks/usePaymentActions.js +1 -76
- package/package.json +49 -49
- package/server/bootstrap.js +59 -1
- package/server/controllers/payone.js +6 -77
- package/server/routes/index.js +1 -1
- package/server/services/applePayService.js +51 -509
- package/server/services/paymentService.js +0 -68
- package/server/services/payone.js +0 -3
- package/server/services/settingsService.js +0 -21
- package/server/services/testConnectionService.js +0 -14
- package/server/services/transactionService.js +2 -16
- package/server/utils/paymentMethodParams.js +60 -21
- package/server/utils/requestBuilder.js +0 -22
- package/admin/src/pages/App/components/icons/index.js +0 -11
- /package/admin/src/components/Initializer/{index.js → index.jsx} +0 -0
- /package/admin/src/components/PluginIcon/{index.js → index.jsx} +0 -0
- /package/admin/src/pages/App/components/{AppHeader.js → AppHeader.jsx} +0 -0
- /package/admin/src/pages/App/components/{AppTabs.js → AppTabs.jsx} +0 -0
- /package/admin/src/pages/App/components/{ApplePayConfigPanel.js → ApplePayConfigPanel.jsx} +0 -0
- /package/admin/src/pages/App/components/{ConfigurationPanel.js → ConfigurationPanel.jsx} +0 -0
- /package/admin/src/pages/App/components/{DocsPanel.js → DocsPanel.jsx} +0 -0
- /package/admin/src/pages/App/components/{GooglePayConfig.js → GooglePayConfig.jsx} +0 -0
- /package/admin/src/pages/App/components/{GooglePayConfigPanel.js → GooglePayConfigPanel.jsx} +0 -0
- /package/admin/src/pages/App/components/{GooglePaybutton.js → GooglePaybutton.jsx} +0 -0
- /package/admin/src/pages/App/components/{HistoryPanel.js → HistoryPanel.jsx} +0 -0
- /package/admin/src/pages/App/components/{StatusBadge.js → StatusBadge.jsx} +0 -0
- /package/admin/src/pages/App/components/{TransactionHistoryItem.js → TransactionHistoryItem.jsx} +0 -0
- /package/admin/src/pages/App/components/icons/{BankIcon.js → BankIcon.jsx} +0 -0
- /package/admin/src/pages/App/components/icons/{ChevronDownIcon.js → ChevronDownIcon.jsx} +0 -0
- /package/admin/src/pages/App/components/icons/{ChevronUpIcon.js → ChevronUpIcon.jsx} +0 -0
- /package/admin/src/pages/App/components/icons/{CreditCardIcon.js → CreditCardIcon.jsx} +0 -0
- /package/admin/src/pages/App/components/icons/{ErrorIcon.js → ErrorIcon.jsx} +0 -0
- /package/admin/src/pages/App/components/icons/{InfoIcon.js → InfoIcon.jsx} +0 -0
- /package/admin/src/pages/App/components/icons/{PaymentIcon.js → PaymentIcon.jsx} +0 -0
- /package/admin/src/pages/App/components/icons/{PendingIcon.js → PendingIcon.jsx} +0 -0
- /package/admin/src/pages/App/components/icons/{PersonIcon.js → PersonIcon.jsx} +0 -0
- /package/admin/src/pages/App/components/icons/{SuccessIcon.js → SuccessIcon.jsx} +0 -0
- /package/admin/src/pages/App/components/icons/{WalletIcon.js → WalletIcon.jsx} +0 -0
- /package/admin/src/pages/App/components/paymentActions/{CaptureForm.js → CaptureForm.jsx} +0 -0
- /package/admin/src/pages/App/components/paymentActions/{CardDetailsInput.js → CardDetailsInput.jsx} +0 -0
- /package/admin/src/pages/App/components/paymentActions/{PaymentResult.js → PaymentResult.jsx} +0 -0
- /package/admin/src/pages/App/components/paymentActions/{RefundForm.js → RefundForm.jsx} +0 -0
- /package/admin/src/pages/App/{index.js → index.jsx} +0 -0
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Box,
|
|
4
|
+
Flex,
|
|
5
|
+
Select,
|
|
6
|
+
Option,
|
|
7
|
+
Typography,
|
|
8
|
+
Link,
|
|
9
|
+
Alert,
|
|
10
|
+
} from "@strapi/design-system";
|
|
3
11
|
import pluginId from "../../../../pluginId";
|
|
4
12
|
import {
|
|
5
13
|
getPaymentMethodOptions,
|
|
6
14
|
supportsCaptureMode,
|
|
7
15
|
getCaptureModeOptions,
|
|
8
|
-
getPaymentMethodDisplayName
|
|
16
|
+
getPaymentMethodDisplayName,
|
|
9
17
|
} from "../../../utils/paymentUtils";
|
|
10
18
|
|
|
11
19
|
const PaymentMethodSelector = ({
|
|
@@ -13,8 +21,12 @@ const PaymentMethodSelector = ({
|
|
|
13
21
|
setPaymentMethod,
|
|
14
22
|
captureMode,
|
|
15
23
|
setCaptureMode,
|
|
16
|
-
onNavigateToConfig
|
|
24
|
+
onNavigateToConfig,
|
|
25
|
+
settings,
|
|
17
26
|
}) => {
|
|
27
|
+
const mode = (settings?.mode || "test").toLowerCase();
|
|
28
|
+
const isLiveMode = mode === "live";
|
|
29
|
+
|
|
18
30
|
return (
|
|
19
31
|
<Box>
|
|
20
32
|
<Flex direction="column" alignItems="stretch" gap={4}>
|
|
@@ -33,36 +45,76 @@ const PaymentMethodSelector = ({
|
|
|
33
45
|
</Select>
|
|
34
46
|
{paymentMethod === "apl" && onNavigateToConfig && (
|
|
35
47
|
<>
|
|
36
|
-
<Alert
|
|
48
|
+
<Alert
|
|
49
|
+
closeLabel="Close"
|
|
50
|
+
title="⚠️ Important: Middleware Configuration Required"
|
|
51
|
+
variant="warning"
|
|
52
|
+
>
|
|
37
53
|
<Typography variant="pi" marginTop={2}>
|
|
38
|
-
<strong>Apple Pay requires middleware configuration</strong> to
|
|
54
|
+
<strong>Apple Pay requires middleware configuration</strong> to
|
|
55
|
+
work properly. You must configure Content Security Policy (CSP)
|
|
56
|
+
in <code>config/middlewares.js</code> to allow Apple Pay
|
|
57
|
+
scripts, otherwise Apple Pay will NOT work.
|
|
39
58
|
</Typography>
|
|
40
59
|
<Typography variant="pi" marginTop={2}>
|
|
41
60
|
Required CSP directives for Apple Pay:
|
|
42
61
|
</Typography>
|
|
43
|
-
<Box
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
62
|
+
<Box
|
|
63
|
+
marginTop={2}
|
|
64
|
+
padding={2}
|
|
65
|
+
background="neutral100"
|
|
66
|
+
borderRadius="4px"
|
|
67
|
+
>
|
|
68
|
+
<Typography
|
|
69
|
+
variant="pi"
|
|
70
|
+
style={{ fontFamily: "monospace", fontSize: "12px" }}
|
|
71
|
+
>
|
|
72
|
+
'script-src': ['https://applepay.cdn-apple.com',
|
|
73
|
+
'https://www.apple.com']
|
|
74
|
+
<br />
|
|
75
|
+
'connect-src': ['https://applepay.cdn-apple.com',
|
|
76
|
+
'https://www.apple.com']
|
|
77
|
+
<br />
|
|
47
78
|
'frame-src': ['https://applepay.cdn-apple.com']
|
|
48
79
|
</Typography>
|
|
49
80
|
</Box>
|
|
50
81
|
<Typography variant="pi" marginTop={2} fontWeight="bold">
|
|
51
|
-
|
|
82
|
+
Without this configuration, Apple Pay will NOT work!
|
|
52
83
|
</Typography>
|
|
53
84
|
</Alert>
|
|
54
|
-
<Alert
|
|
85
|
+
<Alert
|
|
86
|
+
closeLabel="Close"
|
|
87
|
+
title="📥 Apple Pay Domain Verification File Required"
|
|
88
|
+
variant="default"
|
|
89
|
+
>
|
|
55
90
|
<Typography variant="pi" marginTop={2}>
|
|
56
|
-
<strong>Download the Apple Pay domain verification file</strong>
|
|
91
|
+
<strong>Download the Apple Pay domain verification file</strong>{" "}
|
|
92
|
+
from your Payone merchant portal and place it in:
|
|
57
93
|
</Typography>
|
|
58
|
-
<Box
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
94
|
+
<Box
|
|
95
|
+
marginTop={2}
|
|
96
|
+
padding={2}
|
|
97
|
+
background="neutral100"
|
|
98
|
+
borderRadius="4px"
|
|
99
|
+
>
|
|
100
|
+
<Typography
|
|
101
|
+
variant="pi"
|
|
102
|
+
style={{ fontFamily: "monospace", fontSize: "12px" }}
|
|
103
|
+
>
|
|
104
|
+
<strong>Strapi:</strong>{" "}
|
|
105
|
+
<code>
|
|
106
|
+
public/.well-known/apple-developer-merchantid-domain-association
|
|
107
|
+
</code>
|
|
108
|
+
<br />
|
|
109
|
+
<strong>Frontend:</strong>{" "}
|
|
110
|
+
<code>
|
|
111
|
+
public/.well-known/apple-developer-merchantid-domain-association
|
|
112
|
+
</code>
|
|
62
113
|
</Typography>
|
|
63
114
|
</Box>
|
|
64
115
|
<Typography variant="pi" marginTop={2}>
|
|
65
|
-
<strong>Download URL:</strong> Download the domain verification
|
|
116
|
+
<strong>Download URL:</strong> Download the domain verification
|
|
117
|
+
file from Payone documentation:{" "}
|
|
66
118
|
<Link
|
|
67
119
|
href="https://docs.payone.com/payment-methods/apple-pay/apple-pay-without-dev"
|
|
68
120
|
target="_blank"
|
|
@@ -72,11 +124,14 @@ const PaymentMethodSelector = ({
|
|
|
72
124
|
https://docs.payone.com/payment-methods/apple-pay/apple-pay-without-dev
|
|
73
125
|
</Link>
|
|
74
126
|
</Typography>
|
|
75
|
-
<
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
127
|
+
<br />
|
|
128
|
+
<Typography
|
|
129
|
+
variant="pi"
|
|
130
|
+
marginTop={2}
|
|
131
|
+
fontWeight="bold"
|
|
132
|
+
textColor="danger600"
|
|
133
|
+
>
|
|
134
|
+
Without this file, Apple Pay will NOT work on your domain!
|
|
80
135
|
</Typography>
|
|
81
136
|
</Alert>
|
|
82
137
|
<Box padding={3} background="neutral100" borderRadius="4px">
|
|
@@ -88,7 +143,11 @@ const PaymentMethodSelector = ({
|
|
|
88
143
|
e.preventDefault();
|
|
89
144
|
onNavigateToConfig("apple-pay");
|
|
90
145
|
}}
|
|
91
|
-
style={{
|
|
146
|
+
style={{
|
|
147
|
+
cursor: "pointer",
|
|
148
|
+
textDecoration: "underline",
|
|
149
|
+
color: "#0066ff",
|
|
150
|
+
}}
|
|
92
151
|
>
|
|
93
152
|
/plugins/{pluginId}/apple-pay-config
|
|
94
153
|
</Link>
|
|
@@ -98,17 +157,34 @@ const PaymentMethodSelector = ({
|
|
|
98
157
|
)}
|
|
99
158
|
{paymentMethod === "gpp" && onNavigateToConfig && (
|
|
100
159
|
<>
|
|
101
|
-
<Alert
|
|
160
|
+
<Alert
|
|
161
|
+
closeLabel="Close"
|
|
162
|
+
title="⚠️ Important: Middleware Configuration Required"
|
|
163
|
+
variant="warning"
|
|
164
|
+
>
|
|
102
165
|
<Typography variant="pi" marginTop={2}>
|
|
103
|
-
<strong>Google Pay requires middleware configuration</strong> to
|
|
166
|
+
<strong>Google Pay requires middleware configuration</strong> to
|
|
167
|
+
work properly. You must configure Content Security Policy (CSP)
|
|
168
|
+
in <code>config/middlewares.js</code> to allow Google Pay
|
|
169
|
+
scripts, otherwise Google Pay will NOT work.
|
|
104
170
|
</Typography>
|
|
105
171
|
<Typography variant="pi" marginTop={2}>
|
|
106
172
|
Required CSP directives for Google Pay:
|
|
107
173
|
</Typography>
|
|
108
|
-
<Box
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
174
|
+
<Box
|
|
175
|
+
marginTop={2}
|
|
176
|
+
padding={2}
|
|
177
|
+
background="neutral100"
|
|
178
|
+
borderRadius="4px"
|
|
179
|
+
>
|
|
180
|
+
<Typography
|
|
181
|
+
variant="pi"
|
|
182
|
+
style={{ fontFamily: "monospace", fontSize: "12px" }}
|
|
183
|
+
>
|
|
184
|
+
'script-src': ['https://pay.google.com']
|
|
185
|
+
<br />
|
|
186
|
+
'connect-src': ['https://pay.google.com']
|
|
187
|
+
<br />
|
|
112
188
|
'frame-src': ['https://pay.google.com']
|
|
113
189
|
</Typography>
|
|
114
190
|
</Box>
|
|
@@ -125,7 +201,11 @@ const PaymentMethodSelector = ({
|
|
|
125
201
|
e.preventDefault();
|
|
126
202
|
onNavigateToConfig("google-pay");
|
|
127
203
|
}}
|
|
128
|
-
style={{
|
|
204
|
+
style={{
|
|
205
|
+
cursor: "pointer",
|
|
206
|
+
textDecoration: "underline",
|
|
207
|
+
color: "#0066ff",
|
|
208
|
+
}}
|
|
129
209
|
>
|
|
130
210
|
/plugins/{pluginId}/google-pay-config
|
|
131
211
|
</Link>
|
|
@@ -153,4 +233,4 @@ const PaymentMethodSelector = ({
|
|
|
153
233
|
);
|
|
154
234
|
};
|
|
155
235
|
|
|
156
|
-
export default PaymentMethodSelector;
|
|
236
|
+
export default PaymentMethodSelector;
|
|
@@ -2,7 +2,6 @@ import React from "react";
|
|
|
2
2
|
import { Box, Flex, Typography, TextInput, Button } from "@strapi/design-system";
|
|
3
3
|
import { Play } from "@strapi/icons";
|
|
4
4
|
import GooglePayButton from "../GooglePaybutton";
|
|
5
|
-
import ApplePayButton from "../ApplePayButton";
|
|
6
5
|
import CardDetailsInput from "./CardDetailsInput";
|
|
7
6
|
|
|
8
7
|
const PreauthorizationForm = ({
|
|
@@ -14,10 +13,7 @@ const PreauthorizationForm = ({
|
|
|
14
13
|
onPreauthorization,
|
|
15
14
|
paymentMethod,
|
|
16
15
|
settings,
|
|
17
|
-
googlePayToken,
|
|
18
16
|
setGooglePayToken,
|
|
19
|
-
applePayToken,
|
|
20
|
-
setApplePayToken,
|
|
21
17
|
cardtype,
|
|
22
18
|
setCardtype,
|
|
23
19
|
cardpan,
|
|
@@ -42,42 +38,8 @@ const PreauthorizationForm = ({
|
|
|
42
38
|
}
|
|
43
39
|
};
|
|
44
40
|
|
|
45
|
-
const handleApplePayToken = async (token, paymentData) => {
|
|
46
|
-
if (!token) {
|
|
47
|
-
console.error("[Apple Pay] Token is missing in handleApplePayToken");
|
|
48
|
-
return Promise.reject(new Error("Token is missing"));
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
console.log("[Apple Pay] handleApplePayToken called with token:", {
|
|
52
|
-
hasToken: !!token,
|
|
53
|
-
tokenLength: token?.length,
|
|
54
|
-
paymentData: !!paymentData
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
// IMPORTANT: Set token in state immediately (synchronously)
|
|
58
|
-
// This ensures the token is saved before the dialog closes
|
|
59
|
-
setApplePayToken(token);
|
|
60
|
-
|
|
61
|
-
console.log("[Apple Pay] Token saved to state successfully");
|
|
62
|
-
|
|
63
|
-
// Don't call onPreauthorization immediately
|
|
64
|
-
// Let the user manually trigger the payment using the button
|
|
65
|
-
// This prevents the dialog from closing prematurely if there's an error
|
|
66
|
-
// The dialog will close with success, and the user will see the "Process Preauthorization" button
|
|
67
41
|
|
|
68
|
-
// Return success immediately so the dialog closes properly
|
|
69
|
-
// The actual payment processing will happen when the user clicks the button
|
|
70
|
-
return Promise.resolve({
|
|
71
|
-
success: true,
|
|
72
|
-
message: "Token received successfully. Please click 'Process Preauthorization' to complete the payment."
|
|
73
|
-
});
|
|
74
|
-
};
|
|
75
42
|
|
|
76
|
-
const handleApplePayError = (error) => {
|
|
77
|
-
if (onError) {
|
|
78
|
-
onError(error);
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
43
|
return (
|
|
82
44
|
<Flex direction="column" alignItems="stretch" gap={4}>
|
|
83
45
|
<Flex direction="row" gap={2}>
|
|
@@ -139,38 +101,9 @@ const PreauthorizationForm = ({
|
|
|
139
101
|
/>
|
|
140
102
|
) : paymentMethod === "apl" ? (
|
|
141
103
|
<Box>
|
|
142
|
-
<
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
onTokenReceived={handleApplePayToken}
|
|
146
|
-
onError={handleApplePayError}
|
|
147
|
-
settings={settings}
|
|
148
|
-
/>
|
|
149
|
-
{applePayToken && (
|
|
150
|
-
<Box marginTop={3} style={{ width: "100%", display: "flex", flexDirection: "column", alignItems: "flex-start", gap: "8px" }}>
|
|
151
|
-
<Typography variant="pi" textColor="success600" style={{ marginBottom: "8px", fontWeight: "bold" }}>
|
|
152
|
-
✓ Apple Pay token received. You can now process the preauthorization:
|
|
153
|
-
</Typography>
|
|
154
|
-
<Button
|
|
155
|
-
variant="default"
|
|
156
|
-
onClick={() => onPreauthorization(applePayToken)}
|
|
157
|
-
loading={isProcessingPayment}
|
|
158
|
-
startIcon={<Play />}
|
|
159
|
-
style={{ maxWidth: '200px' }}
|
|
160
|
-
disabled={!paymentAmount.trim() || !preauthReference.trim() || isLiveMode}
|
|
161
|
-
className="payment-button payment-button-primary"
|
|
162
|
-
>
|
|
163
|
-
Process Preauthorization
|
|
164
|
-
</Button>
|
|
165
|
-
</Box>
|
|
166
|
-
)}
|
|
167
|
-
{!applePayToken && (
|
|
168
|
-
<Box marginTop={3} style={{ width: "100%", display: "flex", flexDirection: "column", alignItems: "flex-start", gap: "8px" }}>
|
|
169
|
-
<Typography variant="pi" textColor="neutral600" style={{ marginBottom: "8px" }}>
|
|
170
|
-
Apple Pay is not available on localhost. You can test the payment flow without Apple Pay token:
|
|
171
|
-
</Typography>
|
|
172
|
-
</Box>
|
|
173
|
-
)}
|
|
104
|
+
<Typography variant="pi" textColor="neutral600">
|
|
105
|
+
Apple Pay is only supported for Authorization, not Preauthorization.
|
|
106
|
+
</Typography>
|
|
174
107
|
</Box>
|
|
175
108
|
) : (
|
|
176
109
|
<Button
|
|
@@ -22,11 +22,10 @@ export const DEFAULT_PAYMENT_DATA = {
|
|
|
22
22
|
ip: "127.0.0.1",
|
|
23
23
|
customer_is_present: "yes",
|
|
24
24
|
language: "de"
|
|
25
|
-
// Note: successurl, errorurl, backurl are added conditionally based on 3DS setting
|
|
26
25
|
};
|
|
27
26
|
|
|
28
27
|
/**
|
|
29
|
-
* Default currency
|
|
28
|
+
* Default currency
|
|
30
29
|
*/
|
|
31
30
|
export const DEFAULT_CURRENCY = "EUR";
|
|
32
31
|
|
|
@@ -13,7 +13,6 @@ import { DEFAULT_PAYMENT_DATA } from "../constants/paymentConstants";
|
|
|
13
13
|
const usePaymentActions = () => {
|
|
14
14
|
const toggleNotification = useNotification();
|
|
15
15
|
|
|
16
|
-
// Load settings to get enable3DSecure value
|
|
17
16
|
const [settings, setSettings] = useState({ enable3DSecure: false });
|
|
18
17
|
|
|
19
18
|
useEffect(() => {
|
|
@@ -24,19 +23,14 @@ const usePaymentActions = () => {
|
|
|
24
23
|
setSettings(response.data);
|
|
25
24
|
}
|
|
26
25
|
} catch (error) {
|
|
27
|
-
// Silent fail
|
|
28
26
|
}
|
|
29
27
|
};
|
|
30
28
|
loadSettings();
|
|
31
29
|
}, []);
|
|
32
30
|
|
|
33
|
-
// Payment form state
|
|
34
31
|
const [paymentAmount, setPaymentAmount] = useState("1000");
|
|
35
32
|
|
|
36
|
-
// Generate order reference using generateLagOrderNumber
|
|
37
|
-
// Sequence number starts from 1000 and increments based on timestamp
|
|
38
33
|
const generateOrderReference = () => {
|
|
39
|
-
// Use timestamp to generate unique sequence (1000 to 99999 range)
|
|
40
34
|
const sequence = 1000 + Math.floor((Date.now() % 99000));
|
|
41
35
|
return generateLagOrderNumber(sequence);
|
|
42
36
|
};
|
|
@@ -52,13 +46,11 @@ const usePaymentActions = () => {
|
|
|
52
46
|
const [googlePayToken, setGooglePayToken] = useState(null);
|
|
53
47
|
const [applePayToken, setApplePayToken] = useState(null);
|
|
54
48
|
|
|
55
|
-
// Card details for 3DS testing
|
|
56
49
|
const [cardtype, setCardtype] = useState("");
|
|
57
50
|
const [cardpan, setCardpan] = useState("");
|
|
58
51
|
const [cardexpiredate, setCardexpiredate] = useState("");
|
|
59
52
|
const [cardcvc2, setCardcvc2] = useState("");
|
|
60
53
|
|
|
61
|
-
// Payment processing state
|
|
62
54
|
const [isProcessingPayment, setIsProcessingPayment] = useState(false);
|
|
63
55
|
const [paymentResult, setPaymentResult] = useState(null);
|
|
64
56
|
const [paymentError, setPaymentError] = useState(null);
|
|
@@ -88,19 +80,16 @@ const usePaymentActions = () => {
|
|
|
88
80
|
paymentMethod,
|
|
89
81
|
amount: paymentAmount
|
|
90
82
|
});
|
|
91
|
-
|
|
83
|
+
|
|
92
84
|
setIsProcessingPayment(true);
|
|
93
85
|
setPaymentError(null);
|
|
94
86
|
setPaymentResult(null);
|
|
95
87
|
try {
|
|
96
|
-
// Auto-generate reference if empty
|
|
97
88
|
const finalPreauthReference = preauthReference.trim() || generateOrderReference();
|
|
98
89
|
if (!preauthReference.trim()) {
|
|
99
90
|
setPreauthReference(finalPreauthReference);
|
|
100
91
|
}
|
|
101
92
|
|
|
102
|
-
// Determine currency based on card type
|
|
103
|
-
// American Express typically requires USD, other cards use EUR
|
|
104
93
|
const currency = (paymentMethod === "cc" && cardtype === "A") ? "USD" : "EUR";
|
|
105
94
|
|
|
106
95
|
const baseParams = {
|
|
@@ -111,7 +100,6 @@ const usePaymentActions = () => {
|
|
|
111
100
|
...DEFAULT_PAYMENT_DATA
|
|
112
101
|
};
|
|
113
102
|
|
|
114
|
-
// Add card details if credit card payment and 3DS enabled
|
|
115
103
|
if (paymentMethod === "cc" && settings.enable3DSecure !== false) {
|
|
116
104
|
if (cardtype) baseParams.cardtype = cardtype;
|
|
117
105
|
if (cardpan) baseParams.cardpan = cardpan;
|
|
@@ -125,7 +113,6 @@ const usePaymentActions = () => {
|
|
|
125
113
|
|
|
126
114
|
if (needsRedirectUrls) {
|
|
127
115
|
const baseUrl = window.location.origin;
|
|
128
|
-
// Detect current context (admin or content-ui) from pathname
|
|
129
116
|
const currentPath = window.location.pathname;
|
|
130
117
|
const isContentUI = currentPath.includes('/content-ui') || currentPath.includes('/content-manager');
|
|
131
118
|
const basePath = isContentUI ? '/content-ui' : '/admin';
|
|
@@ -149,30 +136,13 @@ const usePaymentActions = () => {
|
|
|
149
136
|
|
|
150
137
|
const result = await payoneRequests.preauthorization(params);
|
|
151
138
|
const responseData = result?.data || result;
|
|
152
|
-
|
|
153
|
-
// Log full response
|
|
154
|
-
console.log("Preauthorization Response:", responseData);
|
|
155
|
-
console.log("Response Status:", responseData.status || responseData.Status);
|
|
156
|
-
console.log("Response Error Code:", responseData.errorcode || responseData.errorCode || responseData.ErrorCode);
|
|
157
|
-
console.log("Response Error Message:", responseData.errormessage || responseData.errorMessage || responseData.ErrorMessage);
|
|
158
|
-
console.log("All redirect URL fields:", {
|
|
159
|
-
redirectUrl: responseData.redirectUrl,
|
|
160
|
-
redirecturl: responseData.redirecturl,
|
|
161
|
-
RedirectUrl: responseData.RedirectUrl,
|
|
162
|
-
redirect_url: responseData.redirect_url,
|
|
163
|
-
url: responseData.url,
|
|
164
|
-
Url: responseData.Url
|
|
165
|
-
});
|
|
166
|
-
|
|
167
139
|
const status = (responseData.status || responseData.Status || "").toUpperCase();
|
|
168
140
|
const errorCode = responseData.errorcode || responseData.errorCode || responseData.ErrorCode;
|
|
169
141
|
const errorMessage = responseData.errormessage || responseData.errorMessage || responseData.ErrorMessage;
|
|
170
142
|
|
|
171
|
-
// Check for 3DS required error (4219)
|
|
172
143
|
const requires3DSErrorCodes = ["4219", 4219];
|
|
173
144
|
const is3DSRequiredError = requires3DSErrorCodes.includes(errorCode);
|
|
174
145
|
|
|
175
|
-
// Check all possible redirect URL fields
|
|
176
146
|
const redirectUrl =
|
|
177
147
|
responseData.redirectUrl ||
|
|
178
148
|
responseData.redirecturl ||
|
|
@@ -182,7 +152,6 @@ const usePaymentActions = () => {
|
|
|
182
152
|
responseData.Url ||
|
|
183
153
|
null;
|
|
184
154
|
|
|
185
|
-
// If 3DS required but no redirect URL, show helpful message
|
|
186
155
|
if (is3DSRequiredError && !redirectUrl) {
|
|
187
156
|
console.warn("3DS authentication required (Error 4219) but no redirect URL found in response");
|
|
188
157
|
console.log("Full response:", JSON.stringify(responseData, null, 2));
|
|
@@ -194,7 +163,6 @@ const usePaymentActions = () => {
|
|
|
194
163
|
return;
|
|
195
164
|
}
|
|
196
165
|
|
|
197
|
-
// Check for other errors (but not 3DS required)
|
|
198
166
|
if ((status === "ERROR" || status === "INVALID" || errorCode) && !is3DSRequiredError) {
|
|
199
167
|
setPaymentError(
|
|
200
168
|
errorMessage ||
|
|
@@ -217,16 +185,8 @@ const usePaymentActions = () => {
|
|
|
217
185
|
|
|
218
186
|
setPaymentResult(responseData);
|
|
219
187
|
|
|
220
|
-
console.log("[Payment] Preauthorization result:", {
|
|
221
|
-
status,
|
|
222
|
-
hasError: !!errorCode,
|
|
223
|
-
errorCode,
|
|
224
|
-
errorMessage
|
|
225
|
-
});
|
|
226
|
-
|
|
227
188
|
if (status === "APPROVED") {
|
|
228
189
|
handlePaymentSuccess("Preauthorization completed successfully");
|
|
229
|
-
// Return success result for Apple Pay callback
|
|
230
190
|
return { success: true, data: responseData };
|
|
231
191
|
} else {
|
|
232
192
|
const errorMsg = errorMessage || `Unexpected status: ${status}`;
|
|
@@ -234,13 +194,11 @@ const usePaymentActions = () => {
|
|
|
234
194
|
{ message: errorMsg },
|
|
235
195
|
`Preauthorization completed with status: ${status}`
|
|
236
196
|
);
|
|
237
|
-
// Return error result for Apple Pay callback
|
|
238
197
|
throw new Error(errorMsg);
|
|
239
198
|
}
|
|
240
199
|
} catch (error) {
|
|
241
200
|
console.error("[Payment] Preauthorization error:", error);
|
|
242
201
|
handlePaymentError(error, "Preauthorization failed");
|
|
243
|
-
// Re-throw error so Apple Pay callback knows it failed
|
|
244
202
|
throw error;
|
|
245
203
|
} finally {
|
|
246
204
|
setIsProcessingPayment(false);
|
|
@@ -253,14 +211,11 @@ const usePaymentActions = () => {
|
|
|
253
211
|
setPaymentResult(null);
|
|
254
212
|
|
|
255
213
|
try {
|
|
256
|
-
// Auto-generate reference if empty
|
|
257
214
|
const finalAuthReference = authReference.trim() || generateOrderReference();
|
|
258
215
|
if (!authReference.trim()) {
|
|
259
216
|
setAuthReference(finalAuthReference);
|
|
260
217
|
}
|
|
261
218
|
|
|
262
|
-
// Determine currency based on card type
|
|
263
|
-
// American Express typically requires USD, other cards use EUR
|
|
264
219
|
const currency = (paymentMethod === "cc" && cardtype === "A") ? "USD" : "EUR";
|
|
265
220
|
|
|
266
221
|
const baseParams = {
|
|
@@ -271,7 +226,6 @@ const usePaymentActions = () => {
|
|
|
271
226
|
...DEFAULT_PAYMENT_DATA
|
|
272
227
|
};
|
|
273
228
|
|
|
274
|
-
// Add card details if credit card payment and 3DS enabled
|
|
275
229
|
if (paymentMethod === "cc" && settings.enable3DSecure !== false) {
|
|
276
230
|
if (cardtype) baseParams.cardtype = cardtype;
|
|
277
231
|
if (cardpan) baseParams.cardpan = cardpan;
|
|
@@ -285,7 +239,6 @@ const usePaymentActions = () => {
|
|
|
285
239
|
|
|
286
240
|
if (needsRedirectUrls) {
|
|
287
241
|
const baseUrl = window.location.origin;
|
|
288
|
-
// Detect current context (admin or content-ui) from pathname
|
|
289
242
|
const currentPath = window.location.pathname;
|
|
290
243
|
const isContentUI = currentPath.includes('/content-ui') || currentPath.includes('/content-manager');
|
|
291
244
|
const basePath = isContentUI ? '/content-ui' : '/admin';
|
|
@@ -309,30 +262,13 @@ const usePaymentActions = () => {
|
|
|
309
262
|
|
|
310
263
|
const result = await payoneRequests.authorization(params);
|
|
311
264
|
const responseData = result?.data || result;
|
|
312
|
-
|
|
313
|
-
// Log full response
|
|
314
|
-
console.log("Authorization Response:", responseData);
|
|
315
|
-
console.log("Response Status:", responseData.status || responseData.Status);
|
|
316
|
-
console.log("Response Error Code:", responseData.errorcode || responseData.errorCode || responseData.ErrorCode);
|
|
317
|
-
console.log("Response Error Message:", responseData.errormessage || responseData.errorMessage || responseData.ErrorMessage);
|
|
318
|
-
console.log("All redirect URL fields:", {
|
|
319
|
-
redirectUrl: responseData.redirectUrl,
|
|
320
|
-
redirecturl: responseData.redirecturl,
|
|
321
|
-
RedirectUrl: responseData.RedirectUrl,
|
|
322
|
-
redirect_url: responseData.redirect_url,
|
|
323
|
-
url: responseData.url,
|
|
324
|
-
Url: responseData.Url
|
|
325
|
-
});
|
|
326
|
-
|
|
327
265
|
const status = (responseData.status || responseData.Status || "").toUpperCase();
|
|
328
266
|
const errorCode = responseData.errorcode || responseData.errorCode || responseData.ErrorCode;
|
|
329
267
|
const errorMessage = responseData.errormessage || responseData.errorMessage || responseData.ErrorMessage;
|
|
330
268
|
|
|
331
|
-
// Check for 3DS required error (4219)
|
|
332
269
|
const requires3DSErrorCodes = ["4219", 4219];
|
|
333
270
|
const is3DSRequiredError = requires3DSErrorCodes.includes(errorCode);
|
|
334
271
|
|
|
335
|
-
// Check all possible redirect URL fields
|
|
336
272
|
const redirectUrl =
|
|
337
273
|
responseData.redirectUrl ||
|
|
338
274
|
responseData.redirecturl ||
|
|
@@ -342,7 +278,6 @@ const usePaymentActions = () => {
|
|
|
342
278
|
responseData.Url ||
|
|
343
279
|
null;
|
|
344
280
|
|
|
345
|
-
// If 3DS required but no redirect URL, show helpful message
|
|
346
281
|
if (is3DSRequiredError && !redirectUrl) {
|
|
347
282
|
console.warn("3DS authentication required (Error 4219) but no redirect URL found in response");
|
|
348
283
|
console.log("Full response:", JSON.stringify(responseData, null, 2));
|
|
@@ -354,7 +289,6 @@ const usePaymentActions = () => {
|
|
|
354
289
|
return;
|
|
355
290
|
}
|
|
356
291
|
|
|
357
|
-
// Check for other errors (but not 3DS required)
|
|
358
292
|
if ((status === "ERROR" || status === "INVALID" || errorCode) && !is3DSRequiredError) {
|
|
359
293
|
setPaymentError(
|
|
360
294
|
errorMessage ||
|
|
@@ -377,13 +311,6 @@ const usePaymentActions = () => {
|
|
|
377
311
|
|
|
378
312
|
setPaymentResult(responseData);
|
|
379
313
|
|
|
380
|
-
console.log("[Payment] Authorization result:", {
|
|
381
|
-
status,
|
|
382
|
-
hasError: !!errorCode,
|
|
383
|
-
errorCode,
|
|
384
|
-
errorMessage
|
|
385
|
-
});
|
|
386
|
-
|
|
387
314
|
if (status === "APPROVED") {
|
|
388
315
|
handlePaymentSuccess("Authorization completed successfully");
|
|
389
316
|
// Return success result for Apple Pay callback
|
|
@@ -394,13 +321,11 @@ const usePaymentActions = () => {
|
|
|
394
321
|
{ message: errorMsg },
|
|
395
322
|
`Authorization completed with status: ${status}`
|
|
396
323
|
);
|
|
397
|
-
// Return error result for Apple Pay callback
|
|
398
324
|
throw new Error(errorMsg);
|
|
399
325
|
}
|
|
400
326
|
} catch (error) {
|
|
401
327
|
console.error("[Payment] Authorization error:", error);
|
|
402
328
|
handlePaymentError(error, "Authorization failed");
|
|
403
|
-
// Re-throw error so Apple Pay callback knows it failed
|
|
404
329
|
throw error;
|
|
405
330
|
} finally {
|
|
406
331
|
setIsProcessingPayment(false);
|