<!--
{
  "availability" : [
    "iOS: 11.0.0 -",
    "iPadOS: 11.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.13.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 4.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "PassKit",
  "identifier" : "/documentation/PassKit/PKPaymentError",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "PassKit (Apple Pay and Wallet)"
    ],
    "preciseIdentifier" : "s:SC18PKPaymentErrorCodeLeV"
  },
  "title" : "PKPaymentError"
}
-->

# PKPaymentError

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

```
struct PKPaymentError
```

## Overview

The user must resolve any errors that you report on the Apple Pay sheet before they’re able to authorize the transaction.  You return any errors in [`PKPaymentAuthorizationResult`](/documentation/PassKit/PKPaymentAuthorizationResult) or [`PKPaymentRequestShippingContactUpdate`](/documentation/PassKit/PKPaymentRequestShippingContactUpdate).

You can build your own payment error (<doc://com.apple.documentation/documentation/Foundation/NSError>), or use one of the following convenience methods from [`PKPaymentRequest`](/documentation/PassKit/PKPaymentRequest) to build it for you.

- For an error with contact information, use [`paymentContactInvalidError(withContactField:localizedDescription:)`](/documentation/PassKit/PKPaymentRequest/paymentContactInvalidError(withContactField:localizedDescription:)).
- For a shipping address that is unserviceable, use [`paymentShippingAddressUnserviceableError(withLocalizedDescription:)`](/documentation/PassKit/PKPaymentRequest/paymentShippingAddressUnserviceableError(withLocalizedDescription:)).
- For an error with the billing address, use [`paymentBillingAddressInvalidError(withKey:localizedDescription:)`](/documentation/PassKit/PKPaymentRequest/paymentBillingAddressInvalidError(withKey:localizedDescription:)).
- For an error with the shipping address, use [`paymentShippingAddressInvalidError(withKey:localizedDescription:)`](/documentation/PassKit/PKPaymentRequest/paymentShippingAddressInvalidError(withKey:localizedDescription:)).

The following code example shows:

- How to create an error directly.
- How to create an error using a convenience method.

Creating payment errors:

```swift
// A general billing address error created with NSError
let billingAddressError = NSError.init(domain: PKPaymentErrorDomain,
                          code: PKPaymentError.billingContactInvalidError.rawValue,
                          userInfo: [NSLocalizedDescriptionKey:"Address has an error",
                          PKPaymentErrorKey.contactFieldUserInfoKey: PKContactField.postalAddress])

// A specific billing address error created with a convenience method
let billingAddressInvalidStreet = PKPaymentRequest.paymentBillingAddressInvalidError(withKey:CNPostalAddressStreetKey,
                                                   localizedDescription: "Invalid street")
```

## Topics

### Describing the error

  <doc://com.apple.documentation/documentation/Foundation/CustomNSError/errorCode-2opgi>

  <doc://com.apple.documentation/documentation/Foundation/CustomNSError/errorUserInfo-1aas5>

### Identifying the error

[`billingContactInvalidError`](/documentation/PassKit/PKPaymentError/billingContactInvalidError)

The error code to indicate an invalid billing address or billing name.

[`shippingContactInvalidError`](/documentation/PassKit/PKPaymentError/shippingContactInvalidError)

The error code to indicate an invalid shipping address, email, phone, or name.

[`shippingAddressUnserviceableError`](/documentation/PassKit/PKPaymentError/shippingAddressUnserviceableError)

The error code for an unserviceable shipping address.

[`couponCodeExpiredError`](/documentation/PassKit/PKPaymentError/couponCodeExpiredError)

The error code that indicates an expired coupon.

[`couponCodeInvalidError`](/documentation/PassKit/PKPaymentError/couponCodeInvalidError)

The error code that indicates an invalid coupon.

[`unknownError`](/documentation/PassKit/PKPaymentError/unknownError)

The error code for an unknown error.

[`PKPaymentError.Code`](/documentation/PassKit/PKPaymentError/Code)

An error code that you provide to indicate problems with address or contact information on an Apple Pay sheet.

### Querying the error domain

[`errorDomain`](/documentation/PassKit/PKPaymentError/errorDomain)

[`PKPaymentErrorDomain`](/documentation/PassKit/PKPaymentErrorDomain)

The error domain for specific errors associated with Apple Pay in-app or web payments.



---

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)