Initialize CSUC Payment Flow
POST/b/checkout/api/sdk/v1/csuc_sdk/submit/:session_id/:pg_code/
This endpoint initializes the Cybersource Unified Checkout (CSUC) payment flow by generating and returning the capture context token and associated configuration.
Flow Summary:
- Validate Inputs: The
pg_codeandsession_idare validated to ensure:- The MID exists and supports Click to Pay payment method
- The payment transaction exists and is valid for payment
- Retrieve Transaction: Fetches the
PaymentTransactionusingsession_id - Create/Reuse Payment Attempt: Either creates a new payment attempt or reuses the latest one
- Generate Capture Context: Calls Cybersource API to create a capture context JWT token containing:
- Allowed card networks and payment types
- Client version and locale settings
- Billing, shipping, and email capture mandates
- Transaction amount and currency
- Decision manager configuration
- Parse Token: Decodes the JWT to extract SDK client configuration:
- JavaScript SDK URL and integrity hash
- Payment form submission URL
- Cache & Return: Caches the complete response (10 min TTL) and returns configuration
Capture Context Caching:
- Capture contexts are cached using key:
{mid_code}_{session_id}_ctp_context - Cache TTL: 600 seconds (10 minutes)
- Subsequent requests with same session reuse cached context
Response Structure:
sdk_client: Contains the Cybersource JS SDK URL, SRI integrity hash, and CORS settingsform_config: Specifies the payment execution endpoint URL and form parameterscapture_context: JWT token to initialize the checkout widget
Typical Use Case:
- Called by frontend before rendering the Cybersource payment widget
- The frontend loads the SDK from
sdk_client.srcwith integrity verification - The
capture_contextis passed to Cybersource's JavaScript SDK - After user completes payment, the widget generates a transient token
- Frontend submits transient token to
form_config.actionURL
Integration Steps:
- Frontend calls this endpoint with
pg_codeandsession_id - Backend generates/retrieves capture context from Cybersource
- Frontend dynamically loads the JS SDK using
sdk_clientconfiguration - Frontend initializes Cybersource widget with
capture_context - User completes payment in Cybersource widget
- Frontend receives transient token from widget
- Frontend POSTs transient token to
form_config.actionURL
Request
Responses
- 200
- 400
- 401