Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bp 3546 use object as array in buckaroo hyva checkout block totals fee get total 22 #27

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
Loading