Checking access…

Skip to main content
Audience: CCG Platform Engineers

Customer Creation β€” Service Flow and Events

Use this page when implementing or debugging customer identification, wallet creation, merchant associations, or vendor provisioning inside wallet-customer-service. For request and response behavior, use Find or Create Customer β€” Internal API.

wallet-customer-service resolves and persists platform, enterprise, merchant, and vendor customer records for the shared V1/V2 /customers/find call. Versioning is applied at the virtual-service and HCP layers.

If you need to...Start with
Understand which customer and wallet are selectedSelecting the CCG customer and wallet
Trace platform, merchant, or vendor recordsPersisting customer and vendor records
Debug vendor provisioningVendor provisioning and events
Check how a vendor's customer model is configuredVendor model configuration
Check the stored relationshipsStored customer relationships

Customer Creation Flow​

Scope of this flow

The diagrams below show identification decisions and entity/event processing inside wallet-customer-service. The API page owns caller-visible inputs and outcomes; the EIMP lookup and CCG database lookup pages own the detailed matching rules.

Selecting the CCG customer and wallet​

The handler validates the request, builds a CreateCustomerForMerchantCommand, and runs EIMP lookups by enterpriseId, hsid, and configured merchant identifiers in parallel. It then looks for an existing CCG customer before creating a wallet.

Two different precedence rules

When multiple EIMP lookups return golden records, the handler selects enterprise ID β†’ HSID β†’ MCID. Within the MCID lookup, merchant-configured criteria sets have their own precedence order.

Customer and wallet decision tree

For an EIMP match, identity data is used first and request values fill missing fields. An existing matching CCG customer is updated; wallet consolidation can transfer payment methods. The wallet upgrade and local-to-enterprise merge pages cover those transitions. The separate MCID criteria-set precedence in EIMP determines which merchant-configured search set runs first within the MCID lookup.

Reusing or creating a local wallet after EIMP fallback​

When EIMP does not yield one usable golden record and an HSID or MCID is available, the service checks for an existing CCG customer before creating a local wallet. This sequence shows the MCID path; a local wallet can be reused within its merchant group.

Local wallet fallback sequence

The next diagram follows the resulting platform, enterprise, merchant, and vendor records and their events. The API page explains what an internal caller sees while vendor provisioning continues.

Persisting customer and vendor records​

This entity and event diagram follows the TWO_TIER vendor path. PASS_THROUGH vendors skip vendor customer provisioning and its creation events.

Customer and vendor record lifecycle

The customer creation process is orchestrated by the service, which coordinates the creation and updating of these entities.

Customer records and merchant associations​

Enterprise Customer Creation

Enterprise Customer records are only created or updated when a customer is found through the Identity Service using one of the following parallel lookup methods:

  • Enterprise ID lookup
  • HSID lookup
  • Search criteria lookup

When a customer is found only through direct database lookup or is newly created without EIMP identity information, the Enterprise Customer record is not created or updated.

The EnterpriseCustomer entity maintains a link between the wallet platform customer and enterprise identity systems, providing integration with enterprise-level identity services.

Merchant Customer Creation

After platform and enterprise customer records are updated, the merchant customer relationship is created or updated.

Key Steps in Merchant Customer Creation​

  1. Find existing merchant customer record or create a new one
  2. Check if data has changed (to avoid unnecessary updates)
  3. Delete existing metadata records
  4. Save new merchant customer record
  5. Publish event based on whether it's a create or update operation
Platform Customer with New Merchant Association

When a customer is found at the platform level but doesn't have an existing relationship with the requested merchant, the system follows a specific flow:

  1. Check for Merchant Association: The system checks if a relationship exists between the platform customer and the specific merchant.

  2. Verify Relationship Status: If no merchant-customer relationship is found, the system creates a new association.

  3. Create New Merchant Customer Record: The system creates a new MerchantCustomer entity with:

    • Reference to the platform customer ID
    • Reference to the merchant ID
    • Customer data fields (name, email, phone, etc.)
    • Merchant-specific metadata from the request
  4. Save Metadata: Any merchant-specific metadata from the request is saved as MerchantCustomerMetadata entries.

  5. Publish Event: A MERCHANT_CUSTOMER_CREATED event is published.

  6. Vendor Customer Creation: After the merchant-customer relationship is established, the system publishes a WALLET_CUSTOMER_CREATION_INITIALIZED event to trigger the vendor customer creation process.

  7. Platform-Level Updates: No changes are made to the enterprise customer relationships or platform customer data, as these already exist.

Distinguishing Between New and Existing Merchant Customers​

The system tracks whether a merchant-customer relationship is new to determine whether to publish a MERCHANT_CUSTOMER_CREATED or MERCHANT_CUSTOMER_UPDATED event.

Handling Customer Data Consistency​

When adding a new merchant association to an existing platform customer:

  1. The system checks if the customer data in the request differs from existing data
  2. If customer data is identical, no updates are performed to avoid unnecessary processing
  3. If customer data differs, the merchant-customer record is updated with the new information

Vendor Merchant Customer Creation for Existing Platform Customers​

When a platform customer exists but doesn't have a vendor merchant customer record for a specific merchant:

  1. Platform Vendor Customer Verification: The system checks if a platform-level vendor customer record exists by looking up the customer ID and vendor name.

  2. CCG Customer Handling: When a customer is found in CCG (Convenient Checkout Group), the vendor customer creation at the platform level is skipped. The system uses the existing vendor customer record for this customer.

  3. Event Processing: When the WALLET_CUSTOMER_CREATION_INITIALIZED event is consumed:

    • For an existing platform customer with no merchant association, the system uses the existing platform vendor customer ID
    • The platform vendor customer ID is used to create a new vendor merchant customer mapping
  4. Vendor Merchant Customer Record Creation: A new VendorMerchantCustomer entity is created with:

    • The platform customer ID
    • The merchant ID
    • The vendor's customer ID
    • A status of "CREATED"
  5. Payment Method Handling: Any pending payment method setups are processed to ensure payment methods associated with the existing platform customer are properly linked to the new merchant relationship.

  6. Notification: After the vendor merchant customer is successfully created, the system publishes a WALLET_CUSTOMER_UPDATED_EVENT to notify other components.

This approach ensures that existing platform customers can be efficiently associated with new merchants without duplicating customer records in vendor systems, maintaining data integrity throughout the ecosystem.

Merchant Customer Metadata Updates

The merchant customer metadata represents custom key-value pairs specific to a merchant-customer relationship:

  1. When updating a merchant customer, all existing metadata is first deleted
  2. New metadata is created from the request's metadata map and saved with the merchant customer

Vendor provisioning and events​

Start with the provisioning steps and event sequence. The vendor model configuration below explains why a vendor follows TWO_TIER or PASS_THROUGH processing.

Initialization is not completion

WALLET_CUSTOMER_CREATION_INITIALIZED starts TWO_TIER vendor provisioning. Do not use it as proof that vendor mappings exist; WALLET_CUSTOMER_UPDATED_EVENT follows after both the vendor platform and merchant mappings are persisted.

Show vendor provisioning steps

Vendor customers represent the mapping between platform customers and their corresponding entities in vendor systems like Stripe. There are two types of vendor customer relationships:

  1. Vendor Platform Customers: A single customer representation in the vendor's platform
  2. Vendor Merchant Customers: A customer's relationship with a specific merchant within the vendor's platform

Vendor Platform Customer Creation​

Platform vendor customers are created when a VENDOR_PLATFORM_CUSTOMER_CREATED event is consumed. This step only runs when the merchant's vendor is configured as TWO_TIER in customer.vendorCustomerModels (see Vendor model configuration below).

The process includes:

  • Finding existing vendor customer record or creating a new one
  • Updating vendor customer with new information
  • Saving the vendor customer record

For PASS_THROUGH vendors (e.g., Optum Bank), this event is not published and no VendorCustomer record is persisted.

Vendor Merchant Customer Creation​

Merchant-specific vendor customers are created when a VENDOR_MERCHANT_CUSTOMER_CREATED event is consumed. As with platform customer creation, this step is gated on the TWO_TIER customer model.

The process includes:

  • Creating a new vendor merchant customer record
  • Setting the appropriate status
  • Saving the record

Vendor Customer Creation Flow​

  1. Vendor provisioning requested:

    • When a customer needs a vendor-merchant mapping, the system checks the vendor's CustomerModel via customer.vendorCustomerModels
    • If TWO_TIER and the vendor-merchant mapping does not exist, WALLET_CUSTOMER_CREATION_INITIALIZED is published to start vendor creation
    • If PASS_THROUGH or ONE_TIER, vendor customer creation is skipped (processVendorCustomer() returns immediately)
  2. Vendor Platform Customer Creation (TWO_TIER only):

    • Once the customer is created in the vendor's platform, a VENDOR_PLATFORM_CUSTOMER_CREATED event is published
    • The service consumes this event and creates a vendor customer record
  3. Vendor Merchant Customer Creation (TWO_TIER only):

    • For each merchant the customer is associated with, a VENDOR_MERCHANT_CUSTOMER_CREATED event is published
    • The service consumes these events and creates vendor merchant customer records

Payment Method Integration​

Vendor customers play a crucial role in payment method setup:

  1. When a payment method setup is initiated but is waiting for customer creation, the system:

    • Finds payment methods waiting for customer creation
    • Updates them with the vendor's customer ID
    • Initiates the payment method setup process
  2. The system updates the payment method with the vendor's customer ID, ensuring payment methods are associated with the correct customer in the vendor's system

Event sequence​

Show published and consumed events

The customer creation process is event-driven, ensuring reliable integration and extensibility:

  • WALLET_CUSTOMER_CREATION_INITIALIZED: Published to start vendor creation when a TWO_TIER vendor-merchant mapping is missing; it does not confirm completion
  • VENDOR_PLATFORM_CUSTOMER_CREATED: Published when a customer is created in the vendor's platform (TWO_TIER vendors only)
  • VENDOR_MERCHANT_CUSTOMER_CREATED: Published when a customer is created for a specific merchant in the vendor's system (TWO_TIER vendors only)
  • WALLET_CUSTOMER_UPDATED_EVENT: Published for a merchant after both the vendor platform and vendor merchant customer mappings are persisted; if their callbacks arrive out of order, publication waits until both are available
  • MERCHANT_CUSTOMER_CREATED: Published when a new merchant-customer relationship is established
  • MERCHANT_CUSTOMER_UPDATED: Published when an existing merchant-customer relationship is updated
  • PAYMENT_UPDATED_EVENT (consumed): Consumed by PaymentConsumerV2 / VersionedPaymentConsumer β€” routes to CardPaymentMethodProcessor or BankAccountPaymentMethodProcessor based on payment method type

This architecture enables:

  • Asynchronous processing and integration with external systems
  • Decoupling of customer creation from downstream processes (e.g., payment method setup)
  • Easy extension for new vendors or merchant requirements

Vendor model configuration​

wallet-customer-service uses a per-vendor configuration property (customer.vendorCustomerModels) to control whether a vendor customer record is created and surfaced in API responses. This replaced the previous hardcoded Stripe-only vendor creation logic.

CustomerModel values​

ValueBehaviour
TWO_TIERVendor customer creation is enabled. The vendor creates its customer records; CCG stores the corresponding VendorCustomer and VendorMerchantCustomer mappings.
PASS_THROUGHVendor customer creation is skipped. No vendor customer record is created by CCG. Used for Optum Bank, which manages its own customer lifecycle.
ONE_TIERReserved. Not currently used in production config.

Application configuration​

# application.yaml (production defaults)
customer:
vendorCustomerModels:
STRIPE: TWO_TIER
OPTUM_BANK: PASS_THROUGH

The config key is the vendor name uppercased (matching Merchant.vendorName). Add a new entry here when onboarding a new vendor.

Response fields and X-Vendors behavior are documented in Find or Create Customer β€” Internal API β†’ Response and vendor status.

Stored customer relationships​

Show database tables and keys

The following database relationships are established:

  1. Customer Table: The core customer entity

    • Contains basic customer information (name, email, phone, etc.)
    • Referenced by other customer-related tables
  2. Enterprise_Customer Table: Links customers to enterprise identity

    • References Customer by customerId
    • Stores enterprise IDs and HSID
  3. Merchant_Customer Table: Links customers to merchants

    • References Customer by customerId
    • References Merchant by merchantId
    • Stores merchant-specific customer information
  4. Merchant_Customer_Metadata Table: Stores merchant-specific metadata

    • References Merchant_Customer by customerId and merchantId
    • Stores key-value pairs of custom data
  5. Vendor_Customer Table: Links platform customers to vendor platform customers

    • Composite primary key of customerId and vendor
    • Stores the vendor's customer ID
  6. Vendor_Merchant_Customer Table: Links customers to merchant-specific vendor representations

    • Composite key of customerId, merchantId, and vendor
    • Stores the vendor's merchant-specific customer ID

Operational checks​

Implementation practices​

  • Always provide as many identifiers as possible in the customer creation request to maximize matching accuracy.
  • Leverage event subscriptions to integrate with downstream systems (e.g., payment, analytics, notifications).
  • Ensure idempotency in customer creation logic to avoid duplicate records.
  • Regularly audit and reconcile customer data across platform, merchant, and vendor systems.
  • Monitor event delivery and processing to ensure all downstream systems are updated as expected.

Troubleshooting​

  • Duplicate Customers: Ensure identifier resolution logic is robust and idempotent.
  • Missing Vendor Records: Check event delivery and vendor integration logs.
  • Stale Metadata: Always delete and recreate merchant customer metadata on update.
  • Integration Failures: Use event logs and retry mechanisms for resilience.