diff --git a/CHANGELOG.md b/CHANGELOG.md index 46d012b8c..ee314db6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Catch possible thrown Error by getting DataClientToken - [0007719](https://bugs.oxid-esales.com/view.php?id=7719): Tracking code also be stored in standard DB field for backwards compatibility +- add possibility to ignore cached tokens. It helps e.g. for webhook registration +- use PayPal-Client v2.0.17 ## [2.5.1] - 2024-09-20 diff --git a/composer.json b/composer.json index 4572713c7..4a2720227 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "giggsey/libphonenumber-for-php": "^8.12", "viison/address-splitter": "^0.3.4", "webmozart/path-util": "^2.3.0", - "oxid-solution-catalysts/paypal-client": "v2.0.16" + "oxid-solution-catalysts/paypal-client": "v2.0.17" }, "require-dev": { "codeception/module-rest": "^1.4.2", diff --git a/metadata.php b/metadata.php index 437c1bfb4..ab15987b6 100755 --- a/metadata.php +++ b/metadata.php @@ -61,7 +61,7 @@ 'en' => 'Use of the online payment service from PayPal. Documentation: PayPal Checkout' ], 'thumbnail' => 'out/img/paypal.png', - 'version' => '2.5.2-rc.1', + 'version' => '2.5.2-rc.2', 'author' => 'OXID eSales AG', 'url' => 'https://www.oxid-esales.com', 'email' => 'info@oxid-esales.com', diff --git a/src/Core/Onboarding/Webhook.php b/src/Core/Onboarding/Webhook.php index b56cee558..b6738a441 100644 --- a/src/Core/Onboarding/Webhook.php +++ b/src/Core/Onboarding/Webhook.php @@ -16,6 +16,7 @@ use OxidSolutionCatalysts\PayPal\Exception\OnboardingException; use OxidSolutionCatalysts\PayPal\Service\ModuleSettings; use OxidSolutionCatalysts\PayPal\Traits\ServiceContainer; +use OxidSolutionCatalysts\PayPalApi\Exception\ApiException; use OxidSolutionCatalysts\PayPalApi\Service\GenericService; class Webhook @@ -119,7 +120,11 @@ public function getAllRegisteredWebhooks(): array { /** @var GenericService $notificationService */ $webhookService = Registry::get(ServiceFactory::class)->getWebhookService(); - $result = $webhookService->request('GET'); + try { + $result = $webhookService->request('GET'); + } catch (ApiException $e) { + $result = []; + } return $result['webhooks'] ?? []; } diff --git a/src/Core/ServiceFactory.php b/src/Core/ServiceFactory.php index 368868807..8e26fb071 100644 --- a/src/Core/ServiceFactory.php +++ b/src/Core/ServiceFactory.php @@ -70,7 +70,7 @@ public function getWebhookService(string $uri = ''): GenericService { return oxNew( GenericService::class, - $this->getClient(), + $this->getClient(false), '/v1/notifications/webhooks' . $uri ); } @@ -125,7 +125,7 @@ public function getIdentityService(): IdentityService * * @return Client */ - private function getClient(): Client + private function getClient(bool $useToken = true): Client { if ($this->client === null) { /** @var Config $config */ @@ -142,12 +142,14 @@ private function getClient(): Client $paymentId = $session->getVariable('paymentid'); $actionHash = md5($sessionId . $basketId . $paymentId); + $sTokenCacheFileName = $useToken ? $config->getTokenCacheFileName() : ''; + $client = new Client( $logger, $config->isSandbox() ? Client::SANDBOX_URL : Client::PRODUCTION_URL, $config->getClientId(), $config->getClientSecret(), - $config->getTokenCacheFileName(), + $sTokenCacheFileName, $actionHash, // must be empty. We do not have the merchant's payerid //and confirmed by paypal we should not use it for auth and