Checking access…

Skip to main content
Audience: CCG Platform Engineers

How to Migrate a V1 Endpoint to V2

Use this checklist when implementing or reviewing a V2 endpoint while V1 traffic remains active. See the comparison reference for exact contract differences and the overview for the design changes.

Migration Checklist for Engineers​

Use this checklist when implementing a new V2 endpoint or migrating a V1 endpoint:

API Contract​

  • Route is under /v2/ prefix
  • POST creation endpoints return 202 Accepted, not 200 OK
  • Response is wrapped in Resource<T> envelope with url field
  • All error responses use Problem DTO (or PaymentApiErrorResponse / RefundApiErrorResponse for domain-specific 422s)

Validation​

  • Bean Validation on all DTO fields with explicit message strings
  • Cross-field rules extracted into a @ConstraintValidator (not inline if/else in service)
  • Business rules that need a 422 (not 400) use PaymentFailedException.forBusinessViolation()
  • Command pipeline used for checks requiring external calls (customer, merchant)

Shared Library​

  • All enums imported from com.optum.wallet.common.enums.*
  • All event DTOs imported from com.optum.wallet.common.events.v2.*
  • No imports from com.optum.wallet.common.event.* (v1)
  • Problem or domain-specific error DTO used β€” not ErrorResponse

Asynchronous Semantics​

  • Service method returns Mono<T> β€” no .block() calls
  • Response returned before async processing completes (202 pattern)
  • Webhook event emitted on all terminal state transitions

Idempotency​

  • merchantTransactionId + merchantId used as composite dedup key
  • Retry count checked and incremented atomically
  • Terminal payments (COMPLETED, FAILED, CANCELLED) returned as-is on retry

Security & Observability​

  • All user-supplied strings passed through LogSanitizationUtil.sanitizeForLog()
  • Sensitive fields (PAN, CVV, account numbers) never logged
  • merchantId, requestId, and resource ID present in structured log fields
  • Merchant ownership verified before returning any resource (404 on mismatch)

Testing​

  • Unit tests cover all validation layers including error paths
  • @WebFluxTest controller test for every HTTP status the endpoint can return
  • Integration test for idempotency (duplicate merchantTransactionId returns existing record)