Skip to content

Commit

Permalink
Merge pull request #27 from buckaroo-it/BP-3546-Use-object-as-array-i…
Browse files Browse the repository at this point in the history
…n-Buckaroo-HyvaCheckout-Block-Totals-Fee-getTotal-22

Bp 3546 use object as array in buckaroo hyva checkout block totals fee get total 22
  • Loading branch information
AlbinaBaraliu authored Jul 5, 2024
2 parents 4d8263c + ec01afe commit c8f66d7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
22 changes: 12 additions & 10 deletions Block/Totals/Fee.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@ class Fee extends \Magento\Framework\View\Element\Template
{
protected PaymentFee $feeHelper;

protected SessionCheckout $sessionCheckout;
protected SessionCheckout $sessionCheckout;

public function __construct(
Context $context,
array $data,
PaymentFee $feeHelper,
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
*
Expand All @@ -33,8 +35,8 @@ public function getTitle(): string
{
try {
$payment = $this->sessionCheckout
->getQuote()
->getPayment();
->getQuote()
->getPayment();
return $this->feeHelper->getBuckarooPaymentFeeLabel($payment->getMethod());
} catch (\Throwable $th) {
return __('Fee');
Expand All @@ -50,11 +52,11 @@ public function getTitle(): string
public function getTotal(): float
{
$totalData = $this->getSegment();
$extensionAttributes = $totalData['extension_attributes'] ?? null;
if (
isset($totalData['extension_attributes']['buckaroo_fee']) &&
is_scalar($totalData['extension_attributes']['buckaroo_fee'])
$extensionAttributes
) {
return floatval($totalData['extension_attributes']['buckaroo_fee']);
return (floatval($extensionAttributes->getBuckarooFee()['buckaroo_fee'][0]));
}
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "buckaroo/magento2-hyva-checkout",
"description": "Buckaroo Magento 2 hyva checkout extension",
"require": {
"php": "~8.1.0"
"php": ">=8.1"
},
"type": "magento2-module",
"license": "CC-BY-NC-ND-3.0",
Expand Down

0 comments on commit c8f66d7

Please sign in to comment.