> ## Documentation Index
> Fetch the complete documentation index at: https://primer.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# PrimerKlarnaScope

> API reference for the Klarna scope

`PrimerKlarnaScope` manages the Klarna multi-step payment flow: category selection, authorization, and finalization.

## Declaration

```swift theme={"dark"}
@MainActor
public protocol PrimerKlarnaScope: PrimerPaymentMethodScope where State == PrimerKlarnaState
```

## Properties

| Property              | Type                             | Description                          |
| --------------------- | -------------------------------- | ------------------------------------ |
| `state`               | `AsyncStream<PrimerKlarnaState>` | Stream of Klarna state changes       |
| `presentationContext` | `PresentationContext`            | `.direct` or `.fromPaymentSelection` |
| `dismissalMechanism`  | `[DismissalMechanism]`           | Supported dismissal methods          |
| `paymentView`         | `UIView?`                        | Klarna's native payment view         |

### Customization

| Property          | Type                     | Description                                                               |
| ----------------- | ------------------------ | ------------------------------------------------------------------------- |
| `screen`          | `KlarnaScreenComponent?` | Full screen replacement. Signature: `(any PrimerKlarnaScope) -> any View` |
| `authorizeButton` | `KlarnaButtonComponent?` | Custom authorize button. Signature: `(any PrimerKlarnaScope) -> any View` |
| `finalizeButton`  | `KlarnaButtonComponent?` | Custom finalize button. Signature: `(any PrimerKlarnaScope) -> any View`  |

## Methods

| Method                                        | Description                      |
| --------------------------------------------- | -------------------------------- |
| `selectPaymentCategory(_ categoryId: String)` | Select a Klarna payment category |
| `authorizePayment()`                          | Start the authorization step     |
| `finalizePayment()`                           | Complete the finalization step   |
| `onBack()`                                    | Navigate back                    |
| `cancel()`                                    | Cancel the Klarna flow           |

## PrimerKlarnaState

```swift theme={"dark"}
public struct PrimerKlarnaState: Equatable {
  public enum Step: Equatable {
    case loading
    case categorySelection
    case viewReady
    case authorizationStarted
    case awaitingFinalization
  }

  var step: Step
  var categories: [KlarnaPaymentCategory]
  var selectedCategoryId: String?
}
```

### Flow

```mermaid theme={"dark"}
stateDiagram-v2
    [*] --> loading
    loading --> categorySelection
    categorySelection --> viewReady
    viewReady --> authorizationStarted
    authorizationStarted --> awaitingFinalization
    awaitingFinalization --> [*]
```

| Property             | Type                      | Description                 |
| -------------------- | ------------------------- | --------------------------- |
| `step`               | `Step`                    | Current step in the flow    |
| `categories`         | `[KlarnaPaymentCategory]` | Available Klarna categories |
| `selectedCategoryId` | `String?`                 | Currently selected category |

## See also

<CardGroup cols={2}>
  <Card title="Scopes overview" icon="diagram-project" href="/sdk/ios-checkout/v3.0.0-beta/configuration/scopes-overview">
    All available scopes
  </Card>
</CardGroup>
