Skip to content

Commit

Permalink
add actionHash to make Request Unique
Browse files Browse the repository at this point in the history
  • Loading branch information
mariolorenz authored and René Gust committed Oct 8, 2024
1 parent 7d64787 commit 6658036
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Core/ServiceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace OxidSolutionCatalysts\PayPal\Core;

use OxidEsales\Eshop\Core\Registry;
use OxidSolutionCatalysts\PayPal\Traits\ServiceContainer;
use OxidSolutionCatalysts\PayPalApi\Client;
use OxidSolutionCatalysts\PayPalApi\Service\Partner;
Expand Down Expand Up @@ -120,12 +121,21 @@ private function getClient(): Client
/** @var LoggerInterface $logger */
$logger = $this->getServiceFromContainer('OxidSolutionCatalysts\PayPal\Logger');

$debug = Registry::getConfig()->getConfigParam('sLogLevel') === 'debug';

// prepare a unique action hash
$session = Registry::getSession();
$sessionId = $session->getId();
$basketId = $session->getVariable('sess_challenge');
$actionHash = md5($sessionId . $basketId);

$client = new Client(
$logger,
$config->isSandbox() ? Client::SANDBOX_URL : Client::PRODUCTION_URL,
$config->getClientId(),
$config->getClientSecret(),
$config->getTokenCacheFileName(),
$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

0 comments on commit 6658036

Please sign in to comment.