Skip to content

Commit

Permalink
codestyles, phpmd, phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniil Tkachev committed Oct 16, 2024
1 parent 72129de commit dd82377
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
15 changes: 12 additions & 3 deletions src/Controller/AccountSavedPaymentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use OxidSolutionCatalysts\Unzer\Traits\ServiceContainer;
use OxidEsales\Eshop\Core\Registry;
use UnzerSDK\Exceptions\UnzerApiException;
use UnzerSDK\Resources\PaymentTypes\Paypal as UnzerSDKPaypal;

class AccountSavedPaymentController extends AccountController
{
Expand Down Expand Up @@ -47,6 +48,11 @@ public function render()
return $this->_sThisTemplate;
}

/**
* @throws \Doctrine\DBAL\Driver\Exception
* @throws \Doctrine\DBAL\Exception
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
protected function setPaymentListsToView(): void
{
$transactionService = $this->getServiceFromContainer(Transaction::class);
Expand All @@ -69,14 +75,17 @@ protected function setPaymentListsToView(): void
$currency,
$customerType
);

$paymentType = $unzerSDK->fetchPaymentType($paymentTypeId);
if (strpos($paymentTypeId, 'crd') && method_exists($paymentType, 'getBrand')) {
$paymentTypes[$paymentType->getBrand()][$transactionOxId] = $paymentType->expose();
}
if (strpos($paymentTypeId, 'ppl')) {
if (!empty($paymentType->getEmail())) {
if (
strpos($paymentTypeId, 'ppl')
&& $paymentType instanceof UnzerSDKPaypal
&& !empty($paymentType->getEmail())
) {
$paymentTypes['paypal'][$transactionOxId] = $paymentType->expose();
}
}
if (strpos($paymentTypeId, 'sdd')) {
$paymentTypes['sepa'][$transactionOxId] = $paymentType->expose();
Expand Down
9 changes: 4 additions & 5 deletions src/Service/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use UnzerSDK\Resources\Payment;
use UnzerSDK\Resources\PaymentTypes\PaylaterInstallment;
use UnzerSDK\Resources\PaymentTypes\PaylaterInvoice;
use UnzerSDK\Resources\PaymentTypes\Paypal as UnzerSDKPaypal;
use UnzerSDK\Resources\TransactionTypes\AbstractTransactionType;
use UnzerSDK\Resources\TransactionTypes\Cancellation;
use UnzerSDK\Resources\TransactionTypes\Charge;
Expand Down Expand Up @@ -690,13 +691,11 @@ private function setPaymentTypes(

foreach ($this->transPaymentTypeIds as $unzerId => $oxVar) {
if (strpos($paymentTypeId, $unzerId)) {
if ($unzerId === 'ppl') {
if (!empty($paymentType->getEmail())) {
$result[$oxVar][$paymentTypeId] = $paymentType->expose();
}
} else {
if ($unzerId === 'ppl' && $paymentType instanceof UnzerSDKPaypal && !empty($paymentType->getEmail())) {
$result[$oxVar][$paymentTypeId] = $paymentType->expose();
continue;
}
$result[$oxVar][$paymentTypeId] = $paymentType->expose();
}
}
return $result;
Expand Down

0 comments on commit dd82377

Please sign in to comment.