V1 vs V2 β What Changed and Why
Engineers understanding the V1-to-V2 design shift and its consequences. For exact contract differences, see the comparison reference. Before changing code, follow the migration checklist.
Purposeβ
This document is the definitive reference for any engineer transitioning from V1 to V2 β whether implementing a new V2 feature, maintaining a V1 service that must interoperate with V2, or reviewing code. It explains what changed, why it changed, and what the practical consequences are for day-to-day development.
Read this document before any domain-specific guide. Understanding the delta between V1 and V2 is the fastest way to become productive.
Summary: Core Philosophy Changesβ
| Aspect | V1 | V2 |
|---|---|---|
| Payment model | Single flat Payment entity per transaction | Payment β PaymentAllocation hierarchy (one payment, N allocations) |
| Split-tender | Not supported | Up to 2 allocations per payment, each processed independently |
| API versioning | No version prefix (e.g. /payments) | Explicit /v2/ prefix on every endpoint |
| Response on creation | 200 OK with final state | 202 Accepted β async; state polled or received via webhook |
| Error contract | ErrorResponse DTO (ad-hoc per controller) | Problem DTO (RFC 7807-aligned) with ErrorGroup taxonomy |
| Idempotency | Partial / inconsistent | Explicit: merchantTransactionId as composite key, 5-attempt limit |
| Validation layers | Single-layer (Bean Validation) | Multi-layer: Bean Validation β structural validator β business rule validator β command pipeline |
| Event model | V1 DTOs in event/ package | V2 DTOs in events/v2/ package of wallet-event-commons |
| Vendor integration | Event Grid used; adapter logic co-located within the payment service | wallet-stripe-adapter-service is a fully separate microservice; all vendor events flow exclusively through Event Grid |
| Refund types | Linked (against a payment) and Unlinked (against a payment method) β both supported | Linked and Unlinked both supported; V2 adds refundAllocations array for per-allocation partial and split-tender refund control |
| State machine | Simple: created β completed / failed | Rich: 15+ states with explicit transient and terminal classifications |
| Shared library | wallet-event-commons with mixed v1/v2 packages | wallet-event-commons v2 packages only (v1 in active deprecation) |
| Observability | Unstructured / partial logging | Structured JSON logging with standard fields; distributed tracing |
V1 vs V2 β State Machine Changesβ
V1 had a flat status model. V2 adds 15+ states to precisely represent asynchronous processing:
| V1 States | V2 States (additions) |
|---|---|
CREATED | INITIATED β PENDING β PROCESSING β PROCESSING_DEDUP_CHECK |
AUTHORIZED | AUTH_REQUIRED β CONFIRMATION_INITIALIZED β AUTHORIZED |
CAPTURED | CAPTURE_INITIALIZED β COMPLETED |
FAILED | FAILED (unchanged terminal) |
CANCELLED | CANCEL_INITIALIZED β CANCELLED / CANCEL_FAILED |
| (not present) | ACCEPTED (ACH bank account accepted, settlement pending) |
| (not present) | ROLLED_BACK (split-tender allocation reversed after sibling failure) |
| (not present) | PENDING_FOR_CUSTOMER_CREATION |
| (not present) | PENDING_FOR_PAYMENT_METHOD_CREATION |
Key implication: V2 clients must treat non-terminal states as "in progress" and use webhooks or polling. The V1 pattern of treating the HTTP response status as the final answer does not apply in V2.
V1 vs V2 β Shared Library (wallet-event-commons)β
| Concern | V1 | V2 |
|---|---|---|
| DTO location | com.optum.wallet.common.event.* | com.optum.wallet.common.events.v2.* |
| Error DTO | ErrorResponse | Problem (RFC 7807) |
| Enums | Some duplicated across packages | Canonical in com.optum.wallet.common.enums.* |
| Refund error DTO | Custom per-service | RefundApiErrorResponse (shared) |
| Webhooks | No shared webhook DTO | Shared MerchantWebhookEvent envelope |
Rule for V2 engineers: Always import from com.optum.wallet.common.events.v2.* and com.optum.wallet.common.enums.*. Never use com.optum.wallet.common.event.* (v1) in new code.
V1 vs V2 β Coding Patternsβ
Customer Identity Resolutionβ
// V1 β customer referenced by internal UUID
{
"customer": { "id": "550e8400-..." }
}
// V2 β customer resolved by external identifier (priority order)
// 1. enterpriseIdentifier (highest priority)
// 2. hsid
// 3. metadata key-value
// At least one must be present.
{
"customer": { "hsid": "b313c1d1-..." }
}
Controller Base Pathβ
// V1
@RequestMapping("/payments")
public class PaymentController { ... }
// V2 β explicit version in base path
@RequestMapping("/v2/payments")
public class PaymentControllerV2 { ... }
Exception Handlingβ
// V1 β ad-hoc per controller
@ExceptionHandler(Exception.class)
public ResponseEntity<ErrorResponse> handle(Exception ex) {
return ResponseEntity.status(500).body(new ErrorResponse(...));
}
// V2 β centralized advisor scoped to V2 controllers
@RestControllerAdvice(assignableTypes = {PaymentControllerV2.class, RefundControllerV2.class})
public class ExceptionHandlersV2 {
@ExceptionHandler(PaymentFailedException.class)
public ResponseEntity<PaymentApiErrorResponse> handlePaymentFailed(PaymentFailedException ex) {
// Returns 422 with partial payment state in body
}
@ExceptionHandler(TransactionCommandException.class)
public ResponseEntity<Problem> handleCommandFailure(TransactionCommandException ex) {
// Returns 400 with Problem DTO
}
}