Contents

PKPaymentError

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

Declaration

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 or PKPaymentRequestShippingContactUpdate.

You can build your own payment error (NSError), or use one of the following convenience methods from PKPaymentRequest to build it for you.

The following code example shows:

  • How to create an error directly.

  • How to create an error using a convenience method.

Creating payment errors:

// 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

Identifying the error

Querying the error domain

See Also

Errors