Skip to main content
Version: v2

Service Architecture

Overview

The wallet-payment-service is a backend microservice responsible for orchestrating the complete payment lifecycle in the Convenient Checkout platform. It sits behind the API gateway and coordinates between merchants, the checkout widget, the Stripe payment processor, and downstream notification systems.


High-Level Component Diagram

Service Boundaries

The Stripe Adapter (wallet-stripe-adapter-service) is a separate microservice that communicates with wallet-payment-service asynchronously via Azure Event Grid, not via direct HTTP calls. This decouples payment orchestration from vendor integration.

The Merchant Service (wallet-merchant-service) is responsible for receiving terminal state events and orchestrating webhook delivery to merchants. It delegates the actual HTTP delivery to the Merchant Webhook Proxy (wallet-merchant-webhook-proxy), which handles payload signing, retry logic, and at-least-once delivery guarantees.


Layer Responsibilities

Controller Layer

ResponsibilityDetails
Request deserializationParse and bind incoming JSON to request DTOs
Header extractionRead X-Merchant-Id, X-Upstream-Env, X-Source
Input validationBean validation (@Valid), schema-level constraints
Response mappingMap service results to HTTP response codes (200, 202, 4xx, 5xx)
No business logicControllers must not contain payment rules or state transitions

Service Layer

ResponsibilityDetails
Payment orchestrationState machine transitions, flow routing (single vs split-tender)
Idempotency enforcementDedup check on merchantTransactionId
Customer resolutionLookup/create customer via identifier priority chain
Allocation processingIterate allocations, delegate to adapter, handle rollback
Event emissionTrigger webhook events on terminal state transitions

Stripe Adapter (wallet-stripe-adapter-service)

This is a separate microservice, not a layer within wallet-payment-service. It communicates via Azure Event Grid.

ResponsibilityDetails
Vendor abstractionTranslate internal payment events to Stripe PaymentIntent API calls
Error translationMap Stripe error codes to internal error taxonomy and publish result events
ResilienceCircuit breaker, timeout, retry policies for Stripe calls
Idempotency keysPass merchantTransactionId as Stripe idempotency key
Event consumptionSubscribe to payment events from Event Grid, publish result events back

Merchant Service & Webhook Proxy (wallet-merchant-servicewallet-merchant-webhook-proxy)

The Merchant Service (wallet-merchant-service) is the domain owner for merchant configuration, onboarding, and webhook event delivery. It subscribes to terminal state events via Event Grid, builds the webhook payload, and delegates delivery to the Merchant Webhook Proxy (wallet-merchant-webhook-proxy).

The Webhook Proxy handles the actual HTTP delivery to the merchant's registered endpoint. This separation keeps the merchant service focused on domain logic while the proxy handles transport-level concerns.

Merchant Service responsibilities:

ResponsibilityDetails
Event consumptionSubscribe to terminal events (COMPLETED, FAILED, CANCELLED, etc.) from Event Grid
Merchant configurationManage merchant settings, onboarding, and webhook URL registration
Payload constructionBuild webhook payload from event data using merchant-specific settings
Delivery delegationForward constructed payloads to the Webhook Proxy for delivery

Webhook Proxy responsibilities:

ResponsibilityDetails
HTTP deliveryPOST to merchant-registered webhook URL
RetryAt-least-once delivery with exponential backoff
SecuritySign payloads with HMAC, include verification headers

Repository Layer

ResponsibilityDetails
Data persistenceCRUD operations on payment, allocation, customer tables
Transaction boundariesEnsure atomicity of state transitions
Query patternsLookup by paymentId, merchantTransactionId, merchantId
Audit columnsMaintain createdAt, updatedAt, createdBy

Security Boundaries

BoundaryMechanism
Merchant → API GatewayOAuth 2.0 bearer token. Scopes: merchant, user, merchant-pci
Payment Service ↔ Event GridAzure-managed authentication; service identity
Stripe Adapter → StripeAPI key authentication (secret key stored in vault)
Service → DatabaseConnection pooling with encrypted credentials
Merchant Service → Webhook Proxy → MerchantSigned payload with HMAC, OAuth2/JWT verification
Data Protection

Sensitive customer and card data (PAN, CVV, full SSN) must never be logged, stored in plaintext, or exposed in API responses. All card data is tokenized by Stripe — services only store masked references (last four, brand, expiry). See Security & Compliance.