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

"Installments not valid" even with installments disabled #432

Closed
galdiuz opened this issue Apr 25, 2019 · 3 comments
Closed

"Installments not valid" even with installments disabled #432

galdiuz opened this issue Apr 25, 2019 · 3 comments
Assignees

Comments

@galdiuz
Copy link

galdiuz commented Apr 25, 2019

Magento version: 2.2.8
Plugin version: 2.4.3 (tested, but would probably appear in 4.0.2 as well)
Description:
If installments has been enabled for credit card payment and is later disabled the value saved for payment/adyen_cc/installments will be a:0:{}. This means that in Gateway/Validator/InstallmentValidator.php the validation on row 82 can succeed even though installments is disabled in the config, as $installmentsAvailable would be "a:0:{}" and PHP strings are truthy.

76 $installmentsAvailable = $this->adyenHelper->getAdyenCcConfigData('installments');
77 $installmentSelected = $payment->getAdditionalInformation('number_of_installments');
78 $ccType = $payment->getAdditionalInformation('cc_type');
79 if ($installmentsAvailable) {
80     $installments = unserialize($installmentsAvailable);
81 }
82 if ($installmentSelected && $installmentsAvailable) {

Proposed solution is to also check payment/adyen_cc/enable_installments. See diff below:

diff --git a/Gateway/Validator/InstallmentValidator.php b/Gateway/Validator/InstallmentValidator.php
index 5a90520..59db8e7 100644
--- a/Gateway/Validator/InstallmentValidator.php
+++ b/Gateway/Validator/InstallmentValidator.php
@@ -70,7 +70,8 @@ class InstallmentValidator extends AbstractValidator
         $fails = [];
         $payment = $validationSubject['payment'];
         $quote = $this->session->getQuote();
-        if ($quote) {
+        $installmentsEnabled = $this->adyenHelper->getAdyenCcConfigData('enable_installments');
+        if ($quote && $installmentsEnabled) {
             $grandTotal = $quote->getGrandTotal();
             $installmentsAvailable = $this->adyenHelper->getAdyenCcConfigData('installments');
             $installmentSelected = $payment->getAdditionalInformation('number_of_installments');
@cyattilakiss
Copy link
Contributor

Hi @galdiuz ,

Thank you for raising this issue, we are going to look at the suggested solution asap.

Best,
Attila
Adyen

@cyattilakiss
Copy link
Contributor

Hi @galdiuz ,

We are going to merge the fix soon. Thank you for raising the issue and suggestions the solution.
Best,
Attila
Adyen

cyattilakiss added a commit that referenced this issue May 3, 2019
PW-1265: add check if installments are enabled. fixes #432
@cyattilakiss
Copy link
Contributor

hi @galdiuz ,
The changes are released in the https://github.com/Adyen/adyen-magento2/releases/tag/4.0.3 version.
Best,
Attila
Adyen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants