Skip to main content
This screen uses all parts of the SDK. It does a readiness check. It charges a variant or an amount that the seller types. It shows each phase and lets the seller cancel. It changes errors into messages. After a payment, it sends a receipt to an email from the buyer. It uses the TapToPayTokens.fetch() helper from Authentication. Your Info.plist must contain the keys from Before you start.

How the example operates

1

One TapToPay per screen

The screen creates its TapToPay one time, in @State. Thus, the reader connection and the token stay when SwiftUI updates the screen.
2

Readiness and permission on appear

.task asks for location permission and reads readiness(). The charge buttons stay off until the account is .active.
3

Prepare at launch and on return

When the account is .active, prepare() connects the reader. It runs again each time that the app comes back to the foreground.
4

Status from phase

status uses a switch on phase. The progress bar shows only during .updatingReader.
5

Cancel while busy

The cancel button shows only while isBusy is true.
6

Receipt after payment

The email field shows only for a payment with canAttachBuyer set to true.
To try the example in sandbox, give environment: .sandbox to PaymentScreen.

Next steps

SDK reference

All public types and members.

Go live

The checklist to complete before you release your app.