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

# CrossmintEmbeddedCheckout

> Swift Structure

**Structure**

A view that shows Crossmint’s hosted checkout for an order.

```swift theme={null}
@MainActor struct CrossmintEmbeddedCheckout
```

Create the order from your backend with the Crossmint Orders API. Pass the `orderId` and `clientSecret` from the response. The checkout page collects the payment. It also takes the buyer through the other steps the order needs, such as identity verification.

```swift theme={null}
CrossmintEmbeddedCheckout(
    apiKey: apiKey,
    orderId: orderId,
    clientSecret: clientSecret
)
```

Pass a `CrossmintCheckoutController` to observe the order as the buyer progresses. As an alternative, attach `onOrderUpdated(_:)` and `onOrderCreationFailed(_:)` to handle the events yourself.

## Initializers

### init(apiKey:orderId:clientSecret:lineItems:payment:recipient:appearance:identityVerificationHandling:controller:)

Creates a checkout for an order.

```swift theme={null}
@MainActor init(apiKey: String, orderId: String? = nil, clientSecret: String? = nil, lineItems: CheckoutLineItems? = nil, payment: CheckoutPayment? = nil, recipient: CheckoutRecipient? = nil, appearance: CheckoutAppearance? = nil, identityVerificationHandling: IdentityVerificationHandling? = nil, controller: CrossmintCheckoutController? = nil)
```

#### Parameters

| Parameter                      | Description                                                                                                                       |
| ------------------------------ | --------------------------------------------------------------------------------------------------------------------------------- |
| `apiKey`                       | Your client-side API key. The key starts with `ck_`.                                                                              |
| `orderId`                      | The identifier of the order your backend created.                                                                                 |
| `clientSecret`                 | The client secret from the same order response.                                                                                   |
| `lineItems`                    | The items of a new order. Not supported yet, so pass `nil`.                                                                       |
| `payment`                      | The payment settings. A `nil` value keeps the checkout defaults.                                                                  |
| `recipient`                    | The recipient of a new order. Not supported yet, so pass `nil`.                                                                   |
| `appearance`                   | The visual customization. A `nil` value keeps the checkout defaults.                                                              |
| `identityVerificationHandling` | The presentation mode for the identity verification step. Pass `IdentityVerificationHandling.external` to show the step yourself. |
| `controller`                   | The controller that receives the order updates.                                                                                   |

### init(apiKey:orderId:clientSecret:lineItems:payment:recipient:appearance:identityVerificationHandling:controller:environment:)

Creates a checkout for an order with an explicit environment.

```swift theme={null}
@MainActor init(apiKey: String, orderId: String? = nil, clientSecret: String? = nil, lineItems: CheckoutLineItems? = nil, payment: CheckoutPayment? = nil, recipient: CheckoutRecipient? = nil, appearance: CheckoutAppearance? = nil, identityVerificationHandling: IdentityVerificationHandling? = nil, controller: CrossmintCheckoutController? = nil, environment: CheckoutEnvironment)
```

The environment normally comes from the API key. Do not use this initializer in new code. Use `init(apiKey:orderId:clientSecret:lineItems:payment:recipient:appearance:identityVerificationHandling:controller:)` instead.

## Instance Properties

| Property | Type        | Description                 |
| -------- | ----------- | --------------------------- |
| `body`   | `some View` | Inherited from `View.body`. |

## Instance Methods

### onOrderCreationFailed(\_:)

Adds an action to perform when order creation fails. The message describes the failure.

```swift theme={null}
@MainActor func onOrderCreationFailed(_ action: @escaping (String) -> Void) -> CrossmintEmbeddedCheckout
```

### onOrderUpdated(\_:)

Adds an action to perform on every order update from the checkout page.

```swift theme={null}
@MainActor func onOrderUpdated(_ action: @escaping (CheckoutOrderUpdate) -> Void) -> CrossmintEmbeddedCheckout
```
