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,6 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useNotification } from "@strapi/
|
|
3
|
-
import payoneRequests from "../utils/api";
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useNotification } from "@strapi/strapi/admin";
|
|
4
3
|
import {
|
|
5
4
|
getPreauthorizationParams,
|
|
6
5
|
getAuthorizationParams,
|
|
@@ -10,61 +9,120 @@ import {
|
|
|
10
9
|
getValidCardExpiryDate,
|
|
11
10
|
} from "../utils/paymentUtils";
|
|
12
11
|
import { DEFAULT_PAYMENT_DATA } from "../constants/paymentConstants";
|
|
12
|
+
import usePayoneRequests from "../utils/api";
|
|
13
|
+
import {
|
|
14
|
+
getLanguageForCountry,
|
|
15
|
+
getCurrencyForCountry,
|
|
16
|
+
} from "../utils/countryLanguageUtils";
|
|
13
17
|
|
|
14
18
|
const usePaymentActions = () => {
|
|
15
|
-
const toggleNotification = useNotification();
|
|
16
|
-
|
|
17
|
-
const [settings, setSettings] = useState({ enable3DSecure: false });
|
|
19
|
+
const { toggleNotification } = useNotification();
|
|
20
|
+
const { getSettings, preauthorization, authorization, capture, refund } = usePayoneRequests();
|
|
21
|
+
const [settings, setSettings] = React.useState({ enable3DSecure: false });
|
|
18
22
|
|
|
19
|
-
useEffect(() => {
|
|
23
|
+
React.useEffect(() => {
|
|
20
24
|
const loadSettings = async () => {
|
|
21
25
|
try {
|
|
22
|
-
const response = await
|
|
26
|
+
const response = await getSettings();
|
|
23
27
|
if (response?.data) {
|
|
24
28
|
setSettings(response.data);
|
|
25
29
|
}
|
|
26
30
|
} catch (error) {
|
|
31
|
+
console.error("Error loading settings:", error);
|
|
27
32
|
}
|
|
28
33
|
};
|
|
29
34
|
loadSettings();
|
|
30
35
|
}, []);
|
|
31
36
|
|
|
32
|
-
const [paymentAmount, setPaymentAmount] = useState("1000");
|
|
33
|
-
|
|
34
37
|
const generateOrderReference = () => {
|
|
35
38
|
const sequence = 1000 + Math.floor((Date.now() % 99000));
|
|
36
39
|
return generateLagOrderNumber(sequence);
|
|
37
40
|
};
|
|
38
41
|
|
|
39
|
-
const [
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
42
|
+
const [paymentState, setPaymentState] = React.useState({
|
|
43
|
+
paymentAmount: "1000",
|
|
44
|
+
preauthReference: generateOrderReference(),
|
|
45
|
+
authReference: generateOrderReference(),
|
|
46
|
+
captureTxid: "",
|
|
47
|
+
refundTxid: "",
|
|
48
|
+
refundSequenceNumber: "2",
|
|
49
|
+
refundReference: "",
|
|
50
|
+
paymentMethod: "cc",
|
|
51
|
+
captureMode: "full",
|
|
52
|
+
googlePayToken: null,
|
|
53
|
+
applePayToken: null,
|
|
54
|
+
cardtype: "",
|
|
55
|
+
cardpan: "",
|
|
56
|
+
cardexpiredate: "",
|
|
57
|
+
cardcvc2: "",
|
|
58
|
+
currency: "EUR",
|
|
59
|
+
firstname: "John",
|
|
60
|
+
lastname: "Doe",
|
|
61
|
+
email: "test@example.com",
|
|
62
|
+
street: "Test Street 123",
|
|
63
|
+
zip: "12345",
|
|
64
|
+
city: "Test City",
|
|
65
|
+
country: "DE",
|
|
66
|
+
telephonenumber: "01752345678",
|
|
67
|
+
salutation: "Herr",
|
|
68
|
+
gender: "m",
|
|
69
|
+
ip: "127.0.0.1",
|
|
70
|
+
language: "de",
|
|
71
|
+
customerIsPresent: "yes",
|
|
72
|
+
narrativeText: "",
|
|
73
|
+
invoiceid: "",
|
|
74
|
+
shippingFirstname: "John",
|
|
75
|
+
shippingLastname: "Doe",
|
|
76
|
+
shippingStreet: "Test Street 123",
|
|
77
|
+
shippingZip: "12345",
|
|
78
|
+
shippingCity: "Test City",
|
|
79
|
+
shippingCountry: "DE",
|
|
80
|
+
successurl: "",
|
|
81
|
+
errorurl: "",
|
|
82
|
+
backurl: "",
|
|
83
|
+
captureSequenceNumber: "1",
|
|
84
|
+
captureCurrency: "EUR",
|
|
85
|
+
refundCurrency: "EUR",
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
const handleFieldChange = (field, value) => {
|
|
89
|
+
setPaymentState((prev) => {
|
|
90
|
+
const newState = { ...prev, [field]: value };
|
|
91
|
+
|
|
92
|
+
if (field === "country" && value) {
|
|
93
|
+
const languageCode = getLanguageForCountry(value);
|
|
94
|
+
const currencyCode = getCurrencyForCountry(value);
|
|
95
|
+
newState.language = languageCode;
|
|
96
|
+
newState.currency = currencyCode;
|
|
97
|
+
newState.shippingCountry = value;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (field === "firstname" && value) {
|
|
101
|
+
newState.shippingFirstname = value;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (field === "lastname" && value) {
|
|
105
|
+
newState.shippingLastname = value;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (field === "street" && value) {
|
|
109
|
+
newState.shippingStreet = value;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return newState;
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const [isProcessingPayment, setIsProcessingPayment] = React.useState(false);
|
|
117
|
+
const [paymentResult, setPaymentResult] = React.useState(null);
|
|
118
|
+
const [paymentError, setPaymentError] = React.useState(null);
|
|
119
|
+
|
|
120
|
+
const handlePaymentError = (errorMessage) => {
|
|
121
|
+
const defaultMessage = "Payment failed. Please check the error message and try again.";
|
|
122
|
+
setPaymentError(errorMessage || defaultMessage);
|
|
65
123
|
toggleNotification({
|
|
66
|
-
type: "
|
|
67
|
-
message: defaultMessage
|
|
124
|
+
type: "danger",
|
|
125
|
+
message: errorMessage || defaultMessage
|
|
68
126
|
});
|
|
69
127
|
};
|
|
70
128
|
|
|
@@ -80,33 +138,51 @@ const usePaymentActions = () => {
|
|
|
80
138
|
setPaymentError(null);
|
|
81
139
|
setPaymentResult(null);
|
|
82
140
|
try {
|
|
83
|
-
const finalPreauthReference =
|
|
84
|
-
|
|
85
|
-
setPreauthReference(finalPreauthReference);
|
|
86
|
-
}
|
|
141
|
+
const finalPreauthReference = generateOrderReference();
|
|
142
|
+
handleFieldChange("preauthReference", finalPreauthReference);
|
|
87
143
|
|
|
88
|
-
const
|
|
144
|
+
const finalCurrency = paymentState.currency || ((paymentState.paymentMethod === "cc" && paymentState.cardtype === "A") ? "USD" : "EUR");
|
|
145
|
+
const finalInvoiceid = paymentState.invoiceid || finalPreauthReference;
|
|
146
|
+
const finalNarrativeText = paymentState.narrativeText || ("Preauthorization for order " + finalPreauthReference);
|
|
89
147
|
|
|
90
148
|
const baseParams = {
|
|
91
|
-
amount: parseInt(paymentAmount),
|
|
92
|
-
currency:
|
|
149
|
+
amount: parseInt(paymentState.paymentAmount),
|
|
150
|
+
currency: finalCurrency,
|
|
93
151
|
reference: finalPreauthReference,
|
|
94
152
|
enable3DSecure: settings.enable3DSecure !== false,
|
|
95
|
-
invoiceid:
|
|
96
|
-
narrative_text:
|
|
97
|
-
|
|
153
|
+
invoiceid: finalInvoiceid,
|
|
154
|
+
narrative_text: finalNarrativeText,
|
|
155
|
+
firstname: paymentState.firstname || DEFAULT_PAYMENT_DATA.firstname,
|
|
156
|
+
lastname: paymentState.lastname || DEFAULT_PAYMENT_DATA.lastname,
|
|
157
|
+
email: paymentState.email || DEFAULT_PAYMENT_DATA.email,
|
|
158
|
+
street: paymentState.street || DEFAULT_PAYMENT_DATA.street,
|
|
159
|
+
zip: paymentState.zip || DEFAULT_PAYMENT_DATA.zip,
|
|
160
|
+
city: paymentState.city || DEFAULT_PAYMENT_DATA.city,
|
|
161
|
+
country: paymentState.country || DEFAULT_PAYMENT_DATA.country,
|
|
162
|
+
telephonenumber: paymentState.telephonenumber || DEFAULT_PAYMENT_DATA.telephonenumber,
|
|
163
|
+
salutation: paymentState.salutation || DEFAULT_PAYMENT_DATA.salutation,
|
|
164
|
+
gender: paymentState.gender || DEFAULT_PAYMENT_DATA.gender,
|
|
165
|
+
ip: paymentState.ip || DEFAULT_PAYMENT_DATA.ip,
|
|
166
|
+
language: paymentState.language || DEFAULT_PAYMENT_DATA.language,
|
|
167
|
+
customer_is_present: paymentState.customerIsPresent || DEFAULT_PAYMENT_DATA.customer_is_present,
|
|
168
|
+
shipping_firstname: paymentState.shippingFirstname || paymentState.firstname || DEFAULT_PAYMENT_DATA.firstname,
|
|
169
|
+
shipping_lastname: paymentState.shippingLastname || paymentState.lastname || DEFAULT_PAYMENT_DATA.lastname,
|
|
170
|
+
shipping_street: paymentState.shippingStreet || paymentState.street || DEFAULT_PAYMENT_DATA.street,
|
|
171
|
+
shipping_zip: paymentState.shippingZip || paymentState.zip || DEFAULT_PAYMENT_DATA.zip,
|
|
172
|
+
shipping_city: paymentState.shippingCity || paymentState.city || DEFAULT_PAYMENT_DATA.city,
|
|
173
|
+
shipping_country: paymentState.shippingCountry || paymentState.country || DEFAULT_PAYMENT_DATA.country,
|
|
98
174
|
};
|
|
99
175
|
|
|
100
|
-
if (paymentMethod === "cc" && settings.enable3DSecure !== false) {
|
|
101
|
-
if (cardtype) baseParams.cardtype = cardtype;
|
|
102
|
-
if (cardpan) baseParams.cardpan = cardpan;
|
|
103
|
-
baseParams.cardexpiredate = getValidCardExpiryDate(cardexpiredate);
|
|
104
|
-
if (cardcvc2) baseParams.cardcvc2 = cardcvc2;
|
|
176
|
+
if (paymentState.paymentMethod === "cc" && settings.enable3DSecure !== false) {
|
|
177
|
+
if (paymentState.cardtype) baseParams.cardtype = paymentState.cardtype;
|
|
178
|
+
if (paymentState.cardpan) baseParams.cardpan = paymentState.cardpan;
|
|
179
|
+
baseParams.cardexpiredate = getValidCardExpiryDate(paymentState.cardexpiredate);
|
|
180
|
+
if (paymentState.cardcvc2) baseParams.cardcvc2 = paymentState.cardcvc2;
|
|
105
181
|
}
|
|
106
182
|
|
|
107
183
|
const needsRedirectUrls =
|
|
108
|
-
(paymentMethod === "cc" && settings.enable3DSecure !== false) ||
|
|
109
|
-
["wlt", "gpp", "apl", "sb"].includes(paymentMethod);
|
|
184
|
+
(paymentState.paymentMethod === "cc" && settings.enable3DSecure !== false) ||
|
|
185
|
+
["wlt", "gpp", "apl", "sb"].includes(paymentState.paymentMethod);
|
|
110
186
|
|
|
111
187
|
if (needsRedirectUrls) {
|
|
112
188
|
const baseUrl = window.location.origin;
|
|
@@ -120,52 +196,42 @@ const usePaymentActions = () => {
|
|
|
120
196
|
baseParams.backurl = `${baseUrl}${basePath}${pluginPath}/back`;
|
|
121
197
|
}
|
|
122
198
|
|
|
123
|
-
const tokenToUse = tokenParam || googlePayToken || applePayToken;
|
|
124
|
-
if (paymentMethod === "gpp" && tokenToUse) {
|
|
199
|
+
const tokenToUse = tokenParam || paymentState.googlePayToken || paymentState.applePayToken;
|
|
200
|
+
if (paymentState.paymentMethod === "gpp" && tokenToUse) {
|
|
125
201
|
baseParams.googlePayToken = tokenToUse;
|
|
126
202
|
baseParams.settings = settings;
|
|
127
|
-
} else if (paymentMethod === "apl" && tokenToUse) {
|
|
203
|
+
} else if (paymentState.paymentMethod === "apl" && tokenToUse) {
|
|
128
204
|
baseParams.applePayToken = tokenToUse;
|
|
129
205
|
baseParams.settings = settings;
|
|
130
206
|
}
|
|
131
207
|
|
|
132
|
-
const params = getPreauthorizationParams(paymentMethod, baseParams);
|
|
208
|
+
const params = getPreauthorizationParams(paymentState.paymentMethod, baseParams);
|
|
133
209
|
|
|
134
|
-
const result = await
|
|
210
|
+
const result = await preauthorization(params);
|
|
135
211
|
const responseData = result?.data || result;
|
|
136
|
-
const status =
|
|
137
|
-
const errorCode = responseData
|
|
138
|
-
const errorMessage = responseData
|
|
139
|
-
|
|
212
|
+
const status = responseData?.Status || null;
|
|
213
|
+
const errorCode = responseData?.errorCode || null;
|
|
214
|
+
const errorMessage = responseData?.errorMessage || null;
|
|
140
215
|
const requires3DSErrorCodes = ["4219", 4219];
|
|
141
216
|
const is3DSRequiredError = requires3DSErrorCodes.includes(errorCode);
|
|
142
|
-
|
|
143
|
-
const redirectUrl =
|
|
144
|
-
responseData.redirectUrl ||
|
|
145
|
-
responseData.redirecturl ||
|
|
146
|
-
responseData.RedirectUrl ||
|
|
147
|
-
responseData.redirect_url ||
|
|
148
|
-
responseData.url ||
|
|
149
|
-
responseData.Url ||
|
|
150
|
-
null;
|
|
217
|
+
const redirectUrl = responseData?.redirectUrl || null;
|
|
151
218
|
|
|
152
219
|
if (is3DSRequiredError && !redirectUrl) {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
(
|
|
220
|
+
handlePaymentError(
|
|
221
|
+
errorMessage + " " +
|
|
222
|
+
(`Error code: ${errorCode || "Unknown"}`)
|
|
156
223
|
);
|
|
157
224
|
setPaymentResult(responseData);
|
|
158
|
-
return;
|
|
225
|
+
return { success: false, data: responseData };
|
|
159
226
|
}
|
|
160
227
|
|
|
161
228
|
if ((status === "ERROR" || status === "INVALID" || errorCode) && !is3DSRequiredError) {
|
|
162
|
-
|
|
163
|
-
errorMessage
|
|
164
|
-
`
|
|
165
|
-
"Preauthorization failed"
|
|
229
|
+
handlePaymentError(
|
|
230
|
+
errorMessage + " " +
|
|
231
|
+
(`Error code: ${errorCode || "Unknown"}`)
|
|
166
232
|
);
|
|
167
233
|
setPaymentResult(responseData);
|
|
168
|
-
return;
|
|
234
|
+
return { success: false, data: responseData };
|
|
169
235
|
}
|
|
170
236
|
|
|
171
237
|
const needsRedirect = responseData.requires3DSRedirect ||
|
|
@@ -185,15 +251,15 @@ const usePaymentActions = () => {
|
|
|
185
251
|
} else {
|
|
186
252
|
const errorMsg = errorMessage || `Unexpected status: ${status}`;
|
|
187
253
|
handlePaymentError(
|
|
188
|
-
|
|
189
|
-
`Preauthorization completed with status: ${status}`
|
|
254
|
+
errorMsg + "Preauthorization completed with status: ${status}"
|
|
190
255
|
);
|
|
191
|
-
|
|
256
|
+
|
|
257
|
+
return { success: false, data: responseData };
|
|
192
258
|
}
|
|
193
259
|
} catch (error) {
|
|
194
|
-
|
|
195
|
-
handlePaymentError(
|
|
196
|
-
|
|
260
|
+
const errorMessage = error.message || "Preauthorization failed";
|
|
261
|
+
handlePaymentError(errorMessage);
|
|
262
|
+
return { success: false, data: error };
|
|
197
263
|
} finally {
|
|
198
264
|
setIsProcessingPayment(false);
|
|
199
265
|
}
|
|
@@ -205,92 +271,124 @@ const usePaymentActions = () => {
|
|
|
205
271
|
setPaymentResult(null);
|
|
206
272
|
|
|
207
273
|
try {
|
|
208
|
-
const finalAuthReference =
|
|
209
|
-
|
|
210
|
-
setAuthReference(finalAuthReference);
|
|
211
|
-
}
|
|
274
|
+
const finalAuthReference = generateOrderReference();
|
|
275
|
+
handleFieldChange("authReference", finalAuthReference);
|
|
212
276
|
|
|
213
|
-
const
|
|
277
|
+
const finalCurrency = paymentState.currency || ((paymentState.paymentMethod === "cc" && paymentState.cardtype === "A") ? "USD" : "EUR");
|
|
278
|
+
const finalInvoiceid = paymentState.invoiceid || finalAuthReference;
|
|
279
|
+
const finalNarrativeText = paymentState.narrativeText || ("Authorization for order " + finalAuthReference);
|
|
214
280
|
|
|
215
281
|
const baseParams = {
|
|
216
|
-
amount: parseInt(paymentAmount),
|
|
217
|
-
currency:
|
|
282
|
+
amount: parseInt(paymentState.paymentAmount),
|
|
283
|
+
currency: finalCurrency,
|
|
218
284
|
reference: finalAuthReference,
|
|
219
285
|
enable3DSecure: settings.enable3DSecure !== false,
|
|
220
|
-
invoiceid:
|
|
221
|
-
narrative_text:
|
|
222
|
-
|
|
286
|
+
invoiceid: finalInvoiceid,
|
|
287
|
+
narrative_text: finalNarrativeText,
|
|
288
|
+
firstname: paymentState.firstname || DEFAULT_PAYMENT_DATA.firstname,
|
|
289
|
+
lastname: paymentState.lastname || DEFAULT_PAYMENT_DATA.lastname,
|
|
290
|
+
email: paymentState.email || DEFAULT_PAYMENT_DATA.email,
|
|
291
|
+
street: paymentState.street || DEFAULT_PAYMENT_DATA.street,
|
|
292
|
+
zip: paymentState.zip || DEFAULT_PAYMENT_DATA.zip,
|
|
293
|
+
city: paymentState.city || DEFAULT_PAYMENT_DATA.city,
|
|
294
|
+
country: paymentState.country || DEFAULT_PAYMENT_DATA.country,
|
|
295
|
+
telephonenumber: paymentState.telephonenumber || DEFAULT_PAYMENT_DATA.telephonenumber,
|
|
296
|
+
salutation: paymentState.salutation || DEFAULT_PAYMENT_DATA.salutation,
|
|
297
|
+
gender: paymentState.gender || DEFAULT_PAYMENT_DATA.gender,
|
|
298
|
+
ip: paymentState.ip || DEFAULT_PAYMENT_DATA.ip,
|
|
299
|
+
language: paymentState.language || DEFAULT_PAYMENT_DATA.language,
|
|
300
|
+
customer_is_present: paymentState.customerIsPresent || DEFAULT_PAYMENT_DATA.customer_is_present,
|
|
301
|
+
shipping_firstname: paymentState.shippingFirstname || paymentState.firstname || DEFAULT_PAYMENT_DATA.firstname,
|
|
302
|
+
shipping_lastname: paymentState.shippingLastname || paymentState.lastname || DEFAULT_PAYMENT_DATA.lastname,
|
|
303
|
+
shipping_street: paymentState.shippingStreet || paymentState.street || DEFAULT_PAYMENT_DATA.street,
|
|
304
|
+
shipping_zip: paymentState.shippingZip || paymentState.zip || DEFAULT_PAYMENT_DATA.zip,
|
|
305
|
+
shipping_city: paymentState.shippingCity || paymentState.city || DEFAULT_PAYMENT_DATA.city,
|
|
306
|
+
shipping_country: paymentState.shippingCountry || paymentState.country || DEFAULT_PAYMENT_DATA.country,
|
|
223
307
|
};
|
|
224
308
|
|
|
225
|
-
if (paymentMethod === "cc" && settings.enable3DSecure !== false) {
|
|
226
|
-
if (cardtype) baseParams.cardtype = cardtype;
|
|
227
|
-
if (cardpan) baseParams.cardpan = cardpan;
|
|
228
|
-
baseParams.cardexpiredate = getValidCardExpiryDate(cardexpiredate);
|
|
229
|
-
if (cardcvc2) baseParams.cardcvc2 = cardcvc2;
|
|
309
|
+
if (paymentState.paymentMethod === "cc" && settings.enable3DSecure !== false) {
|
|
310
|
+
if (paymentState.cardtype) baseParams.cardtype = paymentState.cardtype;
|
|
311
|
+
if (paymentState.cardpan) baseParams.cardpan = paymentState.cardpan;
|
|
312
|
+
baseParams.cardexpiredate = getValidCardExpiryDate(paymentState.cardexpiredate);
|
|
313
|
+
if (paymentState.cardcvc2) baseParams.cardcvc2 = paymentState.cardcvc2;
|
|
230
314
|
}
|
|
231
315
|
|
|
232
316
|
const needsRedirectUrls =
|
|
233
|
-
(paymentMethod === "cc" && settings.enable3DSecure !== false) ||
|
|
234
|
-
["wlt", "gpp", "apl", "sb"].includes(paymentMethod);
|
|
317
|
+
(paymentState.paymentMethod === "cc" && settings.enable3DSecure !== false) ||
|
|
318
|
+
["wlt", "gpp", "apl", "sb"].includes(paymentState.paymentMethod);
|
|
235
319
|
|
|
236
320
|
if (needsRedirectUrls) {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
321
|
+
if (paymentState.successurl) {
|
|
322
|
+
baseParams.successurl = paymentState.successurl;
|
|
323
|
+
} else {
|
|
324
|
+
const baseUrl = window.location.origin;
|
|
325
|
+
const currentPath = window.location.pathname;
|
|
326
|
+
const isContentUI = currentPath.includes('/content-ui') || currentPath.includes('/content-manager');
|
|
327
|
+
const basePath = isContentUI ? '/content-ui' : '/admin';
|
|
328
|
+
const pluginPath = '/plugins/strapi-plugin-payone-provider/payment';
|
|
329
|
+
baseParams.successurl = `${baseUrl}${basePath}${pluginPath}/success`;
|
|
330
|
+
}
|
|
242
331
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
332
|
+
if (paymentState.errorurl) {
|
|
333
|
+
baseParams.errorurl = paymentState.errorurl;
|
|
334
|
+
} else {
|
|
335
|
+
const baseUrl = window.location.origin;
|
|
336
|
+
const currentPath = window.location.pathname;
|
|
337
|
+
const isContentUI = currentPath.includes('/content-ui') || currentPath.includes('/content-manager');
|
|
338
|
+
const basePath = isContentUI ? '/content-ui' : '/admin';
|
|
339
|
+
const pluginPath = '/plugins/strapi-plugin-payone-provider/payment';
|
|
340
|
+
baseParams.errorurl = `${baseUrl}${basePath}${pluginPath}/error`;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
if (paymentState.backurl) {
|
|
344
|
+
baseParams.backurl = paymentState.backurl;
|
|
345
|
+
} else {
|
|
346
|
+
const baseUrl = window.location.origin;
|
|
347
|
+
const currentPath = window.location.pathname;
|
|
348
|
+
const isContentUI = currentPath.includes('/content-ui') || currentPath.includes('/content-manager');
|
|
349
|
+
const basePath = isContentUI ? '/content-ui' : '/admin';
|
|
350
|
+
const pluginPath = '/plugins/strapi-plugin-payone-provider/payment';
|
|
351
|
+
baseParams.backurl = `${baseUrl}${basePath}${pluginPath}/back`;
|
|
352
|
+
}
|
|
246
353
|
}
|
|
247
354
|
|
|
248
|
-
const tokenToUse = tokenParam || googlePayToken || applePayToken;
|
|
249
|
-
if (paymentMethod === "gpp" && tokenToUse) {
|
|
355
|
+
const tokenToUse = tokenParam || paymentState.googlePayToken || paymentState.applePayToken;
|
|
356
|
+
if (paymentState.paymentMethod === "gpp" && tokenToUse) {
|
|
250
357
|
baseParams.googlePayToken = tokenToUse;
|
|
251
358
|
baseParams.settings = settings;
|
|
252
|
-
} else if (paymentMethod === "apl" && tokenToUse) {
|
|
359
|
+
} else if (paymentState.paymentMethod === "apl" && tokenToUse) {
|
|
253
360
|
baseParams.applePayToken = tokenToUse;
|
|
254
361
|
baseParams.settings = settings;
|
|
255
362
|
}
|
|
256
363
|
|
|
257
|
-
const params = getAuthorizationParams(paymentMethod, baseParams);
|
|
364
|
+
const params = getAuthorizationParams(paymentState.paymentMethod, baseParams);
|
|
365
|
+
const result = await authorization(params);
|
|
258
366
|
|
|
259
|
-
const result = await payoneRequests.authorization(params);
|
|
260
367
|
const responseData = result?.data || result;
|
|
261
|
-
const status =
|
|
262
|
-
const errorCode = responseData
|
|
263
|
-
const errorMessage = responseData
|
|
264
|
-
|
|
368
|
+
const status = responseData?.Status || null;
|
|
369
|
+
const errorCode = responseData?.errorCode || null;
|
|
370
|
+
const errorMessage = responseData?.errorMessage || null;
|
|
265
371
|
const requires3DSErrorCodes = ["4219", 4219];
|
|
266
372
|
const is3DSRequiredError = requires3DSErrorCodes.includes(errorCode);
|
|
373
|
+
const redirectUrl = responseData?.redirectUrl || null;
|
|
267
374
|
|
|
268
|
-
const redirectUrl =
|
|
269
|
-
responseData.redirectUrl ||
|
|
270
|
-
responseData.redirecturl ||
|
|
271
|
-
responseData.RedirectUrl ||
|
|
272
|
-
responseData.redirect_url ||
|
|
273
|
-
responseData.url ||
|
|
274
|
-
responseData.Url ||
|
|
275
|
-
null;
|
|
276
375
|
|
|
277
376
|
if (is3DSRequiredError && !redirectUrl) {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
(
|
|
377
|
+
handlePaymentError(
|
|
378
|
+
errorMessage + " " +
|
|
379
|
+
(`Error code: ${errorCode || "Unknown"}`)
|
|
281
380
|
);
|
|
282
381
|
setPaymentResult(responseData);
|
|
283
|
-
return;
|
|
382
|
+
return { success: false, data: responseData };
|
|
284
383
|
}
|
|
285
384
|
|
|
286
385
|
if ((status === "ERROR" || status === "INVALID" || errorCode) && !is3DSRequiredError) {
|
|
287
|
-
|
|
288
|
-
errorMessage
|
|
289
|
-
`
|
|
290
|
-
"Authorization failed"
|
|
386
|
+
handlePaymentError(
|
|
387
|
+
errorMessage + " " +
|
|
388
|
+
(`Error code: ${errorCode || "Unknown"}`)
|
|
291
389
|
);
|
|
292
390
|
setPaymentResult(responseData);
|
|
293
|
-
return;
|
|
391
|
+
return { success: false, data: responseData };
|
|
294
392
|
}
|
|
295
393
|
|
|
296
394
|
const needsRedirect = responseData.requires3DSRedirect ||
|
|
@@ -306,128 +404,93 @@ const usePaymentActions = () => {
|
|
|
306
404
|
|
|
307
405
|
if (status === "APPROVED") {
|
|
308
406
|
handlePaymentSuccess("Authorization completed successfully");
|
|
309
|
-
// Return success result for Apple Pay callback
|
|
310
407
|
return { success: true, data: responseData };
|
|
311
408
|
} else {
|
|
312
|
-
const errorMsg = errorMessage
|
|
409
|
+
const errorMsg = errorMessage + `Unexpected status: ${status}`;
|
|
313
410
|
handlePaymentError(
|
|
314
|
-
|
|
315
|
-
`Authorization completed with status: ${status}`
|
|
411
|
+
errorMsg + "Authorization completed with status: ${status}"
|
|
316
412
|
);
|
|
317
|
-
|
|
413
|
+
return { success: false, data: responseData };
|
|
318
414
|
}
|
|
319
415
|
} catch (error) {
|
|
320
|
-
|
|
321
|
-
handlePaymentError(
|
|
322
|
-
|
|
416
|
+
const errorMessage = error.message || "Authorization failed";
|
|
417
|
+
handlePaymentError(errorMessage);
|
|
418
|
+
return { success: false, data: error };
|
|
323
419
|
} finally {
|
|
324
420
|
setIsProcessingPayment(false);
|
|
325
421
|
}
|
|
326
422
|
};
|
|
327
423
|
|
|
328
424
|
const handleCapture = async () => {
|
|
329
|
-
if (!captureTxid.trim()) {
|
|
330
|
-
|
|
331
|
-
return;
|
|
425
|
+
if (!paymentState.captureTxid.trim()) {
|
|
426
|
+
handlePaymentError("Transaction ID is required for capture");
|
|
427
|
+
return { success: false, data: "Transaction ID is required for capture" };
|
|
332
428
|
}
|
|
333
429
|
setIsProcessingPayment(true);
|
|
334
430
|
setPaymentError(null);
|
|
335
431
|
setPaymentResult(null);
|
|
336
432
|
try {
|
|
337
|
-
const params = getCaptureParams(paymentMethod, {
|
|
338
|
-
txid: captureTxid,
|
|
339
|
-
amount: parseInt(paymentAmount),
|
|
340
|
-
currency: "EUR",
|
|
341
|
-
captureMode: captureMode,
|
|
342
|
-
sequencenumber: 1
|
|
433
|
+
const params = getCaptureParams(paymentState.paymentMethod, {
|
|
434
|
+
txid: paymentState.captureTxid,
|
|
435
|
+
amount: parseInt(paymentState.paymentAmount),
|
|
436
|
+
currency: paymentState.captureCurrency || "EUR",
|
|
437
|
+
captureMode: paymentState.captureMode,
|
|
438
|
+
sequencenumber: parseInt(paymentState.captureSequenceNumber) || 1
|
|
343
439
|
});
|
|
344
440
|
|
|
345
|
-
const result = await
|
|
441
|
+
const result = await capture(params);
|
|
346
442
|
setPaymentResult(result);
|
|
347
443
|
handlePaymentSuccess("Capture completed successfully");
|
|
444
|
+
return { success: true, data: result };
|
|
348
445
|
} catch (error) {
|
|
349
|
-
|
|
446
|
+
const errorMessage = error.message || "Capture failed";
|
|
447
|
+
handlePaymentError(errorMessage);
|
|
448
|
+
return { success: false, data: error };
|
|
350
449
|
} finally {
|
|
351
450
|
setIsProcessingPayment(false);
|
|
352
451
|
}
|
|
353
452
|
};
|
|
354
453
|
|
|
355
454
|
const handleRefund = async () => {
|
|
356
|
-
if (!refundTxid.trim()) {
|
|
357
|
-
|
|
358
|
-
return;
|
|
455
|
+
if (!paymentState.refundTxid.trim()) {
|
|
456
|
+
handlePaymentError("Transaction ID is required for refund");
|
|
457
|
+
return { success: false, data: "Transaction ID is required for refund" };
|
|
359
458
|
}
|
|
360
459
|
setIsProcessingPayment(true);
|
|
361
460
|
setPaymentError(null);
|
|
362
461
|
setPaymentResult(null);
|
|
363
462
|
try {
|
|
364
|
-
const params = getRefundParams(paymentMethod, {
|
|
365
|
-
txid: refundTxid,
|
|
366
|
-
sequencenumber: parseInt(refundSequenceNumber),
|
|
367
|
-
amount: parseInt(paymentAmount),
|
|
368
|
-
currency: "EUR",
|
|
369
|
-
reference: refundReference || `REFUND-${Date.now()}`
|
|
463
|
+
const params = getRefundParams(paymentState.paymentMethod, {
|
|
464
|
+
txid: paymentState.refundTxid,
|
|
465
|
+
sequencenumber: parseInt(paymentState.refundSequenceNumber),
|
|
466
|
+
amount: parseInt(paymentState.paymentAmount),
|
|
467
|
+
currency: paymentState.refundCurrency || "EUR",
|
|
468
|
+
reference: paymentState.refundReference || `REFUND-${Date.now()}`
|
|
370
469
|
});
|
|
371
470
|
|
|
372
|
-
const result = await
|
|
471
|
+
const result = await refund(params);
|
|
373
472
|
setPaymentResult(result);
|
|
374
473
|
handlePaymentSuccess("Refund completed successfully");
|
|
474
|
+
return { success: true, data: result };
|
|
375
475
|
} catch (error) {
|
|
376
|
-
|
|
476
|
+
const errorMessage = error.message || "Refund failed";
|
|
477
|
+
handlePaymentError(errorMessage);
|
|
478
|
+
return { success: false, data: error };
|
|
377
479
|
} finally {
|
|
378
480
|
setIsProcessingPayment(false);
|
|
379
481
|
}
|
|
380
482
|
};
|
|
381
483
|
|
|
382
484
|
return {
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
setPaymentAmount,
|
|
386
|
-
preauthReference,
|
|
387
|
-
setPreauthReference,
|
|
388
|
-
authReference,
|
|
389
|
-
setAuthReference,
|
|
390
|
-
captureTxid,
|
|
391
|
-
setCaptureTxid,
|
|
392
|
-
refundTxid,
|
|
393
|
-
setRefundTxid,
|
|
394
|
-
refundSequenceNumber,
|
|
395
|
-
setRefundSequenceNumber,
|
|
396
|
-
refundReference,
|
|
397
|
-
setRefundReference,
|
|
398
|
-
paymentMethod,
|
|
399
|
-
setPaymentMethod,
|
|
400
|
-
captureMode,
|
|
401
|
-
setCaptureMode,
|
|
402
|
-
|
|
403
|
-
// Processing state
|
|
485
|
+
paymentState,
|
|
486
|
+
handleFieldChange,
|
|
404
487
|
isProcessingPayment,
|
|
405
488
|
paymentResult,
|
|
406
489
|
paymentError,
|
|
407
|
-
|
|
408
|
-
// Handlers
|
|
409
490
|
handlePreauthorization,
|
|
410
491
|
handleAuthorization,
|
|
411
492
|
handleCapture,
|
|
412
493
|
handleRefund,
|
|
413
|
-
|
|
414
|
-
// Google Pay
|
|
415
|
-
googlePayToken,
|
|
416
|
-
setGooglePayToken,
|
|
417
|
-
|
|
418
|
-
// Apple Pay
|
|
419
|
-
applePayToken,
|
|
420
|
-
setApplePayToken,
|
|
421
|
-
|
|
422
|
-
// Card details for 3DS
|
|
423
|
-
cardtype,
|
|
424
|
-
setCardtype,
|
|
425
|
-
cardpan,
|
|
426
|
-
setCardpan,
|
|
427
|
-
cardexpiredate,
|
|
428
|
-
setCardexpiredate,
|
|
429
|
-
cardcvc2,
|
|
430
|
-
setCardcvc2
|
|
431
494
|
};
|
|
432
495
|
};
|
|
433
496
|
|