-
Notifications
You must be signed in to change notification settings - Fork 143
Open
Description
I encountered a problem in which I have two channels:
- Polish
- English
Polish channel contains only polish lang, english has english only.
In the services.yaml file the default language is defined as pl_EN.
When I go to the english channel and try to go to payment, I am redirected to the home page.
The reason is routing configuration:
<?xml version="1.0" encoding="UTF-8" ?>
<routes xmlns="http://symfony.com/schema/routing" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/routing https://symfony.com/schema/routing/routing-1.0.xsd">
<route id="payum_capture_do_session" path="/payment/capture/session-token">
<default key="_controller">Payum\Bundle\PayumBundle\Controller\CaptureController::doSessionTokenAction</default>
</route>
<route id="payum_capture_do" path="/payment/capture/{payum_token}">
<default key="_controller">Payum\Bundle\PayumBundle\Controller\CaptureController::doAction</default>
</route>
</routes>
etc. for any other route in bundle.
Since in Sylius ShopBundle we have a method:
final class NonChannelLocaleListener
{
...
/**
* @throws NotFoundHttpException
*/
public function restrictRequestLocale(RequestEvent $event): void
{
...
$requestLocale = $request->getLocale();
if (!in_array($requestLocale, $this->channelBasedLocaleProvider->getAvailableLocalesCodes(), true)) {
$event->setResponse(
new RedirectResponse(
$this->router->generate(
'sylius_shop_homepage',
['_locale' => $this->channelBasedLocaleProvider->getDefaultLocaleCode()],
),
),
);
}
}
}
everytime we are redirecting to payum routes, $request->getLocale() provides invalid locale, which causes redirect to homepage instead of payment proceeding.
Quick solution for this is to add /{_locale}
in paths (system will automatically provide this locale from previous actions):
<?xml version="1.0" encoding="UTF-8" ?>
<routes xmlns="http://symfony.com/schema/routing" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/routing https://symfony.com/schema/routing/routing-1.0.xsd">
<route id="payum_capture_do_session" path="/{_locale}/payment/capture/session-token">
<default key="_controller">Payum\Bundle\PayumBundle\Controller\CaptureController::doSessionTokenAction</default>
</route>
<route id="payum_capture_do" path="/{_locale}/payment/capture/{payum_token}">
<default key="_controller">Payum\Bundle\PayumBundle\Controller\CaptureController::doAction</default>
</route>
</routes>
for all routes included.
Metadata
Metadata
Assignees
Labels
No labels