Skip to content

Commit

Permalink
BP-3281 Add additional Software header
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivascu Madalin committed Dec 13, 2023
1 parent 9ced5e0 commit f6f9d5e
Showing 1 changed file with 34 additions and 0 deletions.
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.")"
);
}
}

0 comments on commit f6f9d5e

Please sign in to comment.