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-HyvaCheckout-Block-Totals-Fee… #26

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
34 changes: 34 additions & 0 deletions Model/Magewire/Payment/PlaceOrderService.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
namespace Buckaroo\HyvaCheckout\Model\Magewire\Payment;

use Magento\Quote\Model\Quote;
use Composer\InstalledVersions;
use Magento\Framework\Registry;
use Magento\Quote\Api\CartManagementInterface;
use Hyva\Checkout\Model\Magewire\Payment\AbstractPlaceOrderService;

class PlaceOrderService extends AbstractPlaceOrderService
{
private const COMPOSER_MODULE_NAME = 'buckaroo/magento2-hyva-checkout';

protected Registry $registry;

Expand All @@ -19,6 +21,18 @@ public function __construct(
$this->registry = $registry;
parent::__construct($cartManagement);
}



/**
* @throws CouldNotSaveException
*/
public function placeOrder(Quote $quote): int
{
$this->setPlatformInfo($quote);
return parent::placeOrder($quote);
}

/**
* Redirect to buckaroo payment engine
*
Expand Down Expand Up @@ -49,4 +63,24 @@ private function hasRedirect(): bool
$response = $this->getResponse();
return !empty($response->RequiredAction->RedirectURL);
}

/**
* Set platform info to send over
*
* @param Quote $quote
*
* @return void
*/
private function setPlatformInfo(Quote $quote)
{
$version = 'unknown';

if (InstalledVersions::isInstalled(self::COMPOSER_MODULE_NAME)) {
$version = InstalledVersions::getVersion(self::COMPOSER_MODULE_NAME);
}
$quote->getPayment()->setAdditionalInformation(
'buckaroo_platform_info',
" / Hyva Checkout (".$version.")"
);
}
}
4 changes: 2 additions & 2 deletions 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 All @@ -20,7 +20,7 @@
"docs": "https://support.buckaroo.nl"
},
"homepage": "https://www.buckaroo.nl",
"version" : "v1.1.1",
"version" : "v1.1.2",
"minimum-stability": "stable",
"autoload": {
"files": [
Expand Down
Loading