Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public interface TapToPayBridge

What a port implements to read a card with the phone itself. Not for applications, which use com.codename1.payment.terminal.tap.TapToPay.

Ports answer every request through com.codename1.payment.terminal.tap.TapToPayCallbacks, from any thread; the callbacks move to the EDT themselves.

Methods

public abstract boolean isDeviceSupported()True when this device can read a card at all (the right hardware and OS version, NFC present).
public abstract void collect(int requestId, String clientSecret, long amount, String currency, String locationId, String merchantDisplayName, boolean simulated)Takes one payment: set up the SDK if needed, connect the phone as a reader at locationId, retrieve the PaymentIntent and collect and confirm it.
public abstract void cancel(int requestId)Cancels the collection requestId if it is still waiting for a card.
public abstract void connectionTokenReady(int tokenRequestId, String token, String error)Answers a TapToPayCallbacks.fetchConnectionToken request.

Method details

isDeviceSupported

public abstract boolean isDeviceSupported()
True when this device can read a card at all (the right hardware and OS version, NFC present). Answers quickly, with no network.

Returns

whether Tap to Pay can run here

collect

public abstract void collect(int requestId, String clientSecret, long amount, String currency, String locationId, String merchantDisplayName, boolean simulated)
Takes one payment: set up the SDK if needed, connect the phone as a reader at locationId, retrieve the PaymentIntent and collect and confirm it. Answered by TapToPayCallbacks.deliverResult.

Parameters

requestId int
echoed back with the outcome
clientSecret String
the PaymentIntent’s client secret
amount long
the amount in minor units, as the app asked; the PaymentIntent is authoritative, this is for simulators and logs
currency String
the ISO 4217 code, as the app asked
locationId String
the Stripe location the phone acts as a reader for
merchantDisplayName String
the name on the payment sheet, or null
simulated boolean
connect Stripe’s simulated reader instead of the phone

cancel

public abstract void cancel(int requestId)
Cancels the collection requestId if it is still waiting for a card.

Parameters

requestId int
the request to cancel

connectionTokenReady

public abstract void connectionTokenReady(int tokenRequestId, String token, String error)
Answers a TapToPayCallbacks.fetchConnectionToken request.

Parameters

tokenRequestId int
the ID the port asked with
token String
the token, or null when error is set
error String
why no token could be had, or null