ContactlessPaymentSession
public final actor ContactlessPaymentSession
Class to manage and perform contactless payment transaction.
Since
7.0.0-
Constructor to initialize
ContactlessPaymentSession.Declaration
Swift
public init() -
requestAuthorization()AsynchronousRequest authorization from user to allow NFC usage.
This prompts the permission dialog during first time application launch. On subsequent call, this API check the current authorization granted by end user.
When end user allows the authorization, the application is shown in list of default contactless application. Otherwise, application is not shown in the list.
Throws:
nfcPermissionNotAccepted- user does not allow the authorization.systemEligibilityFailed- Device not eligible for contactless payment.unknown(_:)- Unknown error encountered during transaction.
Declaration
Swift
@available(iOS 17.4, *) public func requestAuthorization() async throws -
startEmulation()AsynchronousStart the card emulation and presents a modal user interface to user.
This API is available after
authenticationCompleted. Developer could call this API onauthenticationCompletedorposConnected, depending on the user experience preferred. After this API is called, a modal user presentation is shown, i.e. no further UI modification, except thesetAlertMessage(_:).Throws:
deviceEnvironmentUnsafe(_:)if device environment is unsafe.unknown(_:)if error on starting card emulation.
Declaration
Swift
@available(iOS 17.4, *) nonisolated public func startEmulation() async throws -
startPayment(withDigitalCardID:Asynchronous) Start contactless payment transaction.
The digital card ID provided will be remained as default card at the end of the payment
Application should call
eventStreamto handle each event.Declaration
Swift
@available(iOS 17.4, *) public func startPayment(withDigitalCardID digitalCardID: String? = nil) asyncParameters
digitalCardIDDigital card ID used. Otherwise, it use default card.
-
cancel()AsynchronousCancel ongoing contactless payment transaction.
Declaration
Swift
@available(iOS 17.4, *) public func cancel() async -
An asynchronous sequence of events from contactless payment transaction.
Declaration
Swift
public var eventStream: AsyncStream<Event> -
setAlertMessage(_:Asynchronous) A message to show on the NFC action sheet.
Application should set the message for following events:
authenticationCompleted- start of transaction.posConnected- device is tapped to NFC reader.posDisconnected- device is disconnected from NFC reader.
Declaration
Swift
@available(iOS 17.4, *) nonisolated public func setAlertMessage(_ alertMessage: String) async -
The device eligibility whether it supports contactless payment.
See moreDeclaration
Swift
public enum Eligibility : Sendable -
Errors encounterd for contactless payment session.
See moreDeclaration
Swift
public enum Error : Swift.Error -
Events produced during contactless payment session.
See moreDeclaration
Swift
public enum Event : Sendable -
Struct to manage the authentication flow.
See moreDeclaration
Swift
public struct AuthenticateAction : Sendable
ContactlessPaymentSession Actor Reference