Skip to content

Tokenize with Payment Sheet iOS SDK

The Finix iOS SDK lets you securely collect card and bank account details in your iOS app using a pre-built payment sheet. Payment data is tokenized before it reaches your application, keeping sensitive card data out of your code and ensuring PCI compliance.

Tokens are created in Finix's vault and returned to your app. Use the token immediately to create a Payment Instrument via the Finix API.

Token Expiration

Tokens expire 30 minutes after creation. Create a Payment Instrument as soon as you receive the token.

Installing the library

The library is distributed via CocoaPods. Add it to your Podfile:

pod 'FinixPaymentSheet', :git => 'https://github.com/finix-payments/FinixPaymentSheet.git', :tag => 'v1.0.10'

Then run:

pod install

After installation, import the SDK in your source files:

import FinixPaymentSheet

No bridging headers or additional configuration are required.

System requirements

RequirementValue
iOS12.0+
Xcode14.0+
Swift5.8+

Quick start

Initialize FinixCredentials, create a PaymentAction, present a payment sheet, and handle the token response via the delegate.

class CheckoutViewController: UIViewController {
    var paymentAction: PaymentAction!

    override func viewDidLoad() {
        super.viewDidLoad()

        let credentials = FinixCredentials(
            applicationId: "YOUR_APPLICATION_ID",
            environment: .Sandbox // set to .Production for production
        )
        paymentAction = PaymentAction(credentials: credentials, delegate: self)
    }

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

extension CheckoutViewController: PaymentActionDelegate {
    func paymentAction(_ action: PaymentAction, didSucceedWith response: TokenResponse) {
        // response.id — use this to create a Payment Instrument via the Finix API
        print("Token: \(response.id)")
    }

    func paymentAction(_ action: PaymentAction, didFailWith error: Error) {
        print("Error: \(error.localizedDescription)")
    }
}