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

Include language in the order creation #90

Merged
merged 1 commit into from
Sep 15, 2023
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
15 changes: 13 additions & 2 deletions Model/Request/Transactions.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Mondu\Mondu\Helpers\OrderHelper;
use Mondu\Mondu\Model\Ui\ConfigProvider;
use Magento\Framework\UrlInterface;
use Magento\Framework\Locale\Resolver;

class Transactions extends CommonRequest implements RequestInterface
{
Expand Down Expand Up @@ -52,6 +53,11 @@ class Transactions extends CommonRequest implements RequestInterface
*/
private $buyerParams;

/**
* @var Resolver
*/
private $store;

/**
* @param Curl $curl
* @param CartTotalRepository $cartTotalRepository
Expand All @@ -68,7 +74,8 @@ public function __construct(
ConfigProvider $configProvider,
OrderHelper $orderHelper,
UrlInterface $urlBuilder,
BuyerParamsInterface $buyerParams
BuyerParamsInterface $buyerParams,
Resolver $store
) {
$this->_checkoutSession = $checkoutSession;
$this->_cartTotalRepository = $cartTotalRepository;
Expand All @@ -77,6 +84,7 @@ public function __construct(
$this->orderHelper = $orderHelper;
$this->urlBuilder = $urlBuilder;
$this->buyerParams = $buyerParams;
$this->store = $store;
}

/**
Expand Down Expand Up @@ -140,7 +148,6 @@ protected function getRequestParams()
{
$quote = $this->_checkoutSession->getQuote();
$quote->collectTotals();
$requiresShipping = $quote->getShippingAddress() !== null ? 1 : 0;

$quoteTotals = $this->_cartTotalRepository->get($quote->getId());

Expand All @@ -150,7 +157,11 @@ protected function getRequestParams()
$cancelUrl = $this->urlBuilder->getUrl('mondu/payment_checkout/cancel');
$declinedUrl = $this->urlBuilder->getUrl('mondu/payment_checkout/decline');

$locale = $this->store->getLocale();
$language = $locale ? strstr($locale, '_', true) : 'de';

$order = [
'language' => $language,
'currency' => $quote->getBaseCurrencyCode(),
'state_flow' => ConfigProvider::AUTHORIZATION_STATE_FLOW,
'success_url' => $successUrl,
Expand Down
Loading