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

# Fiat Ramps

> Let users buy and sell crypto in your iOS app using hosted provider widgets, Coinbase Apple Pay, Brale ACH bank transfers, and headless card or Apple Pay checkouts.

Your iOS app can offer fiat on-ramps and off-ramps directly inside your own SwiftUI or UIKit experience. `ParaSwift` exposes methods on `ParaManager`, `ParaHeadlessOnRampCheckout` (with the optional `ParaSwiftMeld` module), and an `onRampEvents` `AsyncStream` for hosted provider checkouts, headless Coinbase Apple Pay orders, headless Brale ACH bank transfers, and routed headless card and Apple Pay checkouts.

> [!NOTE]
>
> Providers, enabled networks, allowed assets, Apple Pay domains, and Brale Plaid mobile OAuth settings are configured per API key in the **Developer Portal**. Set those up first in [Set Up Fiat Onramps](https://docs.getpara.com/v3/swift/setup/developer-portal-payments.md).

## Discover Providers and Assets

Read your key's configuration and catalog items before rendering buy or sell options. `getOnRampConfig` returns feature flags, your default asset, and inline Apple Pay providers enabled for your key, while `getOnRampCatalog` returns paginated asset implementations and provider limits.

```swift RampCatalog.swift theme={null}
import ParaSwift

let config = try await paraManager.getOnRampConfig(walletTypes: ["EVM", "SOLANA"])
let catalog = try await paraManager.getOnRampCatalog(limit: 50)

let defaultAsset = config.defaultOnRampAssetImplementation
let items = catalog.items
```

## Hosted Checkout (Buy and Off-Ramp)

Hosted checkout supports card and bank orders across Stripe, MoonPay, Ramp Network, Coinbase (Widget), Transak, and Banxa, as well as off-ramp sales (`SELL`) for supported providers. Create an order with `createHostedOnRampOrder`, launch the returned portal URL with `launchOnRampPortal` (backed by `ASWebAuthenticationSession`), and inspect the flat order state with `getOnRampOrder`.

> [tab] Buy (On-Ramp)
>
> Create a `.buy` order for a provider supporting `isBuy`, launch the hosted portal, and inspect the flat order when control returns to your app.
>
> ```swift HostedBuy.swift theme={null}
> import Foundation
> import ParaSwift
>
> func buyWithHostedProvider(
>     paraManager: ParaManager,
>     walletId: String,
>     item: ParaOnRampCatalogItem
> ) async throws {
>     guard let provider = item.providers.first(where: {
>         $0.isBuy && $0.provider != .cdp && $0.provider != .brale
>     })?.provider else { return }
>
>     let order = try await paraManager.createHostedOnRampOrder(
>         ParaCreateHostedOnRampOrderParams(
>             walletId: walletId,
>             walletType: item.walletType,
>             provider: provider,
>             type: .buy,
>             assetImplementationId: item.assetImplementationId,
>             fiatQuantity: "25"
>         )
>     )
>
>     if let portalUrl = URL(string: order.portalUrl),
>        let callbackUrl = try await paraManager.launchOnRampPortal(portalUrl: portalUrl) {
>         let callback = ParaManager.parseOnRampPortalCallback(callbackUrl)
>         let orderResult = try await paraManager.getOnRampOrder(
>             walletId: walletId,
>             purchaseId: order.onRampPurchase.id
>         )
>         print("Callback status:", callback.rawStatus ?? "", "Order:", orderResult.status?.rawValue ?? "")
>     }
> }
> ```

> [tab] Sell (Off-Ramp)
>
> Create a `.sell` order for a provider supporting `isSell`. When the callback reports `rawStatus == "deposit_required"` and `orderResult.pendingDeposit` is present, broadcast the deposit transaction with `sendOffRampDeposit`.
>
> ```swift HostedSell.swift theme={null}
> import Foundation
> import ParaSwift
>
> func sellWithHostedProvider(
>     paraManager: ParaManager,
>     walletId: String,
>     item: ParaOnRampCatalogItem
> ) async throws {
>     guard let provider = item.providers.first(where: {
>         $0.isSell && $0.provider != .cdp && $0.provider != .brale
>     })?.provider else { return }
>
>     let order = try await paraManager.createHostedOnRampOrder(
>         ParaCreateHostedOnRampOrderParams(
>             walletId: walletId,
>             walletType: item.walletType,
>             provider: provider,
>             type: .sell,
>             assetImplementationId: item.assetImplementationId,
>             fiatQuantity: "25"
>         )
>     )
>
>     if let portalUrl = URL(string: order.portalUrl),
>        let callbackUrl = try await paraManager.launchOnRampPortal(portalUrl: portalUrl) {
>         let callback = ParaManager.parseOnRampPortalCallback(callbackUrl)
>         let orderResult = try await paraManager.getOnRampOrder(
>             walletId: walletId,
>             purchaseId: order.onRampPurchase.id
>         )
>
>         if callback.rawStatus == "deposit_required",
>            let deposit = orderResult.pendingDeposit {
>             let sent = try await paraManager.sendOffRampDeposit(
>                 ParaSendOffRampDepositParams(
>                     purchaseId: order.onRampPurchase.id,
>                     walletId: walletId,
>                     walletType: orderResult.walletType,
>                     provider: orderResult.provider,
>                     destinationAddress: deposit.destinationAddress,
>                     assetQuantity: deposit.assetQuantity,
>                     chainId: deposit.chainId,
>                     contractAddress: deposit.contractAddress,
>                     asset: deposit.asset,
>                     network: deposit.network,
>                     fiat: deposit.fiat,
>                     fiatQuantity: deposit.fiatQuantity,
>                     providerOrderId: deposit.providerOrderId
>                 )
>             )
>             print("Off-ramp deposit hash:", sent.txHash)
>         }
>     }
> }
> ```

> [!NOTE]
>
> Initialize `ParaManager(environment:apiKey:appScheme:)` with your registered custom URL scheme (or rely on the bundle identifier fallback) so `launchOnRampPortal` can return to your app automatically. When running an off-ramp (`type: .sell`), broadcast the seller's deposit via `sendOffRampDeposit` whenever `callback.rawStatus == "deposit_required"` and `orderResult.pendingDeposit` is present.

## Coinbase Apple Pay (Headless, iOS)

Coinbase headless guest checkout displays a native Apple Pay payment page inside a `WKWebView` hosted on your verified merchant domain.

> [!WARNING]
>
> Headless Coinbase Apple Pay requires at least one allowlisted domain configured in both Coinbase Developer Platform and the Developer Portal (see [Coinbase setup](https://docs.getpara.com/v3/swift/setup/developer-portal-payments.md#coinbase-apple-pay--hosted-widget)), plus a verified U.S. phone number and email on the user's account.

### Method Sequence

1. Optionally call `checkCoinbaseOnrampLimits(_:)` and `createCoinbaseOnrampLimitUpgrade(_:)` to check guest checkout limits and open `upgradeUrl` in a browser or `WKWebView` when `limits.upgradeable == true` and remaining capacity is below the order amount.
2. Call `createCoinbaseOnrampOrder(_:)` with `isQuote: true` to fetch a quote, then with `isQuote: false` (or `nil`) to create the order and receive `paymentLink.url` and `purchaseId`.
3. Load `paymentLink.url` in a `WKWebView` so the user can authorize Apple Pay, parsing WebView events with `ParaManager.parseCoinbaseApplePayEvent(_:origin:allowedOrigins:)`.
4. Call `settleCoinbaseOnrampPurchase(purchaseId:walletId:)` after payment completes (`onramp_api.polling_success` or `onramp_api.commit_success`) or on dismissal to confirm settlement (server-side settlement is idempotent and queries Coinbase directly).

```swift CoinbaseApplePay.swift theme={null}
import Foundation
import ParaSwift

func buyWithCoinbaseApplePay(
    paraManager: ParaManager,
    walletId: String,
    assetImplementationId: String,
    userPhoneNumber: String,
    userEmail: String,
    openUpgradeUrl: @escaping (URL) async -> Void,
    presentPaymentSheet: @escaping (URL) async -> Bool
) async throws {
    let limits = try await paraManager.checkCoinbaseOnrampLimits(
        ParaCoinbaseLimitsParams(phoneNumber: userPhoneNumber)
    )
    let needsLimitUpgrade = (limits.limits ?? []).contains { entry in
        guard let remaining = entry.remaining.flatMap({ Decimal(string: $0) }) else { return false }
        return remaining < 25
    }
    if needsLimitUpgrade, limits.upgradeable == true {
        let upgrade = try await paraManager.createCoinbaseOnrampLimitUpgrade(
            ParaCoinbaseLimitUpgradeParams(phoneNumber: userPhoneNumber)
        )
        if let urlString = upgrade.upgradeUrl, let upgradeUrl = URL(string: urlString) {
            await openUpgradeUrl(upgradeUrl)
            return
        }
    }

    let order = try await paraManager.createCoinbaseOnrampOrder(
        ParaCoinbaseOrderParams(
            paymentAmount: "25.00",
            assetImplementationId: assetImplementationId,
            walletId: walletId,
            phoneNumber: userPhoneNumber,
            email: userEmail
        )
    )

    guard let urlString = order.paymentLink?.url,
          let paymentUrl = URL(string: urlString),
          await presentPaymentSheet(paymentUrl),
          let purchaseId = order.purchaseId else { return }

    let status = try await paraManager.settleCoinbaseOnrampPurchase(
        purchaseId: purchaseId,
        walletId: walletId
    )
    print("Order status:", status)
}
```

> [!NOTE]
>
> `userPhoneNumber` and `userEmail` are placeholders for the buyer's verified contact details. In production, the server validates both against the user's verified Para records. Listen for `onramp_api.polling_success` or `onramp_api.commit_success` with `ParaManager.parseCoinbaseApplePayEvent(_:origin:allowedOrigins:)` and call `settleCoinbaseOnrampPurchase` after payment completes (server-side settlement is idempotent and queries Coinbase directly, so calling on dismissal is also safe).

### Order States and Partner Events

* **Order states**: Real orders track through `ParaOnRampPurchaseStatus` cases `.initiated`, `.finished`, `.cancelled`, `.failed`, or `.unknown(String)`. Quotes (`isQuote: true`) do not persist an order row.
* **Partner events**: `paraManager.onRampEvents` yields `.launched(ParaOnRampEventPayload)` when `createCoinbaseOnrampOrder` creates a real order and `.completed(ParaOnRampEventPayload)` when `settleCoinbaseOnrampPurchase` confirms `.finished`. Server webhooks emit `onramp.completed` and `onramp.cancelled`.

> [!NOTE]
>
> When `domain` is omitted on iOS, Para uses the first allowlisted Apple Pay domain configured on your API key in the Developer Portal. On non-production API keys, orders run in Coinbase sandbox mode (`?useApplePaySandbox=true`) and simulate immediate settlement.

## Brale ACH (Pay by Bank, Headless)

Brale ACH lets U.S. users fund an EVM or Solana wallet from a bank account using Plaid Link iOS (`LinkKit`) and `ParaManager`'s Brale checkout methods. `createBraleAchCheckout(_:)` sets `platform` to `"ios"` automatically when you leave it `nil`.

> [!WARNING]
>
> Production Brale ACH requires the Growth plan or higher, ACH enabled in the Developer Portal, and a biometric-authenticated user (guest and external-wallet-only logins are unsupported). For banks that require OAuth redirects in Plaid Link, enter your **iOS Plaid OAuth redirect URI** (`https://...` Universal Link) in the **ACH** section of the Developer Portal (saving notifies Para for Brale allowlisting), or pass `redirectUri` on `ParaCreateBraleAchCheckoutParams` to override it; until allowlisted by Brale, Para leaves it out of the Plaid link token.

### Method Sequence

1. Call `createBraleAchCheckout(_:)` with `walletId` and `amountUsd` (plus optional `customer: ParaBraleAchCustomer(legalName:)` and `assetImplementationId`).
2. Inspect `checkout.nextAction`:
   * `"launch_plaid"`: Open Plaid Link iOS using `checkout.plaidLinkToken`, then call `linkBraleAchBank(checkoutId:publicToken:)`.
   * `"confirm_deposit"`: Show `checkout.savedBank`.
3. Call `getBraleAchAuthorization(amountLabel:bankLabel:)` and display the returned `text` to the user before requesting consent.
4. Call `submitBraleAchDeposit(checkoutId:authorizationTextVersion:)` to authorize the debit and launch the order.
5. Check progress with `getBraleAchCheckout(checkoutId:)` or `listBraleAchTransfers()`.

```swift BraleAchFlow.swift theme={null}
import ParaSwift

func runBraleAch(
    paraManager: ParaManager,
    walletId: String,
    presentPlaidLink: (String) async throws -> String
) async throws {
    var checkout = try await paraManager.createBraleAchCheckout(
        ParaCreateBraleAchCheckoutParams(
            walletId: walletId,
            amountUsd: "25.00",
            customer: ParaBraleAchCustomer(legalName: "Jane Doe")
        )
    )

    if checkout.nextAction == "launch_plaid", let linkToken = checkout.plaidLinkToken {
        let publicToken = try await presentPlaidLink(linkToken)
        checkout = try await paraManager.linkBraleAchBank(
            checkoutId: checkout.id,
            publicToken: publicToken
        )
    }

    let bankLabel = checkout.savedBank.map { "\($0.name) (\($0.accountNumberMask))" }
    let auth = try await paraManager.getBraleAchAuthorization(
        amountLabel: "$25.00",
        bankLabel: bankLabel
    )
    // Display auth.text to the user and obtain confirmation before submitting:
    let submitted = try await paraManager.submitBraleAchDeposit(
        checkoutId: checkout.id,
        authorizationTextVersion: auth.version
    )
    print("Launched purchase:", submitted.purchaseId ?? "")
}
```

### Order States and Partner Events

* **Checkout stages and `nextAction`**: A checkout transitions across `stage` `"link_required"` (`nextAction`: `"launch_plaid"`), `"linked"` (`nextAction`: `"confirm_deposit"`), and `"submitted"` (`nextAction`: `"wait"`).
* **Brale transfer and order states**: `braleStatus` reports `"pending"`, `"compliance review"`, `"processing"`, `"complete"`, `"canceled"`, `"failed"`, `"refunding"`, or `"refunded"`. Transfers in `"compliance review"` keep the checkout (`stage`: `"submitted"`, `nextAction`: `"wait"`) and order (`.initiated`) open until settled `.finished` or failed `.cancelled`.
* **Partner events**: `paraManager.onRampEvents` yields `.launched(ParaOnRampEventPayload)` when `submitBraleAchDeposit` runs. ACH settlement takes 1 to 3 business days and `.completed` does not emit over the bridge stream; listen for `onramp.completed` on your backend instead.

> [!WARNING]
>
> Subscribe to both [`onramp.completed` and `onramp.cancelled`](https://docs.getpara.com/v3/general/webhooks#event-types) webhooks for Brale ACH. If a bank returns an ACH debit after initial delivery, Brale reverses the transfer and Para emits `onramp.cancelled` after `onramp.completed`.

## Headless Card, Apple Pay & Reusable KYC

Use `ParaHeadlessOnRampCheckout` (`ObservableObject`) with the optional `ParaSwiftMeld` Swift Package library product (`ParaHeadlessOnRampPaymentView`, linked in Xcode alongside `ParaSwift` when needed) to run routed headless card and Apple Pay checkouts in SwiftUI. Keeping `ParaSwiftMeld` separate ensures apps that only use hosted or Brale/Coinbase flows do not link Meld's native payment dependencies. Headless card and Apple Pay orders are currently fulfilled through `.banxa`; pass `applePay: ParaHeadlessOnRampApplePayRequest(...)` when presenting an `.applePay` order. Pair `getKycStatus()`, `createKycSession()`, and `shareKyc(_:)` (for `.banxa` or `.transak`) when `checkout.step == .verificationRequired`.

```swift HeadlessCheckoutView.swift theme={null}
import ParaSwift
import ParaSwiftMeld
import SwiftUI

struct HeadlessCheckoutView: View {
    @ObservedObject var checkout: ParaHeadlessOnRampCheckout
    var applePay: ParaHeadlessOnRampApplePayRequest? = nil

    var body: some View {
        switch checkout.step {
        case .idle:
            Button("Get Quote") { Task { await checkout.start() } }
        case .review:
            Button("Pay Now") { Task { await checkout.confirm() } }
        case .payment:
            if let order = checkout.order {
                ParaHeadlessOnRampPaymentView(
                    order: order,
                    environment: checkout.environment,
                    applePay: applePay,
                    onPaymentSubmitted: { _ in checkout.onPaymentSubmitted() },
                    onCancel: { _ in checkout.onPaymentCancelled() },
                    onError: { code, opts in checkout.onPaymentError(code: code, options: opts) }
                )
            }
        case .success:
            Text("Purchase completed")
        case .failure:
            Text(checkout.error ?? "Checkout failed")
        default:
            ProgressView()
        }
    }
}
```

Unlike hosted, Coinbase Apple Pay, and Brale ACH flows, `createHeadlessOnRampOrder` does not emit `.launched` or `.completed` on `paraManager.onRampEvents`. `ParaHeadlessOnRampCheckout` polls `getOnRampOrder` after submission, and server webhooks (`onramp.completed` and `onramp.cancelled`) remain authoritative.

## Listen for SDK Events and Test Mode

Consume `paraManager.onRampEvents` in a background `Task` to react to lifecycle transitions emitted by the SDK. Both `.launched` and `.completed` deliver a `ParaOnRampEventPayload` aligned with the `onramp.completed` webhook payload.

```swift RampEvents.swift theme={null}
import ParaSwift

func observeRampEvents(paraManager: ParaManager) -> Task<Void, Never> {
    Task {
        for await event in paraManager.onRampEvents {
            switch event {
            case .launched(let payload):
                print("Order launched:", payload.purchaseId)
            case .completed(let payload):
                print("Order completed:", payload.transactionHash ?? "")
            }
        }
    }
}
```

> [!NOTE]
>
> Test mode is controlled by your API key's environment (Beta runs in test mode; production rejects `testMode: true`). In test mode, Brale ACH orders deliver `SBC` on Sepolia, Base Sepolia, Avalanche Fuji, or Solana Devnet (Optimism has no ACH test network), and Coinbase Apple Pay orders simulate settlement immediately.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.