Skip to content

Commit

Permalink
Merge pull request #370 from OXID-eSales/PAYPAL-875_Webhooks
Browse files Browse the repository at this point in the history
Paypal 875 webhooks
  • Loading branch information
mariolorenz authored Dec 13, 2024
2 parents d458195 + 3d8b7bd commit 27e2da3
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
'en' => 'Use of the online payment service from PayPal. Documentation: <a href="https://docs.oxid-esales.com/modules/paypal-checkout/en/latest/" target="_blank">PayPal Checkout</a>'
],
'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',
Expand Down
7 changes: 6 additions & 1 deletion src/Core/Onboarding/Webhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'] ?? [];
}
Expand Down
8 changes: 5 additions & 3 deletions src/Core/ServiceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function getWebhookService(string $uri = ''): GenericService
{
return oxNew(
GenericService::class,
$this->getClient(),
$this->getClient(false),
'/v1/notifications/webhooks' . $uri
);
}
Expand Down Expand Up @@ -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 */
Expand All @@ -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
Expand Down

0 comments on commit 27e2da3

Please sign in to comment.