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
)| Parameter | Type | Required | Description |
|---|---|---|---|
credentials | FinixCredentials | Yes | Your Finix Application ID and environment. See FinixCredentials below. |
delegate | PaymentActionDelegate | Yes | Receives tokenization success and failure callbacks. See PaymentActionDelegate below. |
configuration | Configuration? | No | Customize branding, sheet title, and button label. See Configuration. |
FinixCredentials
FinixCredentials(
applicationId: String,
environment: FinixAPIEndpoint
)| Property | Type | Description |
|---|---|---|
applicationId | String | Your Finix Application ID, found in the Finix Dashboard. |
environment | FinixAPIEndpoint | .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.
| Value | Environment |
|---|---|
.Sandbox | Sandbox |
.Production | Production |
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)| Method | Trigger | Receives |
|---|---|---|
didSucceed(paymentController:instrument:) | Successful tokenization | TokenResponse |
didCancel(paymentController:) | User dismissed the sheet | — |
didFail(paymentController:error:) | Tokenization failed | Error |
After receiving didSucceed, pass instrument.id to your backend and call the Finix API to create a Payment Instrument.
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
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)
}
}