Skip to main content
The Swift SDK is currently in Beta. View the source code on GitHub.
Crossmint Onramp Embedded Checkout Demo

Native iOS onramp with Apple Pay support

You can start testing Onramp in staging. Once you are ready to go live, reach out to sales to enable the feature in production
Crossmint’s Swift SDK (Beta) lets you build a seamless onramp for iOS users to buy crypto with credit cards and native Apple Pay support. In this guide, you’ll learn how to:
  • Install the Swift SDK using Swift Package Manager
  • Create a Crossmint order for your authenticated users
  • Use Crossmint’s embedded checkout component with SwiftUI to handle KYC, payment, and delivery automatically

Requirements

  • iOS 14.0+
  • SwiftUI framework
  • Xcode 13.0 or later

1. Installation

Install the Crossmint Swift SDK using Swift Package Manager.
1

Add Package Dependency

In Xcode, go to File > Add Package Dependencies and add:
https://github.com/Crossmint/crossmint-swift-sdk
Select the CrossmintCheckout product for your target.
2

Create API key

Create a server-side API key with the orders.create and orders.read scopes enabled.

2. Create Order

Use the Create Order API to initiate the purchase process from your backend. Use the following token addresses for USDC on staging:
ChainStaging Token Address
Solana4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU
Base0x036CbD53842c5426634e7929541eC2318f3dCF7e
🚨 IMPORTANT: The payment.receiptEmail parameter is required for compliance reasons. This email is used by Crossmint to determine whether KYC is required for the order. The API accepts either recipient.email OR recipient.walletAddress, not both.
Example API call:
curl --request POST \
  --url https://staging.crossmint.com/api/2022-06-09/orders \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: YOUR_SERVER_API_KEY' \
  --data '{
    "lineItems": [
      {
        "tokenLocator": "solana:4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU",
        "executionParameters": {
          "mode": "exact-in",
          "amount": "5"
        }
      }
    ],
    "payment": {
      "method": "card",
      "receiptEmail": "user@example.com"
    },
    "recipient": {
      "walletAddress": "example-wallet-address"
    }
  }'
{
  "clientSecret": "example-client-secret",
  "order": {
    "orderId": "example-order-id",
    "phase": "payment",
    "locale": "en-US",
    "lineItems": [
      {
        "chain": "solana",
        "metadata": {
          "name": "USDC",
          "description": "USDC Token",
          "imageUrl": "https://cryptologos.cc/logos/usd-coin-usdc-logo.svg?v=040"
        },
        "quote": {
          "status": "valid",
          "charges": {
            "unit": {
              "amount": "1.47",
              "currency": "usd"
            }
          },
          "totalPrice": {
            "amount": "2",
            "currency": "usd"
          },
          "quantityRange": {
            "lowerBound": "1.36",
            "upperBound": "1.36"
          }
        },
        "delivery": {
          "status": "awaiting-payment",
          "recipient": {
            "locator": "solana:example-wallet-address",
            "walletAddress": "example-wallet-address"
          }
        },
        "executionMode": "exact-in",
        "maxSlippageBps": "0",
        "executionParams": {
          "mintHash": "example-mint-hash",
          "mode": "exact-in",
          "amount": "2"
        }
      }
    ],
    "quote": {
      "status": "valid",
      "quotedAt": "2025-03-07T23:04:11.996Z",
      "expiresAt": "2025-03-07T23:14:11.996Z",
      "totalPrice": {
        "amount": "2",
        "currency": "usd"
      }
    },
    "payment": {
      "method": "checkoutcom-flow",
      "currency": "usd",
      "status": "requires-kyc",
      "preparation": {
        "kyc": {
          "provider": "persona",
          "templateId": "example-template-id",
          "referenceId": "example-reference-id"
        }
      }
    }
  }
}

3. Use Component

Once you have the order response with orderId and clientSecret, use Crossmint’s embedded checkout component in your SwiftUI view. The component supports native Apple Pay for a seamless iOS payment experience.
import SwiftUI
import Checkout

struct ContentView: View {
    var body: some View {
        CrossmintEmbeddedCheckout(
            orderId: "your-order-id",
            clientSecret: "your-client-secret",
            payment: CheckoutPayment(
                crypto: CheckoutCryptoPayment(enabled: false),
                fiat: CheckoutFiatPayment(
                    enabled: true,
                    allowedMethods: CheckoutAllowedMethods(
                        googlePay: false,
                        applePay: true,  // Native Apple Pay support
                        card: true
                    )
                )
            ),
            appearance: CheckoutAppearance(
                rules: CheckoutAppearanceRules(
                    destinationInput: CheckoutDestinationInputRule(display: "hidden"),
                    receiptEmailInput: CheckoutReceiptEmailInputRule(display: "hidden")
                )
            )
        )
    }
}

Key Features (Beta)

  • Native Apple Pay: Seamless integration with iOS payment system
  • SwiftUI Components: Modern declarative UI framework
  • Automatic KYC: Handles verification flow automatically
  • Customizable Appearance: Control visibility of UI elements

4. Track Order

After the user completes payment, you can track the order status using webhooks or polling. Configure a webhook endpoint to receive real-time order status updates:
  1. Go to the Crossmint Console
  2. Add your webhook endpoint URL
  3. Subscribe to order.payment.succeeded and order.delivery.succeeded events
Example webhook payload:
{
  "type": "order.payment.succeeded",
  "orderId": "example-order-id",
  "payment": {
    "status": "succeeded",
    "method": "card",
    "currency": "usd"
  }
}

Option 2: Polling

Poll the order status endpoint from your backend:
curl --request GET \
  --url https://staging.crossmint.com/api/2022-06-09/orders/{orderId} \
  --header 'x-api-key: YOUR_SERVER_API_KEY'
Check the order.payment.status and order.lineItems[].delivery.status fields to track progress.

5. Transaction Completion

Upon successful payment:
  • The purchased tokens (minus fees) are sent directly to the user’s wallet
  • User receives an email receipt from hello@crossmint.io
  • The embedded checkout component handles all the complexity of KYC verification and payment processing automatically

6. Next Steps