We will work on Apr 26th (Saturday) and will be off from Apr 30th (Wednesday) until May 2nd (Friday) for public holiday in our country

Commit fb08cd36 authored by Vitaliy Ryaboy's avatar Vitaliy Ryaboy Committed by GitHub

refs #756: fix PaymentMethod::getCurrentPaymentAmount (#757)

* refs #756: fix PaymentMethod::getCurrentPaymentAmount

* fix typo

* refs #756: implemente CR feedback

* Update Helper/PaymentMethods.php

* Update Helper/PaymentMethods.php
Co-authored-by: default avatarAttila Kiss <42297201+cyattilakiss@users.noreply.github.com>
Co-authored-by: default avatarAlexandros Moraitis <alexandros.moraitis@adyen.com>
parent 2a5c3deb
...@@ -173,7 +173,7 @@ class PaymentMethods extends AbstractHelper ...@@ -173,7 +173,7 @@ class PaymentMethods extends AbstractHelper
"countryCode" => $this->getCurrentCountryCode($store, $country), "countryCode" => $this->getCurrentCountryCode($store, $country),
"amount" => [ "amount" => [
"currency" => $currencyCode, "currency" => $currencyCode,
"value" => (int)$this->adyenHelper->formatAmount( "value" => $this->adyenHelper->formatAmount(
$this->getCurrentPaymentAmount(), $this->getCurrentPaymentAmount(),
$currencyCode $currencyCode
), ),
...@@ -253,14 +253,34 @@ class PaymentMethods extends AbstractHelper ...@@ -253,14 +253,34 @@ class PaymentMethods extends AbstractHelper
} }
/** /**
* @return bool|int * @return float
*/ */
protected function getCurrentPaymentAmount() protected function getCurrentPaymentAmount()
{ {
if (($grandTotal = $this->getQuote()->getGrandTotal()) > 0) { $grandTotal = $this->getQuote()->getGrandTotal();
if (!is_numeric($grandTotal)) {
throw new \Exception(
sprintf(
'Cannot retrieve a valid grand total from quote ID: `%s`. Expected a numeric value.',
$this->getQuote()->getEntityId()
)
);
}
$grandTotal = (float) $grandTotal;
if ($grandTotal > 0) {
return $grandTotal; return $grandTotal;
} }
return 10;
throw new \Exception(
sprintf(
'Cannot retrieve a valid grand total from quote ID: `%s`. Expected a float > `0`, got `%f`.',
$this->getQuote()->getEntityId(),
$grandTotal
)
);
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment