From 1f7d1e6f77df29ad73b665a210a43afd8e1a8278 Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Thu, 19 Sep 2024 21:15:17 +0200 Subject: [PATCH] Correct Webhook-Return-URL in multi-shop-systems --- CHANGELOG.md | 1 + .../Controller/Admin/ModuleConfiguration.php | 28 +++++++++++++------ metadata.php | 2 +- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d82d7a2..f8e5314 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed - [0007694](https://bugs.oxid-esales.com/view.php?id=7694): Fix Webhook generation for multi-shops +- [0007722](https://bugs.oxid-esales.com/view.php?id=7722): Correct Webhook-Return-URL in multi-shop-systems ## [1.0.4] - 2024-07-09 diff --git a/extend/Application/Controller/Admin/ModuleConfiguration.php b/extend/Application/Controller/Admin/ModuleConfiguration.php index db133ab..e2cf49c 100644 --- a/extend/Application/Controller/Admin/ModuleConfiguration.php +++ b/extend/Application/Controller/Admin/ModuleConfiguration.php @@ -41,7 +41,7 @@ public function stripeSecondChanceDayDiffs() */ public function stripeIsTestMode() { - return Registry::getConfig()->getShopConfVar('sStripeMode') == 'test'; + return Registry::getConfig()->getShopConfVar('sStripeMode') === 'test'; } /** @@ -79,7 +79,19 @@ public function stripeIsApiKeyUsable($sConfVar) public function stripeGetWebhookCreateUrl() { $config = Registry::getConfig(); - return $config->getCurrentShopUrl().'index.php?cl=stripeWebhook&fnc=createWebhookEndpoint&shp=' . $config->getShopId(); + return $config->getShopUrl(null,false) + . 'index.php?cl=stripeWebhook&fnc=createWebhookEndpoint&shp=' + . $config->getShopId(); + } + + public function stripeGetAdminUrl() + { + $myConfig = Registry::getConfig(); + $adminSslUrl = $myConfig->getConfigParam('sAdminSSLURL'); + $url = $adminSslUrl ? + trim($adminSslUrl, '/') : + trim($myConfig->getConfigParam('sShopURL'), '/') . '/admin'; + return $url . '/'; } /** @@ -118,7 +130,7 @@ protected function stripeCleanUploadFileName($sConfVar) */ public function stripeIsStripe() { - return $this->getEditObjectId() == 'stripe'; + return $this->getEditObjectId() === 'stripe'; } /** @@ -127,13 +139,13 @@ public function stripeIsStripe() */ public function stripeGetConnectUrl($sVarName) { - $sMode = $sVarName == 'sStripeTestToken' ? 'test' : 'live'; - $redirectUrl = Registry::getConfig()->getCurrentShopUrl().'/index.php?cl=stripeConnect&fnc=stripeFinishOnBoarding'; - $redirectUrl.= '&stoken=' . $this->getSession()->getSessionChallengeToken(); + $sMode = $sVarName === 'sStripeTestToken' ? 'test' : 'live'; + $redirectUrl = $this->stripeGetAdminUrl() . '/index.php?cl=stripeConnect&fnc=stripeFinishOnBoarding'; + $redirectUrl.= '&stoken=' . Registry::getSession()->getSessionChallengeToken(); $redirectUrl.= '&shop_param=' . $sMode; $redirectUrl.= '&shp=' . Registry::getConfig()->getShopId(); - if ($sMode == 'test') { + if ($sMode === 'test') { return 'https://dev-osm.oxid-esales.com/stripe-connect?shop_redirect_url=' . rawurlencode($redirectUrl); } return 'https://osm.oxid-esales.com/stripe-connect?shop_redirect_url=' . rawurlencode($redirectUrl); @@ -145,7 +157,7 @@ public function stripeGetConnectUrl($sVarName) public function stripeIsWebhookReady() { $oPaymentHelper = Payment::getInstance(); - if (!$oPaymentHelper->stripeIsWebhookConfigured()) { + if (!$oPaymentHelper && !$oPaymentHelper->stripeIsWebhookConfigured()) { return false; } diff --git a/metadata.php b/metadata.php index 6d727f1..bbb9843 100644 --- a/metadata.php +++ b/metadata.php @@ -57,7 +57,7 @@ 'en' => 'This module integrates STRIPE as payment provider in your OXID Shop.', ], 'thumbnail' => 'stripe_logo.png', - 'version' => '1.0.5-rc.1', + 'version' => '1.0.5-rc.2', 'author' => 'OXID eSales AG', 'url' => 'https://www.oxid-esales.com', 'email' => 'info@oxid-esales.com',