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
|
@@ -42,7 +42,7 @@ const ApplePayButton = ({
|
|
|
42
42
|
const checkApplePayAvailability = async () => {
|
|
43
43
|
try {
|
|
44
44
|
console.log("[Apple Pay] Checking availability...");
|
|
45
|
-
|
|
45
|
+
|
|
46
46
|
// Check secure context using browser's native property
|
|
47
47
|
// This is the most reliable way to check if we're in a secure context
|
|
48
48
|
const isSecureContext = typeof window !== 'undefined' && window.isSecureContext;
|
|
@@ -57,7 +57,7 @@ const ApplePayButton = ({
|
|
|
57
57
|
// - 127.0.0.1 (even on HTTP)
|
|
58
58
|
// - file:// URLs
|
|
59
59
|
const isSecure = isSecureContext || isLocalhost;
|
|
60
|
-
|
|
60
|
+
|
|
61
61
|
console.log("[Apple Pay] Secure context check:", {
|
|
62
62
|
isSecureContext: isSecureContext,
|
|
63
63
|
protocol: protocol,
|
|
@@ -78,12 +78,12 @@ const ApplePayButton = ({
|
|
|
78
78
|
reason: !isSecureContext ? "window.isSecureContext is false" : "Unknown"
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
|
-
|
|
81
|
+
|
|
82
82
|
// First, check if Payment Request API is available
|
|
83
83
|
// Payment Request API works on HTTP too, but Apple Pay JS API requires HTTPS
|
|
84
84
|
if (typeof window === 'undefined' || !window.PaymentRequest) {
|
|
85
85
|
console.log("[Apple Pay] Payment Request API not available");
|
|
86
|
-
|
|
86
|
+
|
|
87
87
|
// Fallback: Check Apple Pay JS API (for Safari, requires HTTPS)
|
|
88
88
|
if (typeof window !== 'undefined' && window.ApplePaySession && isSecure) {
|
|
89
89
|
try {
|
|
@@ -95,11 +95,11 @@ const ApplePayButton = ({
|
|
|
95
95
|
return { available: false, method: null, error: 'insecure_context' };
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
-
|
|
98
|
+
|
|
99
99
|
if (!isSecure && typeof window !== 'undefined' && window.ApplePaySession) {
|
|
100
100
|
console.warn("[Apple Pay] Apple Pay JS API requires HTTPS. Using Payment Request API fallback.");
|
|
101
101
|
}
|
|
102
|
-
|
|
102
|
+
|
|
103
103
|
console.log("[Apple Pay] No Apple Pay support found");
|
|
104
104
|
return { available: false, method: null };
|
|
105
105
|
}
|
|
@@ -152,11 +152,11 @@ const ApplePayButton = ({
|
|
|
152
152
|
try {
|
|
153
153
|
const canPay = await testRequest.canMakePayment();
|
|
154
154
|
console.log("[Apple Pay] canMakePayment result:", canPay);
|
|
155
|
-
|
|
155
|
+
|
|
156
156
|
if (canPay) {
|
|
157
157
|
return { available: true, method: 'paymentRequest' };
|
|
158
158
|
}
|
|
159
|
-
|
|
159
|
+
|
|
160
160
|
// If PaymentRequest says no, try Apple Pay JS API as fallback (only on HTTPS)
|
|
161
161
|
if (typeof window !== 'undefined' && window.ApplePaySession && isSecure) {
|
|
162
162
|
try {
|
|
@@ -172,17 +172,17 @@ const ApplePayButton = ({
|
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
|
-
|
|
175
|
+
|
|
176
176
|
return { available: false, method: null };
|
|
177
177
|
} catch (e) {
|
|
178
178
|
console.error("[Apple Pay] Error checking canMakePayment:", e);
|
|
179
|
-
|
|
179
|
+
|
|
180
180
|
// If it's insecure context error, we can't use Apple Pay JS API
|
|
181
181
|
if (e.message && e.message.includes('insecure')) {
|
|
182
182
|
console.warn("[Apple Pay] Insecure context detected. Apple Pay requires HTTPS.");
|
|
183
183
|
return { available: false, method: null, error: 'insecure_context' };
|
|
184
184
|
}
|
|
185
|
-
|
|
185
|
+
|
|
186
186
|
// For other errors, try Apple Pay JS API as fallback (only on HTTPS)
|
|
187
187
|
if (typeof window !== 'undefined' && window.ApplePaySession && isSecure) {
|
|
188
188
|
try {
|
|
@@ -193,7 +193,7 @@ const ApplePayButton = ({
|
|
|
193
193
|
return { available: false, method: null };
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
|
-
|
|
196
|
+
|
|
197
197
|
return { available: false, method: null };
|
|
198
198
|
}
|
|
199
199
|
}
|
|
@@ -204,7 +204,7 @@ const ApplePayButton = ({
|
|
|
204
204
|
const hostnameFinal = typeof window !== 'undefined' ? window.location.hostname : '';
|
|
205
205
|
const isLocalhostFinal = hostnameFinal === 'localhost' || hostnameFinal === '127.0.0.1';
|
|
206
206
|
const isSecureFinal = isSecureContextFinal || isLocalhostFinal;
|
|
207
|
-
|
|
207
|
+
|
|
208
208
|
if (isSecureFinal) {
|
|
209
209
|
console.log("[Apple Pay] canMakePayment not available, assuming support (secure context)");
|
|
210
210
|
return { available: true, method: 'paymentRequest' };
|
|
@@ -219,20 +219,20 @@ const ApplePayButton = ({
|
|
|
219
219
|
}
|
|
220
220
|
} catch (error) {
|
|
221
221
|
console.error("[Apple Pay] Error checking availability:", error);
|
|
222
|
-
|
|
222
|
+
|
|
223
223
|
// Check if it's insecure context error
|
|
224
224
|
if (error.message && error.message.includes('insecure')) {
|
|
225
225
|
console.warn("[Apple Pay] Insecure context - Apple Pay requires HTTPS");
|
|
226
226
|
return { available: false, method: null, error: 'insecure_context' };
|
|
227
227
|
}
|
|
228
|
-
|
|
228
|
+
|
|
229
229
|
// Fallback: Try Apple Pay JS API (only on HTTPS)
|
|
230
230
|
// Re-check secure context
|
|
231
231
|
const isSecureContextFallback = typeof window !== 'undefined' && window.isSecureContext;
|
|
232
232
|
const hostnameFallback = typeof window !== 'undefined' ? window.location.hostname : '';
|
|
233
233
|
const isLocalhostFallback = hostnameFallback === 'localhost' || hostnameFallback === '127.0.0.1';
|
|
234
234
|
const isSecureFallback = isSecureContextFallback || isLocalhostFallback;
|
|
235
|
-
|
|
235
|
+
|
|
236
236
|
if (typeof window !== 'undefined' && window.ApplePaySession && isSecureFallback) {
|
|
237
237
|
try {
|
|
238
238
|
const canMakePayments = ApplePaySession.canMakePayments();
|
|
@@ -244,16 +244,16 @@ const ApplePayButton = ({
|
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
|
-
|
|
247
|
+
|
|
248
248
|
return { available: false, method: null };
|
|
249
249
|
}
|
|
250
250
|
};
|
|
251
251
|
|
|
252
252
|
useEffect(() => {
|
|
253
253
|
const scriptUrl = "https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js";
|
|
254
|
-
|
|
254
|
+
|
|
255
255
|
console.log("[Apple Pay] Loading Apple Pay SDK script...");
|
|
256
|
-
|
|
256
|
+
|
|
257
257
|
if (document.querySelector(`script[src="${scriptUrl}"]`)) {
|
|
258
258
|
console.log("[Apple Pay] Script already loaded");
|
|
259
259
|
// Script already loaded, check if it's ready
|
|
@@ -270,20 +270,20 @@ const ApplePayButton = ({
|
|
|
270
270
|
script.src = scriptUrl;
|
|
271
271
|
script.crossOrigin = "anonymous";
|
|
272
272
|
script.async = true;
|
|
273
|
-
|
|
273
|
+
|
|
274
274
|
script.onload = () => {
|
|
275
275
|
console.log("[Apple Pay] SDK script loaded successfully");
|
|
276
276
|
setTimeout(() => {
|
|
277
277
|
initializeButton();
|
|
278
278
|
}, 500);
|
|
279
279
|
};
|
|
280
|
-
|
|
280
|
+
|
|
281
281
|
script.onerror = (error) => {
|
|
282
282
|
console.error("[Apple Pay] Failed to load SDK script:", error);
|
|
283
283
|
setIsLoading(false);
|
|
284
284
|
setIsAvailable(false);
|
|
285
285
|
setErrorMessage("Failed to load Apple Pay SDK. Please check Content Security Policy settings.");
|
|
286
|
-
|
|
286
|
+
|
|
287
287
|
// Even if script fails, try to use Payment Request API
|
|
288
288
|
console.log("[Apple Pay] Trying Payment Request API as fallback...");
|
|
289
289
|
setTimeout(() => {
|
|
@@ -306,22 +306,22 @@ const ApplePayButton = ({
|
|
|
306
306
|
const initializeButton = async () => {
|
|
307
307
|
try {
|
|
308
308
|
console.log("[Apple Pay] Initializing button...");
|
|
309
|
-
|
|
310
|
-
const isSecure = typeof window !== 'undefined' &&
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
309
|
+
|
|
310
|
+
const isSecure = typeof window !== 'undefined' &&
|
|
311
|
+
(window.location.protocol === 'https:' ||
|
|
312
|
+
window.location.hostname === 'localhost' ||
|
|
313
|
+
window.location.hostname === '127.0.0.1');
|
|
314
|
+
|
|
315
315
|
console.log("[Apple Pay] Secure context check:", {
|
|
316
316
|
protocol: window.location?.protocol,
|
|
317
317
|
hostname: window.location?.hostname,
|
|
318
318
|
isSecure: isSecure
|
|
319
319
|
});
|
|
320
|
-
|
|
321
|
-
const isLocalhost = typeof window !== 'undefined' &&
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
320
|
+
|
|
321
|
+
const isLocalhost = typeof window !== 'undefined' &&
|
|
322
|
+
(window.location.hostname === 'localhost' ||
|
|
323
|
+
window.location.hostname === '127.0.0.1');
|
|
324
|
+
|
|
325
325
|
if (!isSecure && !isLocalhost && window.location?.protocol === 'http:') {
|
|
326
326
|
const errorMsg = "Apple Pay requires HTTPS. Please access this page via HTTPS (https://yourdomain.com) instead of HTTP. Localhost (http://localhost) is allowed for development.";
|
|
327
327
|
setErrorMessage(errorMsg);
|
|
@@ -331,7 +331,7 @@ const ApplePayButton = ({
|
|
|
331
331
|
console.warn("[Apple Pay] Current URL:", window.location.href);
|
|
332
332
|
return;
|
|
333
333
|
}
|
|
334
|
-
|
|
334
|
+
|
|
335
335
|
// Log context information
|
|
336
336
|
console.log("[Apple Pay] Context info:", {
|
|
337
337
|
protocol: window.location?.protocol,
|
|
@@ -340,16 +340,16 @@ const ApplePayButton = ({
|
|
|
340
340
|
isLocalhost: isLocalhost,
|
|
341
341
|
fullUrl: window.location?.href
|
|
342
342
|
});
|
|
343
|
-
|
|
343
|
+
|
|
344
344
|
// Check availability
|
|
345
345
|
const availability = await checkApplePayAvailability();
|
|
346
346
|
console.log("[Apple Pay] Availability check result:", availability);
|
|
347
|
-
|
|
347
|
+
|
|
348
348
|
setIsAvailable(availability.available);
|
|
349
|
-
|
|
349
|
+
|
|
350
350
|
if (!availability.available) {
|
|
351
351
|
let errorMsg = "Apple Pay is not available on this device or browser.";
|
|
352
|
-
|
|
352
|
+
|
|
353
353
|
if (isLocalhost) {
|
|
354
354
|
errorMsg = "Apple Pay is not available on localhost. Apple Pay requires a registered domain with HTTPS. " +
|
|
355
355
|
"For testing, please use a production domain with HTTPS or test on a device with Safari (iOS/macOS). " +
|
|
@@ -366,7 +366,7 @@ const ApplePayButton = ({
|
|
|
366
366
|
} else {
|
|
367
367
|
errorMsg += " Please use Safari on iOS, macOS, or iPadOS, or a browser that supports Payment Request API (Chrome, Edge, Safari).";
|
|
368
368
|
}
|
|
369
|
-
|
|
369
|
+
|
|
370
370
|
setErrorMessage(errorMsg);
|
|
371
371
|
setIsLoading(false);
|
|
372
372
|
console.warn("[Apple Pay] Not available:", errorMsg);
|
|
@@ -380,14 +380,14 @@ const ApplePayButton = ({
|
|
|
380
380
|
console.error("[Apple Pay] Initialization error:", error);
|
|
381
381
|
setIsLoading(false);
|
|
382
382
|
setIsAvailable(false);
|
|
383
|
-
|
|
383
|
+
|
|
384
384
|
// Check for insecure context error
|
|
385
385
|
if (error.message && error.message.includes('insecure')) {
|
|
386
386
|
setErrorMessage("Apple Pay requires HTTPS. Please access this page via HTTPS (https://yourdomain.com) instead of HTTP. Localhost is allowed for development.");
|
|
387
387
|
} else {
|
|
388
388
|
setErrorMessage(error.message || "Failed to initialize Apple Pay");
|
|
389
389
|
}
|
|
390
|
-
|
|
390
|
+
|
|
391
391
|
if (onError) {
|
|
392
392
|
onError(error);
|
|
393
393
|
}
|
|
@@ -406,11 +406,11 @@ const ApplePayButton = ({
|
|
|
406
406
|
});
|
|
407
407
|
|
|
408
408
|
// Check HTTPS requirement
|
|
409
|
-
const isSecure = typeof window !== 'undefined' &&
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
409
|
+
const isSecure = typeof window !== 'undefined' &&
|
|
410
|
+
(window.location.protocol === 'https:' ||
|
|
411
|
+
window.location.hostname === 'localhost' ||
|
|
412
|
+
window.location.hostname === '127.0.0.1');
|
|
413
|
+
|
|
414
414
|
if (!isSecure && window.location?.protocol === 'http:') {
|
|
415
415
|
const errorMsg = "Apple Pay requires HTTPS. Please access this page via HTTPS.";
|
|
416
416
|
console.error("[Apple Pay]", errorMsg);
|
|
@@ -496,16 +496,35 @@ const ApplePayButton = ({
|
|
|
496
496
|
});
|
|
497
497
|
|
|
498
498
|
merchantSessionPromise.then(session => {
|
|
499
|
-
console.log("[Apple Pay]
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
499
|
+
console.log("[Apple Pay] ========== MERCHANT SESSION RECEIVED ==========");
|
|
500
|
+
console.log("[Apple Pay] Full Merchant Session (JSON):", JSON.stringify(session, null, 2));
|
|
501
|
+
console.log("[Apple Pay] Session Type:", typeof session);
|
|
502
|
+
console.log("[Apple Pay] Is Object:", session instanceof Object);
|
|
503
|
+
console.log("[Apple Pay] Session Keys:", Object.keys(session || {}));
|
|
504
|
+
console.log("[Apple Pay] Session Keys Count:", Object.keys(session || {}).length);
|
|
505
|
+
console.log("[Apple Pay] Has Merchant Identifier:", !!session?.merchantIdentifier);
|
|
506
|
+
console.log("[Apple Pay] Merchant Identifier:", session?.merchantIdentifier);
|
|
507
|
+
console.log("[Apple Pay] Has Merchant Session Identifier:", !!session?.merchantSessionIdentifier);
|
|
508
|
+
console.log("[Apple Pay] Merchant Session Identifier:", session?.merchantSessionIdentifier);
|
|
509
|
+
console.log("[Apple Pay] Domain Name:", session?.domainName);
|
|
510
|
+
console.log("[Apple Pay] Display Name:", session?.displayName);
|
|
511
|
+
console.log("[Apple Pay] Epoch Timestamp:", session?.epochTimestamp);
|
|
512
|
+
console.log("[Apple Pay] Expires At:", session?.expiresAt);
|
|
513
|
+
console.log("[Apple Pay] Nonce:", session?.nonce);
|
|
514
|
+
|
|
515
|
+
// Log all properties
|
|
516
|
+
console.log("[Apple Pay] All Session Properties:");
|
|
517
|
+
if (session && typeof session === 'object') {
|
|
518
|
+
for (const [key, value] of Object.entries(session)) {
|
|
519
|
+
if (typeof value === 'string' && value.length > 200) {
|
|
520
|
+
console.log(`[Apple Pay] ${key}:`, value.substring(0, 200) + "... (truncated, length: " + value.length + ")");
|
|
521
|
+
} else {
|
|
522
|
+
console.log(`[Apple Pay] ${key}:`, value);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
console.log("[Apple Pay] ==========================================");
|
|
527
|
+
|
|
509
528
|
// Validate merchant session
|
|
510
529
|
if (!session || (!session.merchantIdentifier && !session.merchantSessionIdentifier)) {
|
|
511
530
|
console.error("[Apple Pay] Invalid merchant session - missing merchantIdentifier");
|
|
@@ -528,12 +547,12 @@ const ApplePayButton = ({
|
|
|
528
547
|
stack: error.stack,
|
|
529
548
|
response: error.response
|
|
530
549
|
});
|
|
531
|
-
|
|
550
|
+
|
|
532
551
|
// Call onError to notify the user
|
|
533
552
|
if (typeof onError === 'function') {
|
|
534
553
|
onError(new Error(`Apple Pay merchant validation failed: ${error.message}. Please check your Payone Apple Pay configuration in PMI (CONFIGURATION → PAYMENT PORTALS → [Your Portal] → Apple Pay).`));
|
|
535
554
|
}
|
|
536
|
-
|
|
555
|
+
|
|
537
556
|
// Complete with a rejected promise
|
|
538
557
|
// This will cause Apple Pay to close the dialog, which is expected behavior
|
|
539
558
|
// We cannot proceed without a valid merchant session from Payone
|
|
@@ -576,20 +595,20 @@ const ApplePayButton = ({
|
|
|
576
595
|
message: error.message,
|
|
577
596
|
stack: error.stack
|
|
578
597
|
});
|
|
579
|
-
|
|
598
|
+
|
|
580
599
|
// Check if error is due to cancellation (user cancelled)
|
|
581
600
|
// Payment Request API throws "AbortError" when user cancels
|
|
582
|
-
if (error.name === 'AbortError' ||
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
601
|
+
if (error.name === 'AbortError' ||
|
|
602
|
+
(error.message && (
|
|
603
|
+
error.message.includes('Cancelled') ||
|
|
604
|
+
error.message.includes('cancel') ||
|
|
605
|
+
error.message.includes('abort')
|
|
606
|
+
))) {
|
|
588
607
|
console.log("[Apple Pay] User cancelled the payment");
|
|
589
608
|
// Don't call onError for user cancellation
|
|
590
609
|
return;
|
|
591
610
|
}
|
|
592
|
-
|
|
611
|
+
|
|
593
612
|
// If it's a merchant validation error, log it specifically
|
|
594
613
|
if (error.message && (
|
|
595
614
|
error.message.includes('merchant') ||
|
|
@@ -617,11 +636,11 @@ const ApplePayButton = ({
|
|
|
617
636
|
|
|
618
637
|
// Extract payment token
|
|
619
638
|
const paymentToken = response.details?.paymentToken || response.details?.token;
|
|
620
|
-
|
|
639
|
+
|
|
621
640
|
if (!paymentToken) {
|
|
622
641
|
console.error("[Apple Pay] Payment token is missing from response");
|
|
623
642
|
try {
|
|
624
|
-
|
|
643
|
+
await response.complete("fail");
|
|
625
644
|
} catch (completeError) {
|
|
626
645
|
console.error("[Apple Pay] Error completing payment with fail:", completeError);
|
|
627
646
|
}
|
|
@@ -663,11 +682,11 @@ const ApplePayButton = ({
|
|
|
663
682
|
// The callback should set the token in state and return success immediately
|
|
664
683
|
// It should NOT process the payment yet - that will happen when user clicks the button
|
|
665
684
|
const callbackResult = onTokenReceived(tokenString, {
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
685
|
+
paymentToken: paymentToken,
|
|
686
|
+
billingContact: response.payerName || response.details?.billingContact,
|
|
687
|
+
shippingContact: response.shippingAddress || response.details?.shippingAddress,
|
|
688
|
+
shippingOption: response.shippingOption || response.details?.shippingOption
|
|
689
|
+
});
|
|
671
690
|
|
|
672
691
|
// If callback returns a promise, wait for it to resolve or reject
|
|
673
692
|
if (callbackResult && typeof callbackResult.then === 'function') {
|
|
@@ -779,29 +798,56 @@ const ApplePayButton = ({
|
|
|
779
798
|
}
|
|
780
799
|
});
|
|
781
800
|
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
801
|
+
console.log("[Apple Pay] ========== BACKEND RESPONSE START ==========");
|
|
802
|
+
console.log("[Apple Pay] Full Backend Response:", JSON.stringify(merchantSession, null, 2));
|
|
803
|
+
console.log("[Apple Pay] Response Type:", typeof merchantSession);
|
|
804
|
+
console.log("[Apple Pay] Has Data:", !!merchantSession.data);
|
|
805
|
+
console.log("[Apple Pay] Has Error:", !!merchantSession.error);
|
|
806
|
+
|
|
807
|
+
if (merchantSession.data) {
|
|
808
|
+
console.log("[Apple Pay] Data Object:", merchantSession.data);
|
|
809
|
+
console.log("[Apple Pay] Data Type:", typeof merchantSession.data);
|
|
810
|
+
console.log("[Apple Pay] Data Keys:", Object.keys(merchantSession.data));
|
|
811
|
+
console.log("[Apple Pay] Data Keys Count:", Object.keys(merchantSession.data).length);
|
|
812
|
+
console.log("[Apple Pay] Merchant Identifier:", merchantSession.data.merchantIdentifier);
|
|
813
|
+
console.log("[Apple Pay] Domain Name:", merchantSession.data.domainName);
|
|
814
|
+
console.log("[Apple Pay] Display Name:", merchantSession.data.displayName);
|
|
815
|
+
console.log("[Apple Pay] Epoch Timestamp:", merchantSession.data.epochTimestamp);
|
|
816
|
+
console.log("[Apple Pay] Expires At:", merchantSession.data.expiresAt);
|
|
817
|
+
}
|
|
789
818
|
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
819
|
+
if (merchantSession.error) {
|
|
820
|
+
console.log("[Apple Pay] Error Object:", merchantSession.error);
|
|
821
|
+
console.log("[Apple Pay] Error Message:", merchantSession.error.message);
|
|
822
|
+
console.log("[Apple Pay] Error Details:", merchantSession.error.details);
|
|
823
|
+
}
|
|
795
824
|
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
825
|
+
console.log("[Apple Pay] ========== BACKEND RESPONSE END ==========");
|
|
826
|
+
|
|
827
|
+
// Check if there's an error in the response
|
|
828
|
+
if (merchantSession.error) {
|
|
829
|
+
console.error("[Apple Pay] Backend returned error:", merchantSession.error);
|
|
830
|
+
throw new Error(merchantSession.error.message || "Apple Pay merchant validation failed");
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
// Validate merchant session
|
|
834
|
+
const session = merchantSession.data || merchantSession;
|
|
835
|
+
|
|
836
|
+
// Check if session is empty object
|
|
837
|
+
if (!session || Object.keys(session).length === 0) {
|
|
838
|
+
console.error("[Apple Pay] Empty merchant session received from backend");
|
|
839
|
+
console.error("[Apple Pay] Full response:", JSON.stringify(merchantSession, null, 2));
|
|
840
|
+
throw new Error("Empty merchant session received. This usually means Payone did not return a valid merchant session. Please check your Payone Apple Pay configuration in PMI (CONFIGURATION → PAYMENT PORTALS → [Your Portal] → Apple Pay).");
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
if (!session.merchantIdentifier && !session.merchantSessionIdentifier) {
|
|
844
|
+
console.error("[Apple Pay] Invalid merchant session - missing merchantIdentifier");
|
|
845
|
+
console.error("[Apple Pay] Session object:", JSON.stringify(session, null, 2));
|
|
846
|
+
console.error("[Apple Pay] Full response:", JSON.stringify(merchantSession, null, 2));
|
|
847
|
+
throw new Error("Invalid merchant session: missing merchantIdentifier. Please check your Payone Apple Pay configuration in PMI (CONFIGURATION → PAYMENT PORTALS → [Your Portal] → Apple Pay). The merchant session must come from Payone after successful Apple Pay onboarding.");
|
|
848
|
+
}
|
|
803
849
|
|
|
804
|
-
|
|
850
|
+
return session;
|
|
805
851
|
} catch (error) {
|
|
806
852
|
console.error("[Apple Pay] Merchant validation error:", {
|
|
807
853
|
message: error.message,
|