Checking access…

Skip to main content
Version: v2
Audience: Consumers, CCG Platform Engineers

Create a Session

When to use this page

Building the request to create a checkout session. For what a Session is conceptually, see Sessions β€” Overview.

Create a Session via POST v2/sessions to launch the CCG checkout widget for a specific capability β€” a one-time payment, adding a payment method, wallet management, etc.

Integration Details​

Integration Details
  • Prerequisite: Merchant account onboarded to the CCG Platform. See Getting Started.
  • API Endpoint: POST /v2/sessions β€” creates a checkout session
  • API Spec: Create Session
  • Scope: merchant
  • Session Modes: PAYMENT, PAYMENT_METHOD_ENTRY, PAYMENT_WITH_WALLET, WALLET, PAYMENT_METHOD_SELECT, PAYMENT_METHOD_DISPLAY
  • Widget Integration: Pass the checkoutSessionId (Embedded) or hostedUrl (Hosted) returned in the response to the widget
  • Error Handling: See Session Error Codes for session-specific errors


API Request​

API Specification

For complete field definitions, constraints, and validations, refer to the OpenAPI Spec.

The request body has three top-level objects: customer, payment, and config. The config.modes array determines which widget capability is activated β€” choose the mode that matches your use case (one-time payment, add a method, wallet management, etc.).

Full modes table and config field reference

See Sessions β€” Modes, Config & Status Reference for every mode, and the full config object reference for fields beyond modes/channels/vendors (language, save mode, merchant display name, merchantOrigin, and more).

Payment Method Channels​

The config.paymentMethodChannel field controls which channels are available for each payment method type (card: web form, text, email, Apple Pay, Google Pay; bank account: web form). For V2 sessions, use config.vendors[] instead β€” see Vendor Configuration.

WEBFORM is always included automatically for non-agent sessions, even if not explicitly requested β€” this guarantees a web-based payment path is always available. TEXT and EMAIL are delivery channels, not processing channels, and don't affect vendor SDK initialization. Agent sessions do not get WEBFORM force-added β€” agents receive exactly the channels they're authorized for.

V2 Vendor Filter​

For V2 sessions, you can scope the session to a specific payment processor, payment method type, and set of channels using config.vendors[].

See Vendor Configuration for full details, including:

  • How to restrict the session to specific processors (STRIPE, OPTUM_BANK)
  • How vendorConfigs is resolved and returned in the response
  • WEBFORM default behavior and delivery channel handling
  • Error messages when vendorConfigs is empty

Sample Request β€” PAYMENT (One-Time Payment)
curl -X POST "https://api-stg.uhg.com/api/financial/commerce/nonprodcheckout/v1/sessions" \
-H "Authorization: Bearer <token>" \
-H "X-Merchant-Id: <merchant-id>" \
-H "X-Upstream-Env: dev" \
-H "Content-Type: application/json" \
-d '{
"customer": {
"firstName": "Jane",
"lastName": "Doe",
"email": "jane.doe@example.com",
"hsid": "<customer-hsid>",
"phoneNumber": { "number": "9876543210", "countryCode": "1" },
"zip5": "54321"
},
"payment": {
"merchantTransactionId": "<unique-id>",
"amount": 1500,
"authorizeCard": false
},
"config": {
"modes": ["PAYMENT"],
"paymentMethodChannel": {
"card": ["WEBFORM", "GOOGLE_PAY", "APPLE_PAY"],
"bankAccount": ["WEBFORM"]
}
}
}'
Sample Request β€” PAYMENT_METHOD_ENTRY (Add Payment Method)
curl -X POST "https://api-stg.uhg.com/api/financial/commerce/nonprodcheckout/v1/sessions" \
-H "Authorization: Bearer <token>" \
-H "X-Merchant-Id: <merchant-id>" \
-H "X-Upstream-Env: dev" \
-H "Content-Type: application/json" \
-d '{
"customer": {
"firstName": "Jane",
"lastName": "Doe",
"email": "jane.doe@example.com",
"hsid": "<customer-hsid>"
},
"config": {
"modes": ["PAYMENT_METHOD_ENTRY"],
"paymentMethodChannel": {
"card": ["WEBFORM", "TEXT", "EMAIL"],
"bankAccount": ["WEBFORM"]
},
"privacyPolicyUrl": "https://merchant.com/privacy"
}
}'
Sample Request β€” PAYMENT_WITH_WALLET (Pay with Saved Method)
curl -X POST "https://api-stg.uhg.com/api/financial/commerce/nonprodcheckout/v1/sessions" \
-H "Authorization: Bearer <token>" \
-H "X-Merchant-Id: <merchant-id>" \
-H "X-Upstream-Env: dev" \
-H "Content-Type: application/json" \
-d '{
"customer": {
"hsid": "<customer-hsid>"
},
"payment": {
"merchantTransactionId": "<unique-id>",
"amount": 1500,
"authorizeCard": false
},
"config": {
"modes": ["PAYMENT_WITH_WALLET"],
"paymentMethodChannel": {
"card": ["WEBFORM", "GOOGLE_PAY", "APPLE_PAY"],
"bankAccount": ["WEBFORM"]
}
}
}'
Sample Request β€” Express Checkout (PAYMENT with digital wallets)
curl -X POST "https://api-stg.uhg.com/api/financial/commerce/nonprodcheckout/v1/sessions" \
-H "Authorization: Bearer <token>" \
-H "X-Merchant-Id: <merchant-id>" \
-H "X-Upstream-Env: dev" \
-H "Content-Type: application/json" \
-d '{
"customer": {
"name": "John Smith",
"email": "john.smith@example.com",
"ssnLastFour": "1001",
"dateOfBirth": "2000-09-21",
"zip5": "10003",
"phoneNumber": { "number": "9175553352", "countryCode": "1" }
},
"payment": {
"merchantTransactionId": "ORDER-12345",
"statementDescriptorSuffix": "Test Order",
"amount": 15000,
"authorizeCard": false
},
"config": {
"modes": ["PAYMENT"],
"paymentMethodChannel": {
"card": ["WEBFORM", "GOOGLE_PAY", "APPLE_PAY"],
"bankAccount": ["WEBFORM"]
}
}
}'

API Response​

Response Structure

Sample responses show key fields only. For the complete schema, refer to the OpenAPI Spec.

The response's checkoutSessionId and hostedUrl are what you pass to the widget. See API Response Fields for the full field table.

Sample Response β€” Session Created (200)
{
"data": {
"checkoutSessionId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"hostedUrl": "https://walletprod.healthsafepay.com/wallet/v2/checkout?session=a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"url": "https://api-stg.uhg.com/api/financial/commerce/nonprodcheckout/v1/sessions/a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}
}

Status Handling​

After session creation, the widget drives the session through its lifecycle. Poll the session url (returned in the response) to detect the final state, or use the widget's onSuccess / onError callbacks.

  • Poll the url field from the session response
  • Recommended interval: every 2–3 seconds
  • Stop polling when status is COMPLETED, FAILED, EXPIRED, or CANCELED
  • Prefer widget callbacks (onSuccess, onError) over polling when using the Embedded Experience
Full status table

See Session Lifecycle for every status value and its meaning.


Error Handling​

For session-specific error codes and remediation steps, see Session Error Codes and the common error table.


FAQ​

Q: Where should I create the session β€” frontend or backend?
A: Always create sessions from your backend. The JWT token used to authorize the request must never be exposed to the browser.

Q: What is the checkoutSessionId vs hostedUrl?
A: Use checkoutSessionId for the Embedded Experience (pass to OptumCCGWidgetInitializer). Use hostedUrl for the Hosted Experience (open as a popup window).

Q: How long is a session valid?
A: Sessions expire after a period of inactivity (typically 15 minutes). If a session expires, create a new one.

Q: Can I create a session without a customer object?
A: No β€” the customer object is required. For guest users, include at least basic identifying fields. For wallet users, include hsid or enterpriseId to trigger the wallet experience.

Q: What determines wallet vs guest experience?
A: See Sessions β€” Overview for how this is determined.

Q: Can I pass a pre-selected payment method?
A: Yes β€” include paymentMethod.id in the request body to pre-select a specific saved payment method (used with PAYMENT_METHOD_SELECT and PAYMENT_METHOD_DISPLAY modes).

Q: How do I support digital wallets (Apple Pay / Google Pay)?
A: Include GOOGLE_PAY and/or APPLE_PAY in config.paymentMethodChannel.card (V1-style), or in config.vendors[].paymentMethods[].channels (V2-style). WEBFORM is always included automatically for non-agent sessions β€” you do not need to request it explicitly. Domain registration and feature activation are required during onboarding. See Express Checkout for details.


Integration Checklist​

  • Merchant account onboarded to the CCG Platform
  • Session creation always performed server-side (JWT never exposed to browser)
  • customer object includes the appropriate identifier (hsid, enterpriseId) for wallet users
  • payment.merchantTransactionId is unique per transaction
  • config.modes set to the correct capability for your use case
  • config.paymentMethodChannel includes only the channels you have enabled
  • For Apple Pay / Google Pay: domain registered and feature activation confirmed
  • Session url polling or widget callbacks implemented to detect completion
  • Error handling implemented for INVALID_REQUEST, UNAUTHORIZED, and session timeout scenarios
  • Tested with sandbox/staging environment before going live