How maxipago/sdk-java-v2 works
Project Type and Purpose
• This is a Maven‐based Java SDK (client library) designed to simplify integrations with the MaxiPago payment gateway.
• It abstracts XML generation, HTTP communication, and response parsing for operations like auth, capture, sale (credit/debit), boleto, Pix, 3DS2, antifraud, recurring, customer/card management, etc.
File Structure Analysis
• Top‐level pom.xml: Maven project definition.
• src/main/java/com/maxipago: Core package containing:
• Domain models (Customer, Payment, Order, CardInfo, Pix, Wallet, SDWO, etc.)
• Enums (processor IDs, UI types, periods).
• Payment methods subpackage (Card, Boleto, OnlineDebit, Pix, Token).
• Request subpackage (AbstractRequest, Processor, ApiRequest/ApiResponse, TransactionRequest/Response).
• MaxiPago.java: entry point, ties Environment + request builders.
• src/test: Wiremock tests + sample XML responses for contract testing.
README Insights
• Lists supported operations (auth, sale, cancel, refund, zero‐dollar, 3DS, SDWO, dynamic MCC, Pix).
• Shows how Environment selects sandbox/production.
• Demonstrates builder-style, chainable API for constructing requests.
• Exposes key response fields and guidance on using responseCode.
Core Components
a. Component Identification
1. SDK Layer
– Entry Point: MaxiPago (Environment config)
– Request Builders: auth(), sale(), capture(), cancel(), pix(), etc.
– Domain Models: Customer, Payment, Card, Pix, Wallet, Item, SDWO, Device, Document
– Enums: SdkInterfaceEnum, SDWOProcessingType, etc.
2. Request Processing Layer
– AbstractRequest: common XML‐building logic
– Processor: HTTP transport abstraction
– ApiRequest/ApiResponse & RApiRequest/RApiResponse: mapping between domain and raw HTTP payloads
3. Transport / Serialization Layer
– XML Renderer / Serializer (SaveOnFile, RenderOptions)
– HTTP Client (Java URLConnection or 3rd-party HTTP library)
4. Test Harness
– Wiremock server stub
– Sample XML fixtures
5. External Services
– MaxiPago API endpoints (sandbox | production)
– Optional: Fraud Control, 3DS v2 provider, acquiring banks
b. Relationships & Data Flow
• Developer code calls MaxiPago → selects Environment → calls a request builder (e.g., maxiPago.sale()).
• Builder populates Domain Models → AbstractRequest transforms models into XML.
• Processor sends XML via HTTP to external MaxiPago API → receives XML response.
• ApiResponse parsing → maps back to TransactionResponse (domain).
• Response returned to developer.
c. Architectural Patterns & Principles
• Builder / Fluent API for request construction.
• Template Method in AbstractRequest for common XML building + extension hooks.
• Single Responsibility: separate domain models, request builders, transport logic.
• Testable—HTTP interactions isolated via Processor + Wiremock.
• Configuration abstraction: Environment for sandbox vs. production.
d. Key Technologies & Libraries
• Java 8+; Maven for build and dependency management.
• HTTP client (built‐in or Apache HttpClient).
• XML serialization/parsing (manual or JAXB).
• Wiremock for integration tests.