Checking access…

Skip to main content

High-Level Design: Session Termination and Merchant Notification

FieldDetail
Author(s)Convenient Checkout documentation
ReviewersTo be confirmed
StatusDraft β€” implementation and SDK contract verification required
Last Updated2026-11-26
Version1.0
Disclaimer

This draft records the intended web-popup behavior and the currently observed SDK contract. Confirm implementation behavior and obtain engineering review before treating it as an approved implementation contract.

1. Overview​

This design describes how a web checkout session ends when the customer does not complete checkout, what the wallet displays, and what the merchant can learn through the Branded Button SDK. It distinguishes CCG checkout-session termination from HSID authentication-session ownership. Browser communication is best-effort; when the merchant context is gone, the wallet cannot return a result to it.

2. Problem Statement​

A popup can remain open after its merchant page is gone, or a customer can leave checkout through popup closure, logout, or session expiry. Without consistent termination and result handling, the wallet can show a stale checkout and merchants cannot reliably reconcile incomplete outcomes.

3. Goals & Non-Goals​

Goals​

  • Document which web-popup scenarios attempt to terminate the CCG session and where cancellation is best effort.
  • Record the terminal experience without interrupting an active HSID authentication screen.
  • Describe the browser SDK result contract and its limits.
  • Direct merchants to the Sessions API for session status and recovery.

Non-Goals​

  • Mobile-specific termination or SDK behavior.
  • New notifications for completed or failed checkout outcomes.
  • Final UX copy for placeholder terminal screens.
  • HSID settings-initiated logout behavior.
  • Merchant webhooks for popup outcomes.

4. Target Audience & Stakeholders​

StakeholderInterest / Concern
Product and supportConsistent incomplete-checkout outcomes and customer guidance
Wallet and SDK engineeringSession termination, browser messaging, and callback contract
QAScenario coverage across popup, merchant, and HSID navigation
Merchant integratorsResult handling and session-status reconciliation

5. Current State (Before)​

  • The Branded Button SDK receives wallet success, error, and close messages and exposes generic success, error, and close results.
  • A close result has no reason field. The SDK's public error enum identifies SDK or wallet errors, not standardized non-completion reasons.
  • The wallet detects merchant-context loss through popup messages and opener checks, attempts to cancel the CCG session, and can render the Checkout Is No Longer Available screen.
  • On wallet-page unload, the wallet attempts to cancel the CCG session except during HSID settings navigation or a language-change reload.
  • GET /v2/sessions/{sessionId} returns INITIATED or PENDING with HTTP 202, and COMPLETED, FAILED, or CANCELED with HTTP 200.
  • An expired session returns SESSION_TIMEOUT with HTTP 401 and cannot be reused. This is an error response, not an EXPIRED status.
  • The separate checkoutSessionStatus schema includes ACCEPTED and CREATED; those values do not belong to the status field returned by GET /v2/sessions/{sessionId}.

Cancellation requests made during popup closure or merchant-context loss are best effort. Confirm the final session status rather than inferring successful cancellation from a browser event.

6. Proposed Design (After)​

The wallet owns its CCG checkout session and terminal wallet experience. HSID owns its authentication session and any HSID-owned expiry screen. The Branded Button SDK reports browser outcomes only while communication with the merchant page is available; the Sessions API remains authoritative for the final checkout status.

Session termination scenarios​

TriggerCCG session outcomeWallet experienceMerchant outcomeOwnership / verification
Customer closes the wallet popup before completionThe wallet attempts session cancellation during page unload; the request is best effortPopup is closedThe SDK reports generic close when it detects closure; no reason is included. Reconcile through GET /v2/sessions/{sessionId}.Verify the final session status; popup closure alone does not prove cancellation
Merchant tab or window is closedThe wallet detects the missing opener and attempts cancellationShow Checkout Is No Longer Available if the wallet popup remains openNo callback is possible after the merchant context is gone; reconcile the session when the merchant flow resumesWallet context-loss handling
Merchant page reloads or navigates away while wallet is at HSIDThe SDK sends MERCHANT_CONTEXT_LOST on pagehide. If the wallet cannot receive it during the HSID round trip, the wallet checks the opener after return and attempts cancellation when it is no longer the original page.Do not interrupt the HSID screen; show the context-lost screen after detectionNo result is guaranteed after the merchant page is gone; reconcile the session when the merchant flow resumesWallet and SDK implementations; verify the HSID return path
Customer selects Log out in WalletThe wallet posts to the authentication provider's logout URL and follows its redirect. Confirm the resulting CCG session status with the Sessions API.Provider redirect; do not promise a separate logged-out terminal screenThe SDK defines no logout-specific result or reason. Reconcile the session status.Authentication provider owns the effect on the HSID session
CCG checkout session expires during inactivityGET /v2/sessions/{sessionId} returns SESSION_TIMEOUT with HTTP 401; the expired session cannot be reused.Show the timeout failure experience returned by the wallet; final copy remains subject to UX approvalNo expiry-specific SDK reason is defined. Create a new session after confirming the prior session's status.Session Error Codes and wallet implementation
HSID authentication session expiresThe CCG status and HSID authentication session have separate owners.HSID owns its authentication screen; do not infer CCG status from it.No HSID-specific CCG result or reason is defined; reconcile the CCG session separately.HSID owns its authentication session
Customer logs out through HSIDThe authentication provider owns the HSID logout. Confirm the separate CCG status.HSID owns the logout experienceNo HSID-logout-specific SDK result or reason is definedConfirm provider and API behavior before documenting additional effects
Customer opens HSID settingsSettings navigation alone does not trigger CCG cancellation.Preserve the settings round tripNo logout result is implied; reconcile the session if the merchant context changed.Wallet settings navigation handling; see Aha reference

Terminal-screen text is placeholder copy. Exact approved text is not part of this design.

V2 session status and expiry contract​

For GET /v2/sessions/{sessionId}, the status field uses these values:

HTTP responseStatus values
202INITIATED, PENDING
200COMPLETED, FAILED, CANCELED

The separate checkoutSessionStatus schema includes ACCEPTED, CREATED, INITIATED, PENDING, COMPLETED, FAILED, and CANCELED. Do not conflate that field with the status returned by GET /v2/sessions/{sessionId}.

An expired session returns the SESSION_TIMEOUT error with HTTP 401; EXPIRED is not a value in either status enum. The documented recovery is to create a new session because an expired session cannot be reused. A browser close result is not a session-status transition and does not prove that a cancellation request reached the backend.

SDK result contract​

Wallet or browser eventPublic SDK result
WALLET_SUCCESS{ type: 'success', code, data }
WALLET_ERROR{ type: 'error', code: 'WALLET_ERROR', message, title?, detail?, status?, errorDetails? }
WALLET_CLOSE{ type: 'close' }
SDK detects the popup was closed{ type: 'close' }

The SDK error enum currently includes POPUP_BLOCKED, POPUP_ACTIVE, CREATE_SESSION_FAILED, CREATE_SESSION_TIMEOUT, INVALID_CONFIG, WALLET_ERROR, and UNKNOWN. These are SDK or wallet error codes. The current SDK contract defines no separate non-completion reason code for customer closure, Wallet logout, or session expiry. Do not invent reason values or derive a stable reason from free-form error text.

7. Data Flow​

  1. The merchant creates a CCG session on its backend and launches the wallet popup through the Branded Button SDK.
  2. The wallet loads and tracks the CCG session. It displays the terminal experience appropriate to the final status or termination scenario.
  3. If browser communication is available, the wallet posts a success, error, or close message to the merchant origin.
  4. The SDK validates the message origin and popup source, then calls onResult.
  5. The merchant checks the Sessions API for the authoritative final status, especially when the SDK result is close or no callback could be delivered.

MERCHANT_CONTEXT_LOST travels from the merchant SDK to the wallet popup; it is not a merchant-facing result. The wallet validates the origin, attempts to cancel the CCG session, and shows the context-lost terminal screen.

8. Key Decisions​

#DecisionReasoning
1Use browser SDK communication for popup outcomes; do not introduce a webhook for this featureThe outcome is tied to an active browser integration
2Treat the Sessions API as authoritative for final checkout statusA popup result may be unavailable or generic
3Keep CCG checkout-session ownership separate from HSID authentication-session ownershipCCG must not replace HSID-owned authentication or expiry behavior
4Do not claim scenario-specific reasons until the SDK contract exposes themCurrent close results carry no reason field

9. Dependencies​

DependencyTypeOwnerRisk Level
Branded Button SDK communication and reason-code contractSDK implementationWallet SDKHigh
Wallet termination and terminal-screen behaviorWallet web implementationCheckout UIHigh
Merchant-facing integration contentDocumentationConvenient Checkout docsMedium

10. Success Metrics​

MetricTarget
Supported termination scenarios have a documented session outcome, screen, and merchant resultAll in-scope web-popup scenarios
Merchant result claims match the public SDK contractNo undocumented or invented reason codes
Merchants can reconcile incomplete outcomesSessions API and popup integration guidance are cross-linked

11. Risks & Mitigations​

RiskImpactMitigation
Popup closure is reported to the merchant but does not terminate the server sessionSession can remain reusable or staleVerify and test server-side cancellation before marking the behavior supported
SDK does not expose a reason for incomplete checkoutMerchants cannot distinguish logout, expiry, and popup closure from close aloneDocument generic results and add reason codes only through an approved SDK contract
Merchant page is goneBrowser result cannot be deliveredAttempt wallet-side cancellation and document that no callback is guaranteed
HSID settings or authentication flow is interrupted by CCG behaviorCustomer cannot complete the identity flowKeep HSID-owned screens and settings navigation separate from CCG terminal handling

Release verification​

  • Verify popup closure both while session creation is pending and after the wallet loads; distinguish the SDK close callback from backend cancellation.
  • Verify merchant tab closure, reload, and navigation while the wallet is active and during the HSID round trip. Confirm terminal behavior without assuming a callback can reach a page that no longer exists.
  • Verify the logout URL flow with the authentication provider, including the resulting CCG status and HSID-session effect. Do not infer either from the Wallet button label or a generic SDK close.
  • Verify that GET /v2/sessions/{sessionId} returns SESSION_TIMEOUT with HTTP 401 for an expired session, and that recovery uses a new session.
  • Verify CCG timeout behavior during HSID authentication and verify HSID's separate authentication-expiry behavior.
  • Confirm deployed SDK result payloads against the public types. Document non-completion reasons only after an approved contract exposes them.
  • Confirm terminal-screen copy, deployed feature availability, and support guidance with the responsible owners before publishing guarantees.

No feature-specific LLD or ADR was found in the documentation repositories reviewed. Add links if an approved design artifact exists; do not treat this draft HLD as a substitute for an unlocated LLD or ADR.