Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PW-2565 Fixes #26 Make paymentsmethod cache configurable #43

Merged
merged 3 commits into from
Aug 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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