Sylius: Cannot capture payment when the en_US locale is disabled for the channel

Created on 24 Nov 2017  ·  9Comments  ·  Source: Sylius/Sylius

| Q | A
| ---------------- | -----
| Bug report? | yes
| Feature request? | no
| BC Break report? | no
| RFC? | no
| Sylius version | 1.0.4

When placing an order in the shop, it is not possible to capture a payment when the en_US locale is not assigned to the channel for which the order is placed. Example channel locale configuration which triggers this issue:

sylius_admin_channels_locale_settings

When trying to place an order, the user is redirected to the payment/capture route, which results in a NotFoundHttpException being thrown with the folllowing message:

The "en_US" locale is unavailable in this channel.

The error occurs on line 77 of src/Sylius/Bundle/ShopBundle/EventListener/NonChannelLocaleListener.php.

Potential Bug Stale

Most helpful comment

I think I'm running into a related issue caused by the same problem.

When going through the checkout my locale is always nl_NL, but after placing the order the locale changes to en_US.

Presumably this is caused by the payum route definitions (for example payum_capture_do). These do not have knowledge about any locale and fall back to the default (in my case en_US).

All 9 comments

Full stack trace:

Symfony\Component\HttpKernel\Exception\NotFoundHttpException:
The "en_US" locale is unavailable in this channel.

  at vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/EventListener/NonChannelLocaleListener.php:77
  at Sylius\Bundle\ShopBundle\EventListener\NonChannelLocaleListener->restrictRequestLocale(object(GetResponseEvent), 'kernel.request', object(TraceableEventDispatcher))
  at call_user_func(array(object(NonChannelLocaleListener), 'restrictRequestLocale'), object(GetResponseEvent), 'kernel.request', object(TraceableEventDispatcher))
     (vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php:104)
  at Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke(object(GetResponseEvent), 'kernel.request', object(ContainerAwareEventDispatcher))
  at call_user_func(object(WrappedListener), object(GetResponseEvent), 'kernel.request', object(ContainerAwareEventDispatcher))
     (vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php:212)
  at Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(array(object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener)), 'kernel.request', object(GetResponseEvent))
     (vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php:44)
  at Symfony\Component\EventDispatcher\EventDispatcher->dispatch('kernel.request', object(GetResponseEvent))
     (vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php:139)
  at Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch('kernel.request', object(GetResponseEvent))
     (vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:129)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
     (vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:68)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
     (vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:169)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
     (web/app_dev.php:42)

I also have the same problem,disable the en_US,add product image not display,error about The "en_US" locale is unavailable in this channel.

What is the value of %locale% parameters in your apps?

Hi @pamil,

The value of parameters.locale in app/config/config.yml was still en_US. I changed this to nl, cleared the cache, and afterwards I could successfully place an order.

Shouldn't the default locale that is configured for the channel override the setting from the config.yml?

Aad

PS After changing the locale in the config.yml from en_US to nl I couldn't add any product to the cart due to a database error related to a missing shipping method name for the nl locale (even though I didn't select a shipping method yet). This is probably a separate issue, so this need not be handled here.

I think I'm running into a related issue caused by the same problem.

When going through the checkout my locale is always nl_NL, but after placing the order the locale changes to en_US.

Presumably this is caused by the payum route definitions (for example payum_capture_do). These do not have knowledge about any locale and fall back to the default (in my case en_US).

Hi,
This bug is always on Sylius release 1.3.6 with Symfony 4.2.2 too with locale "fr_FR".

bug

This code solved my problem :

capture

same me but solved same @mayiencode
thank you

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in a week if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

igormukhingmailcom picture igormukhingmailcom  ·  3Comments

mikemix picture mikemix  ·  3Comments

hmonglee picture hmonglee  ·  3Comments

eb22fbb4 picture eb22fbb4  ·  3Comments

inssein picture inssein  ·  3Comments