Skip to main content
Version: v2

Request Lifecycle

Overview

This document traces a POST /v2/payments request end-to-end — from the API gateway through the service layers, to the payment vendor, and finally to the webhook dispatch. Understanding this flow is essential before implementing or modifying any payment logic.


End-to-End Sequence — Create Payment


Key Checkpoints

StepWhat HappensFailure Behavior
1 — Gateway authOAuth2 token validated, scope checked (merchant, user, merchant-pci)401 Unauthorized or 403 Forbidden
2 — Request validationJSON schema, field constraints, allocation sum check400 Bad Request with field-level errors
3 — Idempotency checkmerchantTransactionId + merchantId uniquenessReturns existing payment if ≤ 5 attempts; 422 if exceeded
4 — Customer resolutionPriority: enterpriseIdentifierhsidmetadata422 if no customer can be resolved
5 — Vendor processingStripe PaymentIntent created per allocationAllocation marked FAILED; triggers rollback for split-tender
6 — State persistenceTerminal state written atomicallyDatabase transaction ensures consistency
7 — Webhook dispatchAsync delivery with at-least-once guaranteeRetries with exponential backoff; does not block response

Synchronous vs Asynchronous Boundaries

Important

The POST /v2/payments endpoint returns 202 Accepted with status INITIATED or PENDING before vendor processing completes. The merchant must either poll GET /v2/payments/{paymentId} or subscribe to webhooks to learn the final outcome.


GET Payment Lifecycle


Cancel / Capture Flow Summary

OperationMethodPreconditionAsync?
CancelPATCH /v2/payments/{paymentId}/cancelPayment in AUTHORIZED, ACCEPTED, or PENDING stateYes — returns 202
CapturePATCH /v2/payments/{paymentId}/capturePayment in AUTHORIZED stateYes — returns 202