<!--
{
  "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/Code",
  "metadataVersion" : "0.1.0",
  "role" : "Enumeration",
  "symbol" : {
    "kind" : "Enumeration",
    "modules" : [
      "PassKit (Apple Pay and Wallet)"
    ],
    "preciseIdentifier" : "c:@E@PKPaymentErrorCode"
  },
  "title" : "PKPaymentError.Code"
}
-->

# PKPaymentError.Code

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

```
enum Code
```

## 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: [`paymentContactInvalidError(withContactField:localizedDescription:)`](/documentation/PassKit/PKPaymentRequest/paymentContactInvalidError(withContactField:localizedDescription:)).

For a shipping address that is unserviceable: [`paymentShippingAddressUnserviceableError(withLocalizedDescription:)`](/documentation/PassKit/PKPaymentRequest/paymentShippingAddressUnserviceableError(withLocalizedDescription:)).

For an error with the billing address: [`paymentBillingAddressInvalidError(withKey:localizedDescription:)`](/documentation/PassKit/PKPaymentRequest/paymentBillingAddressInvalidError(withKey:localizedDescription:)).

For an error with the shipping address: [`paymentShippingAddressInvalidError(withKey:localizedDescription:)`](/documentation/PassKit/PKPaymentRequest/paymentShippingAddressInvalidError(withKey:localizedDescription:)).

The following code example shows:

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

Creating payment errors:

```objc
// Creating a general shipping address error with NSError
NSError *addressError = [[NSError alloc] initWithDomain:PKPaymentErrorDomain
                        code:PKPaymentShippingContactInvalidError
                        userInfo:@{NSLocalizedDescriptionKey: @"Address is invalid",
                        PKPaymentErrorContactFieldUserInfoKey: PKContactFieldPostalAddress}];

// Creating a shipping address error specific to the zip code:
NSError *zipCodeError = [[NSError alloc] initWithDomain:PKPaymentErrorDomain
                        code:PKPaymentShippingContactInvalidError
                        userInfo:@{NSLocalizedDescriptionKey: @"Zip code is invalid", 
                        PKPaymentErrorContactFieldUserInfoKey: PKContactFieldPostalAddress,                      
                        PKPaymentErrorPostalAddressUserInfoKey:CNPostalAddressPostalCodeKey}];

// Creating a billing address error specific to the street with a convenience method
NSError *billingAddressInvalidStreet = [PKPaymentRequest
                             paymentBillingAddressInvalidErrorWithKey:CNPostalAddressStreetKey 
                             localizedDescription:@"Invalid Street"];
```

## Topics

### Error codes

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

The error code that indicates an expired coupon.

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

The error code that indicates an invalid coupon.

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

The error code that indicates an invalid billing address or billing name.

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

The error code that indicates an invalid shipping address, email, phone, or name.

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

The error code that indicates an unserviceable shipping address.

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

The error code that indicates an unknown error.

### Initializers

[`init?(rawValue: Int)`](/documentation/PassKit/PKPaymentError/Code/init(rawValue:))

## Relationships

### Conforms To

[`RawRepresentable`](/documentation/Swift/RawRepresentable)

[`Equatable`](/documentation/Swift/Equatable)

[`BitwiseCopyable`](/documentation/Swift/BitwiseCopyable)

[`Sendable`](/documentation/Swift/Sendable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Hashable`](/documentation/Swift/Hashable)

---

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)