@@ -184,10 +184,15 @@ public function checkVatNumber($countryCode, $vatNumber, $requesterCountryCode =
184184
185185 $ requestParams = [];
186186 $ requestParams ['countryCode ' ] = $ countryCode ;
187- $ requestParams ['vatNumber ' ] = str_replace ([' ' , '- ' ], ['' , '' ], $ vatNumber );
187+ $ vatNumberSanitized = $ this ->isCountryInEU ($ countryCode )
188+ ? str_replace ([' ' , '- ' , $ countryCode ], ['' , '' , '' ], $ vatNumber )
189+ : str_replace ([' ' , '- ' ], ['' , '' ], $ vatNumber );
190+ $ requestParams ['vatNumber ' ] = $ vatNumberSanitized ;
188191 $ requestParams ['requesterCountryCode ' ] = $ requesterCountryCode ;
189- $ requestParams ['requesterVatNumber ' ] = str_replace ([' ' , '- ' ], ['' , '' ], $ requesterVatNumber );
190-
192+ $ reqVatNumSanitized = $ this ->isCountryInEU ($ requesterCountryCode )
193+ ? str_replace ([' ' , '- ' , $ requesterCountryCode ], ['' , '' , '' ], $ requesterVatNumber )
194+ : str_replace ([' ' , '- ' ], ['' , '' ], $ requesterVatNumber );
195+ $ requestParams ['requesterVatNumber ' ] = $ reqVatNumSanitized ;
191196 // Send request to service
192197 $ result = $ soapClient ->checkVatApprox ($ requestParams );
193198
0 commit comments