How fiserv/ttppackage works
Overall Project Type and Purpose
• The project is an iOS SDK (distributed as both a Swift Package and a CocoaPod) that enables an app to integrate Apple’s Tap to Pay capabilities.
• Its primary goal is to abstract the complexity of device validation, session token management, card reading, payment processing, and handling refunds or inquiry transactions.
• The README details the integration steps including configuration (via FiservTTPConfig), initializing the card reader, and calling various API endpoints.
Breaking Down the File Structure
• The Sources directory holds the core SDK implementation under FiservTTP.
– Files like FiservTTPCardReader.swift indicate the main interface for developers.
– FiservTTPModels.swift contains data structures for configuration and transaction details.
– FiservTTPReader.swift likely encapsulates lower-level functionalities for interacting with iOS’ tap-to-pay hardware or underlying frameworks.
– FiservTTPServices.swift is expected to house the logic that communicates with backend APIs (session token requests, charge, void, refund, inquiry, etc.).
• The tests folder is used for unit-testing the SDK’s core functionalities.
• Build-related files (Package.swift, Podspec) indicate multiple integration options.
Main Components and Their Relationships
a. Public SDK Interface:
– FiservTTPCardReader is the central class exposed to the client app. It aggregates configuration, reader support checks, API methods (initializeSession, readCard, refundCard, etc.), and token management (auto-refresh).
b. Configuration & Models:
– FiservTTPConfig (likely defined in the models), which the app initializes with credentials, environment, merchant details, etc.
c. Service Layer:
– FiservTTPServices encapsulates the network requests and interactions with Commerce Hub or Fiserv’s backend. This includes obtaining session tokens, performing charges, voids, refunds, and inquiries.
d. Lower-level Reader Interaction:
– FiservTTPReader might interface with the Apple Tap to Pay hardware or APIs, verifying device compatibility and initiating payment sessions.
e. External Dependencies and Integrations:
– Apple Device/OS: Checking if the device (iPhone XS or later) supports Tap to Pay.
– Commerce Hub / Fiserv Developer Studio: These external systems provide credential verification and transaction processing.
– Additionally, integration guidance through Swift Package Manager or CocoaPods.
Instructing the Principal Software Engineer
• Clear labels for each component:
– “FiservTTPCardReader”, “FiservTTPConfig/Models”, “FiservTTPServices”, “FiservTTPReader”, “Commerce Hub API”, “Apple Tap-to-Pay Framework”
– Control flow and data exchange between the SDK layers and with external services.
– Internal SDK modules vs. external integrations.
• Possibly include annotations for key flows such as:
– “Initialization (Configuration → Card Reader → Services)”
– “Payment Processing (readCard → Transaction Flow → Response Handling)”