Skip to content

PaymentAction

The main entry point for displaying the payment sheet in your iOS app. Initialize PaymentAction once in your view controller, then call paymentSheet(style:) or bankPaymentSheet() to create a sheet and present(from:paymentSheet:animated:) to display it modally.

On successful tokenization, the delegate's didSucceed(paymentController:instrument:) method is called with a TokenResponse.

Initializer

PaymentAction(
    credentials: FinixCredentials,
    delegate: PaymentActionDelegate,
    configuration: Configuration? = nil
)
ParameterTypeRequiredDescription
credentialsFinixCredentialsYesYour Finix Application ID and environment. See FinixCredentials below.
delegatePaymentActionDelegateYesReceives tokenization success and failure callbacks. See PaymentActionDelegate below.
configurationConfiguration?NoCustomize branding, sheet title, and button label. See Configuration.

FinixCredentials

FinixCredentials(
    applicationId: String,
    environment: FinixAPIEndpoint
)
PropertyTypeDescription
applicationIdStringYour Finix Application ID, found in the Finix Dashboard.
environmentFinixAPIEndpoint.Sandbox for testing, .Production for live payments.

Application IDs are environment-specific — use the one that matches your chosen environment value.

environment

Controls which Finix environment the SDK connects to.

ValueEnvironment
.SandboxSandbox
.ProductionProduction

Your applicationId must belong to the same environment.

PaymentActionDelegate

Implement PaymentActionDelegate to receive tokenization results.

@objc func didSucceed(paymentController: PaymentInputController, instrument: TokenResponse)
@objc func didCancel(paymentController: PaymentInputController)
@objc func didFail(paymentController: PaymentInputController, error: Error)
MethodTriggerReceives
didSucceed(paymentController:instrument:)Successful tokenizationTokenResponse
didCancel(paymentController:)User dismissed the sheet
didFail(paymentController:error:)Tokenization failedError

After receiving didSucceed, pass instrument.id to your backend and call the Finix API to create a Payment Instrument.

Presenting the Payment Sheet

paymentSheet(style:) / bankPaymentSheet() / present(from:paymentSheet:animated:)

Create a payment sheet for the desired collection type, then present it modally.

For card collection, call paymentSheet(style:) with a Form Style:

let sheet = paymentAction.paymentSheet(style: .complete)
paymentAction.present(from: self, paymentSheet: sheet, animated: true)

For bank account (ACH) collection, call bankPaymentSheet():

let bankSheet = paymentAction.bankPaymentSheet()
paymentAction.present(from: self, paymentSheet: bankSheet, animated: true)

Full example

Full example

A complete implementation with credentials, delegate conformance, and optional configuration.

PaymentAction(
    credentials: credentials,
    delegate: self,
    configuration: configuration
)

// Sandbox
let credentials = FinixCredentials(
    applicationId: "APgPDQrLD52TYvqazjHJJchM",
    environment: .Sandbox
)

// Production
let credentials = FinixCredentials(
    applicationId: "APgPDQrLD52TYvqazjHJJchM",
    environment: .Production
)

// Sandbox — use a sandbox Application ID
let credentials = FinixCredentials(
    applicationId: "APgPDQrLD52TYvqazjHJJchM",
    environment: .Sandbox
)

extension CheckoutViewController: PaymentActionDelegate {
    @objc func didSucceed(paymentController: PaymentInputController, instrument: TokenResponse) {
        // instrument.id is the value you pass to the Finix API
        print("Token: \(instrument.id)")
        dismiss(animated: true)
    }

    @objc func didCancel(paymentController: PaymentInputController) {
        dismiss(animated: true)
    }

    @objc func didFail(paymentController: PaymentInputController, error: Error) {
        print("Error: \(error.localizedDescription)")
        dismiss(animated: true)
    }
}

class CheckoutViewController: UIViewController {
    var paymentAction: PaymentAction!

    // Card payment sheet
    func showCardSheet() {
        let sheet = paymentAction.paymentSheet(style: .complete)
        paymentAction.present(from: self, paymentSheet: sheet, animated: true)
    }

    // Bank account (ACH) payment sheet
    func showBankSheet() {
        let bankSheet = paymentAction.bankPaymentSheet()
        paymentAction.present(from: self, paymentSheet: bankSheet, animated: true)
    }
}

class CheckoutViewController: UIViewController {
    var paymentAction: PaymentAction!

    override func viewDidLoad() {
        super.viewDidLoad()

        let credentials = FinixCredentials(
            applicationId: "APgPDQrLD52TYvqazjHJJchM",
            environment: .Production
        )
        let config = Configuration(
            title: "Card Entry",
            branding: Branding(image: UIImage(named: "MyLogo"), title: "My Company"),
            buttonTitle: "Pay Now"
        )
        paymentAction = PaymentAction(
            credentials: credentials,
            delegate: self,
            configuration: config
        )
    }

    func showPaymentSheet() {
        let sheet = paymentAction.paymentSheet(style: .complete)
        paymentAction.present(from: self, paymentSheet: sheet, animated: true)
    }
}

extension CheckoutViewController: PaymentActionDelegate {
    @objc func didSucceed(paymentController: PaymentInputController, instrument: TokenResponse) {
        print("Token: \(instrument.id)")
        dismiss(animated: true)
    }

    @objc func didCancel(paymentController: PaymentInputController) {
        dismiss(animated: true)
    }

    @objc func didFail(paymentController: PaymentInputController, error: Error) {
        print("Error: \(error.localizedDescription)")
        dismiss(animated: true)
    }
}