<!--
{
  "availability" : [

  ],
  "documentType" : "symbol",
  "framework" : "ApplePayontheWeb",
  "identifier" : "/documentation/ApplePayontheWeb/ApplePayError",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Apple Pay on the Web"
    ],
    "preciseIdentifier" : "cl/ApplePayError"
  },
  "title" : "ApplePayError"
}
-->

# ApplePayError

A customizable error type that you create to indicate problems with the address or contact information on an Apple Pay sheet.

```
interface ApplePayError
```

## Overview

When you determine that there’s a problem with an address or contact information on the payment sheet, you can use [`ApplePayError`](/documentation/ApplePayontheWeb/ApplePayError) to create a customized error message. Apple Pay highlights the area with an error and displays your message, making it easier for users to correct errors.

Users must resolve any errors that you report on the Apple Pay sheet before they can finalize their transaction.

The details you provide in an Apple Pay error include:

- **code** — An error code that identifies the area of the error.
- **contactField** — The specific field on the payment sheet with the error.
- **message** — Your custom error message to display on the payment sheet.

For example, if you found an error in the postal code of the shipping address, create an [`ApplePayError`](/documentation/ApplePayontheWeb/ApplePayError) with the custom message text `"ZIP Code is invalid"`, as follows:

```javascript
new ApplePayError("shippingContactInvalid", "postalCode", "ZIP Code is invalid")
```

Apple Pay highlights the postal code field and displays the message text on the payment sheet.

> Note:
> ``doc://com.apple.applepayontheweb/documentation/ApplePayontheWeb/ApplePayError`` requires Apple Pay API version 3 and later, and is only supported in Apple Pay JS API; it’s not available in the <doc://com.apple.documentation/documentation/ApplePayontheWeb/payment-request-api>.

## Topics

### Creating an Apple Pay Error

[`ApplePayError`](/documentation/ApplePayontheWeb/ApplePayError/ApplePayError)

Creates an Apple Pay error object.

### Error Properties

[`code`](/documentation/ApplePayontheWeb/ApplePayError/code)

The error code for this instance.

[`contactField`](/documentation/ApplePayontheWeb/ApplePayError/contactField)

The field name that contains the error on the payment sheet.

[`message`](/documentation/ApplePayontheWeb/ApplePayError/message)

A localized, user-facing string that describes the error.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)