Skip to content

Added functionality to validate Paysera Delivery API credentials (project_id and password) for use during initial setup or configuration changes#5

Merged
mateusz-kaczmarek-paysera merged 3 commits into
paysera:mainfrom
alexleopnet:main
Feb 18, 2026

Conversation

@alexleopnet

Copy link
Copy Markdown
Contributor

What's Changed

New Features

  • validateCredentials() method in DeliveryFacade for credential validation
  • ✅ Public getPublicMerchantClient() method for unauthenticated requests
  • ✅ New CredentialsValidationException exception class for error handling
  • ✅ Rate limiting support (HTTP 429) with proper error handling

Documentation

  • 📚 Comprehensive documentation in docs/VALIDATING_CREDENTIALS.md:
    • Usage examples in configuration forms
    • Setup wizard examples
    • Handling different response types (valid/invalid/rate limit)
    • Architectural flow description
    • Best practices and security notes

Technical Implementation

Code Changes:

  • DeliveryFacade.php - added entry point validateCredentials() method
  • DeliveryOrderService.php - business logic with logging
  • DeliveryApiClient.php - error handling
  • DeliveryOrderApiClient.php - API communication
  • MerchantClientProvider.php - new public client without MAC authentication
  • CredentialsValidationException.php - new exception class
  • BaseException.php - added E_CREDENTIALS_VALIDATION_FAILED constant

Tests:

  • DeliveryFacadeTest.php - tests for facade layer
  • DeliveryOrderServiceTest.php - tests for service layer
  • DeliveryApiClientTest.php - tests for api client
  • DeliveryOrderApiClientTest.php - tests for order api client
  • MerchantClientProviderTest.php - tests for public client

Dependencies:

  • Updated paysera/lib-delivery-api-merchant-client to dev-master with validateProjectCredentials() support

How It Works

The validation uses a public (unauthenticated) API endpoint /rest/v1/projects/validate-credentials:

  • HTTP 204 - credentials are valid
  • HTTP 401 - credentials are invalid
  • HTTP 429 - rate limit exceeded

Usage Example

try {
    $isValid = $deliveryFacade->validateCredentials($projectId, $password);

    if ($isValid) {
        // Save credentials and continue
    } else {
        // Show error: invalid credentials
    }
} catch (CredentialsValidationException $exception) {
    // Handle rate limit or connection errors
}

Important Notes

⚠️ Purpose: This method is intended only for one-time validation during setup. DO NOT use before regular operations (creating orders, etc.)

🔒 Security: Validation is performed server-side, without MAC authentication for the public endpoint

📝 Logging: All validation attempts (successful and failed) are logged via DeliveryLoggerInterface

Added functionality to validate Paysera Delivery API credentials (project_id and password) for use during initial setup or configuration changes
@dankovalenko-paysera

Copy link
Copy Markdown
Contributor

Looks fine

@mateusz-kaczmarek-paysera mateusz-kaczmarek-paysera merged commit 79b6dbc into paysera:main Feb 18, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants