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.
- Endpoint:
POST /v2/customers/find - Scope: Internal CCG endpoint β triggered as part of session and payment flows, not called directly by external merchants.
- API Version:
v2 - Prerequisites: Valid
X-Merchant-Idheader. At least one ofenterpriseId,hsid, ormetadata(mcid) must be provided. - Internal API Reference:
/engineering-guide/internal-api-v2/
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,
π InternalInternal information β not visible in the public (merchant) site.
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
π InternalInternal information β not visible in the public (merchant) site.
Vendor Customer Creation Modelβ
How CCG creates and returns vendor customer data (e.g., Stripe or Optum Bank customer records) depends on the CustomerModel configured per vendor for the merchant.
| CustomerModel | Vendor customer created? | vendorContext response |
|---|---|---|
TWO_TIER | Yes β CCG creates a customer record in the vendor's platform | Includes real vendorPlatformCustomerId and vendorMerchantCustomerId from the vendor's API |
PASS_THROUGH | No β vendor manages its own customer lifecycle | vendorPlatformId is null; vendorPlatformCustomerId is set to the customer's HSID |
ONE_TIER | Reserved β not currently used | β |
The vendorContext field in the response is a map keyed by vendor name (e.g., STRIPE, OPTUM_BANK). Callers can request context for specific vendors by passing the X-Vendors header:
X-Vendors: STRIPE,OPTUM_BANK
When X-Vendors is omitted, all vendors configured for the merchant are included.
For the full engineering details and configuration reference, see Vendor Customer Model Configuration.
API Requestβ
POST /v2/customers/find is an internal CCG endpoint. It is invoked by CCG as part of session and payment flows. For the full request schema and field definitions, see the Internal API Reference.
Request with enterpriseId
POST /v2/customers/find
X-Merchant-Id: <merchant-id>
{
"enterpriseId": "603041336"
}
Request with hsid
POST /v2/customers/find
X-Merchant-Id: <merchant-id>
{
"hsid": "123e4567-e89b-12d3-a456-426614174000"
}
Request with merchant identifiers (metadata)
POST /v2/customers/find
X-Merchant-Id: <merchant-id>
{
"metadata": {
"patientId": "222333444"
}
}
API Responseβ
POST /v2/customers/find always returns 200 OK on success. The operation is idempotent β it creates or updates the customer record and returns the resolved state.
Success β existing enterprise wallet (status: CREATED)
{
"walletCustomerId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"status": "CREATED",
"enterpriseId": "603041336",
"firstName": "Jane",
"lastName": "Doe",
"email": "jane.doe@example.com"
}
Success β new customer, vendor provisioning pending (status: INITIATED)
{
"walletCustomerId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"status": "INITIATED",
"enterpriseId": "603041336"
}
Error β no identifier provided
{
"error": "Required any one of the identifier. Enterprise Id or hsid or MCID"
}
Error β enterpriseId not found in EIMP (no fallback identifier)
{
"error": "Customer Not found for given Enterprise Id"
}
Status Handlingβ
The status field in the customer response reflects vendor provisioning state:
| Status | Meaning |
|---|---|
INITIATED | Customer record created in CCG; vendor provisioning (e.g., Stripe customer registration) is pending asynchronously. |
CREATED | Vendor provisioning complete β customer is ready for payment method setup and payments. |
The endpoint always returns 200 OK. Subscribe to the WALLET_CUSTOMER_CREATION_INITIALIZED event to be notified when vendor provisioning completes and status transitions from INITIATED to CREATED.
Error Handlingβ
| Scenario | Behaviour |
|---|---|
None of enterpriseId, hsid, metadata provided | Validation error β "Required any one of the identifier. Enterprise Id or hsid or MCID" |
enterpriseId provided but not found in EIMP and no fallback identifiers | Not-found error β "Customer Not found for given Enterprise Id" |
Invalid or missing X-Merchant-Id header | Merchant lookup error β request rejected before customer resolution |
For session-level and payment-level error codes that can occur when customer creation is triggered as part of those flows, see Session Error Codes and Payment Error Codes.
FAQβ
Q: Does calling this endpoint multiple times for the same customer create duplicates?
- No. The endpoint is idempotent. If a customer record already exists matching the provided identifiers, it is retrieved and updated β not duplicated.
Q: What happens if both enterpriseId and hsid are provided?
enterpriseIdtakes precedence. If a golden record is found byenterpriseId, thehsidis used only as a supplementary signal.
Q: Why does the customer return status: INITIATED instead of CREATED?
INITIATEDmeans the CCG record exists but the vendor (e.g., Stripe) customer has not been provisioned yet. The provisioning happens asynchronously. Wait for theWALLET_CUSTOMER_CREATION_INITIALIZEDevent before attempting payment method setup.
Q: Can a local wallet be promoted to an enterprise wallet later?
- Yes. If enterprise identity becomes available (e.g., user logs in with their HSID), a subsequent call to this endpoint with the
hsidcan upgrade the local wallet. See Wallet Upgrade Logic for details.
Integration Checklistβ
-
X-Merchant-Idheader is configured correctly for each environment - At least one of
enterpriseId,hsid, ormetadatais included in every request - Response
statusis checked β handleINITIATED(provisioning pending) separately fromCREATED(ready) - Event listener is configured for
WALLET_CUSTOMER_CREATION_INITIALIZEDto detect when vendor provisioning completes - Error handling is implemented for missing-identifier and not-found-in-EIMP cases
- Retry logic does not duplicate customers β confirm idempotency is relied on correctly
- Tested in staging with all three identifier types (
enterpriseId,hsid,metadata)