Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public interface ConnectionTokenProvider
Supplies Stripe Terminal connection tokens, which the Tap to Pay SDK asks for whenever it needs to talk to Stripe.
A connection token is created by your server with its secret key
(POST /v1/terminal/connection_tokens) and handed to the app; the secret
key itself never reaches the device. Fetch a fresh token on every call –
the SDK caches what it needs and asks again when that expires.
ConnectionTokenProvider tokens = () -> {
AsyncResource<String> out = new AsyncResource<>();
Rest.post("https://example.com/terminal/token").fetchAsJsonMap(r -> {
if (r.getResponseCode() == 200) {
out.complete((String) r.getResponseData().get("secret"));
} else {
out.error(new IOException("token: HTTP " + r.getResponseCode()));
}
});
return out;
};Methods
public abstract AsyncResource<String> fetchConnectionToken() | Fetches one connection token. |
Method details
fetchConnectionToken
public abstract AsyncResource<String> fetchConnectionToken()Fetches one connection token. Called on the EDT.
Returns
a resource completed with the token’s
secret, or with an error