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

> ## Agent Instructions
> Treat these docs and the Whop MCP server as the source of truth for Whop API behavior. Don't infer endpoint behavior from marketing pages.
> MCP server: connect https://mcp.whop.com/mcp (streamable HTTP, browser sign-in, no API key in the client config) to search these docs and read or change live Whop data. Setup: https://docs.whop.com/developer/guides/ai_and_mcp.md
> Whop CLI: install with `curl -fsSL https://whop.com/install.sh | sh` to scaffold, run, and deploy Whop apps and websites. It acts on production, not the sandbox. Overview: https://docs.whop.com/cli/overview.md Agent mode: https://docs.whop.com/cli/agent-mode.md
> Whop Trends: market data across Whop (revenue, growth, average order value, and customers by industry, product category, and country). Read it with no API key at `GET https://api.whop.com/api/v1/stats/reports/platform_trends`, or through the MCP server operation `get_platform_trends_report`. Guide and use cases: https://docs.whop.com/developer/guides/trends.md
> Hosting: Whop serves a site or app from the build `whop apps deploy` uploads, with rollbacks, secrets, and server logs. Guide: https://docs.whop.com/developer/websites/hosting.md
> Plugins: in Claude Code, run `/plugin marketplace add whopio/plugins`, then `/plugin install whop@whop`. Guide: https://docs.whop.com/developer/guides/plugins/claude-code.md Every agent tool: https://docs.whop.com/developer/ai/overview.md
> Environments: build and test in the sandbox (API `https://sandbox-api.whop.com/api/v1`, keys at https://sandbox.whop.com/dashboard/developer, SDK environment `Sandbox`; no real money). Production (API `https://api.whop.com/api/v1`, keys at https://whop.com/dashboard/developer, SDK environment `Production`, the SDK default) moves real money, so use it only at launch. The two share no accounts, keys, products, or webhooks, and their keys look identical: never mix them. Sandbox guide: https://docs.whop.com/developer/guides/sandbox.md Comparison: https://docs.whop.com/developer/quickstart.md
> API: send `Authorization: Bearer <API_KEY>` from your server only, and pin a dated version with the `Api-Version-Date` header. OpenAPI spec: https://api.whop.com/api/v1/openapi.json
> Which API: build on the Current API, whose pages live under https://docs.whop.com/api-reference/ (start at https://docs.whop.com/api-reference/overview.md). Pages under /api-reference/legacy/ are the Legacy API. Use one only when https://docs.whop.com/api-reference/stability.md lists the resource as Legacy-only.

# Getting Started with Tap to Pay

> Install the Whop Tap to Pay SDK. Then accept your first in-person card payment on an iPhone without more hardware.

> [!NOTE]
>
> This page documents `WhopTTP` 1.0.0 for iOS.

Tap to Pay changes an iPhone into a card reader. A buyer holds a contactless card, phone, or watch near the iPhone of the seller. Whop records the sale on the account of the seller, the same as other payments. To add Tap to Pay to your iOS app, use the `WhopTTP` Swift package. You use one `TapToPay` object and one `charge` call.

This page shows how to do a first charge. The pages at the end of this page give all other data. For example, they include onboarding and errors.

## Install

Add the package to your `Package.swift` file. You can also select **File → Add Package Dependencies** in Xcode and enter the URL:

```swift Package.swift theme={null}
dependencies: [
    .package(url: "https://github.com/whopio/ttp-swift.git", from: "1.0.0")
]
```

Add the `WhopTTP` product to your app target. Then add `import WhopTTP` to your code.

## Requirements

| | |
| - | - |
| Platform | iOS 18.0+ on iPhone XS or later. The iOS Simulator uses a simulated reader. Use it only for tests in sandbox. |
| Swift | Swift 6.0 (Xcode 16 or later) |
| Install | Swift Package Manager |
| Apple entitlement | Tap to Pay on iPhone (`com.apple.developer.proximity-reader.payment.acceptance`) |
| Info.plist | `NSBluetoothAlwaysUsageDescription` and `NSLocationWhenInUseUsageDescription` |
| Seller | A Whop account (`biz_`) in a [supported country](https://docs.whop.com/tap-to-pay/onboarding.md#supported-countries) |

## Before you start

You must have three items.

**1. The Tap to Pay on iPhone entitlement**

The Account Holder of your Apple Developer account requests it from Apple. [Request the entitlement](https://docs.whop.com/tap-to-pay/entitlement.md) shows each step of the form. After Apple gives you the entitlement, add the capability to the entitlements file of your app target:

```xml YourApp.entitlements theme={null}
<key>com.apple.developer.proximity-reader.payment.acceptance</key>
<true/>
```

**2. Two Info.plist keys**

If one of these keys is not there, the app stops at the first charge:

```xml Info.plist theme={null}
<key>NSBluetoothAlwaysUsageDescription</key>
<string>Bluetooth is used to connect to card readers.</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Location is used to accept card payments.</string>
```

The Bluetooth background mode is not necessary. Before the first charge, ask for When In Use location permission. The [full example](https://docs.whop.com/tap-to-pay/example-app.md) shows how to do this.

**3. A server endpoint that creates an access token**

The SDK uses a short-lived access token. Your server creates this token for the account of the seller, with the `payment:charge` and `payment:basic:read` scopes:

```http theme={null}
POST https://api.whop.com/api/v1/access_tokens
Authorization: Bearer <api_key>
Content-Type: application/json

{ "account_id": "biz_xxxxxxxxxxxxx", "scoped_actions": ["payment:charge", "payment:basic:read"] }
```

Your app gives the `token` from the response to the SDK. [Authentication](https://docs.whop.com/tap-to-pay/authentication.md) has server code in TypeScript, Python, and cURL.

> [!WARNING]
>
> Do not put a Whop API key in your app. A person can remove the key from the app bundle. The key can create tokens for all its permissions. Keep the key on your server. Send only the scoped token to the app.

## Take your first payment

`TapToPay` is a main-actor, `@Observable` object for the account of one seller. Create it with the account ID and a closure that gets a token from your server. Then call `charge`:

```swift CheckoutView.swift theme={null}
import SwiftUI
import WhopTTP

struct CheckoutView: View {
    @State private var tapToPay = TapToPay(accountID: "biz_xxxxxxxxxxxxx") {
        try await YourServer.tapToPayToken()
    }
    @State private var status = "Ready"

    var body: some View {
        VStack(spacing: 16) {
            Text(tapToPay.isBusy ? "Charging…" : status)
            Button("Charge $25") {
                Task {
                    do throws(TapToPayError) {
                        let payment = try await tapToPay.charge(25, currency: "usd")
                        status = "Paid \(payment.id)"
                    } catch {
                        status = error.message
                    }
                }
            }
            .disabled(!tapToPay.isSupported || tapToPay.isBusy)
        }
    }
}
```

`YourServer.tapToPayToken()` is an example name for your call to the token endpoint. It returns the token string.

Run the code on an iPhone. The first charge connects the reader. Thus, the first charge is some seconds slower than the charges after it. On the first charge on a device, iOS also tells the seller to accept the Apple terms for Tap to Pay on iPhone. If the payment is successful, `charge` returns a `TapToPayPayment`. Its `id` is the Whop payment ID (`pay_…`).

> [!NOTE]
>
> In your production app, call `prepare()` when the app starts. Also call it when the app comes back to the foreground. It connects the reader before the first sale. It also shows the Apple terms at that time, not when a buyer is there. Refer to [Prepare the reader](https://docs.whop.com/tap-to-pay/payment-screen.md#prepare-the-reader).

> [!TIP]
>
> Do a test in sandbox first. Give `environment: .sandbox` to `TapToPay`. Create the token with a sandbox API key from [sandbox.whop.com](https://sandbox.whop.com). Refer to [Test in sandbox](https://docs.whop.com/tap-to-pay/testing.md).

## What's next

> [card] [Authentication](https://docs.whop.com/tap-to-pay/authentication.md)
>
> Create tokens on your server. Select production or sandbox.

> [card] [Accept payments](https://docs.whop.com/tap-to-pay/accept-payments.md)
>
> Charge a variant or a custom amount. Add metadata and send receipts.

> [card] [Build the payment screen](https://docs.whop.com/tap-to-pay/payment-screen.md)
>
> Use `phase`, `isBusy`, and `isSupported` to control your UI. Let sellers cancel a charge.

> [card] [Onboard accounts](https://docs.whop.com/tap-to-pay/onboarding.md)
>
> Make sure that an account can use Tap to Pay. Then activate it.

> [card] [Handle errors](https://docs.whop.com/tap-to-pay/errors.md)
>
> All `TapToPayError` codes and the message to show the seller.

> [card] [Go live](https://docs.whop.com/tap-to-pay/go-live.md)
>
> The checklist to complete before you send your app to the App Store.


## Related topics

- [Request the Tap to Pay on iPhone Entitlement](https://docs.whop.com/tap-to-pay/entitlement.md)
- [Getting Started with Elements](https://docs.whop.com/elements/latest/getting-started.md)
- [Tap to Pay SDK Reference](https://docs.whop.com/tap-to-pay/reference.md)
