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 66988071 authored by Rik ter Beek's avatar Rik ter Beek Committed by GitHub

Merge pull request #240 from Adyen/fix-klarna-account

fix for klarna_account
parents 774957a4 d251c235
...@@ -5,6 +5,6 @@ ...@@ -5,6 +5,6 @@
**Tested scenarios** **Tested scenarios**
<!-- Description of tested scenarios --> <!-- Description of tested scenarios -->
<!-- Please verify that the unit tests are passing by running "vendor/bin/phpunit -c ." --> <!-- Please verify that the unit tests are passing by running "vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist vendor/adyen/module-payment/Test/" -->
**Fixed issue**: <!-- #-prefixed issue number --> **Fixed issue**: <!-- #-prefixed issue number -->
\ No newline at end of file
...@@ -464,7 +464,7 @@ class Data extends AbstractHelper ...@@ -464,7 +464,7 @@ class Data extends AbstractHelper
{ {
return $this->getConfigData($field, 'adyen_apple_pay', $storeId); return $this->getConfigData($field, 'adyen_apple_pay', $storeId);
} }
/** /**
* @param null $storeId * @param null $storeId
* @return mixed * @return mixed
...@@ -847,15 +847,15 @@ class Data extends AbstractHelper ...@@ -847,15 +847,15 @@ class Data extends AbstractHelper
*/ */
public function isPaymentMethodOpenInvoiceMethod($paymentMethod) public function isPaymentMethodOpenInvoiceMethod($paymentMethod)
{ {
if (strlen($paymentMethod) >= 9 && substr($paymentMethod, 0, 9) == 'afterpay_') { if (strpos($paymentMethod, 'afterpay') !== false) {
return true;
} elseif (strpos($paymentMethod, 'klarna') !== false) {
return true;
} elseif (strpos($paymentMethod, 'ratepay') !== false) {
return true; return true;
} else {
if ($paymentMethod == 'klarna' || $paymentMethod == 'ratepay') {
return true;
} else {
return false;
}
} }
return false;
} }
public function getRatePayId() public function getRatePayId()
......
...@@ -210,7 +210,8 @@ class Cron ...@@ -210,7 +210,8 @@ class Cron
\Adyen\Payment\Model\Order\PaymentFactory $adyenOrderPaymentFactory, \Adyen\Payment\Model\Order\PaymentFactory $adyenOrderPaymentFactory,
\Adyen\Payment\Model\Resource\Order\Payment\CollectionFactory $adyenOrderPaymentCollectionFactory, \Adyen\Payment\Model\Resource\Order\Payment\CollectionFactory $adyenOrderPaymentCollectionFactory,
AreaList $areaList AreaList $areaList
) { )
{
$this->_scopeConfig = $scopeConfig; $this->_scopeConfig = $scopeConfig;
$this->_adyenLogger = $adyenLogger; $this->_adyenLogger = $adyenLogger;
$this->_notificationFactory = $notificationFactory; $this->_notificationFactory = $notificationFactory;
...@@ -235,7 +236,7 @@ class Cron ...@@ -235,7 +236,7 @@ class Cron
{ {
try { try {
$this->execute(); $this->execute();
} catch(\Exception $e) { } catch (\Exception $e) {
$this->_adyenLogger->addAdyenNotificationCronjob($e->getMessage() . "\n" . $e->getTraceAsString()); $this->_adyenLogger->addAdyenNotificationCronjob($e->getMessage() . "\n" . $e->getTraceAsString());
throw $e; throw $e;
} }
...@@ -536,11 +537,7 @@ class Cron ...@@ -536,11 +537,7 @@ class Cron
} }
// if payment method is klarna, ratepay or openinvoice/afterpay show the reservartion number // if payment method is klarna, ratepay or openinvoice/afterpay show the reservartion number
if (($this->_paymentMethod == "klarna" || $this->_paymentMethod == "afterpay_default" || if ($this->_adyenHelper->isPaymentMethodOpenInvoiceMethod($this->_paymentMethod) && !empty($this->_klarnaReservationNumber)) {
$this->_paymentMethod == "openinvoice" || $this->_paymentMethod == "ratepay"
) && ($this->_klarnaReservationNumber != null &&
$this->_klarnaReservationNumber != "")
) {
$klarnaReservationNumberText = "<br /> reservationNumber: " . $this->_klarnaReservationNumber; $klarnaReservationNumberText = "<br /> reservationNumber: " . $this->_klarnaReservationNumber;
} else { } else {
$klarnaReservationNumberText = ""; $klarnaReservationNumberText = "";
...@@ -1298,6 +1295,11 @@ class Cron ...@@ -1298,6 +1295,11 @@ class Cron
$manualCaptureAllowed = null; $manualCaptureAllowed = null;
$paymentMethod = $this->_paymentMethod; $paymentMethod = $this->_paymentMethod;
// For all openinvoice methods manual capture is the default
if ($this->_adyenHelper->isPaymentMethodOpenInvoiceMethod($paymentMethod)) {
return true;
}
switch ($paymentMethod) { switch ($paymentMethod) {
case 'cup': case 'cup':
case 'cartebancaire': case 'cartebancaire':
...@@ -1314,17 +1316,10 @@ class Cron ...@@ -1314,17 +1316,10 @@ class Cron
case 'jcb': case 'jcb':
case 'laser': case 'laser':
case 'paypal': case 'paypal':
case 'klarna':
case 'afterpay_default':
case 'ratepay':
case 'sepadirectdebit': case 'sepadirectdebit':
$manualCaptureAllowed = true; $manualCaptureAllowed = true;
break; break;
default: default:
// To be sure check if it payment method starts with afterpay_ then manualCapture is allowed
if (strlen($this->_paymentMethod) >= 9 && substr($this->_paymentMethod, 0, 9) == "afterpay_") {
$manualCaptureAllowed = true;
}
$manualCaptureAllowed = false; $manualCaptureAllowed = false;
} }
......
...@@ -24,9 +24,8 @@ ...@@ -24,9 +24,8 @@
namespace Adyen\Payment\Tests\Helper; namespace Adyen\Payment\Tests\Helper;
use Adyen\Payment\Helper\Data; use Adyen\Payment\Helper\Data;
use PHPUnit\Framework\TestCase;
class DataTest extends TestCase class DataTest extends \PHPUnit_Framework_TestCase
{ {
private $dataHelper; private $dataHelper;
...@@ -59,4 +58,16 @@ class DataTest extends TestCase ...@@ -59,4 +58,16 @@ class DataTest extends TestCase
$this->assertEquals("1200", $this->dataHelper->formatAmount("12.00", "USD")); $this->assertEquals("1200", $this->dataHelper->formatAmount("12.00", "USD"));
$this->assertEquals("12", $this->dataHelper->formatAmount("12.00", "JPY")); $this->assertEquals("12", $this->dataHelper->formatAmount("12.00", "JPY"));
} }
public function testisPaymentMethodOpenInvoiceMethod()
{
$this->assertEquals(true, $this->dataHelper->isPaymentMethodOpenInvoiceMethod("klarna"));
$this->assertEquals(true, $this->dataHelper->isPaymentMethodOpenInvoiceMethod("klarna_account"));
$this->assertEquals(true, $this->dataHelper->isPaymentMethodOpenInvoiceMethod("afterpay"));
$this->assertEquals(true, $this->dataHelper->isPaymentMethodOpenInvoiceMethod("afterpay_default"));
$this->assertEquals(true, $this->dataHelper->isPaymentMethodOpenInvoiceMethod("ratepay"));
$this->assertEquals(false, $this->dataHelper->isPaymentMethodOpenInvoiceMethod("ideal"));
$this->assertEquals(true, $this->dataHelper->isPaymentMethodOpenInvoiceMethod("test_klarna"));
}
} }
...@@ -17,9 +17,6 @@ ...@@ -17,9 +17,6 @@
"adyen/php-api-library": "*", "adyen/php-api-library": "*",
"magento/framework": ">=100.1.0" "magento/framework": ">=100.1.0"
}, },
"require-dev": {
"phpunit/phpunit": "~5"
},
"autoload": { "autoload": {
"files": [ "files": [
"registration.php" "registration.php"
......
<phpunit bootstrap="vendor/autoload.php">
<testsuites>
<testsuite name="Adyen payment module tests">
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>
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