---
title: Payment Form Error Messages
slug: payment-form-error-messages
docTags: 
createdAt: 2024-08-28T12:20:55.537Z
---

# Displaying Payment Form Error Messages

The Web SDK is designed to provide feedback quickly and clearly to the consumer.

To display payment form error messages:

1. Add a div with the id **judopay-errors** on your page, ideally below the iframe:&#x20;
   `<div class="judopay-errors"></div>;`

The table below displays all errors that can be returned:

| **ID** | **Error String**                                            |
| ------ | ----------------------------------------------------------- |
| 0      | Card number can only contain numbers                        |
| 1      | Card number not valid                                       |
| 2      | Card type not recognised, please recheck your number        |
| 3      | &#x7B;1} is not supported                                   |
| 4      | Card number required                                        |
| 5      | Card is expired                                             |
| 6      | Card expiry date is not valid                               |
| 7      | Expiry date required                                        |
| 8      | &#x7B;0} code too short for &#x7B;1} card                   |
| 9      | &#x7B;0} code too long for &#x7B;1} card                    |
| 10     | &#x7B;0} code can only contain numbers                      |
| 11     | &#x7B;0} code required for &#x7B;1} card                    |
| 12     | Post/Zip code is invalid                                    |
| 13     | Sorry, an error has occurred, you have not been charged.    |
| 14     | Cardholder Name is required                                 |
| 15     | Cardholder Name can't be less than 4 characters             |
| 16     | Cardholder Name can't contain numbers or special characters |

For error strings containin&#x67;**&#x20;&#x7B;0}** an&#x64;**&#x20;&#x7B;1}**, these will be changed into values depending on the current state of the iframe form.
For example:

- \{**0**} will change to the card verification code acronym. This is named differently depending on the card type (e.g. CVC, CVV).
- \{**1**} will refer to the detected card type, for example Visa, Mastercard, Diners Club International or Discover.

If the iframe has detected a Visa number, the following error message transform would occur:
`{0} code too long for {1} card" -> "CVC code to long for Visa card`

A similar error with an American Express card, the message would appear as:
`CID code too long for American Express card"`

***

## Web SDK Error Responses

There are 2 possible error formats:

1. Error responses from our **Transaction API** (which the Web SDK formats and returns).
   These are caused by the **transaction&#x20;**&#x69;tself, for example:
   1. Incorrect payment credentials
   2. Failure of 3D Secure 2
      For more information on this type of error, see [Enhanced Error Messaging for Web SDK](docId\:qfxaWPAQl_-2EVfP8y94d).

2. Errors thrown by the **Web SDK** code.
   Examples of causes can be:
   1. Scripts failing to load
   2. Closing of a modal
   3. Time-outs
      For more information on this type of error, see [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error).

***

### Enhanced Error Messaging for Web SDK

For Web SDK Version **0.0.29** (or higher), the error response object has the following additional fields describing the error:

- name
- status
- judoDetails

:::hint{type="info"}
Not all errors returned from the Web SDK will have the new format described below.
This only refers to errors that originated from our Transaction API (previous to version 0.0.29) having the following interface: **\{message: string}**.
:::

**Error Object Response Fields**

| **Field**                       | **Description**                                                                                                                                                                                                                                           |
| ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `message`<br />String           | A text description of the error.                                                                                                                                                                                                                          |
| `name`<br />String              | Represents a name for the type of error.                                                                                                                                                                                                                  |
| `status`<br />Number            | A HTTP response status code.                                                                                                                                                                                                                              |
| `judoDetails`<br />Object<br /> | Object giving additional context to the error.<br />For further details on the interface of the judoDetails object, including examples, see [JudoDetails Object](docId\:qfxaWPAQl_-2EVfP8y94d).<br />This field is <font color="#42cbd4">optional</font>. |

***

**Examples of the Enhanced Error Response**

The enhanced error response provides an error object with additional fields to increase the description of the error, for example:

:::::Tabs
::::Tab{title="Cause: Amount = 0.00"}
**Enhanced Error Response:**

:::BlockQuote
\{&#x20;
message: 'Request failed with status code 400',
&#x20;name: "Error",&#x20;
&#x20;status: 400,
&#x20;judoDetails: \{
&#x20;    category: 2,
&#x20;    code: 1,
&#x20;    details: \[\{
&#x20;        code: 4,&#x20;
&#x20;        fieldName: 'Amount',&#x20;
&#x20;         message: 'Sorry, but the amount specified must be greater than   &#x20;
&#x20;         "0".',&#x20;
&#x20;         detail: "Sorry, we're currently unable to process this  &#x20;
&#x20;         request."}],&#x20;
&#x20;         message: "Sorry, we're unable to process your request. Please&#x20;
&#x20;         check your details and try again."
&#x20;    }
}
:::

***
::::

::::Tab{title="Cause: Card Authentication Fails"}
**Enhanced Error Response:**

:::BlockQuote
\{&#x20;
&#x20;  message: 'Request failed with status code 400',&#x20;
&#x20;  name: "Error",
&#x20;  status: 400,
&#x20;  judoDetails: \{
&#x20;       category: 4,
&#x20;       code: 158,
&#x20;       message: "Sorry, but your card authentication has failed."
&#x20;     }
&#x20;}
:::
::::
:::::

### JudoDetails Object

The **judoDetails&#x20;**&#x6F;bject aims to provide additional context around the error.
See below for further information on the optional **judoDetails&#x20;**&#x6F;bject that is now included in the error response:

### JudoDetails Interface

| **Field**                    | **Description**                                                                                                                                                                                                                                                                                                                                                                                                     |
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `message`<br />String        | A text description of the error.                                                                                                                                                                                                                                                                                                                                                                                    |
| `code`<br />Number           | A static numeric code associated with the specific error.                                                                                                                                                                                                                                                                                                                                                           |
| `category`<br />Number<br /> | The type of error:<br />1 - RequestError<br />2 - ModelError<br />3 - ConfigError<br />4 - DuplicationError / ProcessingError<br />5 - ExceptionError                                                                                                                                                                                                                                                               |
| `details`<br />Object<br />  | Object giving additional context to the error.<br />For examples on what this object may look like, see [judoDetails Examples](docId\:qfxaWPAQl_-2EVfP8y94d). <br />This field is <font color="#42cbd4">optional</font>.<br />**For ModelError**:<br />- Array of FieldErrors describing one or more attributes.<br />**For DuplicationError**:<br />- Provides the receiptId and url of the duplicate transaction. |

### JudoDetails Examples

:::::Tabs
::::Tab{title="RequestError Example"}
**Example Category 1:**

:::BlockQuote
\{&#x20;
&#x20;  message: "Sorry, but we were unable to authenticate your request.   &#x20;
&#x20;  Please check your details and try again.",&#x20;
&#x20;  code: 403,&#x20;
&#x20;  category: 1&#x20;
}&#x20;
:::

:::BlockQuote
\{&#x20;
&#x20;  message: "We've been unable to decrypt the supplied Encrypted payload.&#x20;
&#x20;  Please ensure the message has not been modified.",&#x20;
&#x20;  code: 150,&#x20;
&#x20;  category: 1&#x20;
}&#x20;
:::
::::

::::Tab{title="ModelError Example"}
Response will contain one or more FieldErrors in the details block.

**Example Category 2**:

:::BlockQuote
\{&#x20;
details: \[&#x20;
\{&#x20;
&#x20; code: 50,&#x20;
&#x20; fieldName: "PostCode",&#x20;
&#x20; message: "Please supply the postcode"&#x20;
&#x20; },&#x20;
\{&#x20;
&#x20; code: 33,&#x20;
&#x20; fieldName: "Cv2",&#x20;
&#x20; message: "Sorry, the security code entered is invalid. Please check  &#x20;
&#x20; your details and try again."&#x20;
&#x20; }&#x20;
],&#x20;
&#x20; message: "Sorry, we're unable to process your request. Please check  &#x20;
&#x20; your details and try again.",&#x20;
&#x20; code: 1,&#x20;
&#x20; category: 2&#x20;
}&#x20;
:::
::::

::::Tab{title="ConfigError Example"}
**Example Category 3**:

:::BlockQuote
\{&#x20;
&#x20; message: "Sorry, but the amount you're trying to collect is greater  &#x20;
&#x20; than the pre-auth.",&#x20;
&#x20; code: 46,&#x20;
&#x20; category: 3&#x20;
}&#x20;
:::

:::BlockQuote
\{&#x20;
&#x20; message: "Sorry, but the amount you're trying to refund is greater than  &#x20;
&#x20; the original transaction.",&#x20;
&#x20; code: 49,&#x20;
category: 3&#x20;
}&#x20;
:::
::::

::::Tab{title="DuplicationError Example"}
**Example Category 4**:

:::BlockQuote
\{&#x20;
&#x20;details:&#x20;
&#x20;\{&#x20;
&#x20;  receiptId: 717774858666278912,&#x20;
&#x20;  url\:https\://gw1.karatepaysandbox.com/transactions/717774858666278912"&#x20;
&#x20; },&#x20;
&#x20;  message: "Sorry, this payment has been stopped as it is a duplicate    &#x20;
&#x20;  transaction.",&#x20;
&#x20;  code: 86,&#x20;
&#x20;  category: 4&#x20;
}&#x20;
:::
::::

::::Tab{title="ProcessingError Example"}
**Example Category 4**:

:::BlockQuote
\{&#x20;
&#x20; message: "Sorry, but your card authentication attempt was rejected by   &#x20;
&#x20; the issuer.",&#x20;
&#x20; code: 159,&#x20;
&#x20; category: 4&#x20;
}&#x20;
:::
::::

::::Tab{title="ExceptionError Example"}
**Example Category 5**:

:::BlockQuote
\{&#x20;
&#x20; message: "The content-type was not specified or is unsupported for the  &#x20;
&#x20; request made to the Judopay API. Currently supported content-type is  &#x20;
&#x20; limited to application/json.",&#x20;
&#x20; code: 0,&#x20;
&#x20; category: 5&#x20;
}&#x20;
:::
::::
:::::

