Sample CodeiOS, iPadOS, Mac CatalystReviewed 2026-07-21View on Apple Developer

Handling Payment Requests with SiriKit

At a glance

Item Summary
Purpose Add an Intent Extension to your app to handle money transfer requests with Siri.
App architecture A C/Objective-C header, Swift sample with the source-visible chain AppDelegatePaymentHistoryViewControllerPaymentProviderIntents APIs.
Main patterns View-controller organization, Delegate or data-source callbacks
Project style 10 scanned source file(s) across C/Objective-C header, Swift, organized around ranked entry, type, and file boundaries.

Project structure

Source bundle/
├── Payments/
│   ├── AppDelegate.swift
│   └── PaymentHistoryViewController.swift
├── PaymentsFramework/
│   ├── PaymentProvider.swift
│   ├── Contact.swift
│   ├── ContactLookup.swift
│   ├── Payment.swift
│   └── PaymentsFramework.h
├── PaymentsIntentsExtension/
│   ├── SendPaymentIntentHandler.swift
│   ├── IntentsExtension.swift
│   └── INPerson+Contact.swift
├── Configuration/
│   └── SampleCode.xcconfig
└── Payments.xcodeproj/
    └── .xcodesamplecode.plist

Structure observations

  • Architecturally prominent files are ranked from entry points and role-named declarations; resource-only paths are omitted.
  • Primary languages: C/Objective-C header, Swift.
  • The verified tree contains 11 project/configuration file(s) and 9 source declaration(s).

Overall architecture

Reference code

Payments/AppDelegate.swift:12 — architecture anchor

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
    // ...
}

Interpretation

The arrows summarize the source-visible entry, role-named types or folders, and framework direction; when nodes come from structural folders, the sequence is a high-level interpretation rather than proof that every adjacent node calls the next. Ownership is claimed only where the next section cites a stored property or assignment. The diagram is intentionally limited to the dominant path into Intents.

Ownership and state

Ownership evidence

Payments/AppDelegate.swift:15 — stored dependency or nearest verified ownership anchor

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
    // ...
    var window: UIWindow?
    // ...
}
Owner Object or state Relationship Mutation authority
AppDelegate UIWindow (window) stores or receives App/module collaborators
PaymentHistoryViewController PaymentProvider (paymentProvider) creates and retains Initialized by the owner; the binding is immutable
PaymentHistoryViewController Any (activeAppNotificationObserver) stores or receives Owning lexical scope
PaymentHistoryViewController NumberFormatter (amountFormatter) stores or receives Owning lexical scope

Composition arrows indicate a source-visible construction expression or locally owned value state; aggregation means the owner stores or receives a dependency without proving exclusive lifetime ownership.

Class and protocol design

Payments/AppDelegate.swift:13 — representative type boundary

class AppDelegate: UIResponder, UIApplicationDelegate {
    // ...
}
Type Responsibility Depends on or conforms to
AppDelegate Receives callback-driven events UIResponder, UIApplicationDelegate
PaymentHistoryViewController View lifecycle, callbacks, and feature coordination UITableViewController
PaymentProvider Supplies a capability or framework resource Concrete collaborators/imported frameworks
SendPaymentIntentHandler Handles callbacks or feature events NSObject, INSendPaymentIntentHandling
PaymentTableViewCell Owns feature behavior and collaborator lifecycle UITableViewCell
Contact Represents a feature value or composable behavior Concrete collaborators/imported frameworks
ContactLookup Owns feature behavior and collaborator lifecycle Concrete collaborators/imported frameworks
Payment Represents a feature value or composable behavior Concrete collaborators/imported frameworks
IntentsExtension Owns feature behavior and collaborator lifecycle INExtension

No local protocol conformance is claimed as protocol-oriented design; external framework conformances are listed only as dependencies.

Access control

Symbol Access Verified effect Likely rationale
paymentProvider (Payments/PaymentHistoryViewController.swift:13) private Use is restricted to the lexical declaration and same-file extensions allowed by Swift. Inference: keep state mutation or dependency lifetime inside the owning implementation.
activeAppNotificationObserver (Payments/PaymentHistoryViewController.swift:14) private Use is restricted to the lexical declaration and same-file extensions allowed by Swift. Inference: keep state mutation or dependency lifetime inside the owning implementation.
payments (Payments/PaymentHistoryViewController.swift:16) private Use is restricted to the lexical declaration and same-file extensions allowed by Swift. Inference: keep state mutation or dependency lifetime inside the owning implementation.
amountFormatter (Payments/PaymentHistoryViewController.swift:26) private Use is restricted to the lexical declaration and same-file extensions allowed by Swift. Inference: keep state mutation or dependency lifetime inside the owning implementation.

Reference code

Payments/PaymentHistoryViewController.swift:13 — representative boundary

class PaymentHistoryViewController: UITableViewController {
    // ...
    private let paymentProvider = PaymentProvider()
    // ...
}

Swift declarations without a modifier are internal; explicit private, fileprivate, private(set), public, or open entries above are interpreted by language semantics. Objective-C/C samples instead rely on header and implementation boundaries, which are not equivalent to Swift lexical privacy.

Logic ownership and placement

Logic Owning type or file Placement rationale
View lifecycle, callbacks, and feature coordination PaymentHistoryViewController The source’s Controller suffix makes this role explicit.
Receives callback-driven events AppDelegate The source’s Delegate suffix makes this role explicit.
Handles callbacks or feature events SendPaymentIntentHandler The source’s Handler suffix makes this role explicit.
Supplies a capability or framework resource PaymentProvider The source’s Provider suffix makes this role explicit.

Design patterns

Pattern Source evidence Purpose or tradeoff
View-controller organization Payments/PaymentHistoryViewController.swift:11 A controller is the verified coordination boundary; this is MVC-style only where a separate model is present.
Delegate or data-source callbacks Payments/AppDelegate.swift:13 Callback protocols invert event delivery back into the sample’s owner.

Naming conventions

  • Types: Controller: PaymentHistoryViewController; Delegate: AppDelegate; Handler: SendPaymentIntentHandler; Provider: PaymentProvider.
  • Protocols: no local protocol declaration in the scanned source.
  • Methods: applicationDidFinishLaunching, loadPaymentHistory, viewDidLoad, tableView, canSend, send, validate, save.
  • Files: Payments/AppDelegate.swift, Payments/PaymentHistoryViewController.swift, PaymentsFramework/PaymentProvider.swift, PaymentsIntentsExtension/SendPaymentIntentHandler.swift, PaymentsFramework/Contact.swift, PaymentsFramework/ContactLookup.swift.

Architecture takeaways

  • AppDelegate is the main source-visible entry or composition anchor for this sample.
  • Framework work reaches Intents, PaymentsFramework, UIKit through a deliberately small high-level chain; the detailed API graph remains inside the cited implementation files.
  • Stored-property evidence identifies lifecycle collaboration; it does not by itself prove exclusive object ownership.
  • Access-control conclusions separate verified language visibility from the likely design rationale.
  • The source does not justify labeling the design protocol-oriented.

Source map

Source file Relevant symbols
Payments/AppDelegate.swift AppDelegate
Payments/PaymentHistoryViewController.swift PaymentHistoryViewController, PaymentTableViewCell
PaymentsFramework/PaymentProvider.swift PaymentProvider
PaymentsIntentsExtension/SendPaymentIntentHandler.swift SendPaymentIntentHandler
PaymentsFramework/Contact.swift Contact
PaymentsFramework/ContactLookup.swift ContactLookup
PaymentsFramework/Payment.swift Payment
PaymentsIntentsExtension/IntentsExtension.swift IntentsExtension
PaymentsFramework/PaymentsFramework.h Feature implementation
PaymentsIntentsExtension/INPerson+Contact.swift Feature implementation