This Package is an SDK that facilitates enabling Apple's Tap To Pay on iPhone functionality in your own app. With just a bit of configuration and a few lines of code, your iPhone app will be able to securely accept contactless payments on a supported iPhone without any additional hardware (e.g. POS terminal, external card reader device, etc.)
Currently this functionality is only available in the U.S.
By using this Package, you will not need to certify your app. We have taken care of that for you.
Apple Tap to Pay on iPhone requires iPhone XS or later, running iOS 16 or later
You must request a special entitlement from Apple to enable Tap To Pay. Log-into your Apple Developer Account and then click here to request the entitlement. In the text box titled 'PSP, enter 'Fiserv' as the value. Follow the instructions here to add the entitlement to your app's profile
You can obtain test credentials for your app on Fiserv's Developer Studio by following these directions:
Create a new project or open your existing app in XCode. Add the Fiserv Package to your app by following these instructions:
https://github.com/Fiserv/TTPPackage
Create an instance of FiservTTPConfig
and load it with your configuration as follows:
let myConfig = FiservTTPConfig(
secretKey: "<your secret key from Developer Studio>",
apiKey: "<your API key from Developer Studio>",
environment: .Sandbox,
currencyCode: "USD",
merchantId: "<your merchantId from the CommerceHub workspace on Developer Studio>",
merchantName: "<your merchant name as it will be displayed in the Tap to Pay payment sheet>",
merchantCategoryCode: "<your MCC>",
terminalId: "10000001",
terminalProfileId: "3c00e000-a00e-2043-6d63-936859000002")
Now create an instance of FiservTTPCardReader
, which is the main class that your app will interact with. Typically you would put this in a view model.
private let fiservTTPCardReader: FiservTTPCardReader = FiservTTPCardReader(configuration: myConfig)
Early in the startup process of your app, call the following method to validate that the device running your app is supported for Apple Tap To Pay on iPhone:
if !fiservTTPCardReader.readerIsSupported() {
///TODO handle unsupported device
}
You must obtain a session token in order to utilize the SDK. Acquire the token by making this call:
do {
try await fiservTTPCardReader.requestSessionToken()
} catch let error as FiservTTPCardReaderError {
///TODO handle exception
}
Note that the session token will expire in 24 hours. You are responsible for keeping track of when to obtain a new token.
Next you must link the device running the app to an Apple ID. This needs to happen just once. You are responsible for tracking whether the linking process has occurred already or not. If not, then perform linking by making this call:
do {
try await fiservTTPCardReader.linkAcount()
} catch let error as FiservTTPCardReaderError {
///TODO handle exception
}
Now you're ready to initialize the Apple Proximity Reader by calling:
do {
try await fiservTTPCardReader.activateReader()
} catch let error as FiservTTPCardReaderError {
///TODO handle exception
}
NOTE that you must re-initialize the reader session each time the app starts and/or returns to the foreground!
Congrats on getting this far! Now you are ready to process your first payment. Simply make this call and the SDK takes care of the rest for you:
let amount = 10.99 // amount to charge
let merchantOrderId = "your order ID, for tracking purposes"
let merchantTransactionId = "your transaction ID, for tracking purposes"
do {
let chargeResponse = try await readCard(
amount: amount,
merchantOrderId: merchantOrderId,
merchantTransactionId: merchantTransactionId)
///TODO inspect the chargeResponse to see the authorization result
} catch let error as FiservTTPCardReaderError {
///TODO handle exception
}
We've prepared an end-to-end sample app to get you up and running fast. Get the Sample App here
Merchant FAQ's from Apple
Tap to Pay on iPhone Security from Apple
link |
Stars: 2 |
Last commit: 4 days ago |
Optional Response Values
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics