From 59ea28b6ee8feef6ee462cdfb0dd85fa704e5c69 Mon Sep 17 00:00:00 2001 From: Rune Laenen Date: Fri, 21 Aug 2020 10:20:53 +0200 Subject: [PATCH] PW-2565 Make paymentsmethod cache configurable (#43) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds configuration option to make caching of /paymentmethods call configurable. Co-authored-by: Ángel Campos Fixes #26 --- Components/Adyen/PaymentMethodService.php | 1 + Components/Configuration.php | 9 +++++++++ Resources/config.xml | 13 +++++++++---- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Components/Adyen/PaymentMethodService.php b/Components/Adyen/PaymentMethodService.php index b9c44e7a..f53401f2 100644 --- a/Components/Adyen/PaymentMethodService.php +++ b/Components/Adyen/PaymentMethodService.php @@ -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]; diff --git a/Components/Configuration.php b/Components/Configuration.php index 03bd76cf..fea234e5 100644 --- a/Components/Configuration.php +++ b/Components/Configuration.php @@ -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 */ diff --git a/Resources/config.xml b/Resources/config.xml index fc8a38ab..45af0b52 100755 --- a/Resources/config.xml +++ b/Resources/config.xml @@ -47,10 +47,15 @@ notification_auth_password - - google_merchant_id - - + + google_merchant_id + + + + paymentmethods_cache + + Caches the payment methods active in Adyen Customer Area for better performance. + testAPIconnection