PassKit
Accept Apple Pay payments for physical goods, real-world services, donations, and eligible recurring payments, and add passes to the user's Wallet. Covers payment buttons, payment requests, authorization, Wallet passes, and merchant configuration. Targets Swift 6.3 / iOS 26+.
For advanced Apple Pay flows, one PKPaymentRequest can set only one optional
advanced request type: recurring, automatic reload, deferred, Apple Pay Later
availability, or multi-token contexts. Use separate payment requests when a
checkout needs more than one of those modes.
Contents
- Setup
- Displaying the Apple Pay Button
- Creating a Payment Request
- Presenting the Payment Sheet
- Handling Payment Authorization
- Wallet Passes
- Checking Pass Library
- Common Mistakes
- Review Checklist
- References
Setup
Project Configuration
- Enable the Apple Pay capability in Xcode
- Create a Merchant ID in the Apple Developer portal (format:
merchant.com.example.app) - Generate and install a Payment Processing Certificate for your merchant ID
- Add the merchant ID to your entitlements
Availability Check
Always verify the device can make payments before showing Apple Pay UI. If you
check for an active card with canMakePayments(usingNetworks:capabilities:),
Apple's HIG expects Apple Pay to be a primary, prominent payment option wherever
you use that check.
Displaying the Apple Pay Button
SwiftUI
Use the built-in PayWithApplePayButton view in SwiftUI. Use Apple-provided
button APIs for any control labeled Apple Pay; custom buttons must not include
the Apple Pay logo or "Apple Pay" text.
UIKit
Use PKPaymentButton for UIKit-based interfaces.
Button types: .plain, .buy, .setUp, .inStore, .donate,
.checkout, .continue, .book, .subscribe, .reload, .addMoney,
.topUp, .order, .rent, .support, .contribute, .tip
Creating a Payment Request
Build a PKPaymentRequest with your merchant details and the items being purchased.
PassKit amount APIs take NSDecimalNumber, not Double.
The last item in paymentSummaryItems is treated as the total and its label
appears in the Pay line on the payment sheet.
Requesting Shipping and Contact Info
Request only the contact fields needed to price, fulfill, or legally process the order. Collect required product choices, optional notes, per-item shipping destinations, and pickup locations before the Apple Pay button when the payment sheet cannot collect them accurately.
Supported Networks
Query available networks at runtime with PKPaymentRequest.availableNetworks().
Presenting the Payment Sheet
Use PKPaymentAuthorizationController (works in both SwiftUI and UIKit, no view controller needed). The controller's delegate is weak, so retain the controller for the life of the sheet.
Handling Payment Authorization
Implement PKPaymentAuthorizationControllerDelegate to process the payment token.
Handling Shipping Changes
Wallet Passes
Adding a Pass to Wallet
Load signed .pkpass data, verify the device can add passes, then present
PKAddPassesViewController when you want the user to review the pass before
adding it. PKPass(data:) expects signed pass data and can throw invalid-data
or invalid-signature errors. Name invalid-data and invalid-signature
failures explicitly instead of hiding them behind a bare try? in review
guidance.
SwiftUI Wallet Button
Use AddPassToWalletButton as the SwiftUI equivalent to PKAddPassButton.
Checking Pass Library
Use PKPassLibrary to inspect and manage passes the user already has. Check
PKPassLibrary.isPassLibraryAvailable() before pass-library operations, but use
PKAddPassesViewController.canAddPasses() to decide whether the device can add
passes. passes() only returns passes your app can access through its
entitlements. When replacing an existing pass, check the Boolean result from
replacePass(with:) and handle failure. For signed pass bundle construction,
update web services, and replacePass(with:), read
references/wallet-passes.md [blocked].
Common Mistakes
DON'T: Use StoreKit for physical goods
Apple Pay (PassKit) is for physical goods, real-world services, donations, and eligible recurring payments. StoreKit is for virtual goods, app features, and digital-content subscriptions. Using the wrong framework leads to App Review rejection.
DON'T: Hardcode merchant ID in multiple places
Review Checklist
- Apple Pay capability enabled and merchant ID configured in Developer portal
- Payment Processing Certificate generated and installed
-
canMakePayments(usingNetworks:)checked before showing Apple Pay button - Apple Pay is prominent wherever active-card availability is checked
- Product choices, optional details, and complex shipping choices collected before payment sheet
- Last item in
paymentSummaryItemsis the total with merchant display name - Payment summary and token-context amounts use
NSDecimalNumber - Payment token sent to server for processing (never decoded client-side)
-
PKPaymentAuthorizationControllerretained while presented and cleared after finish -
paymentAuthorizationControllerDidFinishdismisses the controller - Shipping method changes recalculate totals via delegate callback
- StoreKit used for virtual goods/digital content; Apple Pay used for physical goods, services, donations, and eligible recurring payments
- Wallet passes loaded from signed
.pkpassbundles -
PKPass(data:)invalid-data and invalid-signature failures surfaced -
PKPassLibrary.isPassLibraryAvailable()used for pass operations, not add-pass capability -
PKAddPassesViewController.canAddPasses()checked before add-pass UI -
PKPassLibrary.replacePass(with:)Boolean result checked when replacing a pass - Apple Pay button uses system-provided
PKPaymentButtonorPayWithApplePayButton - Add-to-Wallet UI uses system-provided
PKAddPassButton,AddPassToWalletButton, orPKAddPassesViewController - Error states handled in authorization result (network failures, declined cards)
References
- Extended patterns (recurring/deferred payments, coupon codes, multi-merchant, pass bundles, pass updates): references/wallet-passes.md [blocked]
- PassKit framework
- PKPaymentRequest
- PKPaymentAuthorizationController
- PKPaymentButton
- PayWithApplePayButton
- AddPassToWalletButton
- PKPass
- PKAddPassesViewController
- PKPassLibrary
- PKPaymentNetwork
- Apple Pay HIG


