# SwagVatIdValidation 500er Fehler

**URL:** <https://forum.shopware.com/t/swagvatidvalidation-500er-fehler/92961>\
**Category:** Plugins\
**Created:** [16. Februar 2022 um 09:43 UTC](https://forum.shopware.com/t/swagvatidvalidation-500er-fehler/92961 "2022-02-16T09:43:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![herieth](https://avatars.discourse-cdn.com/v4/letter/h/898d66/32.png) [@herieth](https://forum.shopware.com/u/herieth)\
**Post date:** [16. Februar 2022 um 09:43 UTC](https://forum.shopware.com/t/swagvatidvalidation-500er-fehler/92961/1 "2022-02-16T09:43:26Z")

</div>

Hallo zusammen,

ein Kunde berichtet seit einiger Zeit von Fehlversuchen bei der Anmeldung mit VAT-ID (erweiterte Prüfung).  
Ich habe es in verschiedenen Konfigurationen versucht, konnte den Fehler aber nicht nachstellen.  
Es passiert laut Log sowohl bei Neuregistrierungen als auch bei Bestandskunden beim Checkout.  
Fehler im Log ist

```auto
AH01071: Got error 'PHP message: PHP Fatal error: Uncaught TypeError: Argument 1 passed to SwagVatIdValidation\\Components\\ValidationService::removeVatIdFromBilling() must be of the type int, null given, called in /domain/web/custom/plugins/SwagVatIdValidation/Components/ValidationService.php on line 164 and defined in /domain/web/custom/plugins/SwagVatIdValidation/Components/ValidationService.php:314\nStack trace:\n#0 /domain/web/custom/plugins/SwagVatIdValidation/Components/ValidationService.php(164): SwagVatIdValidation\\Components\\ValidationService->removeVatIdFromBilling()\n#1 /domain/web/custom/plugins/SwagVatIdValidation/Bundle/AccountBundle/Constraints/AdvancedVatIdValidator.php(68): SwagVatIdValidation\\Components\\ValidationService->validateVatId()\n#2 /domain/web/vendor/symfony/validator/Validator/RecursiveContextualValidator.php(769): SwagVatIdValidation\\Bundle\\AccountBundle\\Constraints\\AdvancedVatIdVali...', referer: https://domain/en/account

```

Aufruf im access.log:

```auto
"POST /en/register/saveRegister/sTarget/account/sTargetAction/index HTTP/1.1" 500 6523

```

Es sieht ja so aus, als würde die Rechnungsadresse nicht (korrekt?) übergeben werden.  
Fällt jemandem ein, in welchem Zusammenhang diese Konstellation eintreten könnte?  
Shopware 5.7.7  
SwagVatIdValidation 2.0.9

Danke für jeden Hinweis.

**PS** : schaltet man die E-Mail-Benachrichtigung nur mittels „Shopbetreiber-E-Mail-Adresse“ ein funktioniert die Benachrichtigung nicht, da

```auto
$emailNotification = $this->config->get(VatIdConfigReaderInterface::EMAIL_NOTIFICATION);

```

in \SwagVatIdValidation\Components\ValidationService::getEmailAddress den String „1“ zurückgibt und das wg.

```auto
(\is_string($emailNotification))

```

als E-Mailadressse zu interpretieren versucht.  
Gibt man direkt eine E-Mailadresse ein geht es.

---

<div class="post-metadata">

**Author:** ![Michael\_Telgmann](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/michael_telgmann/32/20289_2.png) [@Michael\_Telgmann](https://forum.shopware.com/u/Michael_Telgmann)\
**Post date:** [16. Februar 2022 um 14:00 UTC](https://forum.shopware.com/t/swagvatidvalidation-500er-fehler/92961/2 "2022-02-16T14:00:36Z")

</div>

Hallo @herieth

genau dieser Fehler wurde mit der Version 2.0.9 behoben. Kannst du noch mal schauen, wie die Methode bei dir im Code aussieht?

Viele Grüße aus Schöppingen  
Michael Telgmann

---

<div class="post-metadata">

**Author:** ![herieth](https://avatars.discourse-cdn.com/v4/letter/h/898d66/32.png) [@herieth](https://forum.shopware.com/u/herieth)\
**Post date:** [16. Februar 2022 um 15:08 UTC](https://forum.shopware.com/t/swagvatidvalidation-500er-fehler/92961/3 "2022-02-16T15:08:15Z")

</div>

Hallo Michael,

ich vermute die Frage bezieht sich auf das PS:

custom/plugins/SwagVatIdValidation/plugin.xml

```auto
<?xml version="1.0" encoding="utf-8"?>
<plugin xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/shopware/shopware/5.6/engine/Shopware/Components/Plugin/schema/plugin.xsd">

    <label lang="de">Umsatzsteuer-ID Prüfung</label>
    <label lang="en">Vat ID-Validation</label>
    <version>2.0.9</version>

```

custom/plugins/SwagVatIdValidation/Components/ValidationService.php

```auto
    private function getEmailAddress()
    {
        $emailNotification = $this->config->get(VatIdConfigReaderInterface::EMAIL_NOTIFICATION);
 
        if (\is_string($emailNotification)) {
            $emailAddress = $emailNotification;
        } elseif ($emailNotification) {
            $emailAddress = $this->config->get('sMAIL');
        } else {
            return false;
        }
        
        return \filter_var($emailAddress, \FILTER_VALIDATE_EMAIL);
    }

```

die Datenbank speichert in der config unter „shopEmailNotification“

```auto
s:1:"1";

```

also einen String „1“  
Cache sollte es ja wohl nicht sein (hab ich aber gecleant). Vielleicht sollte ich das Plugin neu installieren?  
Schöne Grüße aus Köln  
Helmut Rieth

---

<div class="post-metadata">

**Author:** ![herieth](https://avatars.discourse-cdn.com/v4/letter/h/898d66/32.png) [@herieth](https://forum.shopware.com/u/herieth)\
**Post date:** [16. Februar 2022 um 15:35 UTC](https://forum.shopware.com/t/swagvatidvalidation-500er-fehler/92961/4 "2022-02-16T15:35:02Z")

</div>

Hallo Michael,

sorry, bezieht sich wohl auf

```auto
<changelog version="2.0.9">
        <changes lang="de">PT-12589 - Fehlverhalten bei Validierung von ungültiger ID korrigiert;</changes>

```

Welche Methode genau meinst Du? Diese hier in  
custom/plugins/SwagVatIdValidation/Components/ValidationService.php

```auto
    /**
     * Helper function to remove the VAT Id from the customer billing address
     */
    private function removeVatIdFromBilling(?int $billingAddressId, VatIdValidatorResult $result, bool $deleteVatIdFromAddress): void
    {
        if (!$deleteVatIdFromAddress || empty($billingAddressId)) {
            return;
        }

        $billingAddress = $this->modelManager->getRepository(Address::class)->find($billingAddressId);

        if (!$billingAddress instanceof Address) {
            return;
        }

        $billingAddress->setVatId(null);

        $this->modelManager->persist($billingAddress);
        $this->modelManager->flush($billingAddress);

        $country = $billingAddress->getCountry();
        if (!$country instanceof Country) {
            return;
        }

        $company = $billingAddress->getCompany();
        if ($company === null) {
            return;
        }

        if ($this->isVatIdRequired($company, $country->getId())) {
            $result->setVatIdRequired();
        }
    }

```

evt. hat sich das dann erledigt, da wir das Update gerade gestern gemacht haben …

Schöne Grüße aus Köln  
Helmut

---

<div class="post-metadata">

**Author:** ![Michael\_Telgmann](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/michael_telgmann/32/20289_2.png) [@Michael\_Telgmann](https://forum.shopware.com/u/Michael_Telgmann)\
**Post date:** [17. Februar 2022 um 09:21 UTC](https://forum.shopware.com/t/swagvatidvalidation-500er-fehler/92961/5 "2022-02-17T09:21:20Z")

</div>

Hallo Helmut,

genau, beobachte das mal weiter, der Fehler sollte nicht mehr auftreten.

Für das Config Problem habe ich gestern bereits ein Ticket angelegt: [Shopware Issuetracker](https://issues.shopware.com/issues/PT-12602)

Viele Grüße aus Schöppingen  
Michael Telgmann

---

<div class="post-metadata">

**Author:** ![rene\_boehm](https://avatars.discourse-cdn.com/v4/letter/r/d6d6ee/32.png) [@rene\_boehm](https://forum.shopware.com/u/rene_boehm)\
**Post date:** [6. Juli 2022 um 10:23 UTC](https://forum.shopware.com/t/swagvatidvalidation-500er-fehler/92961/6 "2022-07-06T10:23:44Z")

</div>

Hallo Michael,

wir haben ebenfalls ein Problem mit dem Plugin, ebenfalls 2.0.9 aber Shopware 5.6.9 und einer anderen Fehlermeldung im Checkout.

Vor allem tritt der Fehler nicht kontinuierlich auf. Wir erhalten folgenden Fehler.

 ![Checkout_Fehler](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/3X/c/a/cabe07004fdc2cad75c7f737d4d27c90e614fcbf.png)

Hat jemand auch schon diesen Fehler gehabt oder kann mir einen Tipp geben.

Danke

Gruß René

---

<div class="post-metadata">

**Author:** ![Michael\_Telgmann](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/michael_telgmann/32/20289_2.png) [@Michael\_Telgmann](https://forum.shopware.com/u/Michael_Telgmann)\
**Post date:** [11. Juli 2022 um 13:48 UTC](https://forum.shopware.com/t/swagvatidvalidation-500er-fehler/92961/7 "2022-07-11T13:48:54Z")

</div>

Hallo René,

kannst du dafür bitte ein Ticket erstellen? [Shopware Issuetracker](https://issues.shopware.com/createissue)

Viele Grüße aus Schöppingen  
Michael Telgmann
