Skip to content

Commit

Permalink
Merge pull request #369 from OXID-eSales/feature/1.3.11-bugfix
Browse files Browse the repository at this point in the history
Feature/1.3.11 bugfix
  • Loading branch information
mariolorenz authored Dec 13, 2024
2 parents 5ed1c6a + 6a2d5c4 commit df4ab10
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [1.3.12] - 2024-??-??

- add possibility to ignore cached tokens. It helps e.g. for webhook registration
- Update Client Version v1.0.12

## [1.3.11] - 2024-09-12

- Provide BN codes even to previously overlooked API calls
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": "v1.0.11"
"oxid-solution-catalysts/paypal-client": "v1.0.12"
},
"require-dev": {
"oxid-esales/oxideshop-ce": "^v6.3.0",
Expand Down
2 changes: 1 addition & 1 deletion metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,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' => '1.3.11',
'version' => '1.3.12-rc.1',
'author' => 'OXID eSales AG',
'url' => 'https://www.oxid-esales.com',
'email' => '[email protected]',
Expand Down
14 changes: 12 additions & 2 deletions src/Core/Onboarding/Webhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use OxidSolutionCatalysts\PayPal\Traits\ServiceContainer;
use OxidSolutionCatalysts\PayPal\Service\ModuleSettings;
use OxidSolutionCatalysts\PayPal\Exception\OnboardingException;
use OxidSolutionCatalysts\PayPalApi\Exception\ApiException;
use OxidSolutionCatalysts\PayPalApi\Service\GenericService;

class Webhook
Expand All @@ -32,7 +33,12 @@ public function ensureWebhook(): string
$hook = $this->getHookForUrl($endpoint);
$webhookId = isset($hook['id']) ? $hook['id'] : '';
$registeredEvents = $this->getEnabledEvents($hook);
if (array_diff($this->getAvailableEventNames(), $registeredEvents)) {
if (
array_diff(
array_column($this->getAvailableEventNames(), "name"),
array_column($registeredEvents, "name")
)
) {
$this->removeWebhook($webhookId);
$webhookId = $this->registerWebhooks();
}
Expand Down Expand Up @@ -113,7 +119,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
14 changes: 11 additions & 3 deletions src/Core/ServiceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function getWebhookService(string $uri = ''): GenericService
{
return oxNew(
GenericService::class,
$this->getClient(),
$this->getClient(false),
'/v1/notifications/webhooks' . $uri
);
}
Expand Down Expand Up @@ -111,19 +111,27 @@ public function getIdentityService(): IdentityService
*
* @return Client
*/
private function getClient(): Client
private function getClient(bool $useToken = true): Client
{
if ($this->client === null) {
/** @var Config $config */
$config = oxNew(Config::class);
$logger = new PayPalLogger();
// prepare a unique action hash
$session = Registry::getSession();
$sessionId = $session->getId();
$basketId = $session->getVariable('sess_challenge');
$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
//so not ask for it on the configuration page
Expand Down
6 changes: 5 additions & 1 deletion src/Service/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,11 @@ public function fetchOrderFields(string $paypalOrderId, string $fields = ''): Ap
{
return $this->serviceFactory
->getOrderService()
->showOrderDetails($paypalOrderId, $fields);
->showOrderDetails(
$paypalOrderId,
$fields,
Constants::PAYPAL_PARTNER_ATTRIBUTION_ID_PPCP
);
}

/**
Expand Down

0 comments on commit df4ab10

Please sign in to comment.