Skip to content

Commit

Permalink
Remove PaymentCtrl-Check
Browse files Browse the repository at this point in the history
  • Loading branch information
mariolorenz committed Sep 20, 2024
1 parent 9fd07e6 commit 58fb7af
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 109 deletions.
8 changes: 0 additions & 8 deletions src/Core/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ final class Module
'constraints' => self::PAYMENT_CONSTRAINTS,
'sort' => -1,
'capturedelay' => true,
'paymentCtrl' => false,
'handleAssets' => true,
],
self::PAYMENT_PAYPAL_ID => [
Expand All @@ -126,7 +125,6 @@ final class Module
'constraints' => self::PAYMENT_CONSTRAINTS,
'sort' => 0,
'capturedelay' => true,
'paymentCtrl' => false,
'handleAssets' => false,
],
self::PAYMENT_GOOGLE_PAY_ID => [
Expand All @@ -147,7 +145,6 @@ final class Module
'constraints' => self::PAYMENT_CONSTRAINTS,
'sort' => 0,
'capturedelay' => true,
'paymentCtrl' => false,
'handleAssets' => false,
],
self::PAYMENT_KLARNA_LATER_ID => [
Expand All @@ -168,7 +165,6 @@ final class Module
'constraints' => self::PAYMENT_CONSTRAINTS,
'sort' => 0,
'capturedelay' => true,
'paymentCtrl' => false,
'handleAssets' => false,
],
self::PAYMENT_KLARNA_OVER_TIME_ID => [
Expand All @@ -189,7 +185,6 @@ final class Module
'constraints' => self::PAYMENT_CONSTRAINTS,
'sort' => 0,
'capturedelay' => true,
'paymentCtrl' => false,
'handleAssets' => false,
],
self::PAYMENT_KLARNA_IMMEDIATE_ID => [
Expand All @@ -210,7 +205,6 @@ final class Module
'constraints' => self::PAYMENT_CONSTRAINTS,
'sort' => 0,
'capturedelay' => true,
'paymentCtrl' => false,
'handleAssets' => false,
],
self::PAYMENT_TWINT_ID => [
Expand All @@ -231,7 +225,6 @@ final class Module
'constraints' => self::PAYMENT_CONSTRAINTS,
'sort' => 0,
'capturedelay' => true,
'paymentCtrl' => false,
'handleAssets' => false,
'supported_currencies' => ['CHF'],
],
Expand All @@ -253,7 +246,6 @@ final class Module
'constraints' => self::PAYMENT_CONSTRAINTS,
'sort' => 0,
'capturedelay' => true,
'paymentCtrl' => false,
'handleAssets' => true,
],
];
Expand Down
12 changes: 0 additions & 12 deletions src/Model/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,12 @@ public function isAdyenCreditCardPayment(): bool
return $this->getAdyenPaymentConfigService()->isAdyenCreditCardPayment($this->getId());
}

/**
* Checks if the payment method is show on Payment Controller
*/
public function showInPaymentCtrl(): bool
{
return ($this->isAdyenPayment() &&
$this->getServiceFromContainer(ModuleService::class)->showInPaymentCtrl($this->getId()) &&
$this->getAdyenBoolData('oxactive') === true
);
}

/**
* Checks if the payment method is show on Order Controller
*/
public function showInOrderCtrl(): bool
{
return ($this->isAdyenPayment() &&
!$this->getServiceFromContainer(ModuleService::class)->showInPaymentCtrl($this->getId()) &&
$this->getAdyenBoolData('oxactive') === true
);
}
Expand Down
4 changes: 1 addition & 3 deletions src/Model/PaymentGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ public function executePayment($amount, &$order)
$paymentId = $sessionSettings->getPaymentId();

if ($moduleService->isAdyenPayment($paymentId)) {
if (!$moduleService->showInPaymentCtrl($paymentId)) {
$payGatewayService->doCollectAdyenRequestData();
}
$payGatewayService->doCollectAdyenRequestData();
/** @var Order $order */
$payGatewayService->doFinishAdyenPayment($amount, $order);
}
Expand Down
6 changes: 0 additions & 6 deletions src/Service/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ public function isAdyenCreditCardPayment(string $paymentId): bool
return $paymentId === ModuleCore::PAYMENT_CREDITCARD_ID;
}

public function showInPaymentCtrl(string $paymentId): bool
{
return ($this->isAdyenPayment($paymentId) &&
ModuleCore::PAYMENT_DEFINTIONS[$paymentId]['paymentCtrl']);
}

public function handleAssets(string $paymentId): bool
{
return ($this->isAdyenPayment($paymentId) &&
Expand Down
4 changes: 2 additions & 2 deletions src/Service/PaymentGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function doFinishAdyenPayment(float $amount, Order $order): bool
);
$order->save();

// trigger Capture for all PaymentCtrl-Payments with Capture-Delay "immediate"
// trigger Capture for all Payments with Capture-Delay "immediate"
if ($this->paymentConfigService->isAdyenImmediateCapture($paymentId)) {
$order->captureAdyenOrder($amount);
}
Expand All @@ -86,7 +86,7 @@ public function doFinishAdyenPayment(float $amount, Order $order): bool
}

/**
* put RequestData from OrderCtrl in the session as well as from PaymentCtrl
* put RequestData from OrderCtrl in the session
*/
public function doCollectAdyenRequestData(): void
{
Expand Down
12 changes: 0 additions & 12 deletions tests/Integration/Model/PaymentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,11 @@ public function testIsAdyenPaymentAndCheckCapture($paymentId, $isManualCapture,
$payment->load($paymentId);
$this->assertSame(isset(Module::PAYMENT_DEFINTIONS[$paymentId]), $payment->isAdyenPayment());

// Check: showInPaymentCtrl
$isActive = $payment->getFieldData('oxactive') === '1' ;
$this->assertSame(
(
isset(Module::PAYMENT_DEFINTIONS[$paymentId]) &&
Module::PAYMENT_DEFINTIONS[$paymentId]['paymentCtrl'] &&
$isActive
),
$payment->showInPaymentCtrl()
);

// Check: showInOrderCtrl
$isActive = $payment->getFieldData('oxactive') === '1' ;
$this->assertSame(
(
isset(Module::PAYMENT_DEFINTIONS[$paymentId]) &&
!Module::PAYMENT_DEFINTIONS[$paymentId]['paymentCtrl'] &&
$isActive
),
$payment->showInOrderCtrl()
Expand Down
16 changes: 3 additions & 13 deletions tests/Unit/Model/PaymentGatewayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ public function testExecutePaymentSuccess()
);
$moduleServiceMock = $this->createModuleServiceMock(
$paymentId,
1,
true,
false
true
);

$paymentGatewayMock = $this->createPaymentGatewayMock(
Expand Down Expand Up @@ -72,7 +70,7 @@ public function testExecutePaymentSuccessCollectFromRequest()
0,
1
);
$moduleServiceMock = $this->createModuleServiceMock($paymentId, 1);
$moduleServiceMock = $this->createModuleServiceMock($paymentId);

$paymentGatewayMock = $this->createPaymentGatewayMock(
$sessionSettingsMock,
Expand Down Expand Up @@ -101,7 +99,6 @@ public function testExecutePaymentInvalidAdyenPayment()
);
$moduleServiceMock = $this->createModuleServiceMock(
$paymentId,
0,
false
);

Expand Down Expand Up @@ -169,21 +166,14 @@ private function createPaymentGatewayMock(

private function createModuleServiceMock(
string $paymentId = Module::PAYMENT_CREDITCARD_ID,
int $showInCtrlInvokeCount = 0,
bool $isAdyenPayment = true,
bool $showInPaymentCtrl = true
bool $isAdyenPayment = true
): MockObject {
$moduleServiceMock = $this->createMock(ModuleService::class);
$moduleServiceMock->expects($this->once())
->method('isAdyenPayment')
->with($paymentId)
->willReturn($isAdyenPayment);

$moduleServiceMock->expects($this->exactly($showInCtrlInvokeCount))
->method('showInPaymentCtrl')
->with($paymentId)
->willReturn($showInPaymentCtrl);

return $moduleServiceMock;
}
}
44 changes: 0 additions & 44 deletions tests/Unit/Service/ModuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,39 +30,6 @@ public function testIsAdyenPaymentFalse()
$this->assertFalse($moduleService->isAdyenPayment($paymentId));
}

/**
* @covers \OxidSolutionCatalysts\Adyen\Service\Module::showInPaymentCtrl
*/
public function testShowInPaymentCtrlTrue()
{
$paymentId = ModuleCore::PAYMENT_CREDITCARD_ID;
$moduleService = oxNew(ModuleService::class);

$this->assertTrue($moduleService->showInPaymentCtrl($paymentId));
}

/**
* @covers \OxidSolutionCatalysts\Adyen\Service\Module::showInPaymentCtrl
*/
public function testShowInPaymentCtrlFalseInvalidPaymentId()
{
$paymentId = 'invalid';
$moduleService = oxNew(ModuleService::class);

$this->assertFalse($moduleService->showInPaymentCtrl($paymentId));
}

/**
* @covers \OxidSolutionCatalysts\Adyen\Service\Module::showInPaymentCtrl
*/
public function testShowInPaymentCtrlFalseNoPaymentCtrl()
{
$paymentId = ModuleCore::PAYMENT_PAYPAL_ID;
$moduleService = oxNew(ModuleService::class);

$this->assertFalse($moduleService->showInPaymentCtrl($paymentId));
}

/**
* @covers \OxidSolutionCatalysts\Adyen\Service\Module::handleAssets
*/
Expand All @@ -88,17 +55,6 @@ public function testHandleAssetsFalseInvalidPaymentId()
$this->assertFalse($moduleService->handleAssets($paymentId));
}

/**
* @covers \OxidSolutionCatalysts\Adyen\Service\Module::handleAssets
*/
public function testHandleAssetsFalseNoPaymentCtrl()
{
$paymentId = ModuleCore::PAYMENT_PAYPAL_ID;
$moduleService = oxNew(ModuleService::class);

$this->assertFalse($moduleService->handleAssets($paymentId));
}

/**
* @covers \OxidSolutionCatalysts\Adyen\Service\Module::isCaptureDelay
*/
Expand Down
12 changes: 3 additions & 9 deletions views/frontend/blocks/page/checkout/select_payment.tpl
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
[{if $paymentmethod|method_exists:'isAdyenPayment' && $paymentmethod->isAdyenPayment() && $paymentmethod->showInPaymentCtrl()}]
[{if $paymentmethod|method_exists:'isAdyenPayment' && $paymentmethod->isAdyenPayment() && $oViewConf->checkAdyenHealth() && $oView->isValidAdyenAuthorisation()}]
[{* Show Adyen Payments only if Adyen is healthy *}]
[{if $oViewConf->checkAdyenHealth()}]
[{* We include it as template, so that it can be modified in custom themes *}]
[{if $oView->isValidAdyenAuthorisation()}]
[{include file="modules/osc/adyen/payment/adyen_payment_inauthorisation.tpl"}]
[{else}]
[{include file="modules/osc/adyen/payment/adyen_payment.tpl"}]
[{/if}]
[{/if}]
[{* We include it as template, so that it can be modified in custom themes *}]
[{include file="modules/osc/adyen/payment/adyen_payment_inauthorisation.tpl"}]
[{else}]
[{$smarty.block.parent}]
[{/if}]

0 comments on commit 58fb7af

Please sign in to comment.