Skip to content

Commit

Permalink
Code polish
Browse files Browse the repository at this point in the history
  • Loading branch information
woutse committed Nov 30, 2022
1 parent ec78492 commit ff54fb6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
34 changes: 25 additions & 9 deletions Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ public function getPaidStatus($methodCode)
return $this->store->getConfig('payment/' . $methodCode . '/order_status_processing');
}

/**
* @param $methodCode
* @return bool
*/
public function ignoreB2BInvoice($methodCode)
{
return $this->store->getConfig('payment/' . $methodCode . '/turn_off_invoices_b2b') == 1;
Expand All @@ -236,25 +240,36 @@ public function ignoreB2BInvoice($methodCode)
*/
public function ignoreManualCapture()
{
return $this->store->getConfig('payment/paynl/auto_capture') != 0
&& $this->store->getConfig('payment/paynl/auto_capture') != 1;
return $this->store->getConfig('payment/paynl/auto_capture') != 0 && $this->store->getConfig('payment/paynl/auto_capture') != 1;
}

/**
* @return bool
*/
public function autoCaptureEnabled()
{
return $this->store->getConfig('payment/paynl/auto_capture') >= 1;
}

/**
* @return bool
*/
public function wuunderAutoCaptureEnabled()
{
return $this->store->getConfig('payment/paynl/auto_capture') == 2;
}

/**
* @return bool
*/
public function sherpaEnabled()
{
return $this->store->getConfig('payment/paynl/auto_capture') == 3;
}

/**
* @return bool
*/
public function sendEcommerceAnalytics()
{
return $this->store->getConfig('payment/paynl/google_analytics_ecommerce') == 1;
Expand Down Expand Up @@ -318,15 +333,17 @@ public function getFailoverGateway()
return $this->store->getConfig('payment/paynl/failover_gateway');
}

public function getIconUrl($methodCode, $paymentOptionId)
/**
* @param $methodCode
* @return mixed
*/
public function getIconUrl($methodCode)
{
$brandId = $this->store->getConfig('payment/' . $methodCode . '/brand_id');
if (empty($brandId)) {
$brandId = $this->brands[$methodCode];
}
$iconUrl = $this->resources->getViewFileUrl("Paynl_Payment::logos/" . $brandId . ".png");

return $iconUrl;
return $this->resources->getViewFileUrl("Paynl_Payment::logos/" . $brandId . ".png");
}

public function getIconUrlIssuer($issuerId)
Expand Down Expand Up @@ -356,12 +373,11 @@ public function registerPartialPayments()

public function getPaymentmethodCode($paymentProfileId)
{

//Get all PAY. methods
# Get all PAY. methods
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$paymentHelper = $objectManager->get(\Magento\Payment\Helper\Data::class);
$paymentMethodList = $paymentHelper->getPaymentMethods();
$pay_methods = [];

foreach ($paymentMethodList as $key => $value) {
if (strpos($key, 'paynl_') !== false && $key != 'paynl_payment_paylink') {
$code = $this->store->getConfig('payment/' . $key . '/payment_option_id');
Expand Down
8 changes: 3 additions & 5 deletions Model/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,11 @@ protected function getCustomerGroup($code)
/**
* Get payment method icon
*
* @param string $code
*
* @return string
* @param $code
* @return mixed
*/
protected function getIcon($code)
{
$url = $this->paynlConfig->getIconUrl($code, $this->methods[$code]->getPaymentOptionId());
return $url;
return $this->paynlConfig->getIconUrl($code);
}
}

0 comments on commit ff54fb6

Please sign in to comment.