We will be off from 27/1 (Monday) to 31/1 (Friday) (GMT +7) for our Tet Holiday (Lunar New Year) 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 @@
**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 -->
\ No newline at end of file
......@@ -847,15 +847,15 @@ class Data extends AbstractHelper
*/
public function isPaymentMethodOpenInvoiceMethod($paymentMethod)
{
if (strlen($paymentMethod) >= 9 && substr($paymentMethod, 0, 9) == 'afterpay_') {
if (strpos($paymentMethod, 'afterpay') !== false) {
return true;
} else {
if ($paymentMethod == 'klarna' || $paymentMethod == 'ratepay') {
} elseif (strpos($paymentMethod, 'klarna') !== false) {
return true;
} elseif (strpos($paymentMethod, 'ratepay') !== false) {
return true;
} else {
return false;
}
}
return false;
}
public function getRatePayId()
......
......@@ -210,7 +210,8 @@ class Cron
\Adyen\Payment\Model\Order\PaymentFactory $adyenOrderPaymentFactory,
\Adyen\Payment\Model\Resource\Order\Payment\CollectionFactory $adyenOrderPaymentCollectionFactory,
AreaList $areaList
) {
)
{
$this->_scopeConfig = $scopeConfig;
$this->_adyenLogger = $adyenLogger;
$this->_notificationFactory = $notificationFactory;
......@@ -235,7 +236,7 @@ class Cron
{
try {
$this->execute();
} catch(\Exception $e) {
} catch (\Exception $e) {
$this->_adyenLogger->addAdyenNotificationCronjob($e->getMessage() . "\n" . $e->getTraceAsString());
throw $e;
}
......@@ -536,11 +537,7 @@ class Cron
}
// if payment method is klarna, ratepay or openinvoice/afterpay show the reservartion number
if (($this->_paymentMethod == "klarna" || $this->_paymentMethod == "afterpay_default" ||
$this->_paymentMethod == "openinvoice" || $this->_paymentMethod == "ratepay"
) && ($this->_klarnaReservationNumber != null &&
$this->_klarnaReservationNumber != "")
) {
if ($this->_adyenHelper->isPaymentMethodOpenInvoiceMethod($this->_paymentMethod) && !empty($this->_klarnaReservationNumber)) {
$klarnaReservationNumberText = "<br /> reservationNumber: " . $this->_klarnaReservationNumber;
} else {
$klarnaReservationNumberText = "";
......@@ -1298,6 +1295,11 @@ class Cron
$manualCaptureAllowed = null;
$paymentMethod = $this->_paymentMethod;
// For all openinvoice methods manual capture is the default
if ($this->_adyenHelper->isPaymentMethodOpenInvoiceMethod($paymentMethod)) {
return true;
}
switch ($paymentMethod) {
case 'cup':
case 'cartebancaire':
......@@ -1314,17 +1316,10 @@ class Cron
case 'jcb':
case 'laser':
case 'paypal':
case 'klarna':
case 'afterpay_default':
case 'ratepay':
case 'sepadirectdebit':
$manualCaptureAllowed = true;
break;
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;
}
......
......@@ -24,9 +24,8 @@
namespace Adyen\Payment\Tests\Helper;
use Adyen\Payment\Helper\Data;
use PHPUnit\Framework\TestCase;
class DataTest extends TestCase
class DataTest extends \PHPUnit_Framework_TestCase
{
private $dataHelper;
......@@ -59,4 +58,16 @@ class DataTest extends TestCase
$this->assertEquals("1200", $this->dataHelper->formatAmount("12.00", "USD"));
$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 @@
"adyen/php-api-library": "*",
"magento/framework": ">=100.1.0"
},
"require-dev": {
"phpunit/phpunit": "~5"
},
"autoload": {
"files": [
"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