Customer Creation
- CCG uses three primary identifiers:
enterpriseId,hsid, andmcid - Identification follows a strict precedence order to ensure consistency
- Enterprise wallets enable a unified customer experience across merchants
- Local wallets are created when enterprise identification is not possible but can be shared within merchant groups
- The
findOrCreateCustomerendpoint (POST /customers/find) is the recommended method for customer creation — it performs synchronous identity resolution before returning a response
- Customers are authenticated users, who have a wallet with the Convenient Checkout system.
Overview
CCG (Convenient Checkout Gateway) creates and manages customer records using multiple identifiers to ensure accurate mapping and a seamless experience across merchants and channels. The primary identifiers are:
hsid(HealthSafe ID)enterpriseId(Enterprise Identity)mcid(Merchant Customer Identifiers)
Customer creation requires at least one primary identifier (enterpriseId, hsid, or metadata/mcid); if none is provided, the process cannot continue.
At least one of enterpriseId, hsid, or metadata must be provided. If all three are absent, the API returns an error: "Required any one of the identifier. Enterprise Id or hsid or MCID".
HTTP Status: Always 200 OK on success.
Primary Identifiers
-
enterpriseId: A global identifier representing a consumer's enterprise identity. This enables CCG to consolidate all wallets and payment methods for a customer across all merchants, providing a unified experience and supporting enterprise wallet upgrades.
Example:"enterpriseId": "603041336" -
hsid: HSID (HealthSafe ID) is the authentication (credentials) method developed by UHG for authenticating users for websites and mobile applications.
Format:uuid(Universally Unique Identifier)
Example:"hsid": "123e4567-e89b-12d3-a456-426614174000" -
merchant customer identifiers (
mcid): Merchant-specific identifiers (such aspatientId,subscriberId,dependentCode,exchangeId, etc.) that allow merchants to uniquely identify their customers within their own systems. CCG supports multiple mcids per customer, as defined by each merchant's configuration.
Example:"patientId": "222333444","subscriberId": "ABC789"
Types of Wallets
CCG supports two types of wallets to accommodate different customer identification scenarios:
-
Enterprise Wallet: Created when a customer can be identified with EIMP using enterpriseId or hsid or merchant-specific identifiers (mcid) . This wallet type enables customers to have a unified payment experience across multiple merchants within the enterprise.
-
Local Wallet: Created when a customer can only be identified using merchant-specific identifiers (mcid) but cannot be matched to an enterprise identity. Local wallets can be shared across merchants that belong to the same merchant group, providing a consistent experience within that group.
Local merchant wallets can be upgraded to enterprise wallets when additional identification is available. For details on how this process works,
Identification Precedence
The system follows a strict precedence order when identifying customers:
enterpriseId- Highest precedence, direct match to enterprise identityhsid- Second priority, can be resolved to anenterpriseIdmcid- Uses merchant-specific identifiers with configurable matching rules defined inenterpriseSettings
For details on the enterpriseSettings configuration and how it affects customer identification with mcid, see Customer Look up Logic using enterpriseSettings.
Process Flow — findOrCreateCustomer
Step-by-Step Execution
- Validate Request: Calls
CustomerRequest.validate()to ensure at least one ofenterpriseId,hsid, ormetadatais present. - Build Command: Maps the request to a
CreateCustomerForMerchantCommandwith the merchant ID from theX-Merchant-Idheader and vendor set toSTRIPE. - Identity Resolution (via
CreateCustomerCommandHandler):- Updates metadata with digital-identity-supported IDs.
- Performs parallel identity lookups against the Enterprise Identity Management Platform (EIMP):
- By
enterpriseId - By
hsid - By search ID (metadata-based / mcid)
- By
- If a golden record is found in EIMP:
- Searches for an existing customer in CCG matching the golden record's identifiers.
- If found: updates the customer with identity data (name, email, phone, DOB, ZIP from the identity service, falling back to request values), saves it, handles payment method transfers, and publishes a
WALLET_CUSTOMER_CREATION_INITIALIZEDevent if no vendor-merchant-customer mapping exists yet. - If not found: creates a new enterprise wallet from the identity response.
- If no golden record and only
enterpriseIdwas provided (nohsid, nometadata): throws an error — "Customer Not found for given Enterprise Id". - If no golden record but
hsidormetadatais present: searches for an existing customer byenterpriseId/hsid/merchant-identifier. If found, updates it; if not found, creates a new local wallet from request fields. - Creates or updates the merchant-customer association.
- Enrich Response:
- Fetches the
VendorCustomerrecord (Stripe platform-level) to populatevendorPlatformCustomerId. - Fetches the
VendorMerchantCustomerrecord (Stripe merchant-level), if it exists, to populatestatus,walletVendorMerchantId, andvendorMerchantCustomerId. - If no vendor-merchant mapping exists yet,
statusdefaults to INITIATED.
- Fetches the
- Return
200 OKwith the fully resolvedCustomerResponse.
Wallet Handling Logic
- Enterprise Wallet Creation: When a customer's
enterpriseId,hsid, ormcidmatches a single golden record in EIMP - Local Wallet Creation: When a customer cannot be matched in EIMP using mcid, when multiple/ambiguous matches are found, or when EIMP returns no results
- Wallet Updates: When a customer already exists, the wallet is retrieved and updated with any new information from the identity service (or from the request as a fallback)
- Payment Method Transfers: When wallets are consolidated, payment methods are transferred to ensure the customer has a unified set of payment methods
- Special Cases:
- When a wallet needs to be made inactive, associated payment methods must be handled appropriately
- When a customer has different identifiers across different merchants, the system may need to consolidate wallets
Customer Identification & Wallet Creation Workflow
View Identification Workflow Diagram
MCID Identification with Enterprise Settings
Enterprise Settings Configuration
When identifying customers using merchant customer identifiers (mcid), the system relies on the merchant's enterpriseSettings configuration. This configuration defines:
- The specific merchant identifiers used for customer lookup
- How these identifiers map to enterprise identity fields
- Which fields are required vs. optional for a positive match
- The precedence order for trying different identification strategies
For detailed information on how this works, see Customer Look up Logic using enterpriseSettings.
Local Wallet Creation Process
Local Wallet Creation Workflow
When a customer cannot be identified through EIMP (or when multiple/ambiguous matches are found), a local wallet is created. This process ensures merchants can still provide a consistent payment experience even when enterprise identification isn't possible.
Example Scenarios
Scenario 1: Customer with enterpriseId — existing wallet
- Request: Merchant sends
POST /customers/findwithenterpriseIdandX-Merchant-Idheader - Process:
validate()passes —enterpriseIdis present- Identity service finds a golden record for the
enterpriseIdin EIMP - CCG database finds an existing customer matching the
enterpriseId - Customer record is updated with the latest identity data
VendorCustomerandVendorMerchantCustomerrecords are fetched for response enrichment
- Result: Returns
200 OKwith existing enterprise wallet andstatus: "CREATED"
Scenario 2: Customer with hsid — new enterprise wallet
- Request: Merchant sends
POST /customers/findwithhsidonly - Process:
validate()passes —hsidis present- Identity service resolves the
hsidto a golden record in EIMP - CCG database does not find an existing customer matching the
hsid - A new enterprise wallet is created from the identity response
- A
WALLET_CUSTOMER_CREATION_INITIALIZEDevent is published
- Result: Returns
200 OKwith new enterprise wallet andstatus: "INITIATED"(vendor provisioning pending)
Scenario 3: Customer with enterpriseId only — not found in EIMP
- Request: Merchant sends
POST /customers/findwith onlyenterpriseId(nohsid, nometadata) - Process:
validate()passes —enterpriseIdis present- Identity service finds no golden record for the
enterpriseIdin EIMP - Since only
enterpriseIdwas provided (no fallback identifiers), the system cannot create a wallet
- Result: Returns error — "Customer Not found for given Enterprise Id"
Scenario 4: MCID with single match in EIMP
- Request: Merchant sends
POST /customers/findwithmetadata(e.g.,patientId) - Process:
validate()passes —metadatais present- Identity service searches by mcid using the merchant's
enterpriseSettingscriteria - A single matching golden record is found in EIMP
- CCG database checks if a customer exists for this identity
- If not found, a new enterprise wallet is created
- Result: Returns
200 OKwith enterprise wallet
Scenario 5: MCID with multiple matches or no match in EIMP
- Request: Merchant sends
POST /customers/findwithmetadata(e.g.,patientId) - Process:
validate()passes —metadatais present- Identity service searches by mcid but finds multiple matching records (or no records)
- System cannot determine a single enterprise identity
- A local wallet is created using the mcid
- Result: Returns
200 OKwith local wallet shared within the merchant group
Scenario 6: No identifiers provided
- Request: Merchant sends
POST /customers/findwith noenterpriseId,hsid, ormetadata - Process:
validate()fails — none of the required identifiers are present
- Result: Returns error — "Required any one of the identifier. Enterprise Id or hsid or MCID"
Integration with Merchant Groups
The merchant groups concept is critical for local wallet functionality:
- Merchants within the same group can share local wallets
- A customer identified by mcid at one merchant can have their wallet reused at another merchant in the same group
- This enables scenarios like healthcare provider networks or related retail chains to provide a consistent customer experience