tr_payment_hub 2.0.1
tr_payment_hub: ^2.0.1 copied to clipboard
Turkish payment gateway integration (iyzico, PayTR, Param, Sipay) for Dart/Flutter.
Changelog #
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
Unreleased #
2.0.1 - 2026-01-08 #
Added #
- PaymentUtils - Shared utility class eliminating code duplication across providers
currencyToIso()- ISO 4217 currency mappingcurrencyToProviderCode()- Provider-specific currency codes (TL vs TRY)amountToCents()/amountToCentsString()- Amount formattingparseAmount()- Safe amount parsing with comma/dot handlinggenerateSecureHex()- Cryptographically secure random hex generationgenerateOrderId()/generateConversationId()- Unique ID generationgenerateDefaultInstallmentOptions()/generateDefaultInstallmentInfo()- Fallback installment dataisValidBin()/extractBin()- BIN number validation utilities
- PaymentConfigProductionValidation extension - Production environment safety checks
validateForProduction()- Returns list of potential issuesassertProduction()- Throws if sandbox mode in production
- PaymentException.sanitizedProviderMessage - Filtered error messages (removes SQL, paths, stack traces)
- BuyerInfo IPv6 support - Now validates both IPv4 and IPv6 addresses
Changed #
- Network timeout reduced - 30s → 15s (security hardening against resource exhaustion)
- All providers now use PaymentUtils - Reduced ~120 lines of duplicate code
PayTRProvider- Uses PaymentUtils for ID generation, amount formatting, currency mappingSipayProvider- Uses PaymentUtils for currency mapping, installment defaultsParamProvider- Uses PaymentUtils for ID generation, amount formatting, installment defaults
- LogSanitizer card pattern improved - Now correctly masks 13-19 digit card numbers (was 14-20)
Security #
- CardInfo.toJson() @Deprecated warning - Warns developers about PAN/CVV exposure risk
- Param SHA1 security documentation - Added warning about SHA1 being cryptographically weak (Param API requirement)
- Provider message sanitization - Filters potentially sensitive data from error messages
Documentation #
- Added comprehensive dartdoc to PaymentUtils class
- Updated provider classes with PaymentUtils usage examples
2.0.0 - 2026-01-08 #
Breaking Changes #
- Validation is now mandatory - All model classes (
CardInfo,BuyerInfo,PaymentRequest,RefundRequest) now havevalidate()methods that throwValidationExceptionfor invalid input - CardInfo.toJson() is now @internal - Use
toSafeJson()for logging which masks sensitive data (CVV, card number) - Config classes updated - New optional parameters:
connectionTimeoutandenableRetry - New exception types -
ValidationExceptionandCircuitBreakerOpenExceptionadded
Added #
- ValidationException - Comprehensive input validation with detailed error messages
errorslist for multiple validation errorsfieldproperty to identify the invalid fieldallErrorsgetter for combined error message
- RetryHandler - Exponential backoff retry mechanism
RetryConfig.noRetry- Single attempt onlyRetryConfig.conservative- Safe retry for payment operationsRetryConfig.aggressive- Fast retry for read operations- Jitter support to prevent thundering herd
- Custom retry predicates
- CircuitBreaker - Fault tolerance pattern implementation
- Three states:
closed,open,halfOpen - Automatic state transitions
CircuitBreakerManagerfor managing multiple breakersCircuitBreakerOpenExceptionwith remaining time info
- Three states:
- PaymentLogger - Secure logging with automatic sanitization
- Multiple log levels (debug, info, warning, error)
- Automatic sensitive data masking
- Payment-specific logging methods
- CardInfo.isExpired - Check if card has expired
- CardInfo.toSafeJson() - Safe JSON representation with masked CVV and card number
- BuyerInfo validation - Turkish phone format, TC Kimlik validation, email regex
- PaymentRequest validation - Amount, installment range, basket total verification, 3DS callback URL check
- RefundRequest validation - Transaction ID and amount validation
- Secure random generation - All providers now use
Random.secure()for order IDs
Changed #
- All provider files (
IyzicoProvider,PayTRProvider,ParamProvider,SipayProvider) now use secure random for ID generation - Config classes now include
connectionTimeout(default: 30s) andenableRetry(default: true) - LogSanitizer enhanced - Now masks additional sensitive data patterns:
api_key,apiKeyvaluessecret_key,secretKeyvaluestokenvaluespasswordvalues- CVV/CVC in various formats (lowercase, uppercase, JSON strings)
Security #
- Replaced weak
Random()withRandom.secure()in all providers - CVV is now never exposed in logs or JSON output
- Card numbers are automatically masked in logging
- API keys, secrets, tokens, and passwords are automatically masked in logs
Documentation #
- Added
MIGRATION.mdfor upgrading from v1.x to v2.0.0 - Updated README with security best practices
1.0.4 - 2026-01-01 #
Added #
- Param POS Provider - Full SOAP/XML integration
- Non-3DS and 3D Secure payment support
- Installment query by BIN number
- Refund operations
- Payment status query
- Sipay Provider - Full REST/JSON integration
- Bearer token authentication
- Non-3DS and 3D Secure payment support
- Saved card (tokenization) support
- Installment query
- Refund operations
- HTTP Mocking Infrastructure for testing without real API credentials
PaymentMockClientfactory class with provider-specific mock clients- Constructor injection for all providers (
httpClientparameter) - Realistic mock responses for all endpoints
- Test Fixtures - JSON/XML response files for all providers
test/fixtures/iyzico/- 5 fixture filestest/fixtures/paytr/- 4 fixture filestest/fixtures/param/- 4 XML fixture filestest/fixtures/sipay/- 6 fixture filesTestFixtureshelper class for loading fixtures
- GitHub Actions CI/CD pipeline
- Automated testing on push/PR
- Code formatting check
- Static analysis
- SDK compatibility tests (3.0.0, stable, beta)
- pub.dev score check
Changed #
- Updated README.md with new providers, test cards, and sandbox URLs
- All providers now support dependency injection for testing
- Documentation now includes testing instructions
- SDK constraint relaxed from
^3.10.4to>=3.0.0 <4.0.0for wider compatibility - Removed deprecated lint rules (
package_api_docs,avoid_returning_null_for_future)
Fixed #
- Provider table now correctly shows Param and Sipay as stable
- CI/CD SDK compatibility issue resolved
1.0.3 - 2025-12-24 #
Added #
- Comprehensive dartdoc documentation for all public APIs
toJson()andfromJson()methods for all model classescopyWith()methods for immutable model updatesequalsandhashCodeoverrides for value equalitytoString()overrides for better debugging- English README.md with full API documentation
- Turkish README_TR.md for local users
- Enhanced lint rules in analysis_options.yaml
- Flutter example app with realistic payment flow:
- Payment form with card input
- 3D Secure WebView integration
- Callback URL interception
- Result screen
Changed #
- Updated pubspec.yaml description to meet pub.dev guidelines
- Improved code documentation coverage
- Exports are now alphabetically sorted
1.0.2 - 2025-12-20 #
1.0.0 - 2025-12-15 #
Added #
- Initial release
- iyzico payment provider integration
- Non-3DS and 3D Secure payment support
- Installment query by BIN number
- Refund operations
- Payment status query
- PayTR payment provider integration
- iFrame token based payments
- 3D Secure payment flow
- Callback hash verification
- Refund support
- Core features
- Unified
PaymentProviderinterface PaymentRequest,PaymentResult,RefundRequestmodelsCardInfowith Luhn validation and maskingBuyerInfo,BasketItem,AddressInfomodelsPaymentExceptionwith standardized error codesLogSanitizerfor secure logging
- Unified
- Testing utilities
MockPaymentProviderfor unit testing- Configurable success/failure scenarios
- Custom delay support