Skip to main content
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:
Package.swift
Add the WhopTTP product to your app target. Then add import WhopTTP to your code.

Requirements

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 shows each step of the form. After Apple gives you the entitlement, add the capability to the entitlements file of your app target:
YourApp.entitlements
2

Two Info.plist keys

If one of these keys is not there, the app stops at the first charge:
Info.plist
The Bluetooth background mode is not necessary. Before the first charge, ask for When In Use location permission. The full example 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:
Your app gives the token from the response to the SDK. Authentication has server code in TypeScript, Python, and cURL.
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:
CheckoutView.swift
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_…).
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.
Do a test in sandbox first. Give environment: .sandbox to TapToPay. Create the token with a sandbox API key from sandbox.whop.com. Refer to Test in sandbox.

What’s next

Authentication

Create tokens on your server. Select production or sandbox.

Accept payments

Charge a variant or a custom amount. Add metadata and send receipts.

Build the payment screen

Use phase, isBusy, and isSupported to control your UI. Let sellers cancel a charge.

Onboard accounts

Make sure that an account can use Tap to Pay. Then activate it.

Handle errors

All TapToPayError codes and the message to show the seller.

Go live

The checklist to complete before you send your app to the App Store.