> For the complete documentation index, see [llms.txt](https://docs.onside.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.onside.io/sdk/purchasing/payment-methods.md).

# Managing Payment Methods

Let users manage their saved payment methods (bank cards) with OnsideKit's built-in payment methods manager screen.

OnsideKit provides a built-in screen where users can view, add, and remove the **bank cards** saved to their Onside account.

## Present the manager

```swift
@MainActor static func presentPaymentMethodsManager(
    completion: (@MainActor (Result<Void, OnsidePaymentMethodsManagerError>) -> Void)? = nil
)
```

```swift
Onside.presentPaymentMethodsManager { result in
    switch result {
    case .success:
        // The manager was presented; this does not wait for dismissal.
        break
    case .failure(.loginDiscarded):
        // The user dismissed the login screen shown before the manager.
        break
    case .failure(.notSupportedInLocalTesting):
        // Not available in local-testing mode.
        break
    case .failure(.notSupportedForExternalLogin):
        // External profiles use Apple Pay and cannot manage saved cards.
        break
    case .failure(.presentationFailed):
        // Retry when a window scene is available.
        break
    @unknown default:
        break
    }
}
```

`completion` is optional (`= nil`), so you can also call `Onside.presentPaymentMethodsManager()` with no arguments.

## Behavior

* **Implicit login.** If the user is not authenticated, OnsideKit presents the login flow first. If that login does not complete — the user dismissed it, or it could not be presented — the completion fails with `.loginDiscarded`. See [Authentication & User Account](/sdk/core-concepts/authentication.md).
* **External login.** For an authenticated external profile, the screen is unavailable and the call fails with `.notSupportedForExternalLogin`. Disabling the external delegate does not change an existing session; sign out and use regular Onside login if card management is required.
* **Local testing.** When the SDK is initialized with a `.storekit` configuration, this screen is unavailable and the call fails with `.notSupportedInLocalTesting`. See [Local Testing](/sdk/advanced-and-tooling/local-testing.md).

## Errors

`OnsidePaymentMethodsManagerError`:

<table><thead><tr><th width="280">Case</th><th>Cause</th></tr></thead><tbody><tr><td><code>.loginDiscarded</code></td><td>The login flow shown before the manager did not complete — dismissed by the user, or not presentable.</td></tr><tr><td><code>.notSupportedInLocalTesting</code></td><td>The SDK is running in local-testing mode (a <code>.storekit</code> configuration was passed to <code>initialize</code>).</td></tr><tr><td><code>.notSupportedForExternalLogin</code></td><td>The current profile was authenticated through external login.</td></tr><tr><td><code>.presentationFailed</code></td><td>OnsideKit couldn't present the screen because no active <code>UIWindowScene</code> was available. Nothing was shown. See <a href="/sdk/customization/delegate.md">The Onside Delegate</a> to supply the scene explicitly.</td></tr></tbody></table>

## Customizing presentation

The manager is presented in a window owned by the SDK. You can choose which `UIWindowScene` it uses, set that window's [level](/sdk/customization/delegate.md#window-level), and override its theme via [`OnsideDelegate`](/sdk/customization/delegate.md), using the `.paymentMethodsManager` screen case.

{% hint style="info" %}
Looking to configure **Apple Pay**? That's a separate setup — see [Apple Pay](/sdk/purchasing/apple-pay.md).
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.onside.io/sdk/purchasing/payment-methods.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
