-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b78161
commit be19594
Showing
12 changed files
with
12,198 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ | |
class PaynlPaymentMethodsIdsEnum | ||
{ | ||
const PIN_PAYMENT = 1927; | ||
const VISA_MASTERCARD_PAYMENT = 706; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PaynlPayment\Shopware6\Helper; | ||
|
||
use PaynlPayment\Shopware6\Components\Api; | ||
use Psr\Cache\CacheItemPoolInterface; | ||
|
||
class PublicKeysHelper | ||
{ | ||
const CACHE_KEY = 'paynl_public_encryption_keys'; | ||
const CACHE_TTL = 15768000; | ||
|
||
/** @var Api */ | ||
private $paynlApi; | ||
|
||
/** @var CacheItemPoolInterface */ | ||
private $cache; | ||
|
||
public function __construct(Api $api, CacheItemPoolInterface $cache) | ||
{ | ||
$this->paynlApi = $api; | ||
$this->cache = $cache; | ||
} | ||
|
||
public function getKeys(string $salesChannelId): array | ||
{ | ||
$keysCacheItem = $this->cache->getItem(self::CACHE_KEY); | ||
|
||
if (!$keysCacheItem->isHit() || !$keysCacheItem->get()) { | ||
$keys = $this->paynlApi->getPublicKeys($salesChannelId); | ||
$keysCacheItem->set(json_encode($keys)); | ||
|
||
$this->cache->save($keysCacheItem); | ||
} else { | ||
$keys = json_decode($keysCacheItem->get(), true); | ||
} | ||
|
||
return $keys; | ||
} | ||
} |
Oops, something went wrong.