-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "BP-3546-Use-object-as-array-in-Buckaroo-HyvaCheckout-Block-To…
…tals-Fee-getTotal-22" This reverts commit b3f8499.
- Loading branch information
1 parent
b3f8499
commit 634cdaa
Showing
3 changed files
with
71 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Buckaroo\HyvaCheckout\Block\Totals; | ||
|
||
use Magento\Checkout\Model\Session as SessionCheckout; | ||
use Buckaroo\Magento2\Helper\PaymentFee; | ||
use Magento\Framework\View\Element\Template\Context; | ||
|
||
class Fee extends \Magento\Framework\View\Element\Template | ||
{ | ||
protected PaymentFee $feeHelper; | ||
|
||
protected SessionCheckout $sessionCheckout; | ||
|
||
public function __construct( | ||
Context $context, | ||
array $data, | ||
PaymentFee $feeHelper, | ||
SessionCheckout $sessionCheckout | ||
) | ||
{ | ||
parent::__construct($context, $data); | ||
$this->feeHelper = $feeHelper; | ||
$this->sessionCheckout = $sessionCheckout; | ||
} | ||
|
||
/** | ||
* Get title based on payment method config | ||
* | ||
* @return string | ||
*/ | ||
public function getTitle(): string | ||
{ | ||
try { | ||
$payment = $this->sessionCheckout | ||
->getQuote() | ||
->getPayment(); | ||
return $this->feeHelper->getBuckarooPaymentFeeLabel($payment->getMethod()); | ||
} catch (\Throwable $th) { | ||
return __('Fee'); | ||
} | ||
return __('Fee'); | ||
} | ||
|
||
/** | ||
* Get total from array of data | ||
* | ||
* @return float | ||
*/ | ||
public function getTotal(): float | ||
{ | ||
$totalData = $this->getSegment(); | ||
$extensionAttributes = $totalData['extension_attributes'] ?? null; | ||
if ( | ||
$extensionAttributes | ||
) { | ||
return (floatval($extensionAttributes->getBuckarooFee()['buckaroo_fee'][0])); | ||
} | ||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters