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-3281 Add additional Software header #20

Merged
Merged
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
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.")"
);
}
}
Loading