From 5f8dda098039db479268cda91ceb98c40c59024c Mon Sep 17 00:00:00 2001
From: Philipp Stracker
Date: Thu, 21 Nov 2024 19:10:02 +0100
Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Implement=20PayPal=20connection=20v?=
=?UTF-8?q?ia=20popup?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Components/AdvancedOptionsForm.js | 17 +++++++-
.../resources/js/utils/window.js | 42 +++++++++++++++++++
2 files changed, 57 insertions(+), 2 deletions(-)
create mode 100644 modules/ppcp-settings/resources/js/utils/window.js
diff --git a/modules/ppcp-settings/resources/js/Components/Screens/Onboarding/Components/AdvancedOptionsForm.js b/modules/ppcp-settings/resources/js/Components/Screens/Onboarding/Components/AdvancedOptionsForm.js
index 79724a533..b18edc6fb 100644
--- a/modules/ppcp-settings/resources/js/Components/Screens/Onboarding/Components/AdvancedOptionsForm.js
+++ b/modules/ppcp-settings/resources/js/Components/Screens/Onboarding/Components/AdvancedOptionsForm.js
@@ -8,6 +8,7 @@ import SettingsToggleBlock from '../../../ReusableComponents/SettingsToggleBlock
import Separator from '../../../ReusableComponents/Separator';
import DataStoreControl from '../../../ReusableComponents/DataStoreControl';
import { CommonHooks } from '../../../../data';
+import { openPopup } from '../../../../utils/window';
const AdvancedOptionsForm = ( { setCompleted } ) => {
const { isBusy } = CommonHooks.useBusyState();
@@ -87,9 +88,21 @@ const AdvancedOptionsForm = ( { setCompleted } ) => {
);
return;
}
+
+ const connectionUrl = res.data;
+ const popup = openPopup( connectionUrl );
+
+ if ( ! popup ) {
+ createErrorNotice(
+ __(
+ 'Popup blocked. Please allow popups for this site to connect to PayPal.',
+ 'woocommerce-paypal-payments'
+ )
+ );
+ }
};
- const handleConnect = async () => {
+ const handleManualConnect = async () => {
if ( ! handleFormValidation() ) {
return;
}
@@ -183,7 +196,7 @@ const AdvancedOptionsForm = ( { setCompleted } ) => {
onChange={ setClientSecret }
type="password"
/>
-