Contents

PKPaymentAuthorizationResult

An object that reports the status code and errors for a payment authorization request.

Declaration

class PKPaymentAuthorizationResult

Overview

If the Apple Pay sheet contains errors, you provide a PKPaymentAuthorizationStatus.failure status to PKPaymentAuthorizationResult, and include the errors in the errors array. If there are no errors, you provide a PKPaymentAuthorizationStatus.success status and leave the error array empty.

The following code example shows a failure result with two errors in the postal code and street fields.

A result that reports two errors:

// Error in postal code field.
let shippingInvalidZip =
PKPaymentRequest.paymentShippingAddressInvalidError(withKey:CNPostalAddressPostalCodeKey,
                                                    localizedDescription: "Invalid ZIP code")
// Error in street address field.
let shippingInvalidStreet = PKPaymentRequest.paymentShippingAddressInvalidError(withKey:CNPostalAddressStreetKey,
                                                    localizedDescription: "Missing street name")
// Result with failure status and errors.
let result = PKPaymentAuthorizationResult(status: .failure, 
                                          errors: [shippingInvalidZip, shippingInvalidStreet])

Topics

Initializing a payment authorization result

Setting order details

Setting payment authorization status and errors

See Also

Payment sheet interactions and authorization