Before integrating the SDK, you should create an endpoint on your backend server that creates a new connection token via the Stripe Terminal API. The connection token is used by the SDK to connect to a reader.
An overview of the lifecycle of a connection token:
- When Stripe Terminal is initialized, the SDK attempts to proactively request an connection token from your backend server.
- The SDK uses the connection to connect to a reader.
- Subsequent calls to connect require a new connection token. If you disconnect from a reader, and then call connect again, the SDK will need a new connection token from your backend server.
We suggest making your application’s API client conform to this protocol.
Fetches a connection token from your backend server.
On your backend server, use Stripe’s
/v1/terminal/connection_tokensendpoint to create a connection token, and return the
connection_tokenstring from the response to your app. In your app, call the completion block with the connection token, or an error if fetching the token failed.
- (void)fetchConnectionToken: (nonnull SCPConnectionTokenCompletionBlock)completion;
Call this with a connection token, or an error if creating the connection token failed.