ContactlessPaymentSession

public final actor ContactlessPaymentSession

Class to manage and perform contactless payment transaction.

Since

7.0.0
  • Constructor to initialize ContactlessPaymentSession.

    Declaration

    Swift

    public convenience init()
  • requestAuthorization() Asynchronous

    Request 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:

    Declaration

    Swift

    @available(iOS 17.4, *)
    public func requestAuthorization() async throws
  • startEmulation() Asynchronous

    Start the card emulation and presents a modal user interface to user.

    This API is available after authenticationCompleted. Developer could call this API on authenticationCompleted or posConnected, depending on the user experience preferred. After this API is called, a modal user presentation is shown, i.e. no further UI modification, except the setAlertMessage(_:).

    Throws:

    Declaration

    Swift

    @available(iOS 17.4, *)
    nonisolated public func startEmulation() async throws
  • startPayment(with:) Asynchronous

    Starts a contactless payment flow using the provided input data.

    This method prepares and initiates a contactless transaction based on the ContactlessPaymentInputData provided. Depending on the configuration, the wallet transaction data can be supplied either as an ephemeral value or retrieved from secure storage.

    Throws

    Throws:

    • schemeNotSupported if the provided digital card id does not belong to MasterCard v2 scheme.

    Note

    Available on iOS 17.4 and later.

    See also

    WalletTransactionData for details on configuring wallet transaction values.

    Application should call eventStream to handle other events.

    Declaration

    Swift

    @available(iOS 17.4, *)
    public func startPayment(with contactlessPaymentInputData: ContactlessPaymentInputData) async throws

    Parameters

    contactlessPaymentInputData

    The input data that specifies how wallet transaction data should be sourced and which digital card to use for the transaction. If providing transaction data (either directly or from storage), the digitalCardId must belong to the MasterCard scheme.

    • If .ephemeral, the method uses the provided WalletTransactionData. A nil value may be passed in its associated value.
    • If .storage, the method retrieves the associated digital card and loads its stored wallet transaction data.
  • Start contactless payment transaction.

    The digital card ID provided will be remained as default card at the end of the payment

    Application should call eventStream to handle each event.

    Declaration

    Swift

    @available(iOS 17.4, *)
    public func startPayment(withDigitalCardID digitalCardID: String? = nil) async

    Parameters

    digitalCardID

    Digital card ID used. Otherwise, it use default card.

  • cancel() Asynchronous

    Cancel 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:

    Declaration

    Swift

    @available(iOS 17.4, *)
    nonisolated public func setAlertMessage(_ alertMessage: String) async
  • The device eligibility whether it supports contactless payment.

    See more

    Declaration

    Swift

    public enum Eligibility : Sendable
  • Errors encounterd for contactless payment session.

    See more

    Declaration

    Swift

    public enum Error : Swift.Error
  • Events produced during contactless payment session.

    See more

    Declaration

    Swift

    public enum Event : Sendable
  • Struct to manage the authentication flow.

    See more

    Declaration

    Swift

    public struct AuthenticateAction : Sendable