mollie/Shopware6

reOpenTransaction in class TransactionTransitionService throws Exception for non en/de shops

stefanbwt opened this issue · 13 comments

Hello,

We have several shops in other languages than english or german, eg: it, fr.
When we try to repay an canceled order in the italian shop we get an exception of the function reOpenTransaction in class TransactionTransitionService.
$transaction->getStateMachineState()->getName() throws an Exception for non en/de shops as there is no translation in the database, and fallback language does not work.
Please use $transaction->getStateMachineState()->getTranslation('name') , or just use $transaction->getStateMachineState()->getTechnicalName()

BR
Stefan

Hi there

thank you for this

ok, interesting
so I just need to create a new sales channel with e.g. italian and retry a payment?

thank you

We had a localization problem caused by something different, but it seems like DE or EN do have at least to exist as SW itself and all plugins use DE/EN as fallback in case your language is not natively supported. So, you can ADD as many languages as you want, but DE/EN (preferably DE) must be activated even if you don't plan to use that.
As most plugins only seem to support DE/EN at install time, either install will fail - or you end up with a plugin that you can't translate to IT manually as the required variables aren't even created (text modules and such).
At least, that was our experience. I don't think using a separate sales channel for IT can solve this problem.

hi everyone

so before I fix something, i would love to reproduce it the way you do it
unfortunately i wasn't able to do so

just installed the swag language pack and used a dutch only shop
it all worked

can someone help me with a step by step guide to set up such a shop that breaks things?

thanks

Hi,

the problem should hit you if you disable all unwanted languages in your main sales channel before you install any plugins, including DE and EN.
In our test case, we left only FR as allowed language and then tried to install some plugins. One of the problems we encountered were missing language variables that showed up in the frontend like "group.variableName" in plain text. Also, the Symfony debugger showed errors because of missing or undefined variables - or we had "undefined" errors in the browser console, mostly caused by Ajax requests. Of course, those plugins did not work as intended or even caused a white page of death (500).

The reason seems to be the way Shopware 6 deals with languages - obviously, the developers had not expected that somebody would set up a shop with both DE and(!) EN beeing disabled. This causes the fallback issues. :-(

Dieter

hi
short question, why would i need to install plugins afterwards?
i thought the error happens on the transition when doing the checkout...installing plugins as action seems like trying to get an error when installing the plugin?

can you please help me to reproduce the step in mollie? when i only have dutch, or italian as language, then i do not get an error. languages in the settings cannot be disabled, so it should be enough to un-assign them from the sales channel

i really dont know how to reproduce it
the only thing that might make a difference is because i used the language plugin to get other languages
how did you add your languages? because it sounds as if they dont have all required entries?
if that is the case then i can reproduce it and at least improve/fix the mollie plugin for you, but if other plugins also crash, you might need to finish your snippets

maybe you can help me a bit by only focusing on the steps to reproduce for mollie :) thanks you

Hello,

Steps to reproduce:
We have a demoshop (sw 6552) here https://demoshop.bwtdigital.com/it-it/ with one salesChannel with the languages english, german, and italian. Default language and country is german/germany. SwagLanguage Plugin (3.0.0) and Mollie Plugin(4.2.0) installed
The Mollie Plugin is configured as this:
MolliePayments.config.testMode true
MolliePayments.config.debugMode true
MolliePayments.config.shopwareFailedPayment false
MolliePayments.config.enableCreditCardComponents false
MolliePayments.config.oneClickPaymentsEnabled false
MolliePayments.config.oneClickPaymentsCompactView false
MolliePayments.config.enableApplePayDirect false
MolliePayments.config.createCustomersAtMollie true
MolliePayments.config.useMolliePaymentMethodLimits false
MolliePayments.config.automaticShipping true
MolliePayments.config.automaticCancellation false
MolliePayments.config.refundManagerEnabled true
MolliePayments.config.refundManagerAutoStockReset true
MolliePayments.config.refundManagerVerifyRefund true
MolliePayments.config.refundManagerShowInstructions true
MolliePayments.config.subscriptionsEnabled false
MolliePayments.config.subscriptionsShowIndicator false
MolliePayments.config.subscriptionsAllowAddressEditing false
MolliePayments.config.subscriptionsAllowPauseResume false
MolliePayments.config.subscriptionsAllowSkip false
MolliePayments.config.subscriptionSkipRenewalsOnFailedPayments false
MolliePayments.config.subscriptionsReminderDays 2
MolliePayments.config.subscriptionsCancellationDays 0
MolliePayments.config.fixRoundingDiffEnabled false
MolliePayments.config.useShopwareJavascript true
MolliePayments.config.orderStateWithAPaidTransaction "skip"
MolliePayments.config.orderStateWithAFailedTransaction "skip"
MolliePayments.config.orderStateWithACancelledTransaction "skip"
MolliePayments.config.orderStateWithAAuthorizedTransaction "skip"
MolliePayments.config.orderStateWithAChargebackTransaction "skip"
MolliePayments.config.orderStateWithRefundTransaction "skip"
MolliePayments.config.orderStateWithPartialRefundTransaction "skip"

When i go through the checkout process in the italian page (https://demoshop.bwtdigital.com/it-it/ ) till Mollie windows opens (https://www.mollie.com/checkout/test-mode?method=paypal&token=6.ourkm2)
i click on the lower left link.
Then im redirected to the shop page https://demoshop.bwtdigital.com/it-it/mollie/payment/failed/018b378733ac71a1bc7689aa9ab4e254
Here i click on "Pay with a different Payment Method" Button which will redirect me to https://demoshop.bwtdigital.com/it-it/mollie/payment/retry/018b378733ac71a1bc7689aa9ab4e254 -> error
Error on prod.log:
request.CRITICAL: Uncaught PHP Exception TypeError: "Shopware\Core\System\StateMachine\Aggregation\StateMachineState\StateMachineStateEntity::getName(): Return value must be of type string, null returned.
Comming from Mollie function reOpenTransaction in class TransactionTransitionService where it does $transaction->getStateMachineState()->getName()

BR
Stefan

"short question, why would i need to install plugins afterwards?"

My comment was not directly in reply to the original topic (sorry!), but it pointed to a general problem in Shopware.
Many plugins only come with DE/EN as languages. If you have a shop where both DE/EN are disabled and you install plugins after you disabled them, you are in trouble. Re-enabling DE later will not help you as Shopware failed to initialize some variables at install time of the plugin. Unfortunately, installing the plugin on such a system may work properly without errors.
[Edit: The install procedure may work properly, the plugin will not!]

However, Stafan just wrote that he has DE enabled for his sales channel, so fallback should not be of an issue for him.

Stefan, just do be sure:
Was DE active at install time - or did you re-enable it later when you had those errors?

Dieter

Hi,
DE and EN were always activated.
Most importent thing to reproduce this is MolliePayments.config.shopwareFailedPayment = false.
So not to use the shopware standard failed payment behavior.
If a customer then tries to repay a canceled order he will get that error in the retry route:
http://localhost:8080/it-it/mollie/payment/retry/018b3c191974715398ea3710943391c1
image

To reprocude i did the following this time:

  1. setup vanilla dockware/dev:6.5.6.0
  2. add italian language without swag language pack this time:
    image
  3. add it sales channel it-it:
    image
  4. install/activate latest mollie plugin and set the config according to above
  5. activate payment Method Mollie Paypal and add it to to sales channel
  6. go to checkout process in italian shop, select mollie paypal as payment method until you are redirected to mollie:
    image
  7. Click on Metodo di pagamento
  8. You are redireced to the payment failed site in the shop where you click on the blue Button "Bezahlen Sie mit einer anderen Zahlungsart":
    image
  9. Error Message thrown:
    image

BR
Stefan

Hi Stefan,

ok, then I got your original post wrong - I thought DE/EN are disabled.
That's why I came up with the "deactivated language problem": The symptoms you described sounded pretty familiar to me. But if DE/EN were enabled at all times, that should not be an issue.

Dieter

Hi

so I wasn't able to reproduce it yet, but isn't that a problem in Shopware
doesnt the error say that NULL is returned instead of STRING in the function getName()

then this is a missing-cast error inside the Shopware class

public function getName(): string
    {
        return $this->name;
    }

so the only thing that is possible for me is to use the technical name for the log
it changes the log, which isnt a huge impact in that case. so i hope that will then solve your issue

thank you
just merged this change, it will come with the next version :)