> ## 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.

# Test Tap to Pay in Sandbox

> Run the Tap to Pay SDK on the Whop sandbox, on the iOS Simulator or on an iPhone. Do tests without real money.

The Whop sandbox is a separate copy of Whop for tests, at [sandbox.whop.com](https://sandbox.whop.com). Payments in the sandbox do not use real money. Connect the SDK and your token endpoint to the sandbox. Then you can do a test of each procedure on this site before you go live.

## Sandbox setup

**1. Create a sandbox account and API key**

Sign up at [sandbox.whop.com](https://sandbox.whop.com). Create a business. Create an API key with `payment:charge` and `payment:basic:read`. To also do a test of [onboarding](https://docs.whop.com/tap-to-pay/onboarding.md), add `payout:account:update`.

**2. Create tokens with the sandbox API**

Make your token endpoint call `https://sandbox-api.whop.com/api/v1/access_tokens` with the sandbox key. If you use the TypeScript or Python SDK, give the sandbox environment. Refer to [Test in the Sandbox](https://docs.whop.com/developer/guides/sandbox.md).

**3. Connect TapToPay to the sandbox**

```swift theme={null}
let tapToPay = TapToPay(accountID: "biz_xxxxxxxxxxxxx", environment: .sandbox) {
    try await TapToPayTokens.fetch()
}
```

A sandbox token in a `.production` `TapToPay` fails with `.invalidCredentials`. A production token in a `.sandbox` `TapToPay` also fails.

**4. Check readiness**

Call `readiness()`. If the sandbox account is `.needsOnboarding`, [activate Tap to Pay](https://docs.whop.com/tap-to-pay/onboarding.md#turn-it-on).

## Where to run the SDK

> [tab] iOS Simulator
>
> The Simulator does not have NFC. Thus, the SDK connects a simulated reader. A charge runs from start to end without a card. Use the Simulator to make and do tests of your screens, your token endpoint, and your error procedures.
>
> Use the Simulator only with `.sandbox`. Production does not accept simulated payments.

> [tab] iPhone
>
> On an iPhone with the Tap to Pay on iPhone entitlement, the real reader runs. iOS shows its Tap to Pay screen. Use the iPhone to do a test of the first run: the Apple terms, location permission, and reader updates.
>
> The device must have a passcode. The seller must sign in to an Apple Account on the device.

## Use the example app

The [SDK repository](https://github.com/whopio/ttp-swift) contains `TTPExample`. This app has one screen, and it charges a variant. It does not have a server. On the first start, it asks for an API key, an account ID, and a variant ID. It keeps these values in the Keychain. Then it gives the key directly to the token provider. Use Settings in its toolbar to change between sandbox and production.

> [!WARNING]
>
> `TTPExample` uses the API key as its token. Thus, you can try the SDK without a server. Use a sandbox key that has only `payment:charge` and `payment:basic:read`. Use it only on your device. A production app gets a short-lived token from its server.

## Items to test

* A charge for a variant, and a charge for a custom amount.
* A charge with an email. Also, `attachBuyer` after a charge without an email.
* A cancel while `phase` is `.waitingForCard`.
* A second charge while a charge runs. Make sure that you disable your button. Also make sure that `charge` throws `.busy`.
* A failure of your token endpoint. Make sure that `charge` throws `.credentialsUnavailable`.
* Airplane mode during a charge. Make sure that your app shows the correct messages for `.network` and `.outcomeUnknown`.

## Next steps

> [card] [Go live](https://docs.whop.com/tap-to-pay/go-live.md)
>
> Change to production and release your app.

> [card] [Troubleshooting](https://docs.whop.com/tap-to-pay/troubleshooting.md)
>
> Solutions for frequent setup problems.


## Related topics

- [Tap to Pay Troubleshooting and FAQ](https://docs.whop.com/tap-to-pay/troubleshooting.md)
- [Getting Started with Tap to Pay](https://docs.whop.com/tap-to-pay/getting-started.md)
- [Authenticate the Tap to Pay SDK](https://docs.whop.com/tap-to-pay/authentication.md)
