# 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](/ios/online/token-response).


```swift
PaymentAction(
    credentials: FinixCredentials,
    delegate: PaymentActionDelegate,
    configuration: Configuration? = nil
)
```

| Parameter | Type | Required | Description |
|  --- | --- | --- | --- |
| `credentials` | `FinixCredentials` | Yes | Your Finix Application ID and environment. See [FinixCredentials](#param-credentials). |
| `delegate` | `PaymentActionDelegate` | Yes | Receives tokenization success and failure callbacks. See [PaymentActionDelegate](#param-delegate). |
| `configuration` | `Configuration?` | No | Customize branding, sheet title, and button label. See [Configuration](/ios/online/configuration). |



```swift
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.

Controls which Finix environment the SDK connects to.

| Value | Environment |
|  --- | --- |
| `.Sandbox` | Sandbox |
| `.Production` | Production |


Your `applicationId` must belong to the same environment.

Implement `PaymentActionDelegate` to receive tokenization results.


```swift
@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](/ios/online/token-response) |
| `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.

## Presenting the Payment Sheet

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

For card collection, call `paymentSheet(style:)` with a [Form Style](/ios/online/form-styles):


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

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


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

## Full Example

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