Loading src/Plugin/Commerce/PaymentGateway/SveaCheckout.php +21 −2 Original line number Diff line number Diff line Loading @@ -388,8 +388,14 @@ class SveaCheckout extends OffsitePaymentGatewayBase implements SveaCheckoutInte // cases it will just create duplicated data for first/last names in // billing/shipping profiles. Omit such cases. if ($address['FirstName'] || $address['LastName']) { $full_name = implode(' ', [$address['FirstName'], $address['LastName']]); if ($full_name == $address['FullName']) { // There might be cases when Svea saves name parts vice versa for some // reasons. So check both of possible combinations. $name_parts = [$address['FirstName'], $address['LastName']]; $separator = ''; if (in_array($this->removeSpaces($address['FullName']), [ $this->removeSpaces(implode($separator, $name_parts)), $this->removeSpaces(implode($separator, array_reverse($name_parts))), ])) { unset($mapping['FullName']); } } Loading @@ -401,6 +407,19 @@ class SveaCheckout extends OffsitePaymentGatewayBase implements SveaCheckoutInte } } /** * Removes spaces from the string. * * @param string $string * String. * * @return string * String without spaces. */ protected function removeSpaces(string $string): string { return preg_replace('/\s+/', '', $string); } /** * {@inheritdoc} */ Loading Loading
src/Plugin/Commerce/PaymentGateway/SveaCheckout.php +21 −2 Original line number Diff line number Diff line Loading @@ -388,8 +388,14 @@ class SveaCheckout extends OffsitePaymentGatewayBase implements SveaCheckoutInte // cases it will just create duplicated data for first/last names in // billing/shipping profiles. Omit such cases. if ($address['FirstName'] || $address['LastName']) { $full_name = implode(' ', [$address['FirstName'], $address['LastName']]); if ($full_name == $address['FullName']) { // There might be cases when Svea saves name parts vice versa for some // reasons. So check both of possible combinations. $name_parts = [$address['FirstName'], $address['LastName']]; $separator = ''; if (in_array($this->removeSpaces($address['FullName']), [ $this->removeSpaces(implode($separator, $name_parts)), $this->removeSpaces(implode($separator, array_reverse($name_parts))), ])) { unset($mapping['FullName']); } } Loading @@ -401,6 +407,19 @@ class SveaCheckout extends OffsitePaymentGatewayBase implements SveaCheckoutInte } } /** * Removes spaces from the string. * * @param string $string * String. * * @return string * String without spaces. */ protected function removeSpaces(string $string): string { return preg_replace('/\s+/', '', $string); } /** * {@inheritdoc} */ Loading