diff --git a/.bc-exclude.php b/.bc-exclude.php
index 5e15ac79a..c65a17ef1 100644
--- a/.bc-exclude.php
+++ b/.bc-exclude.php
@@ -9,5 +9,7 @@
\preg_quote('An enum expression Monolog\Level::Debug is not supported in class Monolog\Handler\AbstractHandler'),
// Storefront package is not installed
\preg_quote('"Shopware\Storefront\Framework\Cookie\CookieProviderInterface" could not be found in the located source'),
+ // internal const
+ \preg_quote('Value of constant Swag\PayPal\Setting\Settings::DEFAULT_VALUES changed from array') . '.*',
],
];
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4b95f0ecf..545dd7e52 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,7 @@
# REPLACE_GLOBALLY_WITH_NEXT_VERSION
- Fixes an issue, where cookies are added even though associated payment methods are not active (shopware/SwagPayPal#457)
- Fixes an issue, where the state of a country was not correctly transmitted to PayPal (shopware/SwagPayPal#469)
+- Added option to disable PayPal callbacks (shopware/SwagPayPal#463)
# 10.3.0
- Added compatibility with subscription mixed carts (shopware/shopware#10486)
diff --git a/CHANGELOG_de-DE.md b/CHANGELOG_de-DE.md
index f8414e621..98f7ea3ca 100644
--- a/CHANGELOG_de-DE.md
+++ b/CHANGELOG_de-DE.md
@@ -1,6 +1,7 @@
# REPLACE_GLOBALLY_WITH_NEXT_VERSION
- Behebt ein Problem, bei dem Cookies geladen wurden, obwohl die zugehörigen Zahlungsarten nicht aktiv sind (shopware/SwagPayPal#457)
- Behebt ein Problem, bei dem der Bundesstaat nicht korrekt an PayPal übermittelt wurde (shopware/SwagPayPal#469)
+- Fügt eine Option zum deaktiveren von PayPal Callbacks hinzu (shopware/SwagPayPal#463)
# 10.3.0
- Fügt Kompatibilität mit Abos in gemischten Warenkörben hinzu (shopware/shopware#10486)
diff --git a/src/Checkout/ExpressCheckout/SalesChannel/ExpressCreateOrderRoute.php b/src/Checkout/ExpressCheckout/SalesChannel/ExpressCreateOrderRoute.php
index 23d42ecd4..75c8ee98e 100644
--- a/src/Checkout/ExpressCheckout/SalesChannel/ExpressCreateOrderRoute.php
+++ b/src/Checkout/ExpressCheckout/SalesChannel/ExpressCreateOrderRoute.php
@@ -14,6 +14,7 @@
use Shopware\Core\Framework\Plugin\Exception\DecorationPatternException;
use Shopware\Core\Framework\Validation\DataBag\RequestDataBag;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
+use Shopware\Core\System\SystemConfig\SystemConfigService;
use Shopware\PayPalSDK\Struct\V2\Order\ApplicationContext;
use Shopware\PayPalSDK\Struct\V2\Order\PaymentSource\Common\Attributes\OrderUpdateCallbackConfig;
use Swag\PayPal\Checkout\Cart\Service\CartPriceService;
@@ -22,6 +23,7 @@
use Swag\PayPal\OrdersApi\Builder\PayPalOrderBuilder;
use Swag\PayPal\RestApi\PartnerAttributionId;
use Swag\PayPal\RestApi\V2\Resource\OrderResource;
+use Swag\PayPal\Setting\Settings;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
@@ -40,6 +42,7 @@ public function __construct(
private readonly PayPalOrderBuilder $paypalOrderBuilder,
private readonly OrderResource $orderResource,
private readonly CartPriceService $cartPriceService,
+ private readonly SystemConfigService $systemConfigService,
private readonly RouterInterface $router,
private readonly LoggerInterface $logger,
) {
@@ -80,17 +83,21 @@ public function createPayPalOrder(Request $request, SalesChannelContext $salesCh
$experienceContext->setUserAction(ApplicationContext::USER_ACTION_CONTINUE);
// Configure shipping callback for dynamic price recalculation
- $callbackConfig = new OrderUpdateCallbackConfig();
- $callbackUrl = $this->router->generate(
- 'store-api.paypal.express.shipping_callback',
- ['salesChannelId' => $salesChannelContext->getSalesChannelId(), 'token' => $salesChannelContext->getToken()],
- UrlGeneratorInterface::ABSOLUTE_URL,
- );
- $callbackConfig->setCallbackUrl($callbackUrl);
- $callbackConfig->setCallbackEvents([OrderUpdateCallbackConfig::CALLBACK_EVENT_SHIPPING_OPTIONS]);
- $experienceContext->setOrderUpdateCallbackConfig($callbackConfig);
+ if (!$this->systemConfigService->getBool(Settings::IS_LOCAL_ENVIRONMENT)) {
+ $callbackConfig = new OrderUpdateCallbackConfig();
+ $callbackUrl = $this->router->generate(
+ 'store-api.paypal.express.shipping_callback',
+ ['salesChannelId' => $salesChannelContext->getSalesChannelId(), 'token' => $salesChannelContext->getToken()],
+ UrlGeneratorInterface::ABSOLUTE_URL,
+ );
+ $callbackConfig->setCallbackUrl($callbackUrl);
+ $callbackConfig->setCallbackEvents([OrderUpdateCallbackConfig::CALLBACK_EVENT_SHIPPING_OPTIONS]);
+ $experienceContext->setOrderUpdateCallbackConfig($callbackConfig);
- $this->logger->debug('Configured shipping callback', ['callbackUrl' => $callbackUrl]);
+ $this->logger->debug('Configured shipping callback', ['callbackUrl' => $callbackUrl]);
+ } else {
+ $this->logger->debug('Skipped shipping callback due to being disabled in system config');
+ }
}
$orderResponse = $this->orderResource->create(
diff --git a/src/Resources/app/administration/src/app/snippet/de.json b/src/Resources/app/administration/src/app/snippet/de.json
index ccd895ede..48647fabb 100644
--- a/src/Resources/app/administration/src/app/snippet/de.json
+++ b/src/Resources/app/administration/src/app/snippet/de.json
@@ -83,7 +83,8 @@
"vaultingEnabledACDC": "Vaulting für Kredit- und Debitkarten-Zahlungen verwenden",
"vaultingEnabledVenmo": "Vaulting für Venmo-Zahlungen verwenden",
"crossBorderMessagingEnabled" : "Länderübergreifende Lokalisierung der \"Später bezahlen\"-Nachricht aktivieren",
- "crossBorderBuyerCountry" : "Lokalisierung"
+ "crossBorderBuyerCountry" : "Lokalisierung",
+ "isLocalEnvironment": "Lokale Entwicklungsumgebung"
},
"helpText": {
"clientId": "Die Client-ID der REST-API, die das Plugin dazu verwendet, sich mit der PayPal-API zu authentifizieren.",
diff --git a/src/Resources/app/administration/src/app/snippet/en.json b/src/Resources/app/administration/src/app/snippet/en.json
index 86322d343..7af392094 100644
--- a/src/Resources/app/administration/src/app/snippet/en.json
+++ b/src/Resources/app/administration/src/app/snippet/en.json
@@ -83,7 +83,8 @@
"vaultingEnabledACDC": "Enable Vaulting for credit and debit cards",
"vaultingEnabledVenmo": "Enable Vaulting for Venmo payments",
"crossBorderMessagingEnabled" : "Enable cross-border localization of Pay Later message",
- "crossBorderBuyerCountry" : "Localization"
+ "crossBorderBuyerCountry" : "Localization",
+ "isLocalEnvironment": "Local development environment"
},
"helpText": {
"clientId": "The REST API client ID is used to authenticate this plugin with the PayPal API.",
diff --git a/src/Resources/app/administration/src/constant/swag-paypal-settings.constant.ts b/src/Resources/app/administration/src/constant/swag-paypal-settings.constant.ts
index 48474e671..2910cf19a 100644
--- a/src/Resources/app/administration/src/constant/swag-paypal-settings.constant.ts
+++ b/src/Resources/app/administration/src/constant/swag-paypal-settings.constant.ts
@@ -139,6 +139,8 @@ export const SYSTEM_CONFIGS = [
'SwagPayPal.settings.webhookId',
'SwagPayPal.settings.webhookExecuteToken',
+
+ 'SwagPayPal.settings.isLocalEnvironment',
] as const;
export type SYSTEM_CONFIG = typeof SYSTEM_CONFIGS[number];
diff --git a/src/Resources/app/administration/src/module/swag-paypal-settings/snippet/de.json b/src/Resources/app/administration/src/module/swag-paypal-settings/snippet/de.json
index 5aa718519..f67c77f99 100644
--- a/src/Resources/app/administration/src/module/swag-paypal-settings/snippet/de.json
+++ b/src/Resources/app/administration/src/module/swag-paypal-settings/snippet/de.json
@@ -103,6 +103,10 @@
"info": "Mit länderübergreifende Nachrichten für \"Später bezahlen\" wird die \"Später bezahlen\"-Nachricht in der Sprache des Kunden anzeigt. Diese Funktion ist nur für bestimmte Länder verfügbar. {0}",
"buyerCountryAuto": "Automatische Bestimmung",
"buyerCountryOverride": "Lokalisierung"
+ },
+ "environment": {
+ "title": "Umgebung",
+ "info": "PayPal sendet Bestellstatus-Updates über Webhooks an den Shop und fordert außerdem eine Neuberechnung des Warenkorbs an, wenn Kunden Änderungen in der PayPal Express Checkout-Benutzeroberfläche vornehmen. Wenn der Shop nicht öffentlich zugänglich ist (z. B. wenn es sich um eine Entwicklungs-/Staging-Umgebung handelt oder eine Authentifizierung erfordert), kannst du diese Instanz als \"lokale Umgebung\" kennzeichnen, um Verbindungsfehler zu vermeiden.\nBitte beachte, dass alle Webhook-Listener beim Speichern deregistriert werden."
}
},
"swag-paypal-settings-sales-channel-switch": {
diff --git a/src/Resources/app/administration/src/module/swag-paypal-settings/snippet/en.json b/src/Resources/app/administration/src/module/swag-paypal-settings/snippet/en.json
index 6f5205f88..e988ed455 100644
--- a/src/Resources/app/administration/src/module/swag-paypal-settings/snippet/en.json
+++ b/src/Resources/app/administration/src/module/swag-paypal-settings/snippet/en.json
@@ -103,6 +103,10 @@
"info": "Pay Later messaging is a feature that allows you to display a Pay Later message in the language of the customer. This feature is only available for certain countries. {0}",
"buyerCountryAuto": "Automatic determination",
"buyerCountryOverride": "Localization"
+ },
+ "environment": {
+ "title": "Environment",
+ "info": "PayPal will send order status updates to the shop via webhooks, and will also request cart recalculations when customers make changes in the PayPal Express Checkout UI. If the shop is not publicly accessible (e.g. if it is in a development/staging environment, or if it requires authentication), you can mark this instance as a \"local environment\" to prevent connection errors.\nPlease note that any webhook listener will be deregistered when saving."
}
},
"swag-paypal-settings-sales-channel-switch": {
diff --git a/src/Resources/app/administration/src/module/swag-paypal-settings/view/swag-paypal-settings-advanced/swag-paypal-settings-advanced.html.twig b/src/Resources/app/administration/src/module/swag-paypal-settings/view/swag-paypal-settings-advanced/swag-paypal-settings-advanced.html.twig
index 14bc59055..d09b164f5 100644
--- a/src/Resources/app/administration/src/module/swag-paypal-settings/view/swag-paypal-settings-advanced/swag-paypal-settings-advanced.html.twig
+++ b/src/Resources/app/administration/src/module/swag-paypal-settings/view/swag-paypal-settings-advanced/swag-paypal-settings-advanced.html.twig
@@ -1,3 +1,18 @@
+
+