Skip to content

Commit

Permalink
Merge pull request #30 from OXID-eSales/STRIP-43_WebhookURLs
Browse files Browse the repository at this point in the history
 Correct Webhook-Return-URL in multi-shop-systems
  • Loading branch information
mariolorenz authored Sep 19, 2024
2 parents d0d557d + 1f7d1e6 commit f77c678
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
28 changes: 20 additions & 8 deletions extend/Application/Controller/Admin/ModuleConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function stripeSecondChanceDayDiffs()
*/
public function stripeIsTestMode()
{
return Registry::getConfig()->getShopConfVar('sStripeMode') == 'test';
return Registry::getConfig()->getShopConfVar('sStripeMode') === 'test';
}

/**
Expand Down Expand Up @@ -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 . '/';
}

/**
Expand Down Expand Up @@ -118,7 +130,7 @@ protected function stripeCleanUploadFileName($sConfVar)
*/
public function stripeIsStripe()
{
return $this->getEditObjectId() == 'stripe';
return $this->getEditObjectId() === 'stripe';
}

/**
Expand All @@ -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);
Expand All @@ -145,7 +157,7 @@ public function stripeGetConnectUrl($sVarName)
public function stripeIsWebhookReady()
{
$oPaymentHelper = Payment::getInstance();
if (!$oPaymentHelper->stripeIsWebhookConfigured()) {
if (!$oPaymentHelper && !$oPaymentHelper->stripeIsWebhookConfigured()) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit f77c678

Please sign in to comment.