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
requestIdint- echoed back with the outcome
clientSecretString- the PaymentIntent’s client secret
amountlong- the amount in minor units, as the app asked; the PaymentIntent is authoritative, this is for simulators and logs
currencyString- the ISO 4217 code, as the app asked
locationIdString- the Stripe location the phone acts as a reader for
merchantDisplayNameString- the name on the payment sheet, or null
simulatedboolean- 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
requestIdint- the request to cancel
connectionTokenReady
public abstract void connectionTokenReady(int tokenRequestId, String token, String error)Answers a
TapToPayCallbacks.fetchConnectionToken request.Parameters
tokenRequestIdint- the ID the port asked with
tokenString- the token, or null when
erroris set errorString- why no token could be had, or null