# Changelog

All notable changes to this project will be documented in this file.

## [1.5.0] - 2026-10-12
### Added
- Helper method `Utils::Utf16Len()` for calculating UTF-16 code units length compatible with C# backend length validations.
- Static method `PaymentGatewayRequester::encodeBody()` with safe JSON encoding using `JSON_INVALID_UTF8_SUBSTITUTE` and `JSON_THROW_ON_ERROR`.
- `ext-mbstring` dependency in `composer.json`.

### Fixed
- Fixed UTF-8 multibyte truncation issue in `Utils::ClearAndTruncateText()` ensuring valid UTF-8 strings and length limit within UTF-16 code units.
- Improved `Utils::ClearText()` to replace block HTML tags (`</p>`, `</li>`, `<br>`, `</div>`, `<h1>`-`<h6>`) with spaces, decode HTML entities, and safely handle invalid UTF-8 bytes using `mb_scrub()`.
- Updated `Utils::CheckVariableLen()` and `Utils::CheckValueUrl()` to validate lengths based on UTF-16 code units instead of byte length (`strlen`).
- Fixed JSON body encoding in `PaymentGatewayRequester::sendPostRequest()` to prevent silent `false`/empty body on invalid UTF-8 strings.
- Added timeout settings (`CURLOPT_TIMEOUT` = 30, `CURLOPT_CONNECTTIMEOUT` = 10) in `PaymentGatewayRequester`.
- Fixed token sanitization in `PaymentGatewayRequester` by removing `htmlspecialchars()` escaping (which corrupted tokens with special characters like `&`, `<`, `>`, `"`, `'`) and safely stripping CR/LF characters.
- Fixed JSON field name mappings for API DTOs in `AbstractToArray`:
  - `BasketItem::$text1Long` -> `textLong1`
  - `PaymentRequest::$paymentReferenceType` -> `paymentType`
  - `CardHolder::$cardHolderName` -> `cardholderName`
