Skip to content

Commit

Permalink
PW-2565 Make paymentsmethod cache configurable (#43)
Browse files Browse the repository at this point in the history
Adds configuration option to make caching of /paymentmethods call configurable.

Co-authored-by: Ángel Campos <[email protected]>

Fixes #26
  • Loading branch information
Rune Laenen authored Aug 21, 2020
1 parent fdd9b42 commit 59ea28b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions Components/Adyen/PaymentMethodService.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public function getPaymentMethods(
$locale = null,
$cache = true
): array {
$cache = $cache && $this->configuration->isPaymentmethodsCacheEnabled();
$cacheKey = $this->getCacheKey($countryCode ?? '', $currency ?? '', (string)$value ?? '');
if ($cache && isset($this->cache[$cacheKey])) {
return $this->cache[$cacheKey];
Expand Down
9 changes: 9 additions & 0 deletions Components/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,15 @@ public function getGoogleMerchantId($shop = false): string
return (string)$this->getConfig('google_merchant_id', $shop);
}

/**
* @param bool $shop
* @return bool
*/
public function isPaymentmethodsCacheEnabled($shop = false): bool
{
return (bool)$this->getConfig('paymentmethods_cache', $shop);
}

/**
* @return string
*/
Expand Down
13 changes: 9 additions & 4 deletions Resources/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,15 @@
<name>notification_auth_password</name>
<label lang="en">Notification Auth Password</label>
</element>
<element type="text" scope="shop">
<name>google_merchant_id</name>
<label lang="en">Google Merchant ID</label>
</element>
<element type="text" scope="shop">
<name>google_merchant_id</name>
<label lang="en">Google Merchant ID</label>
</element>
<element type="boolean" scope="shop">
<name>paymentmethods_cache</name>
<label lang="en">Enable Payment Methods cache</label>
<description lang="en">Caches the payment methods active in Adyen Customer Area for better performance.</description>
</element>
<element type="button">
<name>testAPIconnection</name>
<label lang="en">Test API connection</label>
Expand Down

0 comments on commit 59ea28b

Please sign in to comment.