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
@MainActor static func presentPaymentMethodsManager(
completion: (@MainActor (Result<Void, OnsidePaymentMethodsManagerError>) -> Void)? = nil
)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.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
.storekitconfiguration, this screen is unavailable and the call fails with.notSupportedInLocalTesting. See Local Testing.
Errors
OnsidePaymentMethodsManagerError:
.loginDiscarded
The login flow shown before the manager did not complete — dismissed by the user, or not presentable.
.notSupportedInLocalTesting
The SDK is running in local-testing mode (a .storekit configuration was passed to initialize).
.notSupportedForExternalLogin
The current profile was authenticated through external login.
.presentationFailed
OnsideKit couldn't present the screen because no active UIWindowScene was available. Nothing was shown. See The Onside Delegate to supply the scene explicitly.
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, and override its theme via OnsideDelegate, using the .paymentMethodsManager screen case.
Last updated
Was this helpful?