# Let customers pay in their local currency

Add Adaptive Pricing and the Currency Selector Element to mobile checkout.

Use [Adaptive Pricing](https://docs.stripe.com/payments/currencies/localize-prices/adaptive-pricing.md) with the [Currency Selector Element](https://docs.stripe.com/payments/mobile/checkout-sessions/build-a-checkout-page.md#currency-selector) to let eligible customers choose between your integration currency and a localized currency. Stripe localizes prices, provides the required exchange rate disclosure, updates available payment methods, and handles currency conversion.

### Want access to Mobile Checkout Elements?

Mobile Checkout Elements is in private preview. Share your email address to request access.

```bash
curl https://docs.stripe.com/preview/register \
  -X POST \
  -H "Content-Type: application/json" \
  -H "Referer: https://docs.stripe.com/payments/mobile/checkout-sessions/adaptive-pricing" \
  -d '{"email": "EMAIL", "preview": "elements_beta_preview"}'
```
![Checkout with a Currency Selector Element showing 70.23 in GBP and 90.00 in USD, with USD selected and the exchange rate disclosed below.](https://b.stripecdn.com/docs-statics-srv/assets/adaptive-pricing-currency-selector.19ec542d986ec866e58a447febca94fa.png)

The preview supports one-time payments only. Adaptive Pricing requires Checkout Sessions and isn’t supported with the Payment Intents API.

# iOS


## Before you begin

Before you add Adaptive Pricing, complete these tasks:

- [Build a mobile checkout with Checkout Sessions](https://docs.stripe.com/payments/mobile/checkout-sessions/build-a-checkout-page.md).
- Review the Adaptive Pricing [supported regions, currencies, and restrictions](https://docs.stripe.com/payments/currencies/localize-prices/adaptive-pricing.md?payment-ui=embedded-components#restrictions).

When Adaptive Pricing is active, the client-side Session includes localized line items and totals. When a customer selects a currency in the Currency Selector Element, it updates the shared Session, available payment methods, and other Session-backed Elements. The server-side [Checkout Session](https://docs.stripe.com/api/checkout/sessions/object.md) remains denominated in your integration currency and exposes the customer’s presentment context separately.

## Enable Adaptive Pricing on the Checkout Session [Server-side]

Enable Adaptive Pricing in your [Payments settings](https://dashboard.stripe.com/settings/adaptive-pricing) in the Dashboard, or set [adaptive_pricing.enabled](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-adaptive_pricing-enabled) to `true` when you create the Checkout Session on your server. Use an integration currency that’s one of your [settlement currencies](https://docs.stripe.com/payouts/multi-currency-settlement.md).

```curl
curl https://api.stripe.com/v1/checkout/sessions \
  -u "<<YOUR_SECRET_KEY>>:" \
  -d ui_mode=mobile_elements \
  -d "adaptive_pricing[enabled]=true" \
  -d "items[0][type]=one_time_price" \
  -d "items[0][one_time_price][items][0][price]={{PRICE_ID}}" \
  -d "items[0][one_time_price][items][0][quantity]=1"
```

## Configure Adaptive Pricing [Client-side]

When you configure the Currency Selector Element, you must also [render it](https://docs.stripe.com/payments/mobile/checkout-sessions/adaptive-pricing.md#add-currency-selector) and [display localized prices](https://docs.stripe.com/payments/mobile/checkout-sessions/adaptive-pricing.md#render-localized-prices) throughout your checkout.

Configure the Currency Selector Element on your `CheckoutElementsController` to enable Adaptive Pricing on the client.

Display `error.localizedDescription` for loading failures. See [Handle errors](https://docs.stripe.com/payments/mobile/checkout-sessions/build-a-checkout-page.md?platform=ios#handle-errors).

#### UIKit

Configure the controller before you create your view controller.

```swift
@MainActor
final class CheckoutViewController: UIViewController {
    let checkout: CheckoutElementsController

    static func create(
        clientSecret: String
    ) async throws -> CheckoutViewController {
        var configuration = CheckoutElementsController.Configuration(
            clientSecret: clientSecret,
            returnURL: "my-app://stripe-redirect"
        )
        configuration.paymentElement = PaymentElement.Configuration()

        var appearance = CurrencySelectorElement.Configuration.Appearance()
        appearance.cornerRadius = 12
        appearance.background = .secondarySystemBackground
        appearance.selectedBackground = .systemBackground
        appearance.labelContent = .amount

        var currencySelector = CurrencySelectorElement.Configuration()
        currencySelector.appearance = appearance
        configuration.currencySelectorElement = currencySelector

        let checkout = try await CheckoutElementsController(configuration: configuration)
        return CheckoutViewController(checkout: checkout)
    }
}
```

When calling `create`, catch errors and display `error.localizedDescription` using the [controller initialization pattern](https://docs.stripe.com/payments/mobile/checkout-sessions/build-a-checkout-page.md?platform=ios#configure-checkout).

#### SwiftUI

Load the controller before you display your checkout content.

```swift
struct CheckoutContainer: View {
    let clientSecret: String

    @State private var checkout: CheckoutElementsController?
    @State private var loadError: Error?

    var body: some View {
        Group {
            if let checkout {
                CheckoutView(checkout: checkout)
            } else if let loadError {
                Text(loadError.localizedDescription)
            } else {
                ProgressView()
            }
        }
        .task {
            do {
                var configuration = CheckoutElementsController.Configuration(
                    clientSecret: clientSecret,
                    returnURL: "my-app://stripe-redirect"
                )
                configuration.paymentElement = PaymentElement.Configuration()

                var appearance = CurrencySelectorElement.Configuration.Appearance()
                appearance.cornerRadius = 12
                appearance.background = .secondarySystemBackground
                appearance.selectedBackground = .systemBackground
                appearance.labelContent = .amount

                var currencySelector = CurrencySelectorElement.Configuration()
                currencySelector.appearance = appearance
                configuration.currencySelectorElement = currencySelector

                checkout = try await CheckoutElementsController(configuration: configuration)
            } catch {
                loadError = error
            }
        }
    }
}
```

> Configuring the Currency Selector Element doesn’t guarantee that Adaptive Pricing is available for the Checkout Session.

## Add the Currency Selector Element [Client-side]

Place the Currency Selector Element near your order total. It displays only when Adaptive Pricing is available, and updates the Checkout Session when the customer selects a currency.

#### UIKit

```swift
func addCurrencySelector() {
    guard let currencySelector = checkout.getCurrencySelectorElement() else {
        return
    }

    currencySelector.delegate = self
    currencySelector.uiView.translatesAutoresizingMaskIntoConstraints = false
    contentStackView.addArrangedSubview(currencySelector.uiView)
}
```

The Currency Selector Element can grow or shrink when a customer expands or collapses the exchange rate details. To handle these height changes, implement the `currencySelectorElementDidUpdateHeight` delegate method. The Element calls this method within the animation block that updates its height. In your implementation, call `setNeedsLayout()` and `layoutIfNeeded()` on the scroll view that contains the Element to animate the height change smoothly.

```swift
extension CheckoutViewController: CurrencySelectorElementDelegate {
    func currencySelectorElementDidUpdateHeight(
        currencySelectorElement: CurrencySelectorElement
    ) {
        view.setNeedsLayout()
        view.layoutIfNeeded()
    }
}
```

If `getCurrencySelectorElement()` returns `nil`, don’t reserve spacing for the Element.

#### SwiftUI

```swift
struct CheckoutView: View {
    @ObservedObject var checkout: CheckoutElementsController

    var body: some View {
        VStack {
            if let currencySelector = checkout.getCurrencySelectorElement() {
                currencySelector.view
            }
        }
    }
}
```

If `getCurrencySelectorElement()` returns `nil`, don’t reserve spacing for the Element.

## Render localized prices [Client-side]

Render every amount in your checkout from the latest `CheckoutElementsController.session`, including line items, discounts, tax, shipping, and totals.

The `Amount.amount` values are localized strings that already reflect the selected currency and locale. Observe the controller so your UI updates after a currency change.

#### UIKit

```swift
override func viewDidLoad() {
    super.viewDidLoad()

    checkout.$session
        .receive(on: DispatchQueue.main)
        .sink { [weak self] session in
            let totals = session.totals
            self?.subtotalLabel.text = "Subtotal \(totals.subtotal.amount)"
            self?.taxLabel.text = "Tax \(totals.taxExclusive.amount)"
            self?.totalLabel.text = "Total \(totals.total.amount)"
        }
        .store(in: &cancellables)
}
```

#### SwiftUI

```swift
struct OrderSummary: View {
    @ObservedObject var checkout: CheckoutElementsController

    var body: some View {
        let totals = checkout.session.totals

        VStack(alignment: .leading) {
            Text("Subtotal \(totals.subtotal.amount)")

            if totals.discount.minorUnitsAmount != 0 {
                Text("Discount -\(totals.discount.amount)")
            }

            if totals.taxExclusive.minorUnitsAmount != 0 {
                Text("Tax \(totals.taxExclusive.amount)")
            }

            Text("Total \(totals.total.amount)")
        }
    }
}
```

## Testing

To test local currency presentment, pass a location-formatted customer email that includes a `+location_XX` suffix in the local part of the email. `XX` must be a valid [two-letter ISO country code](https://www.nationsonline.org/oneworld/country_code_list.htm).

For example, to test currency presentment for a customer in France, set [customer_email](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-customer_email) to `test+location_FR@example.com` when you create the Checkout Session. Your app displays the currency that a customer in France would see.

```curl
curl https://api.stripe.com/v1/checkout/sessions \
  -u "<<YOUR_SECRET_KEY>>:" \
  -d ui_mode=mobile_elements \
  --data-urlencode "customer_email=test+location_FR@example.com" \
  -d "adaptive_pricing[enabled]=true" \
  -d "items[0][type]=one_time_price" \
  -d "items[0][one_time_price][items][0][price]={{PRICE_ID}}" \
  -d "items[0][one_time_price][items][0][quantity]=1"
```

Stripe test cards work as usual.

