TapToPay. This closure is the token provider.
Create the token on your server
Call Create Access Token with:
The API key must have the two permissions on that account. The token cannot have more permissions than the key.
token. Return only that string to the app.
Put your own login before this endpoint. A person who can call the endpoint can accept payments on the account until the token expires.
Pass a token provider to the SDK
The token provider is anasync throws closure. It returns the token string:
TapToPayTokens.swift
When the SDK calls the token provider
When the SDK calls the token provider
The SDK calls the provider before its first request. Then the SDK keeps the token. The SDK calls the provider again only when Whop rejects the token, for example after the token expires. Then the SDK sends that request one more time with the new token. You do not have to monitor the expiry time.Each
TapToPay instance keeps its own token.When the token provider fails
When the token provider fails
If the provider throws an error or returns an empty string, the charge fails with
TapToPayError code .credentialsUnavailable. If the provider throws a TapToPayError, the SDK gives you that error without a change.If Whop also rejects a new token, the charge fails with .invalidCredentials. Usually, the cause is a token from the other environment. If the token does not have the correct permissions, the charge fails with .requestFailed and an underlyingCode of 403.How to cut off a device
How to cut off a device
Stop the creation of tokens for the device. The last token of the device expires automatically, a maximum of three hours after its creation. To stop a device sooner, use a short
expires_at.Choose an environment
TapToPay uses production if you do not select a different environment:
Each environment rejects tokens from the other environment.
TapToPayEnvironment has only these two cases. Thus, the SDK cannot send your token to a different server.
Next steps
Accept payments
Charge a variant or a custom amount.
Test in sandbox
Do a test of the full procedure without real money.

