strapi-plugin-payone-provider 1.5.8 → 1.6.1
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/components/Initializer/index.jsx +16 -0
- package/admin/src/components/PluginIcon/index.jsx +6 -0
- package/admin/src/index.js +3 -3
- package/admin/src/pages/App/components/AppHeader.jsx +55 -0
- package/admin/src/pages/App/components/AppTabs.jsx +158 -0
- package/admin/src/pages/App/components/ApplePayBtn.jsx +304 -0
- package/admin/src/pages/App/components/ApplePayButton.js +139 -93
- package/admin/src/pages/App/components/ApplePayButton.jsx +908 -0
- package/admin/src/pages/App/components/ApplePayConfig.jsx +298 -0
- package/admin/src/pages/App/components/ApplePayConfigPanel.jsx +81 -0
- package/admin/src/pages/App/components/ConfigurationPanel.jsx +280 -0
- package/admin/src/pages/App/components/DocsPanel.jsx +1057 -0
- package/admin/src/pages/App/components/GooglePayConfig.jsx +217 -0
- package/admin/src/pages/App/components/GooglePayConfigPanel.jsx +82 -0
- package/admin/src/pages/App/components/GooglePaybutton.jsx +300 -0
- package/admin/src/pages/App/components/HistoryPanel.jsx +285 -0
- package/admin/src/pages/App/components/PaymentActionsPanel.jsx +238 -0
- package/admin/src/pages/App/components/StatusBadge.jsx +24 -0
- package/admin/src/pages/App/components/TransactionHistoryItem.jsx +377 -0
- package/admin/src/pages/App/components/icons/BankIcon.jsx +10 -0
- package/admin/src/pages/App/components/icons/ChevronDownIcon.jsx +9 -0
- package/admin/src/pages/App/components/icons/ChevronUpIcon.jsx +9 -0
- package/admin/src/pages/App/components/icons/CreditCardIcon.jsx +9 -0
- package/admin/src/pages/App/components/icons/ErrorIcon.jsx +10 -0
- package/admin/src/pages/App/components/icons/InfoIcon.jsx +9 -0
- package/admin/src/pages/App/components/icons/PaymentIcon.jsx +10 -0
- package/admin/src/pages/App/components/icons/PendingIcon.jsx +9 -0
- package/admin/src/pages/App/components/icons/PersonIcon.jsx +9 -0
- package/admin/src/pages/App/components/icons/SuccessIcon.jsx +9 -0
- package/admin/src/pages/App/components/icons/WalletIcon.jsx +9 -0
- package/admin/src/pages/App/components/icons/index.jsx +11 -0
- package/admin/src/pages/App/components/paymentActions/AuthorizationForm.jsx +205 -0
- package/admin/src/pages/App/components/paymentActions/CaptureForm.jsx +65 -0
- package/admin/src/pages/App/components/paymentActions/CardDetailsInput.jsx +191 -0
- package/admin/src/pages/App/components/paymentActions/PaymentMethodSelector.jsx +236 -0
- package/admin/src/pages/App/components/paymentActions/PaymentResult.jsx +148 -0
- package/admin/src/pages/App/components/paymentActions/PreauthorizationForm.jsx +132 -0
- package/admin/src/pages/App/components/paymentActions/RefundForm.jsx +90 -0
- package/admin/src/pages/App/index.jsx +127 -0
- package/admin/src/pages/constants/paymentConstants.js +1 -2
- package/admin/src/pages/hooks/usePaymentActions.js +96 -0
- package/package.json +2 -2
- package/server/bootstrap.js +65 -0
- package/server/controllers/payone.js +4 -48
- package/server/routes/index.js +1 -1
- package/server/services/applePayService.js +51 -407
- 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 +14 -0
- package/server/utils/paymentMethodParams.js +60 -27
- package/server/utils/requestBuilder.js +0 -22
|
@@ -13,7 +13,10 @@ import { DEFAULT_PAYMENT_DATA } from "../constants/paymentConstants";
|
|
|
13
13
|
const usePaymentActions = () => {
|
|
14
14
|
const toggleNotification = useNotification();
|
|
15
15
|
|
|
16
|
+
<<<<<<< HEAD
|
|
16
17
|
// Load settings to get enable3DSecure value
|
|
18
|
+
=======
|
|
19
|
+
>>>>>>> feature/apple-pay
|
|
17
20
|
const [settings, setSettings] = useState({ enable3DSecure: false });
|
|
18
21
|
|
|
19
22
|
useEffect(() => {
|
|
@@ -24,12 +27,16 @@ const usePaymentActions = () => {
|
|
|
24
27
|
setSettings(response.data);
|
|
25
28
|
}
|
|
26
29
|
} catch (error) {
|
|
30
|
+
<<<<<<< HEAD
|
|
27
31
|
// Silent fail
|
|
32
|
+
=======
|
|
33
|
+
>>>>>>> feature/apple-pay
|
|
28
34
|
}
|
|
29
35
|
};
|
|
30
36
|
loadSettings();
|
|
31
37
|
}, []);
|
|
32
38
|
|
|
39
|
+
<<<<<<< HEAD
|
|
33
40
|
// Payment form state
|
|
34
41
|
const [paymentAmount, setPaymentAmount] = useState("1000");
|
|
35
42
|
|
|
@@ -37,6 +44,11 @@ const usePaymentActions = () => {
|
|
|
37
44
|
// Sequence number starts from 1000 and increments based on timestamp
|
|
38
45
|
const generateOrderReference = () => {
|
|
39
46
|
// Use timestamp to generate unique sequence (1000 to 99999 range)
|
|
47
|
+
=======
|
|
48
|
+
const [paymentAmount, setPaymentAmount] = useState("1000");
|
|
49
|
+
|
|
50
|
+
const generateOrderReference = () => {
|
|
51
|
+
>>>>>>> feature/apple-pay
|
|
40
52
|
const sequence = 1000 + Math.floor((Date.now() % 99000));
|
|
41
53
|
return generateLagOrderNumber(sequence);
|
|
42
54
|
};
|
|
@@ -52,13 +64,19 @@ const usePaymentActions = () => {
|
|
|
52
64
|
const [googlePayToken, setGooglePayToken] = useState(null);
|
|
53
65
|
const [applePayToken, setApplePayToken] = useState(null);
|
|
54
66
|
|
|
67
|
+
<<<<<<< HEAD
|
|
55
68
|
// Card details for 3DS testing
|
|
69
|
+
=======
|
|
70
|
+
>>>>>>> feature/apple-pay
|
|
56
71
|
const [cardtype, setCardtype] = useState("");
|
|
57
72
|
const [cardpan, setCardpan] = useState("");
|
|
58
73
|
const [cardexpiredate, setCardexpiredate] = useState("");
|
|
59
74
|
const [cardcvc2, setCardcvc2] = useState("");
|
|
60
75
|
|
|
76
|
+
<<<<<<< HEAD
|
|
61
77
|
// Payment processing state
|
|
78
|
+
=======
|
|
79
|
+
>>>>>>> feature/apple-pay
|
|
62
80
|
const [isProcessingPayment, setIsProcessingPayment] = useState(false);
|
|
63
81
|
const [paymentResult, setPaymentResult] = useState(null);
|
|
64
82
|
const [paymentError, setPaymentError] = useState(null);
|
|
@@ -88,19 +106,29 @@ const usePaymentActions = () => {
|
|
|
88
106
|
paymentMethod,
|
|
89
107
|
amount: paymentAmount
|
|
90
108
|
});
|
|
109
|
+
<<<<<<< HEAD
|
|
91
110
|
|
|
111
|
+
=======
|
|
112
|
+
|
|
113
|
+
>>>>>>> feature/apple-pay
|
|
92
114
|
setIsProcessingPayment(true);
|
|
93
115
|
setPaymentError(null);
|
|
94
116
|
setPaymentResult(null);
|
|
95
117
|
try {
|
|
118
|
+
<<<<<<< HEAD
|
|
96
119
|
// Auto-generate reference if empty
|
|
120
|
+
=======
|
|
121
|
+
>>>>>>> feature/apple-pay
|
|
97
122
|
const finalPreauthReference = preauthReference.trim() || generateOrderReference();
|
|
98
123
|
if (!preauthReference.trim()) {
|
|
99
124
|
setPreauthReference(finalPreauthReference);
|
|
100
125
|
}
|
|
101
126
|
|
|
127
|
+
<<<<<<< HEAD
|
|
102
128
|
// Determine currency based on card type
|
|
103
129
|
// American Express typically requires USD, other cards use EUR
|
|
130
|
+
=======
|
|
131
|
+
>>>>>>> feature/apple-pay
|
|
104
132
|
const currency = (paymentMethod === "cc" && cardtype === "A") ? "USD" : "EUR";
|
|
105
133
|
|
|
106
134
|
const baseParams = {
|
|
@@ -111,7 +139,10 @@ const usePaymentActions = () => {
|
|
|
111
139
|
...DEFAULT_PAYMENT_DATA
|
|
112
140
|
};
|
|
113
141
|
|
|
142
|
+
<<<<<<< HEAD
|
|
114
143
|
// Add card details if credit card payment and 3DS enabled
|
|
144
|
+
=======
|
|
145
|
+
>>>>>>> feature/apple-pay
|
|
115
146
|
if (paymentMethod === "cc" && settings.enable3DSecure !== false) {
|
|
116
147
|
if (cardtype) baseParams.cardtype = cardtype;
|
|
117
148
|
if (cardpan) baseParams.cardpan = cardpan;
|
|
@@ -125,7 +156,10 @@ const usePaymentActions = () => {
|
|
|
125
156
|
|
|
126
157
|
if (needsRedirectUrls) {
|
|
127
158
|
const baseUrl = window.location.origin;
|
|
159
|
+
<<<<<<< HEAD
|
|
128
160
|
// Detect current context (admin or content-ui) from pathname
|
|
161
|
+
=======
|
|
162
|
+
>>>>>>> feature/apple-pay
|
|
129
163
|
const currentPath = window.location.pathname;
|
|
130
164
|
const isContentUI = currentPath.includes('/content-ui') || currentPath.includes('/content-manager');
|
|
131
165
|
const basePath = isContentUI ? '/content-ui' : '/admin';
|
|
@@ -149,6 +183,7 @@ const usePaymentActions = () => {
|
|
|
149
183
|
|
|
150
184
|
const result = await payoneRequests.preauthorization(params);
|
|
151
185
|
const responseData = result?.data || result;
|
|
186
|
+
<<<<<<< HEAD
|
|
152
187
|
|
|
153
188
|
// Log full response
|
|
154
189
|
console.log("Preauthorization Response:", responseData);
|
|
@@ -164,15 +199,23 @@ const usePaymentActions = () => {
|
|
|
164
199
|
Url: responseData.Url
|
|
165
200
|
});
|
|
166
201
|
|
|
202
|
+
=======
|
|
203
|
+
>>>>>>> feature/apple-pay
|
|
167
204
|
const status = (responseData.status || responseData.Status || "").toUpperCase();
|
|
168
205
|
const errorCode = responseData.errorcode || responseData.errorCode || responseData.ErrorCode;
|
|
169
206
|
const errorMessage = responseData.errormessage || responseData.errorMessage || responseData.ErrorMessage;
|
|
170
207
|
|
|
208
|
+
<<<<<<< HEAD
|
|
171
209
|
// Check for 3DS required error (4219)
|
|
172
210
|
const requires3DSErrorCodes = ["4219", 4219];
|
|
173
211
|
const is3DSRequiredError = requires3DSErrorCodes.includes(errorCode);
|
|
174
212
|
|
|
175
213
|
// Check all possible redirect URL fields
|
|
214
|
+
=======
|
|
215
|
+
const requires3DSErrorCodes = ["4219", 4219];
|
|
216
|
+
const is3DSRequiredError = requires3DSErrorCodes.includes(errorCode);
|
|
217
|
+
|
|
218
|
+
>>>>>>> feature/apple-pay
|
|
176
219
|
const redirectUrl =
|
|
177
220
|
responseData.redirectUrl ||
|
|
178
221
|
responseData.redirecturl ||
|
|
@@ -182,7 +225,10 @@ const usePaymentActions = () => {
|
|
|
182
225
|
responseData.Url ||
|
|
183
226
|
null;
|
|
184
227
|
|
|
228
|
+
<<<<<<< HEAD
|
|
185
229
|
// If 3DS required but no redirect URL, show helpful message
|
|
230
|
+
=======
|
|
231
|
+
>>>>>>> feature/apple-pay
|
|
186
232
|
if (is3DSRequiredError && !redirectUrl) {
|
|
187
233
|
console.warn("3DS authentication required (Error 4219) but no redirect URL found in response");
|
|
188
234
|
console.log("Full response:", JSON.stringify(responseData, null, 2));
|
|
@@ -194,7 +240,10 @@ const usePaymentActions = () => {
|
|
|
194
240
|
return;
|
|
195
241
|
}
|
|
196
242
|
|
|
243
|
+
<<<<<<< HEAD
|
|
197
244
|
// Check for other errors (but not 3DS required)
|
|
245
|
+
=======
|
|
246
|
+
>>>>>>> feature/apple-pay
|
|
198
247
|
if ((status === "ERROR" || status === "INVALID" || errorCode) && !is3DSRequiredError) {
|
|
199
248
|
setPaymentError(
|
|
200
249
|
errorMessage ||
|
|
@@ -217,6 +266,7 @@ const usePaymentActions = () => {
|
|
|
217
266
|
|
|
218
267
|
setPaymentResult(responseData);
|
|
219
268
|
|
|
269
|
+
<<<<<<< HEAD
|
|
220
270
|
console.log("[Payment] Preauthorization result:", {
|
|
221
271
|
status,
|
|
222
272
|
hasError: !!errorCode,
|
|
@@ -227,6 +277,10 @@ const usePaymentActions = () => {
|
|
|
227
277
|
if (status === "APPROVED") {
|
|
228
278
|
handlePaymentSuccess("Preauthorization completed successfully");
|
|
229
279
|
// Return success result for Apple Pay callback
|
|
280
|
+
=======
|
|
281
|
+
if (status === "APPROVED") {
|
|
282
|
+
handlePaymentSuccess("Preauthorization completed successfully");
|
|
283
|
+
>>>>>>> feature/apple-pay
|
|
230
284
|
return { success: true, data: responseData };
|
|
231
285
|
} else {
|
|
232
286
|
const errorMsg = errorMessage || `Unexpected status: ${status}`;
|
|
@@ -234,13 +288,19 @@ const usePaymentActions = () => {
|
|
|
234
288
|
{ message: errorMsg },
|
|
235
289
|
`Preauthorization completed with status: ${status}`
|
|
236
290
|
);
|
|
291
|
+
<<<<<<< HEAD
|
|
237
292
|
// Return error result for Apple Pay callback
|
|
293
|
+
=======
|
|
294
|
+
>>>>>>> feature/apple-pay
|
|
238
295
|
throw new Error(errorMsg);
|
|
239
296
|
}
|
|
240
297
|
} catch (error) {
|
|
241
298
|
console.error("[Payment] Preauthorization error:", error);
|
|
242
299
|
handlePaymentError(error, "Preauthorization failed");
|
|
300
|
+
<<<<<<< HEAD
|
|
243
301
|
// Re-throw error so Apple Pay callback knows it failed
|
|
302
|
+
=======
|
|
303
|
+
>>>>>>> feature/apple-pay
|
|
244
304
|
throw error;
|
|
245
305
|
} finally {
|
|
246
306
|
setIsProcessingPayment(false);
|
|
@@ -253,14 +313,20 @@ const usePaymentActions = () => {
|
|
|
253
313
|
setPaymentResult(null);
|
|
254
314
|
|
|
255
315
|
try {
|
|
316
|
+
<<<<<<< HEAD
|
|
256
317
|
// Auto-generate reference if empty
|
|
318
|
+
=======
|
|
319
|
+
>>>>>>> feature/apple-pay
|
|
257
320
|
const finalAuthReference = authReference.trim() || generateOrderReference();
|
|
258
321
|
if (!authReference.trim()) {
|
|
259
322
|
setAuthReference(finalAuthReference);
|
|
260
323
|
}
|
|
261
324
|
|
|
325
|
+
<<<<<<< HEAD
|
|
262
326
|
// Determine currency based on card type
|
|
263
327
|
// American Express typically requires USD, other cards use EUR
|
|
328
|
+
=======
|
|
329
|
+
>>>>>>> feature/apple-pay
|
|
264
330
|
const currency = (paymentMethod === "cc" && cardtype === "A") ? "USD" : "EUR";
|
|
265
331
|
|
|
266
332
|
const baseParams = {
|
|
@@ -271,7 +337,10 @@ const usePaymentActions = () => {
|
|
|
271
337
|
...DEFAULT_PAYMENT_DATA
|
|
272
338
|
};
|
|
273
339
|
|
|
340
|
+
<<<<<<< HEAD
|
|
274
341
|
// Add card details if credit card payment and 3DS enabled
|
|
342
|
+
=======
|
|
343
|
+
>>>>>>> feature/apple-pay
|
|
275
344
|
if (paymentMethod === "cc" && settings.enable3DSecure !== false) {
|
|
276
345
|
if (cardtype) baseParams.cardtype = cardtype;
|
|
277
346
|
if (cardpan) baseParams.cardpan = cardpan;
|
|
@@ -285,7 +354,10 @@ const usePaymentActions = () => {
|
|
|
285
354
|
|
|
286
355
|
if (needsRedirectUrls) {
|
|
287
356
|
const baseUrl = window.location.origin;
|
|
357
|
+
<<<<<<< HEAD
|
|
288
358
|
// Detect current context (admin or content-ui) from pathname
|
|
359
|
+
=======
|
|
360
|
+
>>>>>>> feature/apple-pay
|
|
289
361
|
const currentPath = window.location.pathname;
|
|
290
362
|
const isContentUI = currentPath.includes('/content-ui') || currentPath.includes('/content-manager');
|
|
291
363
|
const basePath = isContentUI ? '/content-ui' : '/admin';
|
|
@@ -309,6 +381,7 @@ const usePaymentActions = () => {
|
|
|
309
381
|
|
|
310
382
|
const result = await payoneRequests.authorization(params);
|
|
311
383
|
const responseData = result?.data || result;
|
|
384
|
+
<<<<<<< HEAD
|
|
312
385
|
|
|
313
386
|
// Log full response
|
|
314
387
|
console.log("Authorization Response:", responseData);
|
|
@@ -324,15 +397,23 @@ const usePaymentActions = () => {
|
|
|
324
397
|
Url: responseData.Url
|
|
325
398
|
});
|
|
326
399
|
|
|
400
|
+
=======
|
|
401
|
+
>>>>>>> feature/apple-pay
|
|
327
402
|
const status = (responseData.status || responseData.Status || "").toUpperCase();
|
|
328
403
|
const errorCode = responseData.errorcode || responseData.errorCode || responseData.ErrorCode;
|
|
329
404
|
const errorMessage = responseData.errormessage || responseData.errorMessage || responseData.ErrorMessage;
|
|
330
405
|
|
|
406
|
+
<<<<<<< HEAD
|
|
331
407
|
// Check for 3DS required error (4219)
|
|
332
408
|
const requires3DSErrorCodes = ["4219", 4219];
|
|
333
409
|
const is3DSRequiredError = requires3DSErrorCodes.includes(errorCode);
|
|
334
410
|
|
|
335
411
|
// Check all possible redirect URL fields
|
|
412
|
+
=======
|
|
413
|
+
const requires3DSErrorCodes = ["4219", 4219];
|
|
414
|
+
const is3DSRequiredError = requires3DSErrorCodes.includes(errorCode);
|
|
415
|
+
|
|
416
|
+
>>>>>>> feature/apple-pay
|
|
336
417
|
const redirectUrl =
|
|
337
418
|
responseData.redirectUrl ||
|
|
338
419
|
responseData.redirecturl ||
|
|
@@ -342,7 +423,10 @@ const usePaymentActions = () => {
|
|
|
342
423
|
responseData.Url ||
|
|
343
424
|
null;
|
|
344
425
|
|
|
426
|
+
<<<<<<< HEAD
|
|
345
427
|
// If 3DS required but no redirect URL, show helpful message
|
|
428
|
+
=======
|
|
429
|
+
>>>>>>> feature/apple-pay
|
|
346
430
|
if (is3DSRequiredError && !redirectUrl) {
|
|
347
431
|
console.warn("3DS authentication required (Error 4219) but no redirect URL found in response");
|
|
348
432
|
console.log("Full response:", JSON.stringify(responseData, null, 2));
|
|
@@ -354,7 +438,10 @@ const usePaymentActions = () => {
|
|
|
354
438
|
return;
|
|
355
439
|
}
|
|
356
440
|
|
|
441
|
+
<<<<<<< HEAD
|
|
357
442
|
// Check for other errors (but not 3DS required)
|
|
443
|
+
=======
|
|
444
|
+
>>>>>>> feature/apple-pay
|
|
358
445
|
if ((status === "ERROR" || status === "INVALID" || errorCode) && !is3DSRequiredError) {
|
|
359
446
|
setPaymentError(
|
|
360
447
|
errorMessage ||
|
|
@@ -377,6 +464,7 @@ const usePaymentActions = () => {
|
|
|
377
464
|
|
|
378
465
|
setPaymentResult(responseData);
|
|
379
466
|
|
|
467
|
+
<<<<<<< HEAD
|
|
380
468
|
console.log("[Payment] Authorization result:", {
|
|
381
469
|
status,
|
|
382
470
|
hasError: !!errorCode,
|
|
@@ -384,6 +472,8 @@ const usePaymentActions = () => {
|
|
|
384
472
|
errorMessage
|
|
385
473
|
});
|
|
386
474
|
|
|
475
|
+
=======
|
|
476
|
+
>>>>>>> feature/apple-pay
|
|
387
477
|
if (status === "APPROVED") {
|
|
388
478
|
handlePaymentSuccess("Authorization completed successfully");
|
|
389
479
|
// Return success result for Apple Pay callback
|
|
@@ -394,13 +484,19 @@ const usePaymentActions = () => {
|
|
|
394
484
|
{ message: errorMsg },
|
|
395
485
|
`Authorization completed with status: ${status}`
|
|
396
486
|
);
|
|
487
|
+
<<<<<<< HEAD
|
|
397
488
|
// Return error result for Apple Pay callback
|
|
489
|
+
=======
|
|
490
|
+
>>>>>>> feature/apple-pay
|
|
398
491
|
throw new Error(errorMsg);
|
|
399
492
|
}
|
|
400
493
|
} catch (error) {
|
|
401
494
|
console.error("[Payment] Authorization error:", error);
|
|
402
495
|
handlePaymentError(error, "Authorization failed");
|
|
496
|
+
<<<<<<< HEAD
|
|
403
497
|
// Re-throw error so Apple Pay callback knows it failed
|
|
498
|
+
=======
|
|
499
|
+
>>>>>>> feature/apple-pay
|
|
404
500
|
throw error;
|
|
405
501
|
} finally {
|
|
406
502
|
setIsProcessingPayment(false);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "strapi-plugin-payone-provider",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "Strapi plugin for Payone payment gateway integration",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"maintainers": [
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
}
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"axios": "^1.6.
|
|
13
|
+
"axios": "^1.6.3",
|
|
14
14
|
"prop-types": "^15.7.2"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
package/server/bootstrap.js
CHANGED
|
@@ -53,6 +53,11 @@ module.exports = async ({ strapi }) => {
|
|
|
53
53
|
try {
|
|
54
54
|
const Router = require('@koa/router');
|
|
55
55
|
const router = new Router();
|
|
56
|
+
<<<<<<< HEAD
|
|
57
|
+
=======
|
|
58
|
+
const fs = require('fs');
|
|
59
|
+
const path = require('path');
|
|
60
|
+
>>>>>>> feature/apple-pay
|
|
56
61
|
|
|
57
62
|
routes.forEach(route => {
|
|
58
63
|
router.get(route, async (ctx) => {
|
|
@@ -61,7 +66,67 @@ module.exports = async ({ strapi }) => {
|
|
|
61
66
|
});
|
|
62
67
|
});
|
|
63
68
|
|
|
69
|
+
<<<<<<< HEAD
|
|
64
70
|
// Add router to the server app
|
|
71
|
+
=======
|
|
72
|
+
// Register route for Apple Pay .well-known file
|
|
73
|
+
router.get('/.well-known/apple-developer-merchantid-domain-association', async (ctx) => {
|
|
74
|
+
try {
|
|
75
|
+
const publicPath = path.join(process.cwd(), 'public');
|
|
76
|
+
const wellKnownPath = path.join(publicPath, '.well-known');
|
|
77
|
+
const filePath = path.join(wellKnownPath, 'apple-developer-merchantid-domain-association');
|
|
78
|
+
const filePathTxt = path.join(wellKnownPath, 'apple-developer-merchant-id-domain-association.txt');
|
|
79
|
+
|
|
80
|
+
let fileContent = null;
|
|
81
|
+
let filePathFound = null;
|
|
82
|
+
|
|
83
|
+
// Try main file first
|
|
84
|
+
if (fs.existsSync(filePath)) {
|
|
85
|
+
filePathFound = filePath;
|
|
86
|
+
fileContent = fs.readFileSync(filePath, 'utf8');
|
|
87
|
+
}
|
|
88
|
+
// Try alternative file name
|
|
89
|
+
else if (fs.existsSync(filePathTxt)) {
|
|
90
|
+
filePathFound = filePathTxt;
|
|
91
|
+
fileContent = fs.readFileSync(filePathTxt, 'utf8');
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (fileContent) {
|
|
95
|
+
ctx.type = 'text/plain';
|
|
96
|
+
ctx.body = fileContent;
|
|
97
|
+
strapi.log.info(`[Apple Pay] Served well-known file from: ${filePathFound}`);
|
|
98
|
+
} else {
|
|
99
|
+
strapi.log.warn(`[Apple Pay] Well-known file not found. Tried: ${filePath} and ${filePathTxt}`);
|
|
100
|
+
ctx.status = 404;
|
|
101
|
+
ctx.body = {
|
|
102
|
+
error: {
|
|
103
|
+
status: 404,
|
|
104
|
+
name: "NotFoundError",
|
|
105
|
+
message: "Apple Pay domain verification file not found",
|
|
106
|
+
details: {
|
|
107
|
+
expectedPaths: [
|
|
108
|
+
filePath,
|
|
109
|
+
filePathTxt
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
} catch (error) {
|
|
116
|
+
strapi.log.error("[Apple Pay] Serve well-known file error:", error);
|
|
117
|
+
ctx.status = 500;
|
|
118
|
+
ctx.body = {
|
|
119
|
+
error: {
|
|
120
|
+
status: 500,
|
|
121
|
+
name: "InternalServerError",
|
|
122
|
+
message: error.message || "Failed to serve well-known file",
|
|
123
|
+
details: error.stack
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
>>>>>>> feature/apple-pay
|
|
65
130
|
if (strapi.server.app && typeof strapi.server.app.use === 'function') {
|
|
66
131
|
strapi.server.app.use(router.routes());
|
|
67
132
|
strapi.server.app.use(router.allowedMethods());
|
|
@@ -2,30 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
const PLUGIN_NAME = "strapi-plugin-payone-provider";
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* Get Payone service
|
|
7
|
-
* @param {Object} strapi - Strapi instance
|
|
8
|
-
* @returns {Object} Payone service
|
|
9
|
-
*/
|
|
10
5
|
const getPayoneService = (strapi) => {
|
|
11
6
|
return strapi.plugin(PLUGIN_NAME).service("payone");
|
|
12
7
|
};
|
|
13
8
|
|
|
14
|
-
/**
|
|
15
|
-
* Handle error response
|
|
16
|
-
* @param {Object} ctx - Koa context
|
|
17
|
-
* @param {Error} error - Error object
|
|
18
|
-
*/
|
|
19
9
|
const handleError = (ctx, error) => {
|
|
20
10
|
ctx.strapi.log.error("Payone controller error:", error);
|
|
21
11
|
ctx.throw(500, error);
|
|
22
12
|
};
|
|
23
13
|
|
|
24
|
-
/**
|
|
25
|
-
* Hide sensitive key in settings
|
|
26
|
-
* @param {Object} settings - Settings object
|
|
27
|
-
* @returns {Object} Settings with hidden key
|
|
28
|
-
*/
|
|
29
14
|
const hideKey = (settings) => {
|
|
30
15
|
if (settings && settings.key) {
|
|
31
16
|
settings.key = "***HIDDEN***";
|
|
@@ -134,11 +119,6 @@ module.exports = ({ strapi }) => ({
|
|
|
134
119
|
}
|
|
135
120
|
},
|
|
136
121
|
|
|
137
|
-
/**
|
|
138
|
-
* Handle 3D Secure callback from Payone
|
|
139
|
-
* This endpoint receives the callback after customer completes 3DS authentication
|
|
140
|
-
* Works with both /admin/ and /content-ui/ paths
|
|
141
|
-
*/
|
|
142
122
|
async handle3DSCallback(ctx) {
|
|
143
123
|
try {
|
|
144
124
|
const isGetRequest = ctx.request.method === "GET";
|
|
@@ -180,33 +160,11 @@ module.exports = ({ strapi }) => ({
|
|
|
180
160
|
|
|
181
161
|
async validateApplePayMerchant(ctx) {
|
|
182
162
|
try {
|
|
183
|
-
strapi.log.info("[Apple Pay] Merchant validation request received");
|
|
184
163
|
strapi.log.info("[Apple Pay] Request body:", JSON.stringify(ctx.request.body, null, 2));
|
|
185
|
-
strapi.log.info("[Apple Pay] User:", ctx.state.user ? {
|
|
186
|
-
id: ctx.state.user.id,
|
|
187
|
-
email: ctx.state.user.email,
|
|
188
|
-
roles: ctx.state.user.roles?.map(r => r.code)
|
|
189
|
-
} : "No user");
|
|
190
164
|
|
|
191
165
|
const params = ctx.request.body;
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
strapi.log.info("[Apple Pay] Merchant validation result:", {
|
|
195
|
-
hasResult: !!result,
|
|
196
|
-
hasMerchantIdentifier: !!result.merchantIdentifier,
|
|
197
|
-
merchantIdentifier: result.merchantIdentifier,
|
|
198
|
-
domainName: result.domainName,
|
|
199
|
-
displayName: result.displayName,
|
|
200
|
-
epochTimestamp: result.epochTimestamp,
|
|
201
|
-
expiresAt: result.expiresAt
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
// Validate result before sending
|
|
205
|
-
if (!result || !result.merchantIdentifier) {
|
|
206
|
-
strapi.log.error("[Apple Pay] Invalid merchant session returned - missing merchantIdentifier");
|
|
207
|
-
ctx.throw(500, "Apple Pay merchant validation failed: Invalid merchant session. Please check your Payone Apple Pay configuration in PMI.");
|
|
208
|
-
}
|
|
209
|
-
|
|
166
|
+
let result = await getPayoneService(strapi).validateApplePayMerchant(params);
|
|
167
|
+
strapi.log.info("[Apple Pay] Merchant validation result:", JSON.stringify(result, null, 2));
|
|
210
168
|
ctx.body = { data: result };
|
|
211
169
|
} catch (error) {
|
|
212
170
|
strapi.log.error("[Apple Pay] Controller error:", {
|
|
@@ -214,11 +172,9 @@ module.exports = ({ strapi }) => ({
|
|
|
214
172
|
stack: error.stack,
|
|
215
173
|
name: error.name
|
|
216
174
|
});
|
|
217
|
-
|
|
218
|
-
// Return error response instead of empty object
|
|
219
|
-
// This will help frontend understand what went wrong
|
|
175
|
+
|
|
220
176
|
ctx.status = error.status || 500;
|
|
221
|
-
ctx.body = {
|
|
177
|
+
ctx.body = {
|
|
222
178
|
error: {
|
|
223
179
|
message: error.message || "Apple Pay merchant validation failed",
|
|
224
180
|
details: "Please check your Payone Apple Pay configuration in PMI (CONFIGURATION → PAYMENT PORTALS → [Your Portal] → Apple Pay)"
|