PKPaymentError.Code
An error code that you provide to indicate problems with address or contact information on an Apple Pay sheet.
Declaration
enum CodeOverview
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.
For an error with contact information: paymentContactInvalidError(withContactField:localizedDescription:).
For a shipping address that is unserviceable: paymentShippingAddressUnserviceableError(withLocalizedDescription:).
For an error with the billing address: paymentBillingAddressInvalidError(withKey:localizedDescription:).
For an error with the shipping address: 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:
// 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
PKPaymentError.Code.couponCodeExpiredErrorPKPaymentError.Code.couponCodeInvalidErrorPKPaymentError.Code.billingContactInvalidErrorPKPaymentError.Code.shippingContactInvalidErrorPKPaymentError.Code.shippingAddressUnserviceableErrorPKPaymentError.Code.unknownError