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.
- 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 -156
- 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 +27 -16
- 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 -67
- 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 +109 -47
- 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 +7 -12
- 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 +61 -32
- 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/HistoryPanel.jsx +0 -312
- package/admin/src/pages/App/components/PaymentActionsPanel.jsx +0 -280
- 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,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from "react";
|
|
2
2
|
import { Box, Flex, Typography } from "@strapi/design-system";
|
|
3
3
|
import { injectGooglePayScript } from "../../utils/injectGooglePayScript";
|
|
4
4
|
|
|
@@ -7,43 +7,43 @@ const GooglePayButton = ({
|
|
|
7
7
|
currency = "EUR",
|
|
8
8
|
onTokenReceived,
|
|
9
9
|
onError,
|
|
10
|
-
settings
|
|
10
|
+
settings,
|
|
11
11
|
}) => {
|
|
12
|
-
const [isReady, setIsReady] = useState(false);
|
|
13
|
-
const [isLoading, setIsLoading] = useState(true);
|
|
14
|
-
const buttonContainerRef = useRef(null);
|
|
15
|
-
const paymentsClientRef = useRef(null);
|
|
12
|
+
const [isReady, setIsReady] = React.useState(false);
|
|
13
|
+
const [isLoading, setIsLoading] = React.useState(true);
|
|
14
|
+
const buttonContainerRef = React.useRef(null);
|
|
15
|
+
const paymentsClientRef = React.useRef(null);
|
|
16
16
|
|
|
17
17
|
const baseRequest = {
|
|
18
18
|
apiVersion: 2,
|
|
19
|
-
apiVersionMinor: 0
|
|
19
|
+
apiVersionMinor: 0,
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
const getGooglePayConfig = (settings) => {
|
|
23
|
-
const gatewayMerchantId = settings?.mid || settings?.portalid ||
|
|
23
|
+
const gatewayMerchantId = settings?.mid || settings?.portalid || "";
|
|
24
24
|
|
|
25
25
|
const allowedCardNetworks = ["MASTERCARD", "VISA"];
|
|
26
26
|
const allowedAuthMethods = ["PAN_ONLY", "CRYPTOGRAM_3DS"];
|
|
27
27
|
|
|
28
28
|
const tokenizationSpecification = {
|
|
29
|
-
type:
|
|
29
|
+
type: "PAYMENT_GATEWAY",
|
|
30
30
|
parameters: {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
31
|
+
gateway: "payonegmbh",
|
|
32
|
+
gatewayMerchantId: gatewayMerchantId,
|
|
33
|
+
},
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
const baseCardPaymentMethod = {
|
|
37
37
|
type: "CARD",
|
|
38
38
|
parameters: {
|
|
39
39
|
allowedCardNetworks,
|
|
40
|
-
allowedAuthMethods
|
|
41
|
-
}
|
|
40
|
+
allowedAuthMethods,
|
|
41
|
+
},
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
const cardPaymentMethod = {
|
|
45
45
|
...baseCardPaymentMethod,
|
|
46
|
-
tokenizationSpecification
|
|
46
|
+
tokenizationSpecification,
|
|
47
47
|
};
|
|
48
48
|
return {
|
|
49
49
|
baseCardPaymentMethod,
|
|
@@ -51,14 +51,16 @@ const GooglePayButton = ({
|
|
|
51
51
|
};
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
-
useEffect(() => {
|
|
54
|
+
React.useEffect(() => {
|
|
55
55
|
injectGooglePayScript();
|
|
56
56
|
|
|
57
57
|
const checkGooglePay = () => {
|
|
58
58
|
try {
|
|
59
|
-
return
|
|
60
|
-
typeof window
|
|
61
|
-
window.google
|
|
59
|
+
return (
|
|
60
|
+
typeof window !== "undefined" &&
|
|
61
|
+
typeof window.google !== "undefined" &&
|
|
62
|
+
window.google.payments?.api?.PaymentsClient
|
|
63
|
+
);
|
|
62
64
|
} catch (e) {
|
|
63
65
|
return false;
|
|
64
66
|
}
|
|
@@ -80,7 +82,11 @@ const GooglePayButton = ({
|
|
|
80
82
|
const handleScriptError = () => {
|
|
81
83
|
setIsLoading(false);
|
|
82
84
|
if (onError) {
|
|
83
|
-
onError(
|
|
85
|
+
onError(
|
|
86
|
+
new Error(
|
|
87
|
+
"Failed to load Google Pay script. Please check CSP settings."
|
|
88
|
+
)
|
|
89
|
+
);
|
|
84
90
|
}
|
|
85
91
|
};
|
|
86
92
|
|
|
@@ -99,7 +105,11 @@ const GooglePayButton = ({
|
|
|
99
105
|
if (!checkGooglePay()) {
|
|
100
106
|
setIsLoading(false);
|
|
101
107
|
if (onError) {
|
|
102
|
-
onError(
|
|
108
|
+
onError(
|
|
109
|
+
new Error(
|
|
110
|
+
"Google Pay API is not available. Please check if the script is loaded and CSP allows pay.google.com"
|
|
111
|
+
)
|
|
112
|
+
);
|
|
103
113
|
}
|
|
104
114
|
}
|
|
105
115
|
}, 15000);
|
|
@@ -116,32 +126,48 @@ const GooglePayButton = ({
|
|
|
116
126
|
if (!settings || (!settings.mid && !settings.portalid)) {
|
|
117
127
|
setIsLoading(false);
|
|
118
128
|
if (onError) {
|
|
119
|
-
onError(
|
|
129
|
+
onError(
|
|
130
|
+
new Error(
|
|
131
|
+
"Google Pay settings missing. Please configure mid or portalid in settings."
|
|
132
|
+
)
|
|
133
|
+
);
|
|
120
134
|
}
|
|
121
135
|
return;
|
|
122
136
|
}
|
|
123
137
|
|
|
124
138
|
try {
|
|
125
|
-
if (
|
|
139
|
+
if (
|
|
140
|
+
typeof window === "undefined" ||
|
|
141
|
+
typeof window.google === "undefined" ||
|
|
142
|
+
!window.google.payments?.api?.PaymentsClient
|
|
143
|
+
) {
|
|
126
144
|
setIsLoading(false);
|
|
127
145
|
if (onError) {
|
|
128
|
-
onError(
|
|
146
|
+
onError(
|
|
147
|
+
new Error(
|
|
148
|
+
"Google Pay API is not loaded. Please check browser console for CSP errors."
|
|
149
|
+
)
|
|
150
|
+
);
|
|
129
151
|
}
|
|
130
152
|
return;
|
|
131
153
|
}
|
|
132
154
|
|
|
133
|
-
|
|
134
155
|
const environment = settings?.mode === "live" ? "PRODUCTION" : "TEST";
|
|
135
|
-
paymentsClientRef.current = new window.google.payments.api.PaymentsClient(
|
|
136
|
-
|
|
137
|
-
|
|
156
|
+
paymentsClientRef.current = new window.google.payments.api.PaymentsClient(
|
|
157
|
+
{
|
|
158
|
+
environment: environment,
|
|
159
|
+
}
|
|
160
|
+
);
|
|
138
161
|
|
|
139
162
|
const config = getGooglePayConfig(settings);
|
|
140
163
|
|
|
141
164
|
const isReadyToPayRequest = Object.assign({}, baseRequest);
|
|
142
|
-
isReadyToPayRequest.allowedPaymentMethods = [
|
|
165
|
+
isReadyToPayRequest.allowedPaymentMethods = [
|
|
166
|
+
config.baseCardPaymentMethod,
|
|
167
|
+
];
|
|
143
168
|
|
|
144
|
-
paymentsClientRef.current
|
|
169
|
+
paymentsClientRef.current
|
|
170
|
+
.isReadyToPay(isReadyToPayRequest)
|
|
145
171
|
.then((response) => {
|
|
146
172
|
if (response.result) {
|
|
147
173
|
setIsReady(true);
|
|
@@ -193,17 +219,17 @@ const GooglePayButton = ({
|
|
|
193
219
|
|
|
194
220
|
buttonContainerRef.current.innerHTML = "";
|
|
195
221
|
|
|
196
|
-
const gatewayMerchantId = settings?.mid || settings?.portalid ||
|
|
222
|
+
const gatewayMerchantId = settings?.mid || settings?.portalid || "";
|
|
197
223
|
const paymentDataRequest = Object.assign({}, baseRequest);
|
|
198
224
|
paymentDataRequest.allowedPaymentMethods = [config.cardPaymentMethod];
|
|
199
225
|
paymentDataRequest.transactionInfo = {
|
|
200
226
|
totalPriceStatus: "FINAL",
|
|
201
227
|
totalPrice: (parseFloat(amount) / 100).toFixed(2),
|
|
202
|
-
currencyCode: currency
|
|
228
|
+
currencyCode: currency,
|
|
203
229
|
};
|
|
204
230
|
paymentDataRequest.merchantInfo = {
|
|
205
231
|
merchantId: gatewayMerchantId,
|
|
206
|
-
merchantName: settings?.merchantName ||
|
|
232
|
+
merchantName: settings?.merchantName || "Demo Shop",
|
|
207
233
|
};
|
|
208
234
|
|
|
209
235
|
try {
|
|
@@ -211,7 +237,7 @@ const GooglePayButton = ({
|
|
|
211
237
|
onClick: () => handleGooglePayClick(paymentDataRequest),
|
|
212
238
|
buttonColor: "black",
|
|
213
239
|
buttonType: "pay",
|
|
214
|
-
buttonSizeMode: "fill"
|
|
240
|
+
buttonSizeMode: "fill",
|
|
215
241
|
});
|
|
216
242
|
|
|
217
243
|
if (buttonContainerRef.current) {
|
|
@@ -235,7 +261,8 @@ const GooglePayButton = ({
|
|
|
235
261
|
throw new Error("Google Pay client not initialized");
|
|
236
262
|
}
|
|
237
263
|
|
|
238
|
-
const paymentData =
|
|
264
|
+
const paymentData =
|
|
265
|
+
await paymentsClientRef.current.loadPaymentData(paymentDataRequest);
|
|
239
266
|
const rawToken = paymentData.paymentMethodData?.tokenizationData?.token;
|
|
240
267
|
|
|
241
268
|
if (!rawToken) {
|
|
@@ -246,12 +273,16 @@ const GooglePayButton = ({
|
|
|
246
273
|
|
|
247
274
|
try {
|
|
248
275
|
const tokenObj = JSON.parse(token);
|
|
249
|
-
if (
|
|
276
|
+
if (
|
|
277
|
+
!tokenObj.signature ||
|
|
278
|
+
!tokenObj.protocolVersion ||
|
|
279
|
+
!tokenObj.signedMessage
|
|
280
|
+
) {
|
|
250
281
|
throw new Error("Google Pay token is missing required fields");
|
|
251
282
|
}
|
|
252
283
|
token = btoa(unescape(encodeURIComponent(rawToken)));
|
|
253
284
|
} catch (e) {
|
|
254
|
-
if (typeof token ===
|
|
285
|
+
if (typeof token === "string") {
|
|
255
286
|
token = btoa(unescape(encodeURIComponent(token)));
|
|
256
287
|
} else {
|
|
257
288
|
throw new Error(`Invalid Google Pay token format: ${e.message}`);
|
|
@@ -272,26 +303,53 @@ const GooglePayButton = ({
|
|
|
272
303
|
<Box width="100%">
|
|
273
304
|
<Flex direction="column" gap={3} alignItems="stretch">
|
|
274
305
|
{isLoading && (
|
|
275
|
-
<Typography
|
|
306
|
+
<Typography
|
|
307
|
+
variant="pi"
|
|
308
|
+
textColor="neutral600"
|
|
309
|
+
style={{ textAlign: "left" }}
|
|
310
|
+
>
|
|
276
311
|
Loading Google Pay...
|
|
277
312
|
</Typography>
|
|
278
313
|
)}
|
|
279
314
|
{!isLoading && !isReady && (
|
|
280
|
-
<Typography
|
|
315
|
+
<Typography
|
|
316
|
+
variant="pi"
|
|
317
|
+
textColor="neutral600"
|
|
318
|
+
style={{ textAlign: "left" }}
|
|
319
|
+
>
|
|
281
320
|
Google Pay is not available
|
|
282
321
|
</Typography>
|
|
283
322
|
)}
|
|
284
323
|
{!isLoading && isReady && (
|
|
285
324
|
<>
|
|
286
|
-
<Typography
|
|
325
|
+
<Typography
|
|
326
|
+
variant="sigma"
|
|
327
|
+
textColor="neutral700"
|
|
328
|
+
fontWeight="semiBold"
|
|
329
|
+
style={{ textAlign: "left" }}
|
|
330
|
+
>
|
|
287
331
|
Google Pay Payment
|
|
288
332
|
</Typography>
|
|
289
|
-
<Typography
|
|
290
|
-
|
|
333
|
+
<Typography
|
|
334
|
+
variant="pi"
|
|
335
|
+
textColor="neutral600"
|
|
336
|
+
style={{ textAlign: "left" }}
|
|
337
|
+
>
|
|
338
|
+
Click the button below to pay with Google Pay. The token will be
|
|
339
|
+
automatically sent to Payone.
|
|
291
340
|
</Typography>
|
|
292
341
|
</>
|
|
293
342
|
)}
|
|
294
|
-
<Box
|
|
343
|
+
<Box
|
|
344
|
+
ref={buttonContainerRef}
|
|
345
|
+
style={{
|
|
346
|
+
minHeight: "40px",
|
|
347
|
+
width: "100%",
|
|
348
|
+
maxWidth: "200px",
|
|
349
|
+
display: "flex",
|
|
350
|
+
justifyContent: "flex-start",
|
|
351
|
+
}}
|
|
352
|
+
/>
|
|
295
353
|
</Flex>
|
|
296
354
|
</Box>
|
|
297
355
|
);
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Field,
|
|
3
|
+
Flex,
|
|
4
|
+
DesignSystemProvider,
|
|
5
|
+
Tooltip,
|
|
6
|
+
Typography,
|
|
7
|
+
darkTheme,
|
|
8
|
+
lightTheme,
|
|
9
|
+
} from "@strapi/design-system";
|
|
10
|
+
import { Information } from "@strapi/icons";
|
|
11
|
+
import { InputComponent } from "../../utils/getInputComponent";
|
|
12
|
+
import { shouldShowTooltip } from "../../utils/tooltipHelpers";
|
|
13
|
+
import { useSystemTheme } from "../../hooks/use-system-theme";
|
|
14
|
+
|
|
15
|
+
const RenderInput = ({
|
|
16
|
+
hint,
|
|
17
|
+
label,
|
|
18
|
+
name,
|
|
19
|
+
value,
|
|
20
|
+
onChange,
|
|
21
|
+
inputType = "textInput",
|
|
22
|
+
options = [],
|
|
23
|
+
tooltipContent = "",
|
|
24
|
+
additionalMessage = "",
|
|
25
|
+
required = false,
|
|
26
|
+
placeholder,
|
|
27
|
+
onLabel,
|
|
28
|
+
offLabel,
|
|
29
|
+
type = "text",
|
|
30
|
+
className = "payment-input",
|
|
31
|
+
labelStyle = {},
|
|
32
|
+
labelDirection = "column",
|
|
33
|
+
...props
|
|
34
|
+
}) => {
|
|
35
|
+
const systemTheme = useSystemTheme();
|
|
36
|
+
const theme = systemTheme === "dark" ? darkTheme : lightTheme;
|
|
37
|
+
const getLabelStyle = () => {
|
|
38
|
+
if (labelDirection === "row") {
|
|
39
|
+
return {
|
|
40
|
+
display: "flex",
|
|
41
|
+
flexDirection: "row",
|
|
42
|
+
justifyContent: "space-between",
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return { display: "flex", flexDirection: "column" };
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<Flex direction="column" gap={2} alignItems={"stretch"} width={"100%"}>
|
|
50
|
+
<Field.Root hint={hint} width={"100%"} style={getLabelStyle()}>
|
|
51
|
+
<Flex alignItems="center" gap={1} style={{ marginBottom: "5px" }}>
|
|
52
|
+
<Field.Label style={labelStyle}>{label}</Field.Label>
|
|
53
|
+
{shouldShowTooltip(inputType, tooltipContent) && (
|
|
54
|
+
<DesignSystemProvider theme={theme}>
|
|
55
|
+
<Tooltip label={tooltipContent}>
|
|
56
|
+
<Information
|
|
57
|
+
style={{
|
|
58
|
+
cursor: "pointer",
|
|
59
|
+
color: systemTheme === "dark" ? "#fff" : "#000",
|
|
60
|
+
}}
|
|
61
|
+
/>
|
|
62
|
+
</Tooltip>
|
|
63
|
+
</DesignSystemProvider>
|
|
64
|
+
)}
|
|
65
|
+
</Flex>
|
|
66
|
+
<InputComponent
|
|
67
|
+
inputType={inputType}
|
|
68
|
+
name={name}
|
|
69
|
+
value={value}
|
|
70
|
+
onChange={onChange}
|
|
71
|
+
tooltipContent={tooltipContent}
|
|
72
|
+
options={options}
|
|
73
|
+
required={required}
|
|
74
|
+
className={className}
|
|
75
|
+
placeholder={placeholder}
|
|
76
|
+
onLabel={onLabel}
|
|
77
|
+
offLabel={offLabel}
|
|
78
|
+
systemTheme={systemTheme}
|
|
79
|
+
theme={theme}
|
|
80
|
+
type={type}
|
|
81
|
+
{...props}
|
|
82
|
+
/>
|
|
83
|
+
<Field.Hint />
|
|
84
|
+
</Field.Root>
|
|
85
|
+
{additionalMessage && (
|
|
86
|
+
<Typography variant="pi" textColor={"ActiveText"}>
|
|
87
|
+
{additionalMessage}
|
|
88
|
+
</Typography>
|
|
89
|
+
)}
|
|
90
|
+
</Flex>
|
|
91
|
+
);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export default RenderInput;
|
|
@@ -1,23 +1,34 @@
|
|
|
1
|
-
import React from "
|
|
2
|
-
import {
|
|
1
|
+
import * as React from "@strapi/strapi/admin";
|
|
2
|
+
import {
|
|
3
|
+
Badge,
|
|
4
|
+
DesignSystemProvider,
|
|
5
|
+
darkTheme,
|
|
6
|
+
lightTheme,
|
|
7
|
+
} from "@strapi/design-system";
|
|
8
|
+
import { useSystemTheme } from "../../hooks/use-system-theme";
|
|
3
9
|
|
|
4
|
-
const StatusBadge = ({ status }) => {
|
|
10
|
+
const StatusBadge = ({ status, size = "S" }) => {
|
|
5
11
|
const statusColors = {
|
|
6
|
-
APPROVED: "
|
|
7
|
-
PENDING: "
|
|
8
|
-
ERROR: "
|
|
9
|
-
FAILED: "
|
|
10
|
-
INVALID: "
|
|
11
|
-
REDIRECT: "
|
|
12
|
+
APPROVED: "success200",
|
|
13
|
+
PENDING: "warning200",
|
|
14
|
+
ERROR: "danger200",
|
|
15
|
+
FAILED: "danger200",
|
|
16
|
+
INVALID: "danger200",
|
|
17
|
+
REDIRECT: "success100",
|
|
12
18
|
};
|
|
13
|
-
|
|
19
|
+
const systemTheme = useSystemTheme();
|
|
20
|
+
const theme = systemTheme === "dark" ? darkTheme : lightTheme;
|
|
14
21
|
return (
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
<DesignSystemProvider theme={theme}>
|
|
23
|
+
<Badge
|
|
24
|
+
borderColor={statusColors[status]}
|
|
25
|
+
background={"transparent"}
|
|
26
|
+
textColor={statusColors[status]}
|
|
27
|
+
size={size}
|
|
28
|
+
>
|
|
29
|
+
{status || "UNKNOWN"}
|
|
30
|
+
</Badge>
|
|
31
|
+
</DesignSystemProvider>
|
|
21
32
|
);
|
|
22
33
|
};
|
|
23
34
|
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import {
|
|
3
|
+
Button,
|
|
4
|
+
Card,
|
|
5
|
+
CardBody,
|
|
6
|
+
Flex,
|
|
7
|
+
Typography,
|
|
8
|
+
} from "@strapi/design-system";
|
|
9
|
+
import { Cog } from "@strapi/icons";
|
|
10
|
+
import RenderInput from "../RenderInput";
|
|
11
|
+
|
|
12
|
+
const ConfigurationFields = ({
|
|
13
|
+
settings,
|
|
14
|
+
onInputChange,
|
|
15
|
+
onPaymentMethodToggle,
|
|
16
|
+
onNavigateToConfig,
|
|
17
|
+
}) => {
|
|
18
|
+
const handleNavigateToApplePayConfig = () => {
|
|
19
|
+
if (onNavigateToConfig) {
|
|
20
|
+
onNavigateToConfig("apple-pay-config");
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const handleNavigateToGooglePayConfig = () => {
|
|
25
|
+
if (onNavigateToConfig) {
|
|
26
|
+
onNavigateToConfig("google-pay-config");
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<Card padding={8}>
|
|
32
|
+
<CardBody
|
|
33
|
+
style={{
|
|
34
|
+
display: "grid",
|
|
35
|
+
gap: "16px",
|
|
36
|
+
gridTemplateColumns: "repeat(auto-fit, minmax(250px, 1fr))",
|
|
37
|
+
}}
|
|
38
|
+
>
|
|
39
|
+
<Flex direction="column" alignItems={"stretch"} gap={6}>
|
|
40
|
+
<Flex direction="row" gap={2}>
|
|
41
|
+
<RenderInput
|
|
42
|
+
label="Account ID (aid)"
|
|
43
|
+
name="aid"
|
|
44
|
+
value={settings.aid}
|
|
45
|
+
onChange={(e) => onInputChange("aid", e.target.value)}
|
|
46
|
+
required
|
|
47
|
+
inputType="textInput"
|
|
48
|
+
tooltipContent={"Your Payone account ID"}
|
|
49
|
+
/>
|
|
50
|
+
|
|
51
|
+
<RenderInput
|
|
52
|
+
label="Portal ID"
|
|
53
|
+
name="portalid"
|
|
54
|
+
value={settings.portalid}
|
|
55
|
+
onChange={(e) => onInputChange("portalid", e.target.value)}
|
|
56
|
+
required
|
|
57
|
+
inputType="textInput"
|
|
58
|
+
tooltipContent={"Your Payone portal ID"}
|
|
59
|
+
/>
|
|
60
|
+
</Flex>
|
|
61
|
+
<Flex direction="row" gap={2}>
|
|
62
|
+
<RenderInput
|
|
63
|
+
label="Merchant ID (mid)"
|
|
64
|
+
name="mid"
|
|
65
|
+
value={settings.mid}
|
|
66
|
+
onChange={(e) => onInputChange("mid", e.target.value)}
|
|
67
|
+
required
|
|
68
|
+
inputType="textInput"
|
|
69
|
+
tooltipContent={"Your Payone merchant ID"}
|
|
70
|
+
/>
|
|
71
|
+
|
|
72
|
+
<RenderInput
|
|
73
|
+
label="Portal Key"
|
|
74
|
+
name="key"
|
|
75
|
+
type="password"
|
|
76
|
+
value={settings.key}
|
|
77
|
+
onChange={(e) => onInputChange("key", e.target.value)}
|
|
78
|
+
required
|
|
79
|
+
inputType="textInput"
|
|
80
|
+
tooltipContent={"Your Payone portal key (will be encrypted)"}
|
|
81
|
+
/>
|
|
82
|
+
</Flex>
|
|
83
|
+
<Flex direction="row" gap={2}>
|
|
84
|
+
<RenderInput
|
|
85
|
+
label="Domain Name"
|
|
86
|
+
name="domainName"
|
|
87
|
+
value={settings.domainName}
|
|
88
|
+
onChange={(e) => onInputChange("domainName", e.target.value)}
|
|
89
|
+
inputType="textInput"
|
|
90
|
+
tooltipContent={"Your Payone domain name"}
|
|
91
|
+
/>
|
|
92
|
+
|
|
93
|
+
<RenderInput
|
|
94
|
+
label="Display Name"
|
|
95
|
+
name="displayName"
|
|
96
|
+
value={settings.displayName}
|
|
97
|
+
onChange={(e) => onInputChange("displayName", e.target.value)}
|
|
98
|
+
inputType="textInput"
|
|
99
|
+
tooltipContent={"Display name for payment methods (optional)"}
|
|
100
|
+
/>
|
|
101
|
+
</Flex>
|
|
102
|
+
<Flex direction="row" gap={2}>
|
|
103
|
+
<RenderInput
|
|
104
|
+
label="Mode"
|
|
105
|
+
name="mode"
|
|
106
|
+
value={settings.mode || "test"}
|
|
107
|
+
onChange={(e) => onInputChange("mode", e.target.value)}
|
|
108
|
+
required
|
|
109
|
+
inputType="select"
|
|
110
|
+
tooltipContent={"Select the API mode"}
|
|
111
|
+
options={[
|
|
112
|
+
{ value: "test", label: "Test" },
|
|
113
|
+
{ value: "live", label: "Live" },
|
|
114
|
+
]}
|
|
115
|
+
/>
|
|
116
|
+
<RenderInput
|
|
117
|
+
label="Enable 3D Secure"
|
|
118
|
+
name="enable3DSecure"
|
|
119
|
+
value={settings.enable3DSecure ? "yes" : "no"}
|
|
120
|
+
onChange={(e) =>
|
|
121
|
+
onInputChange("enable3DSecure", e.target.value === "yes")
|
|
122
|
+
}
|
|
123
|
+
required
|
|
124
|
+
inputType="select"
|
|
125
|
+
tooltipContent={
|
|
126
|
+
"Enable 3D Secure authentication for credit card payments"
|
|
127
|
+
}
|
|
128
|
+
options={[
|
|
129
|
+
{ value: "yes", label: "Enabled" },
|
|
130
|
+
{ value: "no", label: "Disabled" },
|
|
131
|
+
]}
|
|
132
|
+
/>
|
|
133
|
+
</Flex>
|
|
134
|
+
<Flex direction="row">
|
|
135
|
+
<RenderInput
|
|
136
|
+
label="API Version"
|
|
137
|
+
name="api_version"
|
|
138
|
+
value={settings.api_version || "3.10"}
|
|
139
|
+
onChange={(e) => onInputChange("api_version", e.target.value)}
|
|
140
|
+
required
|
|
141
|
+
inputType="textInput"
|
|
142
|
+
tooltipContent={"Payone API version"}
|
|
143
|
+
/>
|
|
144
|
+
</Flex>
|
|
145
|
+
</Flex>
|
|
146
|
+
|
|
147
|
+
<Flex direction="column" alignItems="stretch" gap={4} marginTop={6}>
|
|
148
|
+
<Typography variant="pi" textColor="neutral600" marginBottom={4}>
|
|
149
|
+
Enable or disable payment methods for your Payone integration
|
|
150
|
+
</Typography>
|
|
151
|
+
|
|
152
|
+
<RenderInput
|
|
153
|
+
label="Credit Card (Visa, Mastercard)"
|
|
154
|
+
name="enableCreditCard"
|
|
155
|
+
value={settings.enableCreditCard === true}
|
|
156
|
+
onChange={(selected) =>
|
|
157
|
+
onPaymentMethodToggle("enableCreditCard", selected)
|
|
158
|
+
}
|
|
159
|
+
inputType="switch"
|
|
160
|
+
labelDirection="row"
|
|
161
|
+
labelStyle={{ fontSize: "16px" }}
|
|
162
|
+
tooltipContent="Enable or disable credit card payments"
|
|
163
|
+
/>
|
|
164
|
+
|
|
165
|
+
<RenderInput
|
|
166
|
+
label="PayPal"
|
|
167
|
+
name="enablePayPal"
|
|
168
|
+
value={settings.enablePayPal === true}
|
|
169
|
+
onChange={(selected) =>
|
|
170
|
+
onPaymentMethodToggle("enablePayPal", selected)
|
|
171
|
+
}
|
|
172
|
+
inputType="switch"
|
|
173
|
+
labelDirection="row"
|
|
174
|
+
labelStyle={{ fontSize: "16px" }}
|
|
175
|
+
tooltipContent="Enable or disable PayPal payments"
|
|
176
|
+
/>
|
|
177
|
+
|
|
178
|
+
<RenderInput
|
|
179
|
+
label="Google Pay"
|
|
180
|
+
name="enableGooglePay"
|
|
181
|
+
value={settings.enableGooglePay === true}
|
|
182
|
+
onChange={(selected) =>
|
|
183
|
+
onPaymentMethodToggle("enableGooglePay", selected)
|
|
184
|
+
}
|
|
185
|
+
inputType="switch"
|
|
186
|
+
labelDirection="row"
|
|
187
|
+
labelStyle={{ fontSize: "16px" }}
|
|
188
|
+
tooltipContent="Enable or disable Google Pay payments"
|
|
189
|
+
/>
|
|
190
|
+
|
|
191
|
+
<RenderInput
|
|
192
|
+
label="Apple Pay"
|
|
193
|
+
name="enableApplePay"
|
|
194
|
+
value={settings.enableApplePay === true}
|
|
195
|
+
onChange={(selected) =>
|
|
196
|
+
onPaymentMethodToggle("enableApplePay", selected)
|
|
197
|
+
}
|
|
198
|
+
inputType="switch"
|
|
199
|
+
labelDirection="row"
|
|
200
|
+
labelStyle={{ fontSize: "16px" }}
|
|
201
|
+
tooltipContent="Enable or disable Apple Pay payments"
|
|
202
|
+
/>
|
|
203
|
+
|
|
204
|
+
<RenderInput
|
|
205
|
+
label="Sofort Banking"
|
|
206
|
+
name="enableSofort"
|
|
207
|
+
value={settings.enableSofort === true}
|
|
208
|
+
onChange={(selected) =>
|
|
209
|
+
onPaymentMethodToggle("enableSofort", selected)
|
|
210
|
+
}
|
|
211
|
+
inputType="switch"
|
|
212
|
+
labelDirection="row"
|
|
213
|
+
labelStyle={{ fontSize: "16px" }}
|
|
214
|
+
tooltipContent="Enable or disable Sofort Banking payments"
|
|
215
|
+
/>
|
|
216
|
+
|
|
217
|
+
<RenderInput
|
|
218
|
+
label="SEPA Direct Debit"
|
|
219
|
+
name="enableSepaDirectDebit"
|
|
220
|
+
value={settings.enableSepaDirectDebit === true}
|
|
221
|
+
onChange={(selected) =>
|
|
222
|
+
onPaymentMethodToggle("enableSepaDirectDebit", selected)
|
|
223
|
+
}
|
|
224
|
+
inputType="switch"
|
|
225
|
+
labelDirection="row"
|
|
226
|
+
labelStyle={{ fontSize: "16px" }}
|
|
227
|
+
tooltipContent="Enable or disable SEPA Direct Debit payments"
|
|
228
|
+
/>
|
|
229
|
+
|
|
230
|
+
<Flex direction="row" gap={2} marginTop={10}>
|
|
231
|
+
<Button
|
|
232
|
+
variant="secondary"
|
|
233
|
+
startIcon={<Cog />}
|
|
234
|
+
onClick={handleNavigateToApplePayConfig}
|
|
235
|
+
className="payment-button"
|
|
236
|
+
>
|
|
237
|
+
Apple Pay Config
|
|
238
|
+
</Button>
|
|
239
|
+
<Button
|
|
240
|
+
variant="secondary"
|
|
241
|
+
startIcon={<Cog />}
|
|
242
|
+
onClick={handleNavigateToGooglePayConfig}
|
|
243
|
+
className="payment-button"
|
|
244
|
+
>
|
|
245
|
+
Google Pay Config
|
|
246
|
+
</Button>
|
|
247
|
+
</Flex>
|
|
248
|
+
</Flex>
|
|
249
|
+
</CardBody>
|
|
250
|
+
</Card>
|
|
251
|
+
);
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
export default ConfigurationFields;
|
|
255
|
+
|