Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat(core): enhance DataVault integration, certificate handling, and test suite #12

Merged
merged 7 commits into from
Jan 29, 2025

Conversation

gustavovalverde
Copy link
Contributor

This PR introduces major improvements to the core functionality and test infrastructure:

DataVault Integration

  • Fixed DataVault token creation and payment processing:
    • Added required fields: channel, store, saveToDataVault
    • Properly handle empty cardNumber and expiration when using tokens
    • Updated field length constraints (dataVaultToken: 36 chars, altMerchantName: 25 chars)
    • Improved schema validation for token-based payments

Certificate Management

  • Enhanced certificate handling in src/config.ts:
    • Support for multiple certificate formats (file paths, PEM content, base64)
    • Proper error handling for invalid certificates
    • Added certificate validation and parsing
    • Added example for certificate verification (examples/check-certificates.ts)

Schema Improvements

  • Restructured payment schemas for better type safety:
    • Split into CardPaymentSchema and TokenPaymentSchema
    • Added proper validation for DataVault operations
    • Updated field constraints to match Azul API requirements
    • Improved type definitions for all operations

Test Suite Enhancements

  • Added comprehensive test card fixtures with helper functions
  • Created utility functions for standardized assertions and error handling
  • Updated all integration tests to use proper validation
  • Added specific tests for:
    • Card limits and expiration validation
    • Certificate handling with various formats
    • DataVault operations with proper fields
    • Payment processing with tokens

Error Handling

  • Improved validation error messages
  • Added handling for temporary system errors
  • Enhanced type safety with proper TypeScript types
  • Added warning logs for debugging

Documentation

  • Updated .env.sample with certificate configuration
  • Added examples for certificate verification
  • Improved code comments and type definitions

This update significantly improves the reliability and maintainability of the codebase, particularly in areas of DataVault integration, certificate handling, and test infrastructure.

- Added new `config.ts` for centralized configuration management
- Added `check-certificates.ts` example for certificate validation
- Updated API client to support certificate configuration
- Enhanced `.env.sample` with certificate-related variables

This improves certificate handling and provides better examples for users implementing certificate-based authentication.
- Update DataVault schemas to include required fields (channel, store)
- Add proper type definitions for Create and Delete operations
- Improve ProcessPaymentSchema to handle DataVault tokens correctly
  - Split into BasePaymentSchema, CardPaymentSchema and TokenPaymentSchema
  - Add proper validation for token-based payments
  - Update field constraints (altMerchantName: 25 chars, dataVaultToken: 36 chars)
- Remove DataVaultTransaction enum in favor of literal types
- Fix documentation comments and typos
- Add test card fixtures with consistent test data
- Create utility functions for common test assertions:
  - expectSuccessfulPayment
  - expectSuccessfulVerification
  - expectSuccessfulVaultResponse
  - expectSuccessfulVoid
  - expectValidationError
  - expectOrderIds
- Update all integration tests to use shared test cards and assertions
- Add proper type guards and response type definitions
- Handle temporary system errors (91) gracefully with warnings
- Improve test descriptions and organization
- Create new example script for end-to-end payment processing
- Demonstrate key Azul API workflows: hold, post, and verification
- Include environment configuration logging and error handling
- Use test card fixture and random order ID for realistic scenario
- Replace hardcoded environment variables with CONFIG import
- Leverage centralized configuration for test API instance setup
- Improve consistency with recent configuration management changes
- Remove test case for non-PEM certificate file
- Simplify test suite by eliminating redundant error handling scenario
- Maintain core certificate error testing logic
- Add environment and channel configuration options
- Clarify certificate and key input methods
- Update payment method example with more detailed parameters
- Improve documentation for API initialization and usage
@crisog crisog self-requested a review January 29, 2025 00:24
src/azul-api/api.ts Show resolved Hide resolved
@crisog crisog merged commit 1e8519c into lucrise-llc:main Jan 29, 2025
Copy link

🎉 This PR is included in version 2.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Copy link

@joelGabriel7 joelGabriel7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i was review this changes and test working really well an exception for 3ds example apper a validation error PostInputMode when i test, i fixed it and created a example workflow to data-vault

@crisog
Copy link
Contributor

crisog commented Jan 29, 2025

i was review this changes and test working really well an exception for 3ds example apper a validation error PostInputMode when i test, i fixed it and created a example workflow to data-vault

Feel free to open a PR, I'll review & merge it 💯

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants