Skip to content

Commit

Permalink
Include language in the order creation (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurmmoreira authored Sep 15, 2023
1 parent a8ec94e commit ac1cc12
Showing 1 changed file with 13 additions and 2 deletions.
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

0 comments on commit ac1cc12

Please sign in to comment.