diff --git a/Model/Magewire/Payment/PlaceOrderService.php b/Model/Magewire/Payment/PlaceOrderService.php index 253d43d..3f9d4fd 100644 --- a/Model/Magewire/Payment/PlaceOrderService.php +++ b/Model/Magewire/Payment/PlaceOrderService.php @@ -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; @@ -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 * @@ -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.")" + ); + } }