Handle Errors {#uc_appendix_handle_errors}
==========================================

The `Unified Checkout` SDK uses a structured error object for all error scenarios. Errors are returned as exceptions from asynchronous methods and are also returned as events for centralized handling.

Error Codes {#ctp-handle-errors-codes}
======================================

Initialization Errors {#ctp-handle-errors-codes_section_kw4_czg_3jc}
--------------------------------------------------------------------

These errors are returned during `VAS.UnifiedCheckout(sessionJWT)`:

|          Reason           |                                                          Description                                                           |
|---------------------------|--------------------------------------------------------------------------------------------------------------------------------|
| `CAPTURE_CONTEXT_EXPIRED` | The supplied JWT has expired. Generate a new session.                                                                          |
| `CAPTURE_CONTEXT_INVALID` | The session JWT is not valid. For example, it has a bad signature or is malformed.                                             |
| `UNUSED_TARGET_ORIGINS`   | One or more `targetOrigins` in the session do not match the current page origin. The `details` array lists the unused origins. |
[Initialization Reason Values]

Mount Errors {#ctp-handle-errors-codes_section_ow4_czg_3jc}
-----------------------------------------------------------

These errors are returned during `checkout.mount()` or `trigger.mount()`:

|           Reason            |                                                                 Description                                                                  |
|-----------------------------|----------------------------------------------------------------------------------------------------------------------------------------------|
| `CHECKOUT_ALREADY_MOUNTED`  | The checkout or trigger is already mounted. Call `unmount()` first, or create a new instance.                                                |
| `MOUNT_CONTAINER_SELECTOR`  | The CSS selector does not match any Document Object Model (DOM) element. Check that the container exists before calling `mount()`.           |
| `MOUNT_ERROR`               | A problem occurred loading the payment iframe.                                                                                               |
| `MOUNT_INVALID_CONTAINER`   | The supplied container parameter is not a valid CSS selector string or `HTMLElement`.                                                        |
| `MOUNT_PAYMENT_TIMEOUT`     | A payment method timed out during initialization.                                                                                            |
| `MOUNT_PAYMENT_UNAVAILABLE` | No payment types could be presented to the customer. This may be due to browser or device support, or errors during checkout initialization. |
| `MOUNT_SIDEBAR_OPTIONS`     | The supplied container parameter is invalid for sidebar mode.                                                                                |
| `MOUNT_TOKEN_TIMEOUT`       | Token creation timed out during mount. This may indicate a network issue.                                                                    |
| `MOUNT_TOKEN_XHR_ERROR`     | A network error occurred during token creation. Check the customer's connectivity.                                                           |
[Mount Reason Values]

Checkout Errors {#ctp-handle-errors-codes_section_sw4_czg_3jc}
--------------------------------------------------------------

|            Reason             |                       Description                        |
|-------------------------------|----------------------------------------------------------|
| `CHECKOUT_ERROR`              | A general checkout error occurred.                       |
| `CHECKOUT_PAYMENT_PARAMETERS` | One or more payment parameters have a validation error.  |
| `CHECKOUT_VALIDATION_PARAMS`  | One or more checkout parameters have a validation error. |
[Checkout Reason Values]

Trigger Errors {#ctp-handle-errors-codes_section_vw4_czg_3jc}
-------------------------------------------------------------

|                Reason                |                                                   Description                                                    |
|--------------------------------------|------------------------------------------------------------------------------------------------------------------|
| `TRIGGER_PAYMENT_TYPE_NOT_SUPPORTED` | The specified payment type cannot be used with a trigger. Only `PANENTRY` and `CLICKTOPAY` values are supported. |
[Trigger Reason Values]

**Payment-Specific Errors** {#ctp-handle-errors-codes_section_xw4_czg_3jc}
--------------------------------------------------------------------------

|                 Reason                 |                      Description                      |
|----------------------------------------|-------------------------------------------------------|
| `CLICK_TO_PAY_SDK_LOAD_ERROR`          | The `Click to Pay`SDK failed to load.                 |
| `ENCRYPT_CARD_FOR_SRC_ENROLMENT_ERROR` | Card encryption for `Click to Pay` enrollment failed. |
| `GOOGLEPAY_CHECKOUT_ERROR`             | A Google Pay checkout error occurred.                 |
| `LAUNCH_SRC_CHECKOUT_ERROR`            | Launching the `Click to Pay` checkout failed.         |
| `TRIGGER_PAYMENT_TYPE_NOT_SUPPORTED`   | The payment type is not supported for triggers.       |
[Payment-Specific Reason Values]

General Errors {#ctp-handle-errors-codes_section_zw4_czg_3jc}
-------------------------------------------------------------

|   Reason Code   |          Description           |
|-----------------|--------------------------------|
| `UNKNOWN_ERROR` | An unknown error has occurred. |

