Releases: comfino/php-sdk
Releases · comfino/php-sdk
2.0.0-beta1
Breaking Changes
- Cache system refactoring:
CacheInvalidateconstructor now requiresPsr\Cache\CacheItemPoolInterfaceinstead ofCache\TagInterop\TaggableCacheItemPoolInterface(removed dependency on abandonedcache/tag-interoppackage).- For tag-based cache invalidation, the injected pool must also implement
Symfony\Contracts\Cache\TagAwareCacheInterface(e.g., Symfony'sTagAwareAdapter). - If the pool does not support tagging,
CacheInvalidatesilently skips the invalidation step. - See UPGRADE.md for migration guide.
- For tag-based cache invalidation, the injected pool must also implement
- Bumped minimum
psr/cachefrom^2.0 || ^3.0to^1.0 || ^2.0 || ^3.0for broader compatibility with legacy stacks. - Widget script class renames:
WidgetInitScriptrenamed toWidgetFrontendInitScript;WidgetInitScriptHelperrenamed toWidgetFrontendInitScriptHelper. Update all class references and constructor calls in your integration. WidgetSdkInitScriptHelperparameter changes (vs. the formerWidgetInitScriptHelperwhen targetingcomfino-sdk.min.js): removedWIDGET_PRICE_SELECTOR,WIDGET_PRICE_OBSERVER_SELECTOR,WIDGET_PRICE_OBSERVER_LEVEL, andEMBED_METHOD; addedENVIRONMENT('sandbox'|'production') andHAS_PRICE_INPUT(bool);PRODUCT_PRICEis now an integer in grosze (smallest currency unit) instead of a PLN float.SettingsManager::getInstance()signature change: a new?ConfigurationManager $configurationManagerparameter has been inserted as the 6th argument (between?PlatformInfoInterfaceandstring $apiKey). All existing call sites must passnullor a configuredConfigurationManagerinstance in that position.OrderInterface::getAllowedProductsConfig(): ?arrayadded: third-party implementations ofOrderInterfacemust now implement this method. The safe default is to returnnull.
Security Fixes
- XSS vulnerabilities in widget initialization and logo rendering — Fixed unescaped JavaScript and HTML injection in
WidgetInitScriptHelperandFrontendHelper. Template values are now properly JSON-encoded and HTML-escaped. - Webhook request validation — Added optional replay attack mitigation and rate-limiting hooks to
WebhookManager. Introduced a 1 MB request body size limit to prevent memory exhaustion. - Cryptographic improvements — Increased token entropy from 80 to 128 bits, replaced
uniqid()withrandom_bytes()for secure random IDs, upgraded MD5 checksums to SHA-256.
Added
- Creditors support:
SettingsManager::getCreditors()fetches available creditors keyed by product type from the Comfino API, with in-memory andCacheManagercaching under the'creditors'key (taggedadmin_product_types). Returnsnullwhen the API key is absent or the call fails; an empty array is a valid "no creditors configured" response. - Allowed-products configuration:
SettingsManager::getAllowedProductsConfig()reads theCOMFINO_ALLOWED_PRODUCTS_CONFIGkey from the injectedConfigurationManagerand returns aComfino\Api\Dto\Payment\AllowedProductConfig[]DTO list (ornullwhen unconfigured).SettingsManager::getAllowedProductsConfigForFrontend()returns the same data as a plain array suitable for JSON /window.comfinoPaywallDataembedding. AllowedProductsConfigBuilder(Comfino\Backend\Payment): static helper that converts the persisted array shape[{type, maxTerm?, minTerm?, terms?}, …]toAllowedProductConfig[]viafromPersistedArray(), and the reverse viatoFrontendArray(). Malformed or type-less entries are silently skipped; returnsnullwhen the result is empty.- Paywall creditors & term constraints:
PaywallConfiggains two new optional readonly properties —?array $creditorsand?array $allowedProductsConfig— both included ingetAsArray().PaywallConfigBuilder::buildConfig()accepts matching optional parameters at the end of its signature (backward compatible). Order::getAllowedProductsConfig(): theOrderclass accepts an optional?array $allowedProductsConfigconstructor parameter (last position, defaults tonull) and exposes it via the newgetAllowedProductsConfig(): ?arraygetter defined onOrderInterface.OrderFactory::createOrder()extension: new optional?array $allowedProductsConfig = nullparameter (last position). When provided, it is threaded through to theOrderconstructor so downstream code can pass$order->getAllowedProductsConfig()directly toAbstractClient::createOrder()/validateOrder().- Platform metadata interfaces:
PlatformInfoInterfacefor exposing platform capabilities and metadata. - Webhook IP filtering:
IpWhitelistandIpWhitelistInterfacefor IP-based access control on webhooks with support for CIDR notation and multiple IP patterns. - Enhanced logging:
CookieServiceModeCheckerfor detecting and logging cookie-based service mode configuration. - Language configuration:
LanguageProviderInterfacefor pluggable language/localization settings. - Frontend environment builders:
AbstractShopEnvironmentBuilderfor constructing shop environment metadata.PaywallConfigBuilderfor building paywall configuration with theme and capability resolution.CapabilityResolverfor resolving platform capabilities and feature flags.ThemeFamilyRulesfor custom theme family and style mapping.
- Shop domain builders:
CartBuilderInterface,CustomerBuilderInterface,AbstractCartBuilder,AbstractCustomerBuilder, andAbstractStatusAdapterfor type-safe shop object construction. - Widget script helpers for the Comfino Web SDK:
WidgetSdkInitScriptandWidgetSdkInitScriptHelperfor integrations targetingcomfino-sdk.min.js— initializes viawindow.Comfino.ComfinoSDK.getInstance(),sdk.init(), andsdk.createWidget(). UseWidgetFrontendInitScriptHelperinstead for the legacyComfinoWidgetFrontend.init()interface. - Migration guide (UPGRADE.md) for v2.0.0 breaking changes.
- Suggested dependency:
symfony/cachefor PSR-6 cache with tag support.
Changed
AllowedProductsConfigBuilder::fromPersistedArray()now drops entries whosetyperesolves toUnknownLoanType(was: kept the flyweight), filterstermsto positive integers (was: any intval result), and drops entries withminTerm > maxTerm(was: kept).
Improved
- Cache system now uses Symfony Cache Contracts (replaces abandoned
cache/tag-interopdependency). - Widget and frontend rendering now use context-aware escaping (JSON encoding for JavaScript,
htmlspecialcharsfor HTML). - Webhook validation enhanced with size limits, optional replay/rate-limit hooks, and IP-based access control via
IpWhitelist. WebhookManagersupports IP whitelist filtering for incoming webhook requests.ApiClientFactoryconstructor updated to accept optionalPlatformInfoInterfacefor platform-aware client configuration.- Logging improvements:
DebugLoggerandErrorLoggernow support cookie service mode detection and enhanced context. WidgetFrontendInitScriptHelper(formerlyWidgetInitScriptHelper) refactored for improved theme and environment support.
1.0.0
Added
- Initial release of the Comfino Payment Gateway PHP Backend SDK.
ConfigurationManagersingleton for centralized API credentials and plugin settings storage via a pluggableStorageAdapterInterface.CacheManagersingleton wrapping a PSR-6CacheItemPoolInterfacewith optional PSR-6 cache-tag interop support.DebugLoggerandErrorLoggersingletons backed by a PSR-3LoggerInterface;SensitiveDataProcessormasks API keys and personal data before writing to logs.LoggerFactoryfor creating preconfigured logger instances.ProductTypeFilterManagerwith a composable filter chain:FilterByProductType,FilterByCartValueLowerLimit,FilterByCartValueUpperLimit,FilterByExcludedCategory.CategoryTreewith lazy construction viaBuildStrategyInterfaceand O(1) ID-indexed lookups;CategoryFilterfor ancestor/descendant exclusion checks.WebhookManagerfor routing authenticated incoming webhook requests to registeredWebhookEndpointInterfaceimplementations with optional rate-limiting and replay-protection hooks.- Built-in webhook endpoint implementations:
StatusNotification,Configuration,CacheInvalidate. ApiClientFactory,OrderFactory, andWebhookManagerFactoryfor consistent object construction in e-commerce plugin integrations.WidgetInitScriptandWidgetInitScriptHelperfor building the Comfino widget initialization script tag.FrontendHelperwith logo URL and paywall auth hash helpers for frontend rendering.- Concrete shop domain model implementations:
Order,Cart,CartItem,Product,Customer,Address,LoanParameters,Seller. Cart::getItemsCount()andCart::getTotalItemsCount()for distinct item count and total quantity respectively.StatusManagersingleton mapping platform-specific order status adapters to Comfino order statuses.FileUtilshelper for safe file read/write operations within plugin contexts.CacheItemTypeenum for typed cache key namespacing.- Depends on
comfino/php-api-client ^2.0for all Comfino REST API communication. - PSR-3 (
psr/log) and PSR-6 (psr/cache) interfaces with no concrete implementations bundled — bring your own (e.g.monolog/monolog,cache/filesystem-adapter). - Docker development environment (PHP 8.1-cli-alpine with optional Xdebug) and
bin/wrapper scripts. - PHPUnit 10.5 test suite (unit tests for all major subsystems).
- GitHub Actions CI matrix across PHP 8.1–8.4 with Codecov coverage upload.
- PHP_CodeSniffer PSR-12 enforcement and PHPStan level-6 static analysis.
- Comprehensive webhook security and signature verification documentation in
docs/webhooks.md.
Improved
- JSON processing in
WebhookEndpointandWidgetInitScriptHelperfor more robust data handling. - Security enhancements in webhook processing, logging, and frontend helper classes.
- Expanded unit test coverage for webhook management, frontend helpers, and widget initialization scripts.
- Composer configuration and project documentation updates.